diff options
author | Maat <maat-pub@mageia.biz> | 2020-05-08 21:52:11 +0200 |
---|---|---|
committer | Maat <maat-pub@mageia.biz> | 2020-05-08 21:52:11 +0200 |
commit | 8ea437e30605e0f66b5220bf904a61d7c1d11ddd (patch) | |
tree | e0db2bb4a012d5b06a633160b19f62f4868ecd28 /phpBB/memberlist.php | |
parent | 36bc1870f21fac04736a1049c1d5b8e127d729f4 (diff) | |
parent | 2fdd46b36431ae0f58bb2e78e42553168db9a0ff (diff) | |
download | forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.gz forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.bz2 forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.xz forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.zip |
Merge remote-tracking branch 'upstream/prep-release-3.2.9'
Diffstat (limited to 'phpBB/memberlist.php')
-rw-r--r-- | phpBB/memberlist.php | 409 |
1 files changed, 291 insertions, 118 deletions
diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index b1982958d5..1343bd7c60 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -20,7 +20,7 @@ $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); include($phpbb_root_path . 'includes/functions_display.' . $phpEx); -$mode = request_var('mode', ''); +$mode = $request->variable('mode', ''); if ($mode === 'contactadmin') { @@ -37,11 +37,11 @@ $user->setup(array('memberlist', 'groups')); $template->assign_var('S_IN_MEMBERLIST', true); // Grab data -$action = request_var('action', ''); -$user_id = request_var('u', ANONYMOUS); -$username = request_var('un', '', true); -$group_id = request_var('g', 0); -$topic_id = request_var('t', 0); +$action = $request->variable('action', ''); +$user_id = $request->variable('u', ANONYMOUS); +$username = $request->variable('un', '', true); +$group_id = $request->variable('g', 0); +$topic_id = $request->variable('t', 0); // Redirect when old mode is used if ($mode == 'leaders') @@ -75,6 +75,7 @@ switch ($mode) { if ($user->data['user_id'] != ANONYMOUS) { + send_status_line(403, 'Forbidden'); trigger_error('NO_VIEW_USERS'); } @@ -83,12 +84,15 @@ switch ($mode) break; } -$start = request_var('start', 0); +/** @var \phpbb\group\helper $group_helper */ +$group_helper = $phpbb_container->get('group_helper'); + +$start = $request->variable('start', 0); $submit = (isset($_POST['submit'])) ? true : false; $default_key = 'c'; -$sort_key = request_var('sk', $default_key); -$sort_dir = request_var('sd', 'a'); +$sort_key = $request->variable('sk', $default_key); +$sort_dir = $request->variable('sd', 'a'); $user_types = array(USER_NORMAL, USER_FOUNDER); if ($auth->acl_get('a_user')) @@ -145,7 +149,7 @@ switch ($mode) } else { - $row['group_name'] = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']; + $row['group_name'] = $group_helper->get_name($row['group_name']); $row['u_group'] = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']); } @@ -169,7 +173,7 @@ switch ($mode) 'LEFT_JOIN' => array( array( 'FROM' => array(USERS_TABLE => 'u'), - 'ON' => 'ug.user_id = u.user_id AND ug.user_pending = 0', + 'ON' => 'ug.user_id = u.user_id', ), array( 'FROM' => array(GROUPS_TABLE => 'g'), @@ -177,7 +181,7 @@ switch ($mode) ), ), - 'WHERE' => $db->sql_in_set('g.group_id', $group_ids, false, true), + 'WHERE' => $db->sql_in_set('g.group_id', $group_ids, false, true) . ' AND ug.user_pending = 0', 'ORDER_BY' => 'u.username_clean ASC', ); @@ -372,6 +376,7 @@ switch ($mode) if (!$auth->acl_get('u_sendim')) { + send_status_line(403, 'Forbidden'); trigger_error('NOT_AUTHORISED'); } @@ -422,7 +427,7 @@ switch ($mode) include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); $subject = sprintf($user->lang['IM_JABBER_SUBJECT'], $user->data['username'], $config['server_name']); - $message = utf8_normalize_nfc(request_var('message', '', true)); + $message = $request->variable('message', '', true); if (empty($message)) { @@ -484,9 +489,31 @@ switch ($mode) } // Get user... - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE ' . (($username) ? "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'" : "user_id = $user_id"); + $sql_array = array( + 'SELECT' => 'u.*', + 'FROM' => array( + USERS_TABLE => 'u' + ), + 'WHERE' => (($username) ? "u.username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'" : "u.user_id = $user_id"), + ); + + /** + * Modify user data SQL before member profile row is created + * + * @event core.memberlist_modify_viewprofile_sql + * @var int user_id The user ID + * @var string username The username + * @var array sql_array Array containing the main query + * @since 3.2.6-RC1 + */ + $vars = array( + 'user_id', + 'username', + 'sql_array', + ); + extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_viewprofile_sql', compact($vars))); + + $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $member = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -518,12 +545,37 @@ switch ($mode) $sql_uid_ary = ($auth_hidden_groups) ? array($user_id) : array($user_id, (int) $user->data['user_id']); // Do the SQL thang - $sql = 'SELECT g.group_id, g.group_name, g.group_type, ug.user_id - FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug - WHERE ' . $db->sql_in_set('ug.user_id', $sql_uid_ary) . ' - AND g.group_id = ug.group_id - AND ug.user_pending = 0'; - $result = $db->sql_query($sql); + $sql_ary = [ + 'SELECT' => 'g.group_id, g.group_name, g.group_type, ug.user_id', + + 'FROM' => [ + GROUPS_TABLE => 'g', + ], + + 'LEFT_JOIN' => [ + [ + 'FROM' => [USER_GROUP_TABLE => 'ug'], + 'ON' => 'g.group_id = ug.group_id', + ], + ], + + 'WHERE' => $db->sql_in_set('ug.user_id', $sql_uid_ary) . ' + AND ug.user_pending = 0', + ]; + + /** + * Modify the query used to get the group data + * + * @event core.modify_memberlist_viewprofile_group_sql + * @var array sql_ary Array containing the query + * @since 3.2.6-RC1 + */ + $vars = array( + 'sql_ary', + ); + extract($phpbb_dispatcher->trigger_event('core.modify_memberlist_viewprofile_group_sql', compact($vars))); + + $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); // Divide data into profile data and current user data $profile_groups = $user_groups = array(); @@ -547,20 +599,14 @@ switch ($mode) $group_data = $group_sort = array(); foreach ($profile_groups as $row) { - if ($row['group_type'] == GROUP_SPECIAL) - { - // Lookup group name in language dictionary - if (isset($user->lang['G_' . $row['group_name']])) - { - $row['group_name'] = $user->lang['G_' . $row['group_name']]; - } - } - else if (!$auth_hidden_groups && $row['group_type'] == GROUP_HIDDEN && !isset($user_groups[$row['group_id']])) + if (!$auth_hidden_groups && $row['group_type'] == GROUP_HIDDEN && !isset($user_groups[$row['group_id']])) { // Skip over hidden groups the user cannot see continue; } + $row['group_name'] = $group_helper->get_name($row['group_name']); + $group_sort[$row['group_id']] = utf8_clean_string($row['group_name']); $group_data[$row['group_id']] = $row; } @@ -568,6 +614,20 @@ switch ($mode) unset($user_groups); asort($group_sort); + /** + * Modify group data before options is created and data is unset + * + * @event core.modify_memberlist_viewprofile_group_data + * @var array group_data Array containing the group data + * @var array group_sort Array containing the sorted group data + * @since 3.2.6-RC1 + */ + $vars = array( + 'group_data', + 'group_sort', + ); + extract($phpbb_dispatcher->trigger_event('core.modify_memberlist_viewprofile_group_data', compact($vars))); + $group_options = ''; foreach ($group_sort as $group_id => $null) { @@ -649,6 +709,7 @@ switch ($mode) $profile_fields = array(); if ($config['load_cpf_viewprofile']) { + /* @var $cp \phpbb\profilefields\manager */ $cp = $phpbb_container->get('profilefields.manager'); $profile_fields = $cp->grab_profile_fields_data($user_id); $profile_fields = (isset($profile_fields[$user_id])) ? $cp->generate_profile_fields_template_data($profile_fields[$user_id]) : array(); @@ -702,42 +763,58 @@ switch ($mode) $member['posts_in_queue'] = 0; } - $template->assign_vars(array( - 'L_POSTS_IN_QUEUE' => $user->lang('NUM_POSTS_IN_QUEUE', $member['posts_in_queue']), + // Define the main array of vars to assign to memberlist_view.html + $template_ary = array( + 'L_POSTS_IN_QUEUE' => $user->lang('NUM_POSTS_IN_QUEUE', $member['posts_in_queue']), - 'POSTS_DAY' => $user->lang('POST_DAY', $posts_per_day), - 'POSTS_PCT' => $user->lang('POST_PCT', $percentage), + 'POSTS_DAY' => $user->lang('POST_DAY', $posts_per_day), + 'POSTS_PCT' => $user->lang('POST_PCT', $percentage), - 'SIGNATURE' => $member['user_sig'], - 'POSTS_IN_QUEUE'=> $member['posts_in_queue'], + 'SIGNATURE' => $member['user_sig'], + 'POSTS_IN_QUEUE' => $member['posts_in_queue'], - 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']), - 'L_SEND_EMAIL_USER' => $user->lang('SEND_EMAIL_USER', $member['username']), - 'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']), - 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), - 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), + 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']), + 'L_SEND_EMAIL_USER' => $user->lang('SEND_EMAIL_USER', $member['username']), + 'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']), + 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), + 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), - 'S_PROFILE_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group'), - 'S_GROUP_OPTIONS' => $group_options, - 'S_CUSTOM_FIELDS' => (isset($profile_fields['row']) && sizeof($profile_fields['row'])) ? true : false, + 'S_PROFILE_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group'), + 'S_GROUP_OPTIONS' => $group_options, + 'S_CUSTOM_FIELDS' => (isset($profile_fields['row']) && count($profile_fields['row'])) ? true : false, - 'U_USER_ADMIN' => ($auth->acl_get('a_user')) ? append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=overview&u=' . $user_id, true, $user->session_id) : '', - 'U_USER_BAN' => ($auth->acl_get('m_ban') && $user_id != $user->data['user_id']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=ban&mode=user&u=' . $user_id, true, $user->session_id) : '', - 'U_MCP_QUEUE' => ($auth->acl_getf_global('m_approve')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue', true, $user->session_id) : '', + 'U_USER_ADMIN' => ($auth->acl_get('a_user')) ? append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=overview&u=' . $user_id, true, $user->session_id) : '', + 'U_USER_BAN' => ($auth->acl_get('m_ban') && $user_id != $user->data['user_id']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=ban&mode=user&u=' . $user_id, true, $user->session_id) : '', + 'U_MCP_QUEUE' => ($auth->acl_getf_global('m_approve')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue', true, $user->session_id) : '', - 'U_SWITCH_PERMISSIONS' => ($auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_id) ? append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=switch_perm&u={$user_id}&hash=" . generate_link_hash('switchperm')) : '', - 'U_EDIT_SELF' => ($user_id == $user->data['user_id'] && $auth->acl_get('u_chgprofileinfo')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_profile&mode=profile_info') : '', + 'U_SWITCH_PERMISSIONS' => ($auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_id) ? append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=switch_perm&u={$user_id}&hash=" . generate_link_hash('switchperm')) : '', + 'U_EDIT_SELF' => ($user_id == $user->data['user_id'] && $auth->acl_get('u_chgprofileinfo')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_profile&mode=profile_info') : '', - 'S_USER_NOTES' => ($user_notes_enabled) ? true : false, - 'S_WARN_USER' => ($warn_user_enabled) ? true : false, - 'S_ZEBRA' => ($user->data['user_id'] != $user_id && $user->data['is_registered'] && $zebra_enabled) ? true : false, - 'U_ADD_FRIEND' => (!$friend && !$foe && $friends_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', - 'U_ADD_FOE' => (!$friend && !$foe && $foes_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&mode=foes&add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', - 'U_REMOVE_FRIEND' => ($friend && $friends_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&remove=1&usernames[]=' . $user_id) : '', - 'U_REMOVE_FOE' => ($foe && $foes_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&remove=1&mode=foes&usernames[]=' . $user_id) : '', + 'S_USER_NOTES' => ($user_notes_enabled) ? true : false, + 'S_WARN_USER' => ($warn_user_enabled) ? true : false, + 'S_ZEBRA' => ($user->data['user_id'] != $user_id && $user->data['is_registered'] && $zebra_enabled) ? true : false, + 'U_ADD_FRIEND' => (!$friend && !$foe && $friends_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', + 'U_ADD_FOE' => (!$friend && !$foe && $foes_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&mode=foes&add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', + 'U_REMOVE_FRIEND' => ($friend && $friends_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&remove=1&usernames[]=' . $user_id) : '', + 'U_REMOVE_FOE' => ($foe && $foes_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&remove=1&mode=foes&usernames[]=' . $user_id) : '', - 'U_CANONICAL' => generate_board_url() . '/' . append_sid("memberlist.$phpEx", 'mode=viewprofile&u=' . $user_id, true, ''), - )); + 'U_CANONICAL' => generate_board_url() . '/' . append_sid("memberlist.$phpEx", 'mode=viewprofile&u=' . $user_id, true, ''), + ); + + /** + * Modify user's template vars before we display the profile + * + * @event core.memberlist_modify_view_profile_template_vars + * @var array template_ary Array with user's template vars + * @since 3.2.6-RC1 + */ + $vars = array( + 'template_ary', + ); + extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_view_profile_template_vars', compact($vars))); + + // Assign vars to memberlist_view.html + $template->assign_vars($template_ary); if (!empty($profile_fields['row'])) { @@ -797,8 +874,8 @@ switch ($mode) include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); } - $user_id = request_var('u', 0); - $topic_id = request_var('t', 0); + $user_id = $request->variable('u', 0); + $topic_id = $request->variable('t', 0); if ($user_id) { @@ -816,6 +893,8 @@ switch ($mode) { trigger_error('NO_EMAIL'); } + + /** @var $form \phpbb\message\form */ $form = $phpbb_container->get('message.form.' . $form_name); $form->bind($request); @@ -871,6 +950,8 @@ switch ($mode) // The basic memberlist $page_title = $user->lang['MEMBERLIST']; $template_html = 'memberlist_body.html'; + + /* @var $pagination \phpbb\pagination */ $pagination = $phpbb_container->get('pagination'); // Sorting @@ -919,9 +1000,9 @@ switch ($mode) $sql_select = $sql_where_data = $sql_from = $sql_where = $order_by = ''; - $form = request_var('form', ''); - $field = request_var('field', ''); - $select_single = request_var('select_single', false); + $form = $request->variable('form', ''); + $field = $request->variable('field', ''); + $select_single = $request->variable('select_single', false); // Search URL parameters, if any of these are in the URL we do a search $search_params = array('username', 'email', 'jabber', 'search_group_id', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'ip'); @@ -929,22 +1010,22 @@ switch ($mode) // We validate form and field here, only id/class allowed $form = (!preg_match('/^[a-z0-9_-]+$/i', $form)) ? '' : $form; $field = (!preg_match('/^[a-z0-9_-]+$/i', $field)) ? '' : $field; - if ((($mode == '' || $mode == 'searchuser') || sizeof(array_intersect($request->variable_names(\phpbb\request\request_interface::GET), $search_params)) > 0) && ($config['load_search'] || $auth->acl_get('a_'))) + if ((($mode == '' || $mode == 'searchuser') || count(array_intersect($request->variable_names(\phpbb\request\request_interface::GET), $search_params)) > 0) && ($config['load_search'] || $auth->acl_get('a_'))) { - $username = request_var('username', '', true); - $email = strtolower(request_var('email', '')); - $jabber = request_var('jabber', ''); - $search_group_id = request_var('search_group_id', 0); + $username = $request->variable('username', '', true); + $email = strtolower($request->variable('email', '')); + $jabber = $request->variable('jabber', ''); + $search_group_id = $request->variable('search_group_id', 0); // when using these, make sure that we actually have values defined in $find_key_match - $joined_select = request_var('joined_select', 'lt'); - $active_select = request_var('active_select', 'lt'); - $count_select = request_var('count_select', 'eq'); + $joined_select = $request->variable('joined_select', 'lt'); + $active_select = $request->variable('active_select', 'lt'); + $count_select = $request->variable('count_select', 'eq'); - $joined = explode('-', request_var('joined', '')); - $active = explode('-', request_var('active', '')); - $count = (request_var('count', '') !== '') ? request_var('count', 0) : ''; - $ipdomain = request_var('ip', ''); + $joined = explode('-', $request->variable('joined', '')); + $active = explode('-', $request->variable('active', '')); + $count = ($request->variable('count', '') !== '') ? $request->variable('count', 0) : ''; + $ipdomain = $request->variable('ip', ''); $find_key_match = array('lt' => '<', 'gt' => '>', 'eq' => '='); @@ -976,7 +1057,7 @@ switch ($mode) $sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), $jabber)) . ' ' : ''; $sql_where .= (is_numeric($count) && isset($find_key_match[$count_select])) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : ''; - if (isset($find_key_match[$joined_select]) && sizeof($joined) == 3) + if (isset($find_key_match[$joined_select]) && count($joined) == 3) { $joined_time = gmmktime(0, 0, 0, (int) $joined[1], (int) $joined[2], (int) $joined[0]); @@ -986,13 +1067,24 @@ switch ($mode) } } - if (isset($find_key_match[$active_select]) && sizeof($active) == 3 && $auth->acl_get('u_viewonline')) + if (isset($find_key_match[$active_select]) && count($active) == 3 && $auth->acl_get('u_viewonline')) { $active_time = gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]); if ($active_time !== false) { - $sql_where .= " AND u.user_lastvisit " . $find_key_match[$active_select] . ' ' . $active_time; + if ($active_select === 'lt' && (int) $active[0] == 0 && (int) $active[1] == 0 && (int) $active[2] == 0) + { + $sql_where .= ' AND u.user_lastvisit = 0'; + } + else if ($active_select === 'gt') + { + $sql_where .= ' AND u.user_lastvisit ' . $find_key_match[$active_select] . ' ' . $active_time; + } + else + { + $sql_where .= ' AND (u.user_lastvisit > 0 AND u.user_lastvisit < ' . $active_time . ')'; + } } } @@ -1078,7 +1170,7 @@ switch ($mode) } } - $first_char = request_var('first_char', ''); + $first_char = $request->variable('first_char', ''); if ($first_char == 'other') { @@ -1142,18 +1234,18 @@ switch ($mode) $avatar_img = phpbb_get_group_avatar($group_row); // ... same for group rank - $user_rank_data = array( + $group_rank_data = array( 'title' => null, 'img' => null, 'img_src' => null, ); if ($group_row['group_rank']) { - $user_rank_data = phpbb_get_user_rank($group_row, false); + $group_rank_data = $group_helper->get_rank($group_row); - if ($user_rank_data['img']) + if ($group_rank_data['img']) { - $user_rank_data['img'] .= '<br />'; + $group_rank_data['img'] .= '<br />'; } } // include modules for manage groups link display or not @@ -1177,14 +1269,14 @@ switch ($mode) $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_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'], + 'GROUP_NAME' => $group_helper->get_name($group_row['group_name']), 'GROUP_COLOR' => $group_row['group_colour'], 'GROUP_TYPE' => $user->lang['GROUP_IS_' . $group_row['l_group_type']], - 'GROUP_RANK' => $user_rank_data['title'], + 'GROUP_RANK' => $group_rank_data['title'], 'AVATAR_IMG' => $avatar_img, - 'RANK_IMG' => $user_rank_data['img'], - 'RANK_IMG_SRC' => $user_rank_data['img_src'], + 'RANK_IMG' => $group_rank_data['img'], + 'RANK_IMG_SRC' => $group_rank_data['img_src'], 'U_PM' => ($auth->acl_get('u_sendpm') && $auth->acl_get('u_masspm_group') && $group_row['group_receive_pm'] && $config['allow_privmsg'] && $config['allow_mass_pm']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&g=' . $group_id) : '', 'U_MANAGE' => ($can_manage_group) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_groups&mode=manage') : false,) @@ -1250,7 +1342,7 @@ switch ($mode) // Build a relevant pagination_url $params = $sort_params = array(); - // We do not use request_var() here directly to save some calls (not all variables are set) + // We do not use $request->variable() here directly to save some calls (not all variables are set) $check_params = array( 'g' => array('g', 0), 'sk' => array('sk', $default_key), @@ -1267,7 +1359,7 @@ switch ($mode) 'count_select' => array('count_select', 'eq'), 'joined' => array('joined', ''), 'active' => array('active', ''), - 'count' => (request_var('count', '') !== '') ? array('count', 0) : array('count', ''), + 'count' => ($request->variable('count', '') !== '') ? array('count', 0) : array('count', ''), 'ip' => array('ip', ''), 'first_char' => array('first_char', ''), ); @@ -1280,7 +1372,7 @@ switch ($mode) continue; } - $param = call_user_func_array('request_var', $call); + $param = call_user_func_array(array($request, 'variable'), $call); // Encode strings, convert everything else to int in order to prevent empty parameters. $param = urlencode($key) . '=' . ((is_string($param)) ? urlencode($param) : (int) $param); $params[] = $param; @@ -1304,11 +1396,6 @@ switch ($mode) } $sort_params[] = "mode=$mode"; - $pagination_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&', $params)); - $sort_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&', $sort_params)); - - unset($search_params, $sort_params); - $u_first_char_params = implode('&', $u_first_char_params); $u_first_char_params .= ($u_first_char_params) ? '&' : ''; @@ -1320,20 +1407,51 @@ switch ($mode) } $first_characters['other'] = $user->lang['OTHER']; + $first_char_block_vars = []; + foreach ($first_characters as $char => $desc) { - $template->assign_block_vars('first_char', array( + $first_char_block_vars[] = [ 'DESC' => $desc, 'VALUE' => $char, 'S_SELECTED' => ($first_char == $char) ? true : false, 'U_SORT' => append_sid("{$phpbb_root_path}memberlist.$phpEx", $u_first_char_params . 'first_char=' . $char) . '#memberlist', - )); + ]; } + /** + * Modify memberlist sort and pagination parameters + * + * @event core.memberlist_modify_sort_pagination_params + * @var array sort_params Array with URL parameters for sorting + * @var array params Array with URL parameters for pagination + * @var array first_characters Array that maps each letter in a-z, 'other' and the empty string to their display representation + * @var string u_first_char_params Concatenated URL parameters for first character search links + * @var array first_char_block_vars Template block variables for each first character + * @var int total_users Total number of users found in this search + * @since 3.2.6-RC1 + */ + $vars = [ + 'sort_params', + 'params', + 'first_characters', + 'u_first_char_params', + 'first_char_block_vars', + 'total_users', + ]; + extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_sort_pagination_params', compact($vars))); + + $template->assign_block_vars_array('first_char', $first_char_block_vars); + + $pagination_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&', $params)); + $sort_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&', $sort_params)); + + unset($search_params, $sort_params); + // Some search user specific data if (($mode == '' || $mode == 'searchuser') && ($config['load_search'] || $auth->acl_get('a_'))) { - $group_selected = request_var('search_group_id', 0); + $group_selected = $request->variable('search_group_id', 0); $s_group_select = '<option value="0"' . ((!$group_selected) ? ' selected="selected"' : '') . '> </option>'; $group_ids = array(); @@ -1377,7 +1495,7 @@ switch ($mode) while ($row = $db->sql_fetchrow($result)) { $group_ids[] = $row['group_id']; - $s_group_select .= '<option value="' . $row['group_id'] . '"' . (($group_selected == $row['group_id']) ? ' selected="selected"' : '') . '>' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>'; + $s_group_select .= '<option value="' . $row['group_id'] . '"' . (($group_selected == $row['group_id']) ? ' selected="selected"' : '') . '>' . $group_helper->get_name($row['group_name']) . '</option>'; } $db->sql_freeresult($result); @@ -1433,6 +1551,7 @@ switch ($mode) // Load custom profile fields if ($config['load_cpf_memberlist']) { + /* @var $cp \phpbb\profilefields\manager */ $cp = $phpbb_container->get('profilefields.manager'); $cp_row = $cp->generate_profile_fields_template_headlines('field_show_on_ml'); @@ -1444,7 +1563,7 @@ switch ($mode) $leaders_set = false; // So, did we get any users? - if (sizeof($user_list)) + if (count($user_list)) { // Session time?! Session time... $sql = 'SELECT session_user_id, MAX(session_time) AS session_time @@ -1464,19 +1583,58 @@ switch ($mode) // Do the SQL thang if ($mode == 'group') { - $sql = "SELECT u.* - $sql_select - FROM " . USERS_TABLE . " u - $sql_from - WHERE " . $db->sql_in_set('u.user_id', $user_list) . " - $sql_where_data"; + $sql_from_ary = explode(',', $sql_from); + $extra_tables = []; + foreach ($sql_from_ary as $entry) + { + $table_data = explode(' ', trim($entry)); + + if (empty($table_data[0]) || empty($table_data[1])) + { + continue; + } + + $extra_tables[$table_data[0]] = $table_data[1]; + } + + $sql_array = array( + 'SELECT' => 'u.*' . $sql_select, + 'FROM' => array_merge([USERS_TABLE => 'u'], $extra_tables), + 'WHERE' => $db->sql_in_set('u.user_id', $user_list) . $sql_where_data . '', + ); } else { - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $user_list); + $sql_array = array( + 'SELECT' => 'u.*', + 'FROM' => array( + USERS_TABLE => 'u' + ), + 'WHERE' => $db->sql_in_set('u.user_id', $user_list), + ); } + + /** + * Modify user data SQL before member row is created + * + * @event core.memberlist_modify_memberrow_sql + * @var string mode Memberlist mode + * @var string sql_select Additional select statement + * @var string sql_from Additional from statement + * @var array sql_array Array containing the main query + * @var array user_list Array containing list of users + * @since 3.2.6-RC1 + */ + $vars = array( + 'mode', + 'sql_select', + 'sql_from', + 'sql_array', + 'user_list', + ); + extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_memberrow_sql', compact($vars))); + + $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $id_cache = array(); @@ -1487,9 +1645,10 @@ switch ($mode) $id_cache[$row['user_id']] = $row; } + $db->sql_freeresult($result); - // Load custom profile fields + // Load custom profile fields if required if ($config['load_cpf_memberlist']) { // Grab all profile fields from users in id cache for later use - similar to the poster cache @@ -1516,7 +1675,7 @@ switch ($mode) } // do we need to display contact fields as such - $use_contact_fields = false; + $use_contact_fields = true; /** * Modify list of users before member row is created @@ -1529,7 +1688,7 @@ switch ($mode) $vars = array('user_list', 'use_contact_fields'); extract($phpbb_dispatcher->trigger_event('core.memberlist_memberrow_before', compact($vars))); - for ($i = 0, $end = sizeof($user_list); $i < $end; ++$i) + for ($i = 0, $end = count($user_list); $i < $end; ++$i) { $user_id = $user_list[$i]; $row = $id_cache[$user_id]; @@ -1545,21 +1704,21 @@ switch ($mode) $memberrow = array_merge(phpbb_show_profile($row, false, false, false), array( 'ROW_NUMBER' => $i + ($start + 1), - 'S_CUSTOM_PROFILE' => (isset($cp_row['row']) && sizeof($cp_row['row'])) ? true : false, + 'S_CUSTOM_PROFILE' => (isset($cp_row['row']) && count($cp_row['row'])) ? true : false, 'S_GROUP_LEADER' => $is_leader, 'S_INACTIVE' => $row['user_type'] == USER_INACTIVE, 'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $row['username']), )); - if (isset($cp_row['row']) && sizeof($cp_row['row'])) + if (isset($cp_row['row']) && count($cp_row['row'])) { $memberrow = array_merge($memberrow, $cp_row['row']); } $template->assign_block_vars('memberrow', $memberrow); - if (isset($cp_row['blockrow']) && sizeof($cp_row['blockrow'])) + if (isset($cp_row['blockrow']) && count($cp_row['blockrow'])) { foreach ($cp_row['blockrow'] as $field_data) { @@ -1574,7 +1733,7 @@ switch ($mode) $pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $total_users, $config['topics_per_page'], $start); // Generate page - $template->assign_vars(array( + $template_vars = array( 'TOTAL_USERS' => $user->lang('LIST_USERS', (int) $total_users), 'PROFILE_IMG' => $user->img('icon_user_profile', $user->lang['PROFILE']), @@ -1599,8 +1758,22 @@ switch ($mode) 'S_LEADERS_SET' => $leaders_set, 'S_MODE_SELECT' => $s_sort_key, 'S_ORDER_SELECT' => $s_sort_dir, - 'S_MODE_ACTION' => $pagination_url) + 'S_MODE_ACTION' => $pagination_url, ); + + /** + * Modify memberlist page template vars + * + * @event core.memberlist_modify_template_vars + * @var array params Array containing URL parameters + * @var string sort_url Sorting URL base + * @var array template_vars Array containing template vars + * @since 3.2.2-RC1 + */ + $vars = array('params', 'sort_url', 'template_vars'); + extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_template_vars', compact($vars))); + + $template->assign_vars($template_vars); } // Output the page |