aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_display.php
diff options
context:
space:
mode:
authorCullen Walsh <ckwalsh@cullenwalsh.com>2011-06-18 22:50:52 -0700
committerCullen Walsh <ckwalsh@cullenwalsh.com>2012-03-18 22:21:36 +0000
commita06380c69a154659f4f9985238008640670669e0 (patch)
treeda434f22d28052a74d33d43ad1f8c92f1fb13e36 /phpBB/includes/functions_display.php
parentd0bb14ded1960de47eb07d955a483d74fd9e0af2 (diff)
downloadforums-a06380c69a154659f4f9985238008640670669e0.tar
forums-a06380c69a154659f4f9985238008640670669e0.tar.gz
forums-a06380c69a154659f4f9985238008640670669e0.tar.bz2
forums-a06380c69a154659f4f9985238008640670669e0.tar.xz
forums-a06380c69a154659f4f9985238008640670669e0.zip
[feature/avatars] Make avatars generic
Adding a cleaning function for data coming from the users/groups tables so drivers only deal with clean data (ideally). Refactored get_user_avatar() and get_group_avatar() to use an underlying get_avatar() function. PHPBB3-10018
Diffstat (limited to 'phpBB/includes/functions_display.php')
-rw-r--r--phpBB/includes/functions_display.php66
1 files changed, 37 insertions, 29 deletions
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index 23900dfd88..b82f004505 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -1280,6 +1280,36 @@ 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::FROM_USER);
+ return get_avatar($row, $alt, $ignore_config);
+}
+
+/**
+* Get group avatar
+*
+* @param array $group_row Row from the groups table
+* @param string $alt Optional language string for alt tag within image, can be a language key or text
+* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
+*
+* @return string Avatar html
+*/
+function get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = false)
+{
+ $row = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver::FROM_GROUP);
+ return get_avatar($row, $alt, $ignore_config);
+}
+
+/**
+* Get avatar
+*
+* @param array $row Row cleaned by phpbb_avatar_driver::clean_row
+* @param string $alt Optional language string for alt tag within image, can be a language key or text
+* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
+*
+* @return string Avatar html
+*/
+function get_avatar($row, $alt, $ignore_config = false)
+{
global $user, $config, $cache, $phpbb_root_path, $phpEx;
static $avatar_manager = null;
@@ -1290,12 +1320,12 @@ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false
}
$avatar_data = array(
- 'src' => $user_row['user_avatar'],
- 'width' => $user_row['user_avatar_width'],
- 'height' => $user_row['user_avatar_height'],
+ 'src' => $row['avatar'],
+ 'width' => $row['avatar_width'],
+ 'height' => $row['avatar_height'],
);
- switch ($user_row['user_avatar_type'])
+ switch ($row['avatar_type'])
{
case AVATAR_UPLOAD:
// Compatibility with old avatars
@@ -1341,16 +1371,16 @@ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false
$avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->get_driver());
}
- $avatar = $avatar_manager->get_driver($user_row['user_avatar_type']);
+ $avatar = $avatar_manager->get_driver($row['avatar_type']);
if ($avatar)
{
if ($avatar->custom_html)
{
- return $avatar->get_html($user_row, $ignore_config);
+ return $avatar->get_html($row, $ignore_config);
}
- $avatar_data = $avatar->get_data($user_row, $ignore_config);
+ $avatar_data = $avatar->get_data($row, $ignore_config);
}
else
{
@@ -1372,25 +1402,3 @@ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false
return $html;
}
-
-/**
-* Get group avatar
-*
-* @param array $group_row Row from the groups table
-* @param string $alt Optional language string for alt tag within image, can be a language key or text
-* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
-*
-* @return string Avatar html
-*/
-function get_group_avatar($group_row, $alt = 'GROUP_AVATAR', $ignore_config = false)
-{
- // Kind of abusing this functionality...
- $avatar_row = array(
- 'user_avatar' => $group_row['group_avatar'],
- 'user_avatar_type' => $group_row['group_avatar_type'],
- 'user_avatar_width' => $group_row['group_avatar_width'],
- 'user_avatar_height' => $group_row['group_avatar_height'],
- );
-
- return get_user_avatar($group_row, $alt, $ignore_config);
-}