aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/includes/acp/acp_groups.php2
-rw-r--r--phpBB/includes/acp/acp_users.php2
-rw-r--r--phpBB/includes/avatar/driver/driver.php41
-rw-r--r--phpBB/includes/avatar/driver/interface.php11
-rw-r--r--phpBB/includes/avatar/manager.php19
-rw-r--r--phpBB/includes/functions_display.php4
-rw-r--r--phpBB/includes/ucp/ucp_profile.php2
7 files changed, 24 insertions, 57 deletions
diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php
index 5a45b3b572..d4a3e40d93 100644
--- a/phpBB/includes/acp/acp_groups.php
+++ b/phpBB/includes/acp/acp_groups.php
@@ -293,7 +293,7 @@ class acp_groups
sort($avatar_drivers);
// This is normalised data, without the group_ prefix
- $avatar_data = phpbb_avatar_driver::clean_row($group_row, phpbb_avatar_driver_interface::FROM_GROUP);
+ $avatar_data = phpbb_avatar_manager::clean_row($group_row);
}
diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php
index 9c12116062..cd50b02ca1 100644
--- a/phpBB/includes/acp/acp_users.php
+++ b/phpBB/includes/acp/acp_users.php
@@ -1692,7 +1692,7 @@ class acp_users
sort($avatar_drivers);
// This is normalised data, without the user_ prefix
- $avatar_data = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver_interface::FROM_USER);
+ $avatar_data = phpbb_avatar_manager::clean_row($user_row);
if ($submit)
{
diff --git a/phpBB/includes/avatar/driver/driver.php b/phpBB/includes/avatar/driver/driver.php
index 277130e819..7028df4b64 100644
--- a/phpBB/includes/avatar/driver/driver.php
+++ b/phpBB/includes/avatar/driver/driver.php
@@ -119,45 +119,4 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface
{
return true;
}
-
- /**
- * @inheritdoc
- **/
- public static function clean_row($row, $src = phpbb_avatar_driver_interface::FROM_USER)
- {
- $return = array();
- $prefix = false;
-
- if ($src == phpbb_avatar_driver_interface::FROM_USER)
- {
- $prefix = 'user_';
- }
- else if ($src == phpbb_avatar_driver_interface::FROM_GROUP)
- {
- $prefix = 'group_';
- }
-
- if ($prefix)
- {
- $len = strlen($prefix);
- foreach ($row as $key => $val)
- {
- $sub = substr($key, 0, $len);
- if ($sub == $prefix)
- {
- $return[substr($key, $len)] = $val;
- }
- else
- {
- $return[$key] = $val;
- }
- }
- }
- else
- {
- $return = $row;
- }
-
- return $return;
- }
}
diff --git a/phpBB/includes/avatar/driver/interface.php b/phpBB/includes/avatar/driver/interface.php
index dcec5811bb..8c8a067d13 100644
--- a/phpBB/includes/avatar/driver/interface.php
+++ b/phpBB/includes/avatar/driver/interface.php
@@ -22,12 +22,6 @@ if (!defined('IN_PHPBB'))
interface phpbb_avatar_driver_interface
{
/**
- * @TODO
- */
- const FROM_USER = 0;
- const FROM_GROUP = 1;
-
- /**
* Get the avatar url and dimensions
*
* @param $ignore_config Whether this function should respect the users prefs
@@ -63,9 +57,4 @@ interface phpbb_avatar_driver_interface
* @TODO
**/
public function delete($row);
-
- /**
- * @TODO
- **/
- public static function clean_row($row, $src = phpbb_avatar_driver_interface::FROM_USER);
}
diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php
index 41429f3a06..054bb0cee9 100644
--- a/phpBB/includes/avatar/manager.php
+++ b/phpBB/includes/avatar/manager.php
@@ -125,4 +125,23 @@ class phpbb_avatar_manager
return array_keys(self::$valid_drivers);
}
+
+ /**
+ * Strip out user_ and group_ prefixes from keys
+ **/
+ public static function clean_row($row)
+ {
+ $keys = array_keys($row);
+ $values = array_values($row);
+
+ $keys = array_map(
+ function ($key)
+ {
+ return preg_replace('(user_|group_)', '', $key);
+ },
+ $row
+ );
+
+ return array_combine($keys, $values);
+ }
}
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index 82638b7f2b..619c30ada5 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -1281,7 +1281,7 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank
*/
function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false)
{
- $row = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver_interface::FROM_USER);
+ $row = phpbb_avatar_manager::clean_row($user_row);
return get_avatar($row, $alt, $ignore_config);
}
@@ -1296,7 +1296,7 @@ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false
*/
function get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = false)
{
- $row = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver_interface::FROM_GROUP);
+ $row = phpbb_avatar_manager::clean_row($user_row);
return get_avatar($row, $alt, $ignore_config);
}
diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php
index 9d22fd4dba..44dc57cfd7 100644
--- a/phpBB/includes/ucp/ucp_profile.php
+++ b/phpBB/includes/ucp/ucp_profile.php
@@ -557,7 +557,7 @@ class ucp_profile
sort($avatar_drivers);
// This is normalised data, without the user_ prefix
- $avatar_data = phpbb_avatar_driver::clean_row($user->data, phpbb_avatar_driver_interface::FROM_USER);
+ $avatar_data = phpbb_avatar_manager::clean_row($user->data);
if ($submit)
{