mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/12612] Move functions from memberlist.php to functions_display.php
PHPBB3-12612
This commit is contained in:
parent
73c69cc653
commit
7e66fa0f8d
2 changed files with 163 additions and 163 deletions
|
@ -1440,3 +1440,166 @@ function phpbb_gen_download_links($param_key, $param_val, $phpbb_root_path, $php
|
|||
|
||||
return $links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare profile data
|
||||
*/
|
||||
function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = false)
|
||||
{
|
||||
global $config, $auth, $template, $user, $phpEx, $phpbb_root_path, $phpbb_dispatcher;
|
||||
|
||||
$username = $data['username'];
|
||||
$user_id = $data['user_id'];
|
||||
|
||||
$rank_title = $rank_img = $rank_img_src = '';
|
||||
get_user_rank($data['user_rank'], (($user_id == ANONYMOUS) ? false : $data['user_posts']), $rank_title, $rank_img, $rank_img_src);
|
||||
|
||||
if ((!empty($data['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_user'))
|
||||
{
|
||||
$email = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&u=' . $user_id) : (($config['board_hide_emails'] && !$auth->acl_get('a_user')) ? '' : 'mailto:' . $data['user_email']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$email = '';
|
||||
}
|
||||
|
||||
if ($config['load_onlinetrack'])
|
||||
{
|
||||
$update_time = $config['load_online_time'] * 60;
|
||||
$online = (time() - $update_time < $data['session_time'] && ((isset($data['session_viewonline']) && $data['session_viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$online = false;
|
||||
}
|
||||
|
||||
if ($data['user_allow_viewonline'] || $auth->acl_get('u_viewonline'))
|
||||
{
|
||||
$last_active = (!empty($data['session_time'])) ? $data['session_time'] : $data['user_lastvisit'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$last_active = '';
|
||||
}
|
||||
|
||||
$age = '';
|
||||
|
||||
if ($config['allow_birthdays'] && $data['user_birthday'])
|
||||
{
|
||||
list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $data['user_birthday']));
|
||||
|
||||
if ($bday_year)
|
||||
{
|
||||
$now = $user->create_datetime();
|
||||
$now = phpbb_gmgetdate($now->getTimestamp() + $now->getOffset());
|
||||
|
||||
$diff = $now['mon'] - $bday_month;
|
||||
if ($diff == 0)
|
||||
{
|
||||
$diff = ($now['mday'] - $bday_day < 0) ? 1 : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$diff = ($diff < 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
$age = max(0, (int) ($now['year'] - $bday_year - $diff));
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('phpbb_get_banned_user_ids'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
||||
}
|
||||
|
||||
// Can this user receive a Private Message?
|
||||
$can_receive_pm = (
|
||||
// They must be a "normal" user
|
||||
$data['user_type'] != USER_IGNORE &&
|
||||
|
||||
// They must not be deactivated by the administrator
|
||||
($data['user_type'] != USER_INACTIVE || $data['user_inactive_reason'] != INACTIVE_MANUAL) &&
|
||||
|
||||
// They must be able to read PMs
|
||||
sizeof($auth->acl_get_list($user_id, 'u_readpm')) &&
|
||||
|
||||
// They must not be permanently banned
|
||||
!sizeof(phpbb_get_banned_user_ids($user_id, false)) &&
|
||||
|
||||
// They must allow users to contact via PM
|
||||
(($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $data['user_allow_pm'])
|
||||
);
|
||||
|
||||
// Dump it out to the template
|
||||
$template_data = array(
|
||||
'AGE' => $age,
|
||||
'RANK_TITLE' => $rank_title,
|
||||
'JOINED' => $user->format_date($data['user_regdate']),
|
||||
'LAST_ACTIVE' => (empty($last_active)) ? ' - ' : $user->format_date($last_active),
|
||||
'POSTS' => ($data['user_posts']) ? $data['user_posts'] : 0,
|
||||
'WARNINGS' => isset($data['user_warnings']) ? $data['user_warnings'] : 0,
|
||||
|
||||
'USERNAME_FULL' => get_username_string('full', $user_id, $username, $data['user_colour']),
|
||||
'USERNAME' => get_username_string('username', $user_id, $username, $data['user_colour']),
|
||||
'USER_COLOR' => get_username_string('colour', $user_id, $username, $data['user_colour']),
|
||||
'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $data['user_colour']),
|
||||
|
||||
'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' => $rank_img,
|
||||
'RANK_IMG_SRC' => $rank_img_src,
|
||||
'S_JABBER_ENABLED' => ($config['jab_enable']) ? true : false,
|
||||
|
||||
'S_WARNINGS' => ($auth->acl_getf_global('m_') || $auth->acl_get('m_warn')) ? true : false,
|
||||
|
||||
'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$user_id&sr=posts") : '',
|
||||
'U_NOTES' => ($user_notes_enabled && $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $user_id, true, $user->session_id) : '',
|
||||
'U_WARN' => ($warn_user_enabled && $auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $user_id, true, $user->session_id) : '',
|
||||
'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && $can_receive_pm) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $user_id) : '',
|
||||
'U_EMAIL' => $email,
|
||||
'U_JABBER' => ($data['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=jabber&u=' . $user_id) : '',
|
||||
|
||||
'USER_JABBER' => $data['user_jabber'],
|
||||
'USER_JABBER_IMG' => ($data['user_jabber']) ? $user->img('icon_contact_jabber', $data['user_jabber']) : '',
|
||||
|
||||
'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
|
||||
*
|
||||
* @event core.memberlist_prepare_profile_data
|
||||
* @var array data Array with user's data
|
||||
* @var array template_data Template array with user's data
|
||||
* @since 3.1.0-a1
|
||||
*/
|
||||
$vars = array('data', 'template_data');
|
||||
extract($phpbb_dispatcher->trigger_event('core.memberlist_prepare_profile_data', compact($vars)));
|
||||
|
||||
return $template_data;
|
||||
}
|
||||
|
||||
function _sort_last_active($first, $second)
|
||||
{
|
||||
global $id_cache, $sort_dir;
|
||||
|
||||
$lesser_than = ($sort_dir === 'd') ? -1 : 1;
|
||||
|
||||
if (isset($id_cache[$first]['group_leader']) && $id_cache[$first]['group_leader'] && (!isset($id_cache[$second]['group_leader']) || !$id_cache[$second]['group_leader']))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (isset($id_cache[$second]['group_leader']) && (!isset($id_cache[$first]['group_leader']) || !$id_cache[$first]['group_leader']) && $id_cache[$second]['group_leader'])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $lesser_than * (int) ($id_cache[$first]['last_visit'] - $id_cache[$second]['last_visit']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1485,166 +1485,3 @@ $template->set_filenames(array(
|
|||
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
|
||||
|
||||
page_footer();
|
||||
|
||||
/**
|
||||
* Prepare profile data
|
||||
*/
|
||||
function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = false)
|
||||
{
|
||||
global $config, $auth, $template, $user, $phpEx, $phpbb_root_path, $phpbb_dispatcher;
|
||||
|
||||
$username = $data['username'];
|
||||
$user_id = $data['user_id'];
|
||||
|
||||
$rank_title = $rank_img = $rank_img_src = '';
|
||||
get_user_rank($data['user_rank'], (($user_id == ANONYMOUS) ? false : $data['user_posts']), $rank_title, $rank_img, $rank_img_src);
|
||||
|
||||
if ((!empty($data['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_user'))
|
||||
{
|
||||
$email = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&u=' . $user_id) : (($config['board_hide_emails'] && !$auth->acl_get('a_user')) ? '' : 'mailto:' . $data['user_email']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$email = '';
|
||||
}
|
||||
|
||||
if ($config['load_onlinetrack'])
|
||||
{
|
||||
$update_time = $config['load_online_time'] * 60;
|
||||
$online = (time() - $update_time < $data['session_time'] && ((isset($data['session_viewonline']) && $data['session_viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$online = false;
|
||||
}
|
||||
|
||||
if ($data['user_allow_viewonline'] || $auth->acl_get('u_viewonline'))
|
||||
{
|
||||
$last_active = (!empty($data['session_time'])) ? $data['session_time'] : $data['user_lastvisit'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$last_active = '';
|
||||
}
|
||||
|
||||
$age = '';
|
||||
|
||||
if ($config['allow_birthdays'] && $data['user_birthday'])
|
||||
{
|
||||
list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $data['user_birthday']));
|
||||
|
||||
if ($bday_year)
|
||||
{
|
||||
$now = $user->create_datetime();
|
||||
$now = phpbb_gmgetdate($now->getTimestamp() + $now->getOffset());
|
||||
|
||||
$diff = $now['mon'] - $bday_month;
|
||||
if ($diff == 0)
|
||||
{
|
||||
$diff = ($now['mday'] - $bday_day < 0) ? 1 : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$diff = ($diff < 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
$age = max(0, (int) ($now['year'] - $bday_year - $diff));
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('phpbb_get_banned_user_ids'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
||||
}
|
||||
|
||||
// Can this user receive a Private Message?
|
||||
$can_receive_pm = (
|
||||
// They must be a "normal" user
|
||||
$data['user_type'] != USER_IGNORE &&
|
||||
|
||||
// They must not be deactivated by the administrator
|
||||
($data['user_type'] != USER_INACTIVE || $data['user_inactive_reason'] != INACTIVE_MANUAL) &&
|
||||
|
||||
// They must be able to read PMs
|
||||
sizeof($auth->acl_get_list($user_id, 'u_readpm')) &&
|
||||
|
||||
// They must not be permanently banned
|
||||
!sizeof(phpbb_get_banned_user_ids($user_id, false)) &&
|
||||
|
||||
// They must allow users to contact via PM
|
||||
(($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $data['user_allow_pm'])
|
||||
);
|
||||
|
||||
// Dump it out to the template
|
||||
$template_data = array(
|
||||
'AGE' => $age,
|
||||
'RANK_TITLE' => $rank_title,
|
||||
'JOINED' => $user->format_date($data['user_regdate']),
|
||||
'LAST_ACTIVE' => (empty($last_active)) ? ' - ' : $user->format_date($last_active),
|
||||
'POSTS' => ($data['user_posts']) ? $data['user_posts'] : 0,
|
||||
'WARNINGS' => isset($data['user_warnings']) ? $data['user_warnings'] : 0,
|
||||
|
||||
'USERNAME_FULL' => get_username_string('full', $user_id, $username, $data['user_colour']),
|
||||
'USERNAME' => get_username_string('username', $user_id, $username, $data['user_colour']),
|
||||
'USER_COLOR' => get_username_string('colour', $user_id, $username, $data['user_colour']),
|
||||
'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $data['user_colour']),
|
||||
|
||||
'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' => $rank_img,
|
||||
'RANK_IMG_SRC' => $rank_img_src,
|
||||
'S_JABBER_ENABLED' => ($config['jab_enable']) ? true : false,
|
||||
|
||||
'S_WARNINGS' => ($auth->acl_getf_global('m_') || $auth->acl_get('m_warn')) ? true : false,
|
||||
|
||||
'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$user_id&sr=posts") : '',
|
||||
'U_NOTES' => ($user_notes_enabled && $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $user_id, true, $user->session_id) : '',
|
||||
'U_WARN' => ($warn_user_enabled && $auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $user_id, true, $user->session_id) : '',
|
||||
'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && $can_receive_pm) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $user_id) : '',
|
||||
'U_EMAIL' => $email,
|
||||
'U_JABBER' => ($data['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=jabber&u=' . $user_id) : '',
|
||||
|
||||
'USER_JABBER' => $data['user_jabber'],
|
||||
'USER_JABBER_IMG' => ($data['user_jabber']) ? $user->img('icon_contact_jabber', $data['user_jabber']) : '',
|
||||
|
||||
'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
|
||||
*
|
||||
* @event core.memberlist_prepare_profile_data
|
||||
* @var array data Array with user's data
|
||||
* @var array template_data Template array with user's data
|
||||
* @since 3.1.0-a1
|
||||
*/
|
||||
$vars = array('data', 'template_data');
|
||||
extract($phpbb_dispatcher->trigger_event('core.memberlist_prepare_profile_data', compact($vars)));
|
||||
|
||||
return $template_data;
|
||||
}
|
||||
|
||||
function _sort_last_active($first, $second)
|
||||
{
|
||||
global $id_cache, $sort_dir;
|
||||
|
||||
$lesser_than = ($sort_dir === 'd') ? -1 : 1;
|
||||
|
||||
if (isset($id_cache[$first]['group_leader']) && $id_cache[$first]['group_leader'] && (!isset($id_cache[$second]['group_leader']) || !$id_cache[$second]['group_leader']))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (isset($id_cache[$second]['group_leader']) && (!isset($id_cache[$first]['group_leader']) || !$id_cache[$first]['group_leader']) && $id_cache[$second]['group_leader'])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $lesser_than * (int) ($id_cache[$first]['last_visit'] - $id_cache[$second]['last_visit']);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue