diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-06-18 15:15:56 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-06-18 16:56:44 +0200 |
commit | 7e66fa0f8df3304f12737c1e1346340841d91eee (patch) | |
tree | ff7e0c244713349a4bb8d1e23f234b0dd6a146d3 /phpBB | |
parent | 73c69cc6536b189ca29494ca6e550e0432f419b3 (diff) | |
download | forums-7e66fa0f8df3304f12737c1e1346340841d91eee.tar forums-7e66fa0f8df3304f12737c1e1346340841d91eee.tar.gz forums-7e66fa0f8df3304f12737c1e1346340841d91eee.tar.bz2 forums-7e66fa0f8df3304f12737c1e1346340841d91eee.tar.xz forums-7e66fa0f8df3304f12737c1e1346340841d91eee.zip |
[ticket/12612] Move functions from memberlist.php to functions_display.php
PHPBB3-12612
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/includes/functions_display.php | 163 | ||||
-rw-r--r-- | phpBB/memberlist.php | 163 |
2 files changed, 163 insertions, 163 deletions
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 4606a9f7ca..7e5f0ca143 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -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']); + } +} diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 4eb6d79272..c4d0a5258d 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -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']); - } -} |