From 1933a8ab4785f9a039f88521c1fe6ece2ae5d4ad Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 20 Aug 2021 16:57:36 +0200 Subject: [PATCH] [ticket/15769] Make basic upload, refresh, and errors work PHPBB3-15769 --- phpBB/assets/javascript/phpbb-avatars.js | 16 ++++++++-------- phpBB/includes/ucp/ucp_profile.php | 13 +++++++++++++ phpBB/phpbb/avatar/driver/upload.php | 2 +- .../migration/data/v400/increase_avatar_size.php | 10 +++++----- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/phpBB/assets/javascript/phpbb-avatars.js b/phpBB/assets/javascript/phpbb-avatars.js index dfb1bc1f92..7c0a7e82d2 100644 --- a/phpBB/assets/javascript/phpbb-avatars.js +++ b/phpBB/assets/javascript/phpbb-avatars.js @@ -165,17 +165,17 @@ return; } - // trigger_error() was called which likely means a permission error was encountered. - if (typeof response.title !== 'undefined') { - return; - } - // Handle errors while deleting file if (typeof response.error !== 'undefined') { - phpbb.alert(response.error.title, response.error.message); - } + phpbb.alert(response.error.title, response.error.messages.join('
')); + } else { + alert = phpbb.alert(response.MESSAGE_TITLE, response.MESSAGE_TEXT); - phpbb.avatars.destroy(); + setTimeout(function() { + window.location = response.REFRESH_DATA.url.replace('&', '&'); + }, response.REFRESH_DATA.time * 1000); + phpbb.avatars.destroy(); + } }, /** diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index a83f178b21..3200fd281a 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -711,6 +711,19 @@ class ucp_profile trigger_error($message); } } + else if ($request->is_ajax()) + { + $error = $phpbb_avatar_manager->localize_errors($user, $error); + + $json_response = new \phpbb\json_response; + $json_response->send([ + 'success' => false, + 'error' => [ + 'title' => $language->lang('INFORMATION'), + 'messages' => $error, + ], + ]); + } } } else diff --git a/phpBB/phpbb/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php index 0305f9c395..3cef5b554f 100644 --- a/phpBB/phpbb/avatar/driver/upload.php +++ b/phpBB/phpbb/avatar/driver/upload.php @@ -107,7 +107,7 @@ class upload extends \phpbb\avatar\driver\driver $template->assign_vars([ 'AVATAR_ALLOWED_EXTENSIONS' => implode(',', preg_replace('/^/', '.', $this->allowed_extensions)), 'AVATAR_UPLOAD_SIZE' => $this->config['avatar_filesize'], - 'S_CROPPING_AVAILABLE' => image_cropper::is_available(), + 'S_CROPPING_AVAILABLE' => true, 'T_ASSETS_PATH' => $web_path . '/assets', ]); diff --git a/phpBB/phpbb/db/migration/data/v400/increase_avatar_size.php b/phpBB/phpbb/db/migration/data/v400/increase_avatar_size.php index c7d4eccd14..a6448eda90 100644 --- a/phpBB/phpbb/db/migration/data/v400/increase_avatar_size.php +++ b/phpBB/phpbb/db/migration/data/v400/increase_avatar_size.php @@ -31,10 +31,10 @@ class increase_avatar_size extends container_aware_migration public function increase_size(): void { - $this->config['avatar_filesize'] = max(262144, $this->config['avatar_filesize']); // Increase to 256 KiB - $this->config['avatar_max_height'] = max('120', $this->config['avatar_max_height']); // Increase to max 120px height - $this->config['avatar_max_width'] = max('120', $this->config['avatar_max_width']); // Increase to max 120px width - $this->config['avatar_min_height'] = max('40', $this->config['avatar_min_height']); // Increase to min 40px height - $this->config['avatar_min_width'] = max('40', $this->config['avatar_min_width']); // Increase to max 40px width + $this->config->set('avatar_filesize', max(262144, $this->config['avatar_filesize'])); // Increase to 256 KiB + $this->config->set('avatar_max_height', max('120', $this->config['avatar_max_height'])); // Increase to max 120px height + $this->config->set('avatar_max_width', max('120', $this->config['avatar_max_width'])); // Increase to max 120px width + $this->config->set('avatar_min_height', max('40', $this->config['avatar_min_height'])); // Increase to min 40px height + $this->config->set('avatar_min_width', max('40', $this->config['avatar_min_width'])); // Increase to max 40px width } }