aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/avatar
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2013-11-13 09:52:21 -0800
committerNils Adermann <naderman@naderman.de>2013-11-13 09:52:21 -0800
commit52845b22f24c19757a437ab0bda8b7583a10a398 (patch)
treefe524543e830c607682477ef751b43f1ebb8ebd5 /phpBB/phpbb/avatar
parente48b2c07ebe95aaff93eed6c7df5dff5d6c50fe2 (diff)
parent13a4ceedb18ba938d3cd18e2f68707385bc9283a (diff)
downloadforums-52845b22f24c19757a437ab0bda8b7583a10a398.tar
forums-52845b22f24c19757a437ab0bda8b7583a10a398.tar.gz
forums-52845b22f24c19757a437ab0bda8b7583a10a398.tar.bz2
forums-52845b22f24c19757a437ab0bda8b7583a10a398.tar.xz
forums-52845b22f24c19757a437ab0bda8b7583a10a398.zip
Merge pull request #1815 from marc1706/ticket/11525
[ticket/11525] Only remove group or user prefix from given avatar data
Diffstat (limited to 'phpBB/phpbb/avatar')
-rw-r--r--phpBB/phpbb/avatar/manager.php38
1 files changed, 18 insertions, 20 deletions
diff --git a/phpBB/phpbb/avatar/manager.php b/phpBB/phpbb/avatar/manager.php
index 5fe5e2b0a1..6ce924d2eb 100644
--- a/phpBB/phpbb/avatar/manager.php
+++ b/phpBB/phpbb/avatar/manager.php
@@ -178,14 +178,16 @@ 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 array $row User data or group data
+ * @param string $prefix Prefix of data keys (e.g. user), should not include the trailing underscore
*
- * @return array User data or group data with keys that have been
- * stripped from the preceding "user_" or "group_"
+ * @return array User or group data with keys that have been
+ * stripped from the preceding "user_" or "group_"
+ * Also the group id is prefixed with g, when the prefix group is removed.
*/
- 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))
@@ -193,23 +195,19 @@ class manager
return self::$default_row;
}
- $keys = array_keys($row);
- $values = array_values($row);
-
- $keys = array_map(array('\phpbb\avatar\manager', 'strip_prefix'), $keys);
+ $output = array();
+ foreach ($row as $key => $value)
+ {
+ $key = preg_replace("#^(?:{$prefix}_)#", '', $key);
+ $output[$key] = $value;
+ }
- return array_combine($keys, $values);
- }
+ if ($prefix === 'group' && isset($output['id']))
+ {
+ $output['id'] = 'g' . $output['id'];
+ }
- /**
- * Strip prepending user_ or group_ prefix from key
- *
- * @param string Array key
- * @return string Key that has been stripped from its prefix
- */
- static protected function strip_prefix($key)
- {
- return preg_replace('#^(?:user_|group_)#', '', $key);
+ return $output;
}
/**