diff options
Diffstat (limited to 'phpBB/phpbb/avatar')
-rw-r--r-- | phpBB/phpbb/avatar/driver/gravatar.php | 5 | ||||
-rw-r--r-- | phpBB/phpbb/avatar/driver/local.php | 1 | ||||
-rw-r--r-- | phpBB/phpbb/avatar/driver/remote.php | 5 | ||||
-rw-r--r-- | phpBB/phpbb/avatar/driver/upload.php | 30 | ||||
-rw-r--r-- | phpBB/phpbb/avatar/manager.php | 36 |
5 files changed, 71 insertions, 6 deletions
diff --git a/phpBB/phpbb/avatar/driver/gravatar.php b/phpBB/phpbb/avatar/driver/gravatar.php index 4aa7445d20..2082e0fd02 100644 --- a/phpBB/phpbb/avatar/driver/gravatar.php +++ b/phpBB/phpbb/avatar/driver/gravatar.php @@ -69,6 +69,11 @@ class gravatar extends \phpbb\avatar\driver\driver $row['avatar_width'] = $request->variable('avatar_gravatar_width', 0); $row['avatar_height'] = $request->variable('avatar_gravatar_height', 0); + if (empty($row['avatar'])) + { + return false; + } + if (!function_exists('validate_data')) { require($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); diff --git a/phpBB/phpbb/avatar/driver/local.php b/phpBB/phpbb/avatar/driver/local.php index ff1996854b..07b3ed59de 100644 --- a/phpBB/phpbb/avatar/driver/local.php +++ b/phpBB/phpbb/avatar/driver/local.php @@ -120,7 +120,6 @@ class local extends \phpbb\avatar\driver\driver if (empty($category) || empty($file)) { - $error[] = 'NO_AVATAR_SELECTED'; return false; } diff --git a/phpBB/phpbb/avatar/driver/remote.php b/phpBB/phpbb/avatar/driver/remote.php index 455ddebf62..1bd7f6c927 100644 --- a/phpBB/phpbb/avatar/driver/remote.php +++ b/phpBB/phpbb/avatar/driver/remote.php @@ -53,6 +53,11 @@ class remote extends \phpbb\avatar\driver\driver $width = $request->variable('avatar_remote_width', 0); $height = $request->variable('avatar_remote_height', 0); + if (empty($url)) + { + return false; + } + if (!preg_match('#^(http|https|ftp)://#i', $url)) { $url = 'http://' . $url; diff --git a/phpBB/phpbb/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php index c43004f340..003b23659f 100644 --- a/phpBB/phpbb/avatar/driver/upload.php +++ b/phpBB/phpbb/avatar/driver/upload.php @@ -19,6 +19,31 @@ namespace phpbb\avatar\driver; class upload extends \phpbb\avatar\driver\driver { /** + * @var \phpbb\mimetype\guesser + */ + protected $mimetype_guesser; + + /** + * Construct a driver object + * + * @param \phpbb\config\config $config phpBB configuration + * @param string $phpbb_root_path Path to the phpBB root + * @param string $php_ext PHP file extension + * @param \phpbb_path_helper $path_helper phpBB path helper + * @param \phpbb\mimetype\guesser $mimetype_guesser Mimetype guesser + * @param \phpbb\cache\driver\driver_interface $cache Cache driver + */ + public function __construct(\phpbb\config\config $config, $phpbb_root_path, $php_ext, \phpbb\path_helper $path_helper, \phpbb\mimetype\guesser $mimetype_guesser, \phpbb\cache\driver\driver_interface $cache = null) + { + $this->config = $config; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + $this->path_helper = $path_helper; + $this->mimetype_guesser = $mimetype_guesser; + $this->cache = $cache; + } + + /** * {@inheritdoc} */ public function get_data($row, $ignore_config = false) @@ -70,7 +95,7 @@ class upload extends \phpbb\avatar\driver\driver if (!empty($upload_file['name'])) { - $file = $upload->form_upload('avatar_upload_file'); + $file = $upload->form_upload('avatar_upload_file', $this->mimetype_guesser); } else if (!empty($this->config['allow_avatar_remote_upload']) && !empty($url)) { @@ -100,11 +125,10 @@ class upload extends \phpbb\avatar\driver\driver return false; } - $file = $upload->remote_upload($url); + $file = $upload->remote_upload($url, $this->mimetype_guesser); } else { - $error[] = 'NO_AVATAR_SELECTED'; return false; } diff --git a/phpBB/phpbb/avatar/manager.php b/phpBB/phpbb/avatar/manager.php index 7cf136be2c..42ae61a9a2 100644 --- a/phpBB/phpbb/avatar/manager.php +++ b/phpBB/phpbb/avatar/manager.php @@ -41,8 +41,8 @@ class manager static protected $default_row = array( 'avatar' => '', 'avatar_type' => '', - 'avatar_width' => '', - 'avatar_height' => '', + 'avatar_width' => 0, + 'avatar_height' => 0, ); /** @@ -307,4 +307,36 @@ class manager return $error; } + + /** + * Handle deleting avatars + * + * @param \phpbb\db\driver\driver_interface $db phpBB dbal + * @param \phpbb\user $user phpBB user object + * @param array $avatar_data Cleaned user data containing the user's + * avatar data + * @param string $table Database table from which the avatar should be deleted + * @param string $prefix Prefix of user data columns in database + * @return null + */ + public function handle_avatar_delete(\phpbb\db\driver\driver_interface $db, \phpbb\user $user, $avatar_data, $table, $prefix) + { + if ($driver = $this->get_driver($avatar_data['avatar_type'])) + { + $driver->delete($avatar_data); + } + + $result = self::$default_row; + + foreach ($result as $key => $value) + { + $result[$prefix . $key] = $value; + unset($result[$key]); + } + + $sql = 'UPDATE ' . $table . ' + SET ' . $db->sql_build_array('UPDATE', $result) . ' + WHERE ' . $prefix . 'id = ' . (int) $avatar_data['id']; + $db->sql_query($sql); + } } |