diff options
author | Marc Alexander <admin@m-a-styles.de> | 2013-10-24 13:55:23 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2013-10-24 13:55:23 +0200 |
commit | 9d4d212e0f71789e1f0332046dd852d80ab9c8ba (patch) | |
tree | e3de96df60d80c913414cc7ac54952de7a78c955 /phpBB/phpbb/avatar | |
parent | 2adf3d7a3473fe8d01e850329bd935e97f09668d (diff) | |
download | forums-9d4d212e0f71789e1f0332046dd852d80ab9c8ba.tar forums-9d4d212e0f71789e1f0332046dd852d80ab9c8ba.tar.gz forums-9d4d212e0f71789e1f0332046dd852d80ab9c8ba.tar.bz2 forums-9d4d212e0f71789e1f0332046dd852d80ab9c8ba.tar.xz forums-9d4d212e0f71789e1f0332046dd852d80ab9c8ba.zip |
[ticket/11525] Only remove group or user prefix from given avatar data
Until now, the user data had both user_id and group_id keys in the avatar
data. As both group_ and user_ prefixes were removed the group_id was
collapsed onto the user_id and therefore all users in the same group had
the same prefix for their uploaded avatars. This patch will make sure
that the correct id is used depending on whether it's a group's or user's
avatar data.
PHPBB3-11525
Diffstat (limited to 'phpBB/phpbb/avatar')
-rw-r--r-- | phpBB/phpbb/avatar/manager.php | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/phpBB/phpbb/avatar/manager.php b/phpBB/phpbb/avatar/manager.php index c28380a401..f2bb1a5dbe 100644 --- a/phpBB/phpbb/avatar/manager.php +++ b/phpBB/phpbb/avatar/manager.php @@ -178,14 +178,15 @@ class manager } /** - * Strip out user_ and group_ prefixes from keys + * Strip out user_, group_, or other prefixes from array keys * * @param array $row User data or group data + * @param string $prefix Prefix of data keys * * @return array User data or group data with keys that have been * stripped from the preceding "user_" or "group_" */ - static public function clean_row($row) + static public function clean_row($row, $prefix = '') { // Upon creation of a user/group $row might be empty if (empty($row)) @@ -196,7 +197,7 @@ class manager $keys = array_keys($row); $values = array_values($row); - $keys = array_map(array('\phpbb\avatar\manager', 'strip_prefix'), $keys); + array_walk($keys, array('\phpbb\avatar\manager', 'strip_prefix'), $prefix); return array_combine($keys, $values); } @@ -205,11 +206,12 @@ class manager * Strip prepending user_ or group_ prefix from key * * @param string Array key - * @return string Key that has been stripped from its prefix + * @return void */ - static protected function strip_prefix($key) + static protected function strip_prefix(&$key, $null, $prefix) { - return preg_replace('#^(?:user_|group_)#', '', $key); + $regex = ($prefix !== '') ? "#^(?:{$prefix}_)#" : '#^(?:user_|group_)#'; + $key = preg_replace($regex, '', $key); } /** |