mirror of
https://github.com/phpbb/phpbb.git
synced 2025-01-17 22:28:46 +01:00
Merge pull request #5778 from gijsmartens/ticket/15233
[ticket/15233] Standardize avatar output variables
This commit is contained in:
commit
2d42b2a6c2
@ -113,7 +113,7 @@
|
||||
<legend>{L_GROUP_AVATAR}</legend>
|
||||
<dl>
|
||||
<dt><label>{L_CURRENT_IMAGE}{L_COLON}</label><br /><span>{L_AVATAR_EXPLAIN}</span></dt>
|
||||
<dd>{AVATAR}</dd>
|
||||
<dd>{% if AVATAR_HTML %}{{ AVATAR_HTML }}{% else %}<img src="{{ ADMIN_ROOT_PATH ~ 'images/no_avatar.gif' }}" alt="">{% endif %}</dd>
|
||||
<dd><label for="avatar_delete"><input type="checkbox" name="avatar_delete" id="avatar_delete" /> {L_DELETE_AVATAR}</label></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<!-- IF ERROR --><p class="error">{ERROR}</p><!-- ENDIF -->
|
||||
<dl>
|
||||
<dt><label>{L_CURRENT_IMAGE}{L_COLON}</label><br /><span>{L_AVATAR_EXPLAIN}</span></dt>
|
||||
<dd>{AVATAR}</dd>
|
||||
<dd>{% if AVATAR_HTML %}{{ AVATAR_HTML }}{% else %}<img src="{{ ADMIN_ROOT_PATH ~ 'images/no_avatar.gif' }}" alt="">{% endif %}</dd>
|
||||
<dd><label for="avatar_delete"><input type="checkbox" name="avatar_delete" id="avatar_delete" /> {L_DELETE_AVATAR}</label></dd>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
@ -124,6 +124,7 @@ services:
|
||||
class: phpbb\group\helper
|
||||
arguments:
|
||||
- '@auth'
|
||||
- '@avatar.helper'
|
||||
- '@cache'
|
||||
- '@config'
|
||||
- '@language'
|
||||
|
@ -6,6 +6,16 @@ services:
|
||||
- '@dispatcher'
|
||||
- '@avatar.driver_collection'
|
||||
|
||||
avatar.helper:
|
||||
class: phpbb\avatar\helper
|
||||
arguments:
|
||||
- '@config'
|
||||
- '@dispatcher'
|
||||
- '@language'
|
||||
- '@avatar.manager'
|
||||
- '@path_helper'
|
||||
- '@user'
|
||||
|
||||
# ----- Avatar drivers -----
|
||||
avatar.driver_collection:
|
||||
class: phpbb\di\service_collection
|
||||
|
@ -14,6 +14,7 @@ services:
|
||||
user_loader:
|
||||
class: phpbb\user_loader
|
||||
arguments:
|
||||
- '@avatar.helper'
|
||||
- '@dbal.conn'
|
||||
- '%core.root_path%'
|
||||
- '%core.php_ext%'
|
||||
|
@ -721,8 +721,6 @@ class acp_groups
|
||||
}
|
||||
}
|
||||
|
||||
$avatar = phpbb_get_group_avatar($group_row, 'GROUP_AVATAR', true);
|
||||
|
||||
if (isset($phpbb_avatar_manager) && !$update)
|
||||
{
|
||||
// Merge any avatar errors into the primary error array
|
||||
@ -742,6 +740,12 @@ class acp_groups
|
||||
break;
|
||||
}
|
||||
|
||||
/** @var \phpbb\avatar\helper $avatar_helper */
|
||||
$avatar_helper = $phpbb_container->get('avatar.helper');
|
||||
|
||||
$group_avatar = $avatar_helper->get_group_avatar($group_row, 'GROUP_AVATAR', true);
|
||||
$template->assign_vars($avatar_helper->get_template_vars($group_avatar));
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_EDIT' => true,
|
||||
'S_ADD_GROUP' => ($action == 'add') ? true : false,
|
||||
@ -771,10 +775,7 @@ 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_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,15 @@ 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($avatar_helper->get_template_vars($avatar));
|
||||
|
||||
$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),
|
||||
'ERROR' => !empty($error) ? implode('<br />', $error) : '',
|
||||
|
||||
'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,12 @@ 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);
|
||||
$template->assign_vars($avatar_helper->get_template_vars($avatar, 'CURRENT_USER_'));
|
||||
|
||||
// The following assigns all _common_ variables that may be used at any point in a template.
|
||||
$template->assign_vars(array(
|
||||
'SITENAME' => $config['sitename'],
|
||||
@ -3875,8 +3887,8 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
|
||||
'LOGGED_IN_USER_LIST' => $online_userlist,
|
||||
'RECORD_USERS' => $l_online_record,
|
||||
|
||||
'NO_AVATAR_SOURCE' => $avatar_helper->get_no_avatar_source(),
|
||||
'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_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,8 +1653,14 @@ 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);
|
||||
$avatar_vars = $avatar_helper->get_template_vars($avatar);
|
||||
|
||||
// Dump it out to the template
|
||||
$template_data = array(
|
||||
$template_data = array_merge($avatar_vars, [
|
||||
'AGE' => $age,
|
||||
'RANK_TITLE' => $user_rank_data['title'],
|
||||
'JOINED' => $user->format_date($data['user_regdate']),
|
||||
@ -1669,7 +1675,6 @@ 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),
|
||||
'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'],
|
||||
@ -1691,7 +1696,7 @@ function phpbb_show_profile($data, $user_notes_enabled = false, $warn_user_enabl
|
||||
'L_SEND_EMAIL_USER' => $user->lang('SEND_EMAIL_USER', $username),
|
||||
'L_CONTACT_USER' => $user->lang('CONTACT_USER', $username),
|
||||
'L_VIEWING_PROFILE' => $user->lang('VIEWING_PROFILE', $username),
|
||||
);
|
||||
]);
|
||||
|
||||
/**
|
||||
* Preparing a user's data before displaying it in profile and memberlist
|
||||
|
@ -185,15 +185,6 @@ class mcp_notes
|
||||
trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
|
||||
}
|
||||
|
||||
if (!function_exists('phpbb_get_user_rank'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
$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']);
|
||||
$sort_by_sql = array('a' => 'u.username_clean', 'b' => 'l.log_time', 'c' => 'l.log_ip', 'd' => 'l.log_operation');
|
||||
@ -231,6 +222,20 @@ class mcp_notes
|
||||
$base_url = $this->u_action . "&$u_sort_param$keywords_param";
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start);
|
||||
|
||||
if (!function_exists('phpbb_get_user_rank'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
||||
}
|
||||
|
||||
// Generate the appropriate user information for the user we are looking at
|
||||
$rank_data = phpbb_get_user_rank($userrow, $userrow['user_posts']);
|
||||
|
||||
/** @var \phpbb\avatar\helper $avatar_helper */
|
||||
$avatar_helper = $phpbb_container->get('avatar.helper');
|
||||
|
||||
$avatar = $avatar_helper->get_user_avatar($userrow);
|
||||
$template->assign_vars($avatar_helper->get_template_vars($avatar));
|
||||
|
||||
$template->assign_vars(array(
|
||||
'U_POST_ACTION' => $this->u_action,
|
||||
'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false,
|
||||
@ -252,10 +257,8 @@ 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,
|
||||
'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,12 @@ 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($avatar_helper->get_template_vars($avatar));
|
||||
|
||||
$template->assign_vars(array(
|
||||
'U_POST_ACTION' => $this->u_action,
|
||||
@ -355,7 +360,6 @@ 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,
|
||||
'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 +374,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 +495,12 @@ 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);
|
||||
$template->assign_vars($avatar_helper->get_template_vars($avatar));
|
||||
|
||||
// OK, they didn't submit a warning so lets build the page for them to do so
|
||||
$template->assign_vars(array(
|
||||
@ -507,7 +516,6 @@ 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,
|
||||
'RANK_IMG' => $user_rank_data['img'],
|
||||
|
||||
'S_CAN_NOTIFY' => $s_can_notify,
|
||||
|
@ -431,7 +431,11 @@ 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);
|
||||
/** @var \phpbb\avatar\helper $avatar_helper */
|
||||
$avatar_helper = $phpbb_container->get('avatar.helper');
|
||||
|
||||
$group_avatar = $avatar_helper->get_group_avatar($group_row, 'GROUP_AVATAR', true);
|
||||
$template->assign_vars($avatar_helper->get_template_vars($group_avatar));
|
||||
|
||||
$template->assign_vars(array(
|
||||
'GROUP_NAME' => $group_helper->get_name($group_name),
|
||||
@ -439,11 +443,6 @@ class ucp_groups
|
||||
'GROUP_COLOUR' => (isset($group_row['group_colour'])) ? $group_row['group_colour'] : '',
|
||||
'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'] : '',
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,6 @@ 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_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") : '',
|
||||
@ -273,6 +272,15 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
|
||||
'U_FORWARD_PM' => ($config['forward_pm'] && $auth->acl_get('u_sendpm') && $auth->acl_get('u_pm_forward')) ? "$url&mode=compose&action=forward&f=$folder_id&p=" . $message_row['msg_id'] : '',
|
||||
);
|
||||
|
||||
if (!empty($user_info['avatar']))
|
||||
{
|
||||
/** @var \phpbb\avatar\helper $avatar_helper */
|
||||
$avatar_helper = $phpbb_container->get('avatar.helper');
|
||||
|
||||
$avatar_data = $avatar_helper->get_template_vars($user_info['avatar'], 'AUTHOR_');
|
||||
$msg_data = array_merge($msg_data, $avatar_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify pm and sender data before it is assigned to the template
|
||||
*
|
||||
@ -409,7 +417,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 +457,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,14 @@ 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($avatar_helper->get_template_vars($avatar));
|
||||
|
||||
$template->assign_vars(array(
|
||||
'ERROR' => (count($error)) ? implode('<br />', $error) : '',
|
||||
'AVATAR' => $avatar,
|
||||
'ERROR' => !empty($error) ? implode('<br />', $error) : '',
|
||||
|
||||
'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"',
|
||||
|
||||
|
@ -1290,8 +1290,6 @@ switch ($mode)
|
||||
break;
|
||||
}
|
||||
|
||||
$avatar_img = phpbb_get_group_avatar($group_row);
|
||||
|
||||
// ... same for group rank
|
||||
$group_rank_data = array(
|
||||
'title' => null,
|
||||
@ -1331,6 +1329,12 @@ switch ($mode)
|
||||
'U_BREADCRUMB' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=group&g=$group_id"),
|
||||
));
|
||||
|
||||
/** @var \phpbb\avatar\helper $avatar_helper */
|
||||
$avatar_helper = $phpbb_container->get('avatar.helper');
|
||||
|
||||
$group_avatar = $avatar_helper->get_group_avatar($group_row);
|
||||
$template->assign_vars($avatar_helper->get_template_vars($group_avatar));
|
||||
|
||||
$template->assign_vars(array(
|
||||
'GROUP_DESC' => generate_text_for_display($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_bitfield'], $group_row['group_desc_options']),
|
||||
'GROUP_NAME' => $group_helper->get_name($group_row['group_name']),
|
||||
@ -1338,7 +1342,6 @@ switch ($mode)
|
||||
'GROUP_TYPE' => $user->lang['GROUP_IS_' . $group_row['l_group_type']],
|
||||
'GROUP_RANK' => $group_rank_data['title'],
|
||||
|
||||
'AVATAR_IMG' => $avatar_img,
|
||||
'RANK_IMG' => $group_rank_data['img'],
|
||||
'RANK_IMG_SRC' => $group_rank_data['img_src'],
|
||||
|
||||
|
267
phpBB/phpbb/avatar/helper.php
Normal file
267
phpBB/phpbb/avatar/helper.php
Normal file
@ -0,0 +1,267 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\avatar;
|
||||
|
||||
use phpbb\avatar\driver\driver_interface;
|
||||
use phpbb\config\config;
|
||||
use phpbb\event\dispatcher;
|
||||
use phpbb\language\language;
|
||||
use phpbb\path_helper;
|
||||
use phpbb\user;
|
||||
|
||||
/**
|
||||
* Avatar helper object.
|
||||
*
|
||||
* Generates avatars and their variables for display.
|
||||
*/
|
||||
class helper
|
||||
{
|
||||
/** @var config */
|
||||
protected $config;
|
||||
|
||||
/** @var dispatcher */
|
||||
protected $dispatcher;
|
||||
|
||||
/** @var language */
|
||||
protected $language;
|
||||
|
||||
/** @var manager */
|
||||
protected $manager;
|
||||
|
||||
/** @var path_helper */
|
||||
protected $path_helper;
|
||||
|
||||
/** @var user */
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param config $config Config object
|
||||
* @param dispatcher $dispatcher Event dispatcher object
|
||||
* @param language $language Language object
|
||||
* @param manager $manager Avatar manager object
|
||||
* @param path_helper $path_helper Path helper object
|
||||
* @param user $user User object
|
||||
*/
|
||||
public function __construct(
|
||||
config $config,
|
||||
dispatcher $dispatcher,
|
||||
language $language,
|
||||
manager $manager,
|
||||
path_helper $path_helper,
|
||||
user $user
|
||||
)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->language = $language;
|
||||
$this->manager = $manager;
|
||||
$this->path_helper = $path_helper;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an avatar's template variables.
|
||||
*
|
||||
* @param array $avatar The avatar's data
|
||||
* @param string $prefix The variables' prefix
|
||||
* @return array The avatar's template variables
|
||||
*/
|
||||
public function get_template_vars(array $avatar, string $prefix = ''): array
|
||||
{
|
||||
$prefix = $prefix && substr($prefix, -1) !== '_' ? "{$prefix}_" : $prefix;
|
||||
|
||||
return [
|
||||
"{$prefix}AVATAR" => $avatar,
|
||||
|
||||
"{$prefix}AVATAR_SOURCE" => $avatar['src'],
|
||||
"{$prefix}AVATAR_TITLE" => $avatar['title'],
|
||||
"{$prefix}AVATAR_TYPE" => $avatar['type'],
|
||||
|
||||
"{$prefix}AVATAR_WIDTH" => $avatar['width'],
|
||||
"{$prefix}AVATAR_HEIGHT" => $avatar['height'],
|
||||
|
||||
"{$prefix}AVATAR_LAZY" => $avatar['lazy'],
|
||||
"{$prefix}AVATAR_HTML" => $avatar['html'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user avatar data.
|
||||
*
|
||||
* @param array $row The user's table row
|
||||
* @param string $title Optional language string/key for the title
|
||||
* @param bool $ignore_config Ignores the config setting, to still be able to view the avatar in the UCP
|
||||
* @param bool $lazy Indicator whether the avatar should be lazy loaded (requires JS) or not
|
||||
* @return array The avatar data array
|
||||
*/
|
||||
public function get_user_avatar(array $row, string $title = 'USER_AVATAR', bool $ignore_config = false, bool $lazy = false): array
|
||||
{
|
||||
$row = manager::clean_row($row, 'user');
|
||||
|
||||
return $this->get_avatar($row, $title, $ignore_config, $lazy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get group avatar data.
|
||||
*
|
||||
* @param array $row The group's table row
|
||||
* @param string $title Optional language string/key for the title
|
||||
* @param bool $ignore_config Ignores the config setting, to still be able to view the avatar in the UCP
|
||||
* @param bool $lazy Indicator whether the avatar should be lazy loaded (requires JS) or not
|
||||
* @return array The avatar data array
|
||||
*/
|
||||
public function get_group_avatar(array $row, string $title = 'GROUP_AVATAR', bool $ignore_config = false, bool $lazy = false): array
|
||||
{
|
||||
$row = manager::clean_row($row, 'group');
|
||||
|
||||
return $this->get_avatar($row, $title, $ignore_config, $lazy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get avatar data.
|
||||
*
|
||||
* @param array $row The cleaned table row
|
||||
* @param string $title Optional language string/key for the title
|
||||
* @param bool $ignore_config Ignores the config setting, to still be able to view the avatar in the UCP
|
||||
* @param bool $lazy Indicator whether the avatar should be lazy loaded (requires JS) or not
|
||||
* @return array The avatar data array
|
||||
*/
|
||||
public function get_avatar(array $row, string $title, bool $ignore_config = false, bool $lazy = false): array
|
||||
{
|
||||
if (!$this->config['allow_avatar'] && !$ignore_config)
|
||||
{
|
||||
return [
|
||||
'html' => '',
|
||||
'lazy' => false,
|
||||
'src' => '',
|
||||
'title' => '',
|
||||
'type' => '',
|
||||
'width' => 0,
|
||||
'height' => 0,
|
||||
];
|
||||
}
|
||||
|
||||
$data = [
|
||||
'src' => $row['avatar'],
|
||||
'width' => $row['avatar_width'],
|
||||
'height' => $row['avatar_height'],
|
||||
'title' => $this->language->lang($title),
|
||||
'lazy' => $lazy,
|
||||
'type' => '',
|
||||
'html' => '',
|
||||
];
|
||||
|
||||
/** @var driver_interface $driver */
|
||||
$driver = $this->manager->get_driver($row['avatar_type'], !$ignore_config);
|
||||
|
||||
if ($driver !== null)
|
||||
{
|
||||
$data = array_merge($data, $driver->get_data($row), [
|
||||
'type' => $driver->get_name(),
|
||||
'html' => $driver->get_custom_html($this->user, $row, $title),
|
||||
]);
|
||||
|
||||
/**
|
||||
* The type is used in the template to determine what driver is used,
|
||||
* and potentially to add an additional class to the avatar <img> element.
|
||||
*
|
||||
* While it's possible to str_replace('avatar.driver.', '', $data['type'])
|
||||
* for all the core drivers, this will be awkward for extensions' avatar drivers.
|
||||
* As they will most likely want to adjust the type in the event below,
|
||||
* and then have to search for a different definition than they used in their services.yml
|
||||
*
|
||||
* For example, 'ext.vendor.avatar.driver.custom_driver'
|
||||
* They will then have to look for: 'ext.vendor.custom_driver'
|
||||
*
|
||||
* So only remove 'avatar.driver.' if it is at the beginning of the driver's name.
|
||||
*/
|
||||
if (strpos($data['type'], 'avatar.driver.') === 0)
|
||||
{
|
||||
$data['type'] = substr($data['type'], strlen('avatar.driver.'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['src'] = '';
|
||||
}
|
||||
|
||||
if (empty($data['html']) && !empty($data['src']))
|
||||
{
|
||||
$data['html'] = $this->get_avatar_html($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Event to modify avatar data array
|
||||
*
|
||||
* @event core.avatar_helper_get_avatar
|
||||
* @var array row The cleaned table row
|
||||
* @var string title The language string/key for the title
|
||||
* @var bool ignore_config Ignores the config setting, to still be able to view the avatar in the UCP
|
||||
* @var bool lazy Indicator whether the avatar should be lazy loaded (requires JS) or not
|
||||
* @var array data The avatar data array
|
||||
* @since 4.0.0
|
||||
*/
|
||||
$vars = ['row', 'title', 'ignore_config', 'lazy', 'data'];
|
||||
extract($this->dispatcher->trigger_event('core.avatar_helper_get_avatar', compact($vars)));
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the "no avatar" source string.
|
||||
*
|
||||
* @return string The "no avatar" source string
|
||||
*/
|
||||
public function get_no_avatar_source(): string
|
||||
{
|
||||
/**
|
||||
* We need to correct the phpBB root path in case this is called from a controller,
|
||||
* because the web path will be incorrect otherwise.
|
||||
*/
|
||||
$board_url = defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH;
|
||||
$web_path = $board_url ? generate_board_url() . '/' : $this->path_helper->get_web_root_path();
|
||||
$style_path = rawurlencode($this->user->style['style_path']);
|
||||
|
||||
return "{$web_path}styles/{$style_path}/theme/images/no_avatar.gif";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an avatar's HTML <img> element.
|
||||
*
|
||||
* Created for Backwards Compatibility (BC).
|
||||
* Styles should generate their own HTML element instead.
|
||||
*
|
||||
* @deprecated 4.1.0 After admin style is reworked aswell
|
||||
*
|
||||
* @param array $data The avatar data array
|
||||
* @return string The avatar's HTML <img> element
|
||||
*/
|
||||
private function get_avatar_html(array $data): string
|
||||
{
|
||||
if ($data['lazy'])
|
||||
{
|
||||
$data['src'] = $this->get_no_avatar_source() . ' data-src="' . $data['src'];
|
||||
}
|
||||
|
||||
$src = ' src="' . $data['src'] . '"';
|
||||
$alt = ' alt="' . $data['title'] . '"';
|
||||
|
||||
$width = $data['width'] ? ' width="' . $data['width'] . '"' : '';
|
||||
$height = $data['height'] ? ' height="' . $data['height'] . '"' : '';
|
||||
|
||||
return '<img class="avatar"' . $src . $width . $height . $alt . ' />';
|
||||
}
|
||||
}
|
@ -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,19 @@ 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_SOURCE' => $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,
|
||||
|
||||
'AVATAR_HTML' => $avatar ? $avatar['html'] : '',
|
||||
'AVATAR_LAZY' => $avatar ? $avatar['lazy'] : true,
|
||||
|
||||
'U_MARK_READ' => (!$this->notification_read) ? $u_mark_read : '',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -327,11 +339,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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
<div>
|
||||
<div class="column1">
|
||||
<!-- IF AVATAR_IMG --><div>{AVATAR_IMG}</div><!-- ENDIF -->
|
||||
<!-- IF AVATAR_HTML --><div>{AVATAR_HTML}</div><!-- ENDIF -->
|
||||
</div>
|
||||
|
||||
<div class="column2">
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
<div>
|
||||
<div class="column1">
|
||||
<!-- IF AVATAR_IMG --><div>{AVATAR_IMG}</div><!-- ENDIF -->
|
||||
<!-- IF AVATAR_HTML --><div>{AVATAR_HTML}</div><!-- ENDIF -->
|
||||
</div>
|
||||
|
||||
<div class="column2">
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
<div>
|
||||
<div class="column1">
|
||||
<!-- IF AVATAR_IMG --><div>{AVATAR_IMG}</div><!-- ENDIF -->
|
||||
<!-- IF AVATAR_HTML --><div>{AVATAR_HTML}</div><!-- ENDIF -->
|
||||
</div>
|
||||
|
||||
<div class="column2">
|
||||
|
@ -26,7 +26,7 @@
|
||||
{% EVENT memberlist_body_group_desc_after %}
|
||||
|
||||
<p>
|
||||
<!-- IF AVATAR_IMG -->{AVATAR_IMG}<!-- ENDIF -->
|
||||
<!-- IF AVATAR_HTML -->{AVATAR_HTML}<!-- ENDIF -->
|
||||
{% EVENT memberlist_body_group_rank_before %}
|
||||
{% if RANK_IMG %}{{ RANK_IMG }}{% endif %}
|
||||
{% if GROUP_RANK %}
|
||||
|
@ -8,9 +8,9 @@
|
||||
<div class="panel bg1">
|
||||
<div class="inner">
|
||||
|
||||
<!-- IF AVATAR_IMG -->
|
||||
<!-- IF AVATAR_HTML -->
|
||||
<dl class="left-box">
|
||||
<dt class="profile-avatar">{AVATAR_IMG}</dt>
|
||||
<dt class="profile-avatar">{AVATAR_HTML}</dt>
|
||||
<!-- EVENT memberlist_view_rank_avatar_before -->
|
||||
<!-- IF RANK_TITLE --><dd style="text-align: center;">{RANK_TITLE}</dd><!-- ENDIF -->
|
||||
<!-- IF RANK_IMG --><dd style="text-align: center;">{RANK_IMG}</dd><!-- ENDIF -->
|
||||
@ -29,7 +29,7 @@
|
||||
<!-- IF U_USER_BAN --> [ <a href="{U_USER_BAN}">{L_USER_BAN}</a> ]<!-- ENDIF -->
|
||||
<!-- IF U_SWITCH_PERMISSIONS --> [ <a href="{U_SWITCH_PERMISSIONS}">{L_USE_PERMISSIONS}</a> ]<!-- ENDIF -->
|
||||
</dd>
|
||||
<!-- IF not AVATAR_IMG -->
|
||||
<!-- IF not AVATAR_HTML -->
|
||||
<!-- EVENT memberlist_view_rank_no_avatar_before -->
|
||||
<!-- IF RANK_TITLE --><dt>{L_RANK}{L_COLON}</dt> <dd>{RANK_TITLE}</dd><!-- ENDIF -->
|
||||
<!-- IF RANK_IMG --><dt><!-- IF RANK_TITLE --> <!-- ELSE -->{L_RANK}{L_COLON}<!-- ENDIF --></dt> <dd>{RANK_IMG}</dd><!-- ENDIF -->
|
||||
|
@ -106,11 +106,11 @@
|
||||
|
||||
{% if S_REGISTERED_USER %}
|
||||
{% EVENT navbar_header_user_profile_prepend %}
|
||||
<li id="username_logged_in" class="rightside {% if CURRENT_USER_AVATAR %} no-bulletin{% endif %}">
|
||||
<li id="username_logged_in" class="rightside {% if CURRENT_USER_AVATAR_HTML %} no-bulletin{% endif %}">
|
||||
{% EVENT navbar_header_username_prepend %}
|
||||
<div class="header-profile dropdown-container">
|
||||
<a href="{{ U_PROFILE }}" class="header-avatar dropdown-trigger">
|
||||
{% if CURRENT_USER_AVATAR %}{{ CURRENT_USER_AVATAR }} {% endif %}
|
||||
{% if CURRENT_USER_AVATAR_HTML %}{{ CURRENT_USER_AVATAR_HTML }} {% endif %}
|
||||
{{ CURRENT_USERNAME_SIMPLE }}
|
||||
{{ Icon('iconify', 'fa:caret-down', '', true, '', {'style': 'color: #' ~ CURRENT_USER_GROUP_COLOR}) }}
|
||||
</a>
|
||||
|
@ -22,7 +22,7 @@
|
||||
<!-- IF notifications.URL -->
|
||||
<a class="notification-block" href="<!-- IF notifications.UNREAD -->{notifications.U_MARK_READ}" data-real-url="{notifications.URL}<!-- ELSE -->{notifications.URL}<!-- ENDIF -->">
|
||||
<!-- ENDIF -->
|
||||
<!-- IF notifications.AVATAR -->{notifications.AVATAR}<!-- ELSE --><img class="avatar notification-avatar" src="{T_THEME_PATH}/images/no_avatar.gif" alt="" /><!-- ENDIF -->
|
||||
<!-- IF notifications.AVATAR -->{notifications.AVATAR_HTML}<!-- ELSE --><img class="avatar notification-avatar" src="{{ NO_AVATAR_SOURCE }}" alt="" /><!-- ENDIF -->
|
||||
<div class="notification-text">
|
||||
<p class="notification-title">{notifications.FORMATTED_TITLE}</p>
|
||||
<!-- IF notifications.REFERENCE --><p class="notification-reference">{notifications.REFERENCE}</p><!-- ENDIF -->
|
||||
|
@ -8,7 +8,7 @@
|
||||
<!-- IF ERROR --><p class="error">{ERROR}</p><!-- ENDIF -->
|
||||
<dl>
|
||||
<dt><label>{L_CURRENT_IMAGE}{L_COLON}</label><br /><span>{L_AVATAR_EXPLAIN}</span></dt>
|
||||
<dd><!-- IF AVATAR -->{AVATAR}<!-- ELSE --><img src="{T_THEME_PATH}/images/no_avatar.gif" alt="" /><!-- ENDIF --></dd>
|
||||
<dd><!-- IF AVATAR -->{AVATAR_HTML}<!-- ELSE --><img src="{{ NO_AVATAR_SOURCE }}" alt="" /><!-- ENDIF --></dd>
|
||||
<dd><label for="avatar_delete"><input type="checkbox" name="avatar_delete" id="avatar_delete" /> {L_DELETE_AVATAR}</label></dd>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
@ -67,7 +67,7 @@
|
||||
<dl>
|
||||
<dt>
|
||||
<div class="list-inner notification-item">
|
||||
<!-- IF notification_list.AVATAR -->{notification_list.AVATAR}<!-- ELSE --><img class="avatar notification-avatar" src="{T_THEME_PATH}/images/no_avatar.gif" alt="" /><!-- ENDIF -->
|
||||
<!-- IF notification_list.AVATAR -->{notification_list.AVATAR_HTML}<!-- ELSE --><img class="avatar notification-avatar" src="{{ NO_AVATAR_SOURCE }}" alt="" /><!-- ENDIF -->
|
||||
<div class="notification-text">
|
||||
<!-- IF notification_list.URL --><a href="<!-- IF notification_list.UNREAD -->{notification_list.U_MARK_READ}<!-- ELSE -->{notification_list.URL}<!-- ENDIF -->"><!-- ENDIF -->
|
||||
<p class="notification-title">{notification_list.FORMATTED_TITLE}<!-- IF notification_list.REFERENCE --> {notification_list.REFERENCE}<!-- ENDIF --></p>
|
||||
|
@ -26,10 +26,10 @@
|
||||
<div class="inner">
|
||||
|
||||
<dl class="postprofile" id="profile{MESSAGE_ID}">
|
||||
<dt class="<!-- IF RANK_TITLE or RANK_IMG -->has-profile-rank<!-- ELSE -->no-profile-rank<!-- ENDIF --> <!-- IF AUTHOR_AVATAR -->has-avatar<!-- ELSE -->no-avatar<!-- ENDIF -->">
|
||||
<dt class="<!-- IF RANK_TITLE or RANK_IMG -->has-profile-rank<!-- ELSE -->no-profile-rank<!-- ENDIF --> <!-- IF AUTHOR_AVATAR_HTML -->has-avatar<!-- ELSE -->no-avatar<!-- ENDIF -->">
|
||||
<div class="avatar-container">
|
||||
<!-- EVENT ucp_pm_viewmessage_avatar_before -->
|
||||
<!-- IF AUTHOR_AVATAR --><a href="{U_MESSAGE_AUTHOR}" class="avatar">{AUTHOR_AVATAR}</a><!-- ENDIF -->
|
||||
<!-- IF AUTHOR_AVATAR_HTML --><a href="{U_MESSAGE_AUTHOR}" class="avatar">{AUTHOR_AVATAR_HTML}</a><!-- ENDIF -->
|
||||
<!-- EVENT ucp_pm_viewmessage_avatar_after -->
|
||||
</div>
|
||||
{% apply spaceless %}
|
||||
|
@ -140,11 +140,11 @@
|
||||
<div class="inner">
|
||||
|
||||
<dl class="postprofile" id="profile{postrow.POST_ID}"<!-- IF postrow.S_POST_HIDDEN --> style="display: none;"<!-- ENDIF -->>
|
||||
<dt class="<!-- IF postrow.RANK_TITLE or postrow.RANK_IMG -->has-profile-rank<!-- ELSE -->no-profile-rank<!-- ENDIF --> <!-- IF postrow.POSTER_AVATAR -->has-avatar<!-- ELSE -->no-avatar<!-- ENDIF -->">
|
||||
<dt class="<!-- IF postrow.RANK_TITLE or postrow.RANK_IMG -->has-profile-rank<!-- ELSE -->no-profile-rank<!-- ENDIF --> <!-- IF postrow.POSTER_AVATAR_HTML -->has-avatar<!-- ELSE -->no-avatar<!-- ENDIF -->">
|
||||
<div class="avatar-container">
|
||||
<!-- EVENT viewtopic_body_avatar_before -->
|
||||
<!-- IF postrow.POSTER_AVATAR -->
|
||||
<!-- IF postrow.U_POST_AUTHOR --><a href="{postrow.U_POST_AUTHOR}" class="avatar">{postrow.POSTER_AVATAR}</a><!-- ELSE --><span class="avatar">{postrow.POSTER_AVATAR}</span><!-- ENDIF -->
|
||||
<!-- IF postrow.POSTER_AVATAR_HTML -->
|
||||
<!-- IF postrow.U_POST_AUTHOR --><a href="{postrow.U_POST_AUTHOR}" class="avatar">{postrow.POSTER_AVATAR_HTML}</a><!-- ELSE --><span class="avatar">{postrow.POSTER_AVATAR}</span><!-- ENDIF -->
|
||||
<!-- ENDIF -->
|
||||
<!-- EVENT viewtopic_body_avatar_after -->
|
||||
</div>
|
||||
|
@ -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')) ? $avatar_helper->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,6 @@ 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_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'],
|
||||
@ -2111,6 +2112,11 @@ for ($i = 0, $end = count($post_list); $i < $end; ++$i)
|
||||
'S_DELETE_PERMANENT' => $permanent_delete_allowed,
|
||||
);
|
||||
|
||||
if ($user_cache[$poster_id]['avatar'])
|
||||
{
|
||||
$post_row += $avatar_helper->get_template_vars($user_cache[$poster_id]['avatar'], 'POSTER_');
|
||||
}
|
||||
|
||||
$user_poster_data = $user_cache[$poster_id];
|
||||
|
||||
$current_row_number = $i;
|
||||
|
@ -69,7 +69,11 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case
|
||||
));
|
||||
$user->data['user_email'] = '';
|
||||
|
||||
$this->user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
|
||||
$avatar_helper = $this->getMockBuilder('\phpbb\avatar\helper')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->user_loader = new \phpbb\user_loader($avatar_helper, $db, $phpbb_root_path, $phpEx, USERS_TABLE);
|
||||
|
||||
$driver_helper = new \phpbb\passwords\driver\helper($this->config);
|
||||
$passwords_drivers = array(
|
||||
|
@ -113,7 +113,11 @@ class phpbb_group_helper_test_case extends phpbb_test_case
|
||||
$user = new \phpbb\user($lang, '\phpbb\datetime');
|
||||
$user->data['user_id'] = ANONYMOUS;
|
||||
|
||||
$this->group_helper = new \phpbb\group\helper($auth, $cache_service, $config, $lang, $phpbb_dispatcher, $path_helper, $user);
|
||||
$avatar_helper = $this->getMockBuilder('\phpbb\avatar\helper')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->group_helper = new \phpbb\group\helper($auth, $avatar_helper, $cache_service, $config, $lang, $phpbb_dispatcher, $path_helper, $user);
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
|
@ -63,6 +63,9 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
|
||||
|
||||
global $db, $config, $user, $auth, $cache, $phpbb_container;
|
||||
|
||||
$avatar_helper = $this->getMockBuilder('\phpbb\avatar\helper')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$db = $this->db = $this->new_dbal();
|
||||
$config = $this->config = new \phpbb\config\config(array(
|
||||
'allow_privmsg' => true,
|
||||
@ -77,7 +80,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
|
||||
$user->data['user_id'] = 0;
|
||||
$user->data['user_type'] = USER_NORMAL;
|
||||
$this->user = $user;
|
||||
$this->user_loader = new \phpbb\user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users');
|
||||
$this->user_loader = new \phpbb\user_loader($avatar_helper, $this->db, $phpbb_root_path, $phpEx, 'phpbb_users');
|
||||
$auth = $this->auth = new phpbb_mock_notifications_auth();
|
||||
$cache_driver = new \phpbb\cache\driver\dummy();
|
||||
$cache = $this->cache = new \phpbb\cache\service(
|
||||
|
@ -48,6 +48,7 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas
|
||||
));
|
||||
$this->container->set('group_helper', new \phpbb\group\helper(
|
||||
$this->getMockBuilder('\phpbb\auth\auth')->disableOriginalConstructor()->getMock(),
|
||||
$this->getMockBuilder('\phpbb\avatar\helper')->disableOriginalConstructor()->getMock(),
|
||||
$this->cache,
|
||||
$this->config,
|
||||
new \phpbb\language\language(
|
||||
|
@ -44,6 +44,9 @@ class notification_method_email_test extends phpbb_tests_notification_base
|
||||
|
||||
global $db, $config, $user, $auth, $cache, $phpbb_container;
|
||||
|
||||
$avatar_helper = $this->getMockBuilder('\phpbb\avatar\helper')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$db = $this->db = $this->new_dbal();
|
||||
$config = $this->config = new \phpbb\config\config([
|
||||
'allow_privmsg' => true,
|
||||
@ -56,7 +59,7 @@ class notification_method_email_test extends phpbb_tests_notification_base
|
||||
$lang = new \phpbb\language\language($lang_loader);
|
||||
$user = new \phpbb\user($lang, '\phpbb\datetime');
|
||||
$this->user = $user;
|
||||
$this->user_loader = new \phpbb\user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users');
|
||||
$this->user_loader = new \phpbb\user_loader($avatar_helper, $this->db, $phpbb_root_path, $phpEx, 'phpbb_users');
|
||||
$auth = $this->auth = new phpbb_mock_notifications_auth();
|
||||
$cache_driver = new \phpbb\cache\driver\dummy();
|
||||
$cache = $this->cache = new \phpbb\cache\service(
|
||||
|
@ -112,8 +112,12 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
|
||||
$type_cast_helper = $this->createMock('\phpbb\request\type_cast_helper_interface');
|
||||
$request = $this->createMock('\phpbb\request\request');
|
||||
|
||||
$avatar_helper = $this->getMockBuilder('\phpbb\avatar\helper')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
|
||||
$user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
|
||||
$user_loader = new \phpbb\user_loader($avatar_helper, $db, $phpbb_root_path, $phpEx, USERS_TABLE);
|
||||
|
||||
// Container
|
||||
$phpbb_container = new ContainerBuilder();
|
||||
|
@ -57,7 +57,11 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
|
||||
];
|
||||
$lang->add_lang('common');
|
||||
|
||||
$user_loader = new phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
|
||||
$avatar_helper = $this->getMockBuilder('\phpbb\avatar\helper')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$user_loader = new phpbb\user_loader($avatar_helper, $db, $phpbb_root_path, $phpEx, USERS_TABLE);
|
||||
$user_loader->load_users(array(2, 3, 4, 5, 6));
|
||||
|
||||
$this->notification = new phpbb_mock_notification_type_post(
|
||||
|
@ -25,8 +25,11 @@ class phpbb_user_loader_test extends phpbb_database_test_case
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$avatar_helper = $this->getMockBuilder('\phpbb\avatar\helper')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->db = $this->new_dbal();
|
||||
$this->user_loader = new \phpbb\user_loader($this->db, __DIR__ . '/../../phpBB/', 'php', 'phpbb_users');
|
||||
$this->user_loader = new \phpbb\user_loader($avatar_helper, $this->db, __DIR__ . '/../../phpBB/', 'php', 'phpbb_users');
|
||||
}
|
||||
|
||||
public function test_load_get()
|
||||
|
Loading…
x
Reference in New Issue
Block a user