mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/15233] Standardize avatar output variables
PHPBB3-15233
This commit is contained in:
parent
3137070d50
commit
7e3d22063a
16 changed files with 182 additions and 50 deletions
|
@ -123,6 +123,7 @@ services:
|
|||
class: phpbb\group\helper
|
||||
arguments:
|
||||
- '@auth'
|
||||
- '@avatar.helper'
|
||||
- '@cache'
|
||||
- '@config'
|
||||
- '@language'
|
||||
|
|
|
@ -14,6 +14,7 @@ services:
|
|||
user_loader:
|
||||
class: phpbb\user_loader
|
||||
arguments:
|
||||
- '@avatar.helper'
|
||||
- '@dbal.conn'
|
||||
- '%core.root_path%'
|
||||
- '%core.php_ext%'
|
||||
|
|
|
@ -721,7 +721,7 @@ class acp_groups
|
|||
}
|
||||
}
|
||||
|
||||
$avatar = phpbb_get_group_avatar($group_row, 'GROUP_AVATAR', true);
|
||||
$group_avatar = $group_helper->get_avatar($group_row, 'GROUP_AVATAR', true);
|
||||
|
||||
if (isset($phpbb_avatar_manager) && !$update)
|
||||
{
|
||||
|
@ -771,10 +771,14 @@ class acp_groups
|
|||
|
||||
'S_RANK_OPTIONS' => $rank_options,
|
||||
'S_GROUP_OPTIONS' => group_select_options(false, false, (($user->data['user_type'] == USER_FOUNDER) ? false : 0)),
|
||||
'AVATAR' => empty($avatar) ? '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />' : $avatar,
|
||||
'AVATAR' => empty($group_avatar['html']) ? '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />' : $group_avatar['html'],
|
||||
'AVATAR_LAZY' => $group_avatar['lazy'],
|
||||
'AVATAR_SRC' => $group_avatar['src'],
|
||||
'AVATAR_TITLE' => $group_avatar['title'],
|
||||
'AVATAR_TYPE' => $group_avatar['type'],
|
||||
'AVATAR_WIDTH' => $group_avatar['width'],
|
||||
'AVATAR_HEIGHT' => $group_avatar['height'],
|
||||
'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'],
|
||||
'AVATAR_WIDTH' => (isset($group_row['group_avatar_width'])) ? $group_row['group_avatar_width'] : '',
|
||||
'AVATAR_HEIGHT' => (isset($group_row['group_avatar_height'])) ? $group_row['group_avatar_height'] : '',
|
||||
|
||||
'GROUP_TYPE_FREE' => GROUP_FREE,
|
||||
'GROUP_TYPE_OPEN' => GROUP_OPEN,
|
||||
|
|
|
@ -1968,12 +1968,22 @@ class acp_users
|
|||
$error = $phpbb_avatar_manager->localize_errors($user, $error);
|
||||
}
|
||||
|
||||
$avatar = phpbb_get_user_avatar($user_row, 'USER_AVATAR', true);
|
||||
/** @var \phpbb\avatar\helper $avatar_helper */
|
||||
$avatar_helper = $phpbb_container->get('avatar.helper');
|
||||
|
||||
$avatar = $avatar_helper->get_user_avatar($user_row, 'USER_AVATAR', true);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_AVATAR' => true,
|
||||
'ERROR' => (!empty($error)) ? implode('<br />', $error) : '',
|
||||
'AVATAR' => (empty($avatar) ? '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />' : $avatar),
|
||||
|
||||
'AVATAR' => empty($avatar['html']) ? '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />' : $avatar['html'],
|
||||
'AVATAR_LAZY' => $avatar['lazy'],
|
||||
'AVATAR_SOURCE' => $avatar['src'],
|
||||
'AVATAR_TITLE' => $avatar['title'],
|
||||
'AVATAR_TYPE' => $avatar['type'],
|
||||
'AVATAR_WIDTH' => $avatar['width'],
|
||||
'AVATAR_HEIGHT' => $avatar['height'],
|
||||
|
||||
'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"',
|
||||
|
||||
|
|
|
@ -3523,6 +3523,8 @@ function phpbb_quoteattr($data, $entities = null)
|
|||
/**
|
||||
* Get user avatar
|
||||
*
|
||||
* @deprecated 4.0.0 Use \phpbb\avatar\helper::get_user_avatar() instead
|
||||
*
|
||||
* @param array $user_row Row from the users 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
|
||||
|
@ -3539,6 +3541,8 @@ function phpbb_get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config =
|
|||
/**
|
||||
* Get group avatar
|
||||
*
|
||||
* @deprecated 4.0.0 Use \phpbb\avatar\helper::get_group_avatar() instead
|
||||
*
|
||||
* @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
|
||||
|
@ -3555,6 +3559,8 @@ function phpbb_get_group_avatar($group_row, $alt = 'GROUP_AVATAR', $ignore_confi
|
|||
/**
|
||||
* Get avatar
|
||||
*
|
||||
* @deprecated 4.0.0 Use \phpbb\avatar\helper::get_avatar() instead
|
||||
*
|
||||
* @param array $row Row cleaned by \phpbb\avatar\manager::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
|
||||
|
@ -3862,6 +3868,11 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
|
|||
// Add form token for login box, in case page is presenting a login form.
|
||||
add_form_key('login', '_LOGIN');
|
||||
|
||||
/** @var \phpbb\avatar\helper $avatar_helper */
|
||||
$avatar_helper = $phpbb_container->get('avatar.helper');
|
||||
|
||||
$avatar = $avatar_helper->get_user_avatar($user->data);
|
||||
|
||||
// The following assigns all _common_ variables that may be used at any point in a template.
|
||||
$template->assign_vars(array(
|
||||
'SITENAME' => $config['sitename'],
|
||||
|
@ -3876,7 +3887,13 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
|
|||
'RECORD_USERS' => $l_online_record,
|
||||
|
||||
'PRIVATE_MESSAGE_COUNT' => (!empty($user->data['user_unread_privmsg'])) ? $user->data['user_unread_privmsg'] : 0,
|
||||
'CURRENT_USER_AVATAR' => phpbb_get_user_avatar($user->data),
|
||||
'CURRENT_USER_AVATAR' => $avatar['html'],
|
||||
'CURRENT_USER_AVATAR_LAZY' => $avatar['lazy'],
|
||||
'CURRENT_USER_AVATAR_SOURCE' => $avatar['src'],
|
||||
'CURRENT_USER_AVATAR_TITLE' => $avatar['title'],
|
||||
'CURRENT_USER_AVATAR_TYPE' => $avatar['type'],
|
||||
'CURRENT_USER_AVATAR_WIDTH' => $avatar['width'],
|
||||
'CURRENT_USER_AVATAR_HEIGHT' => $avatar['height'],
|
||||
'CURRENT_USERNAME_SIMPLE' => get_username_string('no_profile', $user->data['user_id'], $user->data['username'], $user->data['user_colour']),
|
||||
'CURRENT_USERNAME_FULL' => get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour']),
|
||||
'CURRENT_USER_GROUP_COLOR' => $user->data['user_colour'],
|
||||
|
|
|
@ -1570,7 +1570,7 @@ function phpbb_get_user_rank($user_data, $user_posts)
|
|||
*/
|
||||
function phpbb_show_profile($data, $user_notes_enabled = false, $warn_user_enabled = false, $check_can_receive_pm = true)
|
||||
{
|
||||
global $config, $auth, $user, $phpEx, $phpbb_root_path, $phpbb_dispatcher;
|
||||
global $config, $auth, $user, $phpEx, $phpbb_root_path, $phpbb_dispatcher, $phpbb_container;
|
||||
|
||||
$username = $data['username'];
|
||||
$user_id = $data['user_id'];
|
||||
|
@ -1653,6 +1653,11 @@ function phpbb_show_profile($data, $user_notes_enabled = false, $warn_user_enabl
|
|||
(($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $data['user_allow_pm'])
|
||||
);
|
||||
|
||||
/** @var \phpbb\avatar\helper $avatar_helper */
|
||||
$avatar_helper = $phpbb_container->get('avatar.helper');
|
||||
|
||||
$avatar = $avatar_helper->get_user_avatar($data);
|
||||
|
||||
// Dump it out to the template
|
||||
$template_data = array(
|
||||
'AGE' => $age,
|
||||
|
@ -1669,7 +1674,14 @@ function phpbb_show_profile($data, $user_notes_enabled = false, $warn_user_enabl
|
|||
|
||||
'A_USERNAME' => addslashes(get_username_string('username', $user_id, $username, $data['user_colour'])),
|
||||
|
||||
'AVATAR_IMG' => phpbb_get_user_avatar($data),
|
||||
'AVATAR_IMG' => $avatar['html'],
|
||||
'AVATAR_LAZY' => $avatar['lazy'],
|
||||
'AVATAR_SOURCE' => $avatar['src'],
|
||||
'AVATAR_TITLE' => $avatar['title'],
|
||||
'AVATAR_TYPE' => $avatar['type'],
|
||||
'AVATAR_WIDTH' => $avatar['width'],
|
||||
'AVATAR_HEIGHT' => $avatar['height'],
|
||||
|
||||
'ONLINE_IMG' => (!$config['load_onlinetrack']) ? '' : (($online) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')),
|
||||
'S_ONLINE' => ($config['load_onlinetrack'] && $online) ? true : false,
|
||||
'RANK_IMG' => $user_rank_data['img'],
|
||||
|
|
|
@ -192,7 +192,11 @@ class mcp_notes
|
|||
|
||||
// Generate the appropriate user information for the user we are looking at
|
||||
$rank_data = phpbb_get_user_rank($userrow, $userrow['user_posts']);
|
||||
$avatar_img = phpbb_get_user_avatar($userrow);
|
||||
|
||||
/** @var \phpbb\avatar\helper $avatar_helper */
|
||||
$avatar_helper = $phpbb_container->get('avatar.helper');
|
||||
|
||||
$avatar = $avatar_helper->get_user_avatar($userrow);
|
||||
|
||||
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
|
||||
$sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_IP'], 'd' => $user->lang['SORT_ACTION']);
|
||||
|
@ -252,10 +256,15 @@ class mcp_notes
|
|||
'USERNAME' => get_username_string('username', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
|
||||
'U_PROFILE' => get_username_string('profile', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
|
||||
|
||||
'AVATAR_IMG' => $avatar_img,
|
||||
'AVATAR_IMG' => $avatar['html'],
|
||||
'AVATAR_LAZY' => $avatar['lazy'],
|
||||
'AVATAR_SOURCE' => $avatar['src'],
|
||||
'AVATAR_TITLE' => $avatar['title'],
|
||||
'AVATAR_TYPE' => $avatar['type'],
|
||||
'AVATAR_WIDTH' => $avatar['width'],
|
||||
'AVATAR_HEIGHT' => $avatar['height'],
|
||||
'RANK_IMG' => $rank_data['img'],
|
||||
'RANK_TITLE' => $rank_data['title'],
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ class mcp_warn
|
|||
function mcp_warn_post_view($action)
|
||||
{
|
||||
global $phpEx, $phpbb_root_path, $config, $request;
|
||||
global $template, $db, $user, $phpbb_dispatcher;
|
||||
global $template, $db, $user, $phpbb_dispatcher, $phpbb_container;
|
||||
|
||||
$post_id = $request->variable('p', 0);
|
||||
$forum_id = $request->variable('f', 0);
|
||||
|
@ -342,7 +342,11 @@ class mcp_warn
|
|||
}
|
||||
|
||||
$user_rank_data = phpbb_get_user_rank($user_row, $user_row['user_posts']);
|
||||
$avatar_img = phpbb_get_user_avatar($user_row);
|
||||
|
||||
/** @var \phpbb\avatar\helper $avatar_helper */
|
||||
$avatar_helper = $phpbb_container->get('avatar.helper');
|
||||
|
||||
$avatar = $avatar_helper->get_user_avatar($user_row);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'U_POST_ACTION' => $this->u_action,
|
||||
|
@ -355,7 +359,13 @@ class mcp_warn
|
|||
'POSTS' => ($user_row['user_posts']) ? $user_row['user_posts'] : 0,
|
||||
'WARNINGS' => ($user_row['user_warnings']) ? $user_row['user_warnings'] : 0,
|
||||
|
||||
'AVATAR_IMG' => $avatar_img,
|
||||
'AVATAR_IMG' => $avatar['html'],
|
||||
'AVATAR_LAZY' => $avatar['lazy'],
|
||||
'AVATAR_SOURCE' => $avatar['src'],
|
||||
'AVATAR_TITLE' => $avatar['title'],
|
||||
'AVATAR_TYPE' => $avatar['type'],
|
||||
'AVATAR_WIDTH' => $avatar['width'],
|
||||
'AVATAR_HEIGHT' => $avatar['height'],
|
||||
'RANK_IMG' => $user_rank_data['img'],
|
||||
|
||||
'L_WARNING_POST_DEFAULT' => sprintf($user->lang['WARNING_POST_DEFAULT'], generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&p=$post_id#p$post_id"),
|
||||
|
@ -370,7 +380,7 @@ class mcp_warn
|
|||
function mcp_warn_user_view($action)
|
||||
{
|
||||
global $phpEx, $phpbb_root_path, $config, $request;
|
||||
global $template, $db, $user, $phpbb_dispatcher;
|
||||
global $template, $db, $user, $phpbb_dispatcher, $phpbb_container;
|
||||
|
||||
$user_id = $request->variable('u', 0);
|
||||
$username = $request->variable('username', '', true);
|
||||
|
@ -491,7 +501,11 @@ class mcp_warn
|
|||
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
||||
}
|
||||
$user_rank_data = phpbb_get_user_rank($user_row, $user_row['user_posts']);
|
||||
$avatar_img = phpbb_get_user_avatar($user_row);
|
||||
|
||||
/** @var \phpbb\avatar\helper $avatar_helper */
|
||||
$avatar_helper = $phpbb_container->get('avatar.helper');
|
||||
|
||||
$avatar = $avatar_helper->get_user_avatar($user_row);
|
||||
|
||||
// OK, they didn't submit a warning so lets build the page for them to do so
|
||||
$template->assign_vars(array(
|
||||
|
@ -507,7 +521,13 @@ class mcp_warn
|
|||
'USERNAME' => get_username_string('username', $user_row['user_id'], $user_row['username'], $user_row['user_colour']),
|
||||
'U_PROFILE' => get_username_string('profile', $user_row['user_id'], $user_row['username'], $user_row['user_colour']),
|
||||
|
||||
'AVATAR_IMG' => $avatar_img,
|
||||
'AVATAR_IMG' => $avatar['html'],
|
||||
'AVATAR_LAZY' => $avatar['lazy'],
|
||||
'AVATAR_SOURCE' => $avatar['src'],
|
||||
'AVATAR_TITLE' => $avatar['title'],
|
||||
'AVATAR_TYPE' => $avatar['type'],
|
||||
'AVATAR_WIDTH' => $avatar['width'],
|
||||
'AVATAR_HEIGHT' => $avatar['height'],
|
||||
'RANK_IMG' => $user_rank_data['img'],
|
||||
|
||||
'S_CAN_NOTIFY' => $s_can_notify,
|
||||
|
|
|
@ -431,7 +431,7 @@ class ucp_groups
|
|||
$group_name = $group_row['group_name'];
|
||||
$group_type = $group_row['group_type'];
|
||||
|
||||
$avatar = phpbb_get_group_avatar($group_row, 'GROUP_AVATAR', true);
|
||||
$group_avatar = $group_helper->get_avatar($group_row, 'GROUP_AVATAR', true);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'GROUP_NAME' => $group_helper->get_name($group_name),
|
||||
|
@ -440,10 +440,14 @@ class ucp_groups
|
|||
'GROUP_DESC_DISP' => generate_text_for_display($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_bitfield'], $group_row['group_desc_options']),
|
||||
'GROUP_TYPE' => $group_row['group_type'],
|
||||
|
||||
'AVATAR' => !empty($avatar) ? $avatar : '',
|
||||
'AVATAR_IMAGE' => !empty($avatar) ? $avatar : '',
|
||||
'AVATAR_WIDTH' => isset($group_row['group_avatar_width']) ? $group_row['group_avatar_width'] : '',
|
||||
'AVATAR_HEIGHT' => isset($group_row['group_avatar_height']) ? $group_row['group_avatar_height'] : '',
|
||||
'AVATAR' => empty($group_avatar['html']) ? '<img class="avatar" src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />' : $group_avatar['html'],
|
||||
'AVATAR_IMAGE' => empty($group_avatar['html']) ? '<img class="avatar" src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />' : $group_avatar['html'],
|
||||
'AVATAR_LAZY' => $group_avatar['lazy'],
|
||||
'AVATAR_SRC' => $group_avatar['src'],
|
||||
'AVATAR_TITLE' => $group_avatar['title'],
|
||||
'AVATAR_TYPE' => $group_avatar['type'],
|
||||
'AVATAR_WIDTH' => $group_avatar['width'],
|
||||
'AVATAR_HEIGHT' => $group_avatar['height'],
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -221,7 +221,13 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
|
|||
|
||||
'RANK_TITLE' => $user_info['rank_title'],
|
||||
'RANK_IMG' => $user_info['rank_image'],
|
||||
'AUTHOR_AVATAR' => (isset($user_info['avatar'])) ? $user_info['avatar'] : '',
|
||||
'AUTHOR_AVATAR' => !empty($user_info['avatar']) ? $user_info['avatar']['html'] : '',
|
||||
'AUTHOR_AVATAR_LAZY' => !empty($user_info['avatar']) ? $user_info['avatar']['lazy'] : false,
|
||||
'AUTHOR_AVATAR_SOURCE' => !empty($user_info['avatar']) ? $user_info['avatar']['src'] : '',
|
||||
'AUTHOR_AVATAR_TITLE' => !empty($user_info['avatar']) ? $user_info['avatar']['title'] : '',
|
||||
'AUTHOR_AVATAR_TYPE' => !empty($user_info['avatar']) ? $user_info['avatar']['type'] : '',
|
||||
'AUTHOR_AVATAR_WIDTH' => !empty($user_info['avatar']) ? $user_info['avatar']['width'] : 0,
|
||||
'AUTHOR_AVATAR_HEIGHT' => !empty($user_info['avatar']) ? $user_info['avatar']['height'] : 0,
|
||||
'AUTHOR_JOINED' => $user->format_date($user_info['user_regdate']),
|
||||
'AUTHOR_POSTS' => (int) $user_info['user_posts'],
|
||||
'U_AUTHOR_POSTS' => ($config['load_search'] && $auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$author_id&sr=posts") : '',
|
||||
|
@ -409,7 +415,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
|
|||
*/
|
||||
function get_user_information($user_id, $user_row)
|
||||
{
|
||||
global $db, $auth, $user;
|
||||
global $db, $auth, $user, $phpbb_container;
|
||||
global $phpbb_root_path, $phpEx, $config;
|
||||
|
||||
if (!$user_id)
|
||||
|
@ -449,7 +455,10 @@ function get_user_information($user_id, $user_row)
|
|||
}
|
||||
}
|
||||
|
||||
$user_row['avatar'] = ($user->optionget('viewavatars')) ? phpbb_get_user_avatar($user_row) : '';
|
||||
/** @var \phpbb\avatar\helper $avatar_helper */
|
||||
$avatar_helper = $phpbb_container->get('avatar.helper');
|
||||
|
||||
$user_row['avatar'] = ($user->optionget('viewavatars')) ? $avatar_helper->get_user_avatar($user_row) : [];
|
||||
|
||||
if (!function_exists('phpbb_get_user_rank'))
|
||||
{
|
||||
|
|
|
@ -757,11 +757,20 @@ class ucp_profile
|
|||
$error = $phpbb_avatar_manager->localize_errors($user, $error);
|
||||
}
|
||||
|
||||
$avatar = phpbb_get_user_avatar($user->data, 'USER_AVATAR', true);
|
||||
/** @var \phpbb\avatar\helper $avatar_helper */
|
||||
$avatar_helper = $phpbb_container->get('avatar.helper');
|
||||
|
||||
$avatar = $avatar_helper->get_user_avatar($user->data, 'USER_AVATAR', true);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'ERROR' => (count($error)) ? implode('<br />', $error) : '',
|
||||
'AVATAR' => $avatar,
|
||||
'AVATAR' => $avatar['html'],
|
||||
'AVATAR_LAZY' => $avatar['lazy'],
|
||||
'AVATAR_SOURCE' => $avatar['src'],
|
||||
'AVATAR_TITLE' => $avatar['title'],
|
||||
'AVATAR_TYPE' => $avatar['type'],
|
||||
'AVATAR_WIDTH' => $avatar['width'],
|
||||
'AVATAR_HEIGHT' => $avatar['height'],
|
||||
|
||||
'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"',
|
||||
|
||||
|
|
|
@ -1290,7 +1290,7 @@ switch ($mode)
|
|||
break;
|
||||
}
|
||||
|
||||
$avatar_img = phpbb_get_group_avatar($group_row);
|
||||
$avatar = $group_helper->get_avatar($group_row);
|
||||
|
||||
// ... same for group rank
|
||||
$group_rank_data = array(
|
||||
|
@ -1338,7 +1338,14 @@ switch ($mode)
|
|||
'GROUP_TYPE' => $user->lang['GROUP_IS_' . $group_row['l_group_type']],
|
||||
'GROUP_RANK' => $group_rank_data['title'],
|
||||
|
||||
'AVATAR_IMG' => $avatar_img,
|
||||
'AVATAR_IMG' => $avatar['html'],
|
||||
'AVATAR_LAZY' => $avatar['lazy'],
|
||||
'AVATAR_SRC' => $avatar['src'],
|
||||
'AVATAR_TITLE' => $avatar['title'],
|
||||
'AVATAR_TYPE' => $avatar['type'],
|
||||
'AVATAR_WIDTH' => $avatar['width'],
|
||||
'AVATAR_HEIGHT' => $avatar['height'],
|
||||
|
||||
'RANK_IMG' => $group_rank_data['img'],
|
||||
'RANK_IMG_SRC' => $group_rank_data['img_src'],
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
namespace phpbb\group;
|
||||
|
||||
use phpbb\auth\auth;
|
||||
use phpbb\avatar\helper as avatar_helper;
|
||||
use phpbb\cache\service as cache;
|
||||
use phpbb\config\config;
|
||||
use phpbb\language\language;
|
||||
|
@ -26,6 +27,9 @@ class helper
|
|||
/** @var auth */
|
||||
protected $auth;
|
||||
|
||||
/** @var avatar_helper */
|
||||
protected $avatar_helper;
|
||||
|
||||
/** @var cache */
|
||||
protected $cache;
|
||||
|
||||
|
@ -54,6 +58,7 @@ class helper
|
|||
* Constructor
|
||||
*
|
||||
* @param auth $auth Authentication object
|
||||
* @param avatar_helper $avatar_helper Avatar helper object
|
||||
* @param cache $cache Cache service object
|
||||
* @param config $config Configuration object
|
||||
* @param language $language Language object
|
||||
|
@ -61,9 +66,10 @@ class helper
|
|||
* @param path_helper $path_helper Path helper object
|
||||
* @param user $user User object
|
||||
*/
|
||||
public function __construct(auth $auth, cache $cache, config $config, language $language, dispatcher_interface $dispatcher, path_helper $path_helper, user $user)
|
||||
public function __construct(auth $auth, avatar_helper $avatar_helper, cache $cache, config $config, language $language, dispatcher_interface $dispatcher, path_helper $path_helper, user $user)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->avatar_helper = $avatar_helper;
|
||||
$this->cache = $cache;
|
||||
$this->config = $config;
|
||||
$this->language = $language;
|
||||
|
@ -278,17 +284,17 @@ class helper
|
|||
|
||||
/**
|
||||
* Get group avatar.
|
||||
* Wrapper function for phpbb_get_group_avatar()
|
||||
* Wrapper function for \phpbb\avatar\helper::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
|
||||
* @param bool $lazy If true, will be lazy loaded (requires JS)
|
||||
*
|
||||
* @return string Avatar html
|
||||
* @return array Avatar data
|
||||
*/
|
||||
function get_avatar($group_row, $alt = 'GROUP_AVATAR', $ignore_config = false, $lazy = false)
|
||||
{
|
||||
return phpbb_get_group_avatar($group_row, $alt, $ignore_config, $lazy);
|
||||
return $this->avatar_helper->get_group_avatar($group_row, $alt, $ignore_config, $lazy);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -284,10 +284,11 @@ abstract class base implements \phpbb\notification\type\type_interface
|
|||
$u_mark_read = append_sid($this->phpbb_root_path . 'index.' . $this->php_ext, 'mark_notification=' . $this->notification_id . '&hash=' . $mark_hash . '&redirect=' . urlencode($redirect));
|
||||
}
|
||||
|
||||
return array(
|
||||
$avatar = $this->get_avatar();
|
||||
|
||||
return [
|
||||
'NOTIFICATION_ID' => $this->notification_id,
|
||||
'STYLING' => $this->get_style_class(),
|
||||
'AVATAR' => $this->get_avatar(),
|
||||
'FORMATTED_TITLE' => $this->get_title(),
|
||||
'REFERENCE' => $this->get_reference(),
|
||||
'FORUM' => $this->get_forum(),
|
||||
|
@ -295,8 +296,17 @@ abstract class base implements \phpbb\notification\type\type_interface
|
|||
'URL' => $this->get_url(),
|
||||
'TIME' => $this->user->format_date($this->notification_time),
|
||||
'UNREAD' => !$this->notification_read,
|
||||
|
||||
'AVATAR' => $avatar ? $avatar['html'] : '',
|
||||
'AVATAR_LAZY' => $avatar ? $avatar['lazy'] : true,
|
||||
'AVATAR_SRC' => $avatar ? $avatar['src'] : '',
|
||||
'AVATAR_TITLE' => $avatar ? $avatar['title'] : '',
|
||||
'AVATAR_TYPE' => $avatar ? $avatar['type'] : '',
|
||||
'AVATAR_WIDTH' => $avatar ? $avatar['width'] : 0,
|
||||
'AVATAR_HEIGHT' => $avatar ? $avatar['height'] : 0,
|
||||
|
||||
'U_MARK_READ' => (!$this->notification_read) ? $u_mark_read : '',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -327,11 +337,11 @@ abstract class base implements \phpbb\notification\type\type_interface
|
|||
/**
|
||||
* Get the user's avatar (fall back)
|
||||
*
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
public function get_avatar()
|
||||
{
|
||||
return '';
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,6 +23,9 @@ namespace phpbb;
|
|||
*/
|
||||
class user_loader
|
||||
{
|
||||
/** @var \phpbb\avatar\helper */
|
||||
protected $avatar_helper;
|
||||
|
||||
/** @var \phpbb\db\driver\driver_interface */
|
||||
protected $db = null;
|
||||
|
||||
|
@ -45,13 +48,15 @@ class user_loader
|
|||
/**
|
||||
* User loader constructor
|
||||
*
|
||||
* @param \phpbb\avatar\helper $avatar_helper Avatar helper object
|
||||
* @param \phpbb\db\driver\driver_interface $db A database connection
|
||||
* @param string $phpbb_root_path Path to the phpbb includes directory.
|
||||
* @param string $php_ext php file extension
|
||||
* @param string $users_table The name of the database table (phpbb_users)
|
||||
*/
|
||||
public function __construct(\phpbb\db\driver\driver_interface $db, $phpbb_root_path, $php_ext, $users_table)
|
||||
public function __construct(\phpbb\avatar\helper $avatar_helper, \phpbb\db\driver\driver_interface $db, $phpbb_root_path, $php_ext, $users_table)
|
||||
{
|
||||
$this->avatar_helper = $avatar_helper;
|
||||
$this->db = $db;
|
||||
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
|
@ -182,23 +187,23 @@ class user_loader
|
|||
* Typically this should be left as false and you should make sure
|
||||
* you load users ahead of time with load_users()
|
||||
* @param bool @lazy If true, will be lazy loaded (requires JS)
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
public function get_avatar($user_id, $query = false, $lazy = false)
|
||||
{
|
||||
if (!($user = $this->get_user($user_id, $query)))
|
||||
{
|
||||
return '';
|
||||
return [];
|
||||
}
|
||||
|
||||
$row = array(
|
||||
$row = [
|
||||
'avatar' => $user['user_avatar'],
|
||||
'avatar_type' => $user['user_avatar_type'],
|
||||
'avatar_width' => $user['user_avatar_width'],
|
||||
'avatar_height' => $user['user_avatar_height'],
|
||||
);
|
||||
];
|
||||
|
||||
return phpbb_get_avatar($row, 'USER_AVATAR', false, $lazy);
|
||||
return $this->avatar_helper->get_avatar($row, 'USER_AVATAR', false, $lazy);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1179,6 +1179,9 @@ if (!empty($topic_data['poll_start']))
|
|||
unset($poll_end, $poll_info, $poll_options_template_data, $poll_template_data, $voted_id);
|
||||
}
|
||||
|
||||
/** @var \phpbb\avatar\helper $avatar_helper */
|
||||
$avatar_helper = $phpbb_container->get('avatar.helper');
|
||||
|
||||
// If the user is trying to reach the second half of the topic, fetch it starting from the end
|
||||
$store_reverse = false;
|
||||
$sql_limit = $config['posts_per_page'];
|
||||
|
@ -1417,7 +1420,7 @@ while ($row = $db->sql_fetchrow($result))
|
|||
'sig_bbcode_bitfield' => '',
|
||||
|
||||
'online' => false,
|
||||
'avatar' => ($user->optionget('viewavatars')) ? phpbb_get_user_avatar($row) : '',
|
||||
'avatar' => ($user->optionget('viewavatars')) ? $avatar_helper->get_user_avatar($row) : [],
|
||||
'rank_title' => '',
|
||||
'rank_image' => '',
|
||||
'rank_image_src' => '',
|
||||
|
@ -1481,7 +1484,7 @@ while ($row = $db->sql_fetchrow($result))
|
|||
'viewonline' => $row['user_allow_viewonline'],
|
||||
'allow_pm' => $row['user_allow_pm'],
|
||||
|
||||
'avatar' => ($user->optionget('viewavatars')) ? phpbb_get_user_avatar($row) : '',
|
||||
'avatar' => ($user->optionget('viewavatars')) ? $this->get_user_avatar($row) : [],
|
||||
'age' => '',
|
||||
|
||||
'rank_title' => '',
|
||||
|
@ -2026,7 +2029,6 @@ for ($i = 0, $end = count($post_list); $i < $end; ++$i)
|
|||
$u_pm = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&action=quotepost&p=' . $row['post_id']);
|
||||
}
|
||||
|
||||
//
|
||||
$post_row = array(
|
||||
'POST_AUTHOR_FULL' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_full'] : get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
|
||||
'POST_AUTHOR_COLOUR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_colour'] : get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
|
||||
|
@ -2038,7 +2040,13 @@ for ($i = 0, $end = count($post_list); $i < $end; ++$i)
|
|||
'RANK_IMG_SRC' => $user_cache[$poster_id]['rank_image_src'],
|
||||
'POSTER_JOINED' => $user_cache[$poster_id]['joined'],
|
||||
'POSTER_POSTS' => $user_cache[$poster_id]['posts'],
|
||||
'POSTER_AVATAR' => $user_cache[$poster_id]['avatar'],
|
||||
'POSTER_AVATAR' => $user_cache[$poster_id]['avatar'] ? $user_cache[$poster_id]['avatar']['html'] : '',
|
||||
'POSTER_AVATAR_LAZY' => $user_cache[$poster_id]['avatar'] ? $user_cache[$poster_id]['avatar']['lazy'] : false,
|
||||
'POSTER_AVATAR_SOURCE' => $user_cache[$poster_id]['avatar'] ? $user_cache[$poster_id]['avatar']['src'] : '',
|
||||
'POSTER_AVATAR_TITLE' => $user_cache[$poster_id]['avatar'] ? $user_cache[$poster_id]['avatar']['title'] : '',
|
||||
'POSTER_AVATAR_TYPE' => $user_cache[$poster_id]['avatar'] ? $user_cache[$poster_id]['avatar']['type'] : '',
|
||||
'POSTER_AVATAR_WIDTH' => $user_cache[$poster_id]['avatar'] ? $user_cache[$poster_id]['avatar']['width'] : 0,
|
||||
'POSTER_AVATAR_HEIGHT' => $user_cache[$poster_id]['avatar'] ? $user_cache[$poster_id]['avatar']['height'] : 0,
|
||||
'POSTER_WARNINGS' => $auth->acl_get('m_warn') ? $user_cache[$poster_id]['warnings'] : '',
|
||||
'POSTER_AGE' => $user_cache[$poster_id]['age'],
|
||||
'CONTACT_USER' => $user_cache[$poster_id]['contact_user'],
|
||||
|
|
Loading…
Add table
Reference in a new issue