aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/memberlist.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/memberlist.php')
-rw-r--r--phpBB/memberlist.php276
1 files changed, 138 insertions, 138 deletions
diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php
index 589877305f..ff74d0d0cd 100644
--- a/phpBB/memberlist.php
+++ b/phpBB/memberlist.php
@@ -77,189 +77,196 @@ switch ($mode)
$page_title = $user->lang['THE_TEAM'];
$template_html = 'memberlist_leaders.html';
- $user_ary = $auth->acl_get_list(false, array('a_', 'm_'), false);
+ $sql_ary = array(
+ 'SELECT' => 'g.group_id, g.group_name, g.group_colour, g.group_type, g.group_teampage, ug.user_id as ug_user_id',
- $admin_id_ary = $global_mod_id_ary = $mod_id_ary = $forum_id_ary = array();
- foreach ($user_ary as $forum_id => $forum_ary)
- {
- foreach ($forum_ary as $auth_option => $id_ary)
- {
- if (!$forum_id)
- {
- if ($auth_option == 'a_')
- {
- $admin_id_ary = array_merge($admin_id_ary, $id_ary);
- }
- else
- {
- $global_mod_id_ary = array_merge($global_mod_id_ary, $id_ary);
- }
- continue;
- }
- else
- {
- $mod_id_ary = array_merge($mod_id_ary, $id_ary);
- }
+ 'FROM' => array(GROUPS_TABLE => 'g'),
- if ($forum_id)
- {
- foreach ($id_ary as $id)
- {
- $forum_id_ary[$id][] = $forum_id;
- }
- }
- }
- }
-
- $admin_id_ary = array_unique($admin_id_ary);
- $global_mod_id_ary = array_unique($global_mod_id_ary);
-
- $mod_id_ary = array_merge($mod_id_ary, $global_mod_id_ary);
- $mod_id_ary = array_unique($mod_id_ary);
+ 'LEFT_JOIN' => array(
+ array(
+ 'FROM' => array(USER_GROUP_TABLE => 'ug'),
+ 'ON' => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . (int) $user->data['user_id'],
+ ),
+ ),
- // Admin group id...
- $sql = 'SELECT group_id
- FROM ' . GROUPS_TABLE . "
- WHERE group_name = 'ADMINISTRATORS'";
- $result = $db->sql_query($sql);
- $admin_group_id = (int) $db->sql_fetchfield('group_id');
- $db->sql_freeresult($result);
+ 'WHERE' => '',
- // Get group memberships for the admin id ary...
- $admin_memberships = group_memberships($admin_group_id, $admin_id_ary);
+ 'ORDER_BY' => 'g.group_teampage ASC',
+ );
- $admin_user_ids = array();
+ $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));
- if (!empty($admin_memberships))
+ $group_ids = $groups_ary = array();
+ while ($row = $db->sql_fetchrow($result))
{
- // ok, we only need the user ids...
- foreach ($admin_memberships as $row)
+ if ($row['group_type'] == GROUP_HIDDEN && !$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $user->data['user_id'])
{
- $admin_user_ids[$row['user_id']] = true;
+ $row['group_name'] = $user->lang['GROUP_UNDISCLOSED'];
+ $row['u_group'] = '';
+ }
+ else
+ {
+ $row['group_name'] = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
+ $row['u_group'] = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']);
}
- }
- unset($admin_memberships);
-
- $sql = 'SELECT forum_id, forum_name
- FROM ' . FORUMS_TABLE;
- $result = $db->sql_query($sql);
- $forums = array();
- while ($row = $db->sql_fetchrow($result))
- {
- $forums[$row['forum_id']] = $row['forum_name'];
+ if ($row['group_teampage'])
+ {
+ // Only put groups into the array we want to display.
+ // We are fetching all groups, to ensure we got all data for default groups.
+ $group_ids[] = (int) $row['group_id'];
+ }
+ $groups_ary[(int) $row['group_id']] = $row;
}
$db->sql_freeresult($result);
- $sql = $db->sql_build_query('SELECT', array(
- 'SELECT' => 'u.user_id, u.group_id as default_group, u.username, u.username_clean, u.user_colour, u.user_rank, u.user_posts, u.user_allow_pm, g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id as ug_user_id',
+ $sql_ary = array(
+ 'SELECT' => 'u.user_id, u.group_id as default_group, u.username, u.username_clean, u.user_colour, u.user_rank, u.user_posts, u.user_allow_pm, g.group_id',
'FROM' => array(
- USERS_TABLE => 'u',
- GROUPS_TABLE => 'g'
+ USER_GROUP_TABLE => 'ug',
),
'LEFT_JOIN' => array(
array(
- 'FROM' => array(USER_GROUP_TABLE => 'ug'),
- 'ON' => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . $user->data['user_id']
- )
+ 'FROM' => array(USERS_TABLE => 'u'),
+ 'ON' => 'ug.user_id = u.user_id AND ug.user_pending = 0',
+ ),
+ array(
+ 'FROM' => array(GROUPS_TABLE => 'g'),
+ 'ON' => 'ug.group_id = g.group_id',
+ ),
),
- 'WHERE' => $db->sql_in_set('u.user_id', array_unique(array_merge($admin_id_ary, $mod_id_ary)), false, true) . '
- AND u.group_id = g.group_id',
+ 'WHERE' => $db->sql_in_set('g.group_id', $group_ids, false, true),
- 'ORDER_BY' => 'g.group_name ASC, u.username_clean ASC'
- ));
- $result = $db->sql_query($sql);
+ 'ORDER_BY' => 'u.username_clean ASC',
+ );
+
+ $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));
+ $user_ary = array();
while ($row = $db->sql_fetchrow($result))
{
- $which_row = (in_array($row['user_id'], $admin_id_ary)) ? 'admin' : 'mod';
+ $row['forums'] = '';
+ $row['forums_ary'] = array();
+ $user_ary[(int) $row['user_id']] = $row;
+ $user_ids[] = (int) $row['user_id'];
+ $group_users[(int) $row['group_id']][] = (int) $row['user_id'];
+ }
+ $db->sql_freeresult($result);
- // We sort out admins not within the 'Administrators' group.
- // Else, we will list those as admin only having the permission to view logs for example.
- if ($which_row == 'admin' && empty($admin_user_ids[$row['user_id']]))
- {
- // Remove from admin_id_ary, because the user may be a mod instead
- unset($admin_id_ary[array_search($row['user_id'], $admin_id_ary)]);
+ if ($config['teampage_forums'])
+ {
+ $template->assign_var('S_DISPLAY_MODERATOR_FORUMS', true);
+ // Get all moderators
+ $perm_ary = $auth->acl_get_list(array_unique($user_ids), array('m_'), false);
- if (!in_array($row['user_id'], $mod_id_ary) && !in_array($row['user_id'], $global_mod_id_ary))
- {
- continue;
- }
- else
+ foreach ($perm_ary as $forum_id => $forum_ary)
+ {
+ foreach ($forum_ary as $auth_option => $id_ary)
{
- $which_row = 'mod';
+ foreach ($id_ary as $id)
+ {
+ if (!$forum_id)
+ {
+ $user_ary[$id]['forums'] = $user->lang['ALL_FORUMS'];
+ }
+ else
+ {
+ $user_ary[$id]['forums_ary'][] = $forum_id;
+ }
+ }
}
}
- $s_forum_select = '';
- $undisclosed_forum = false;
+ $sql = 'SELECT forum_id, forum_name
+ FROM ' . FORUMS_TABLE;
+ $result = $db->sql_query($sql);
- if (isset($forum_id_ary[$row['user_id']]) && !in_array($row['user_id'], $global_mod_id_ary))
+ $forums = array();
+ while ($row = $db->sql_fetchrow($result))
{
- if ($which_row == 'mod' && sizeof(array_diff(array_keys($forums), $forum_id_ary[$row['user_id']])))
+ $forums[$row['forum_id']] = $row['forum_name'];
+ }
+ $db->sql_freeresult($result);
+
+ foreach ($user_ary as $user_id => $user_data)
+ {
+ if (!$user_data['forums'])
{
- foreach ($forum_id_ary[$row['user_id']] as $forum_id)
+ foreach ($user_data['forums_ary'] as $forum_id)
{
+ $user_ary[$user_id]['forums_options'] = true;
if (isset($forums[$forum_id]))
{
if ($auth->acl_get('f_list', $forum_id))
{
- $s_forum_select .= '<option value="">' . $forums[$forum_id] . '</option>';
- }
- else
- {
- $undisclosed_forum = true;
+ $user_ary[$user_id]['forums'] .= '<option value="">' . $forums[$forum_id] . '</option>';
}
}
}
}
}
+ }
- // If the mod is only moderating non-viewable forums we skip the user. There is no gain in displaying the person then...
- if (!$s_forum_select && $undisclosed_forum)
+ foreach ($groups_ary as $group_id => $group_data)
+ {
+ if ($group_data['group_teampage'])
{
-// $s_forum_select = '<option value="">' . $user->lang['FORUM_UNDISCLOSED'] . '</option>';
- continue;
+ $template->assign_block_vars('group', array(
+ 'GROUP_NAME' => $group_data['group_name'],
+ 'GROUP_COLOR' => $group_data['group_colour'],
+ 'U_GROUP' => $group_data['u_group'],
+ ));
}
- // The person is moderating several "public" forums, therefore the person should be listed, but not giving the real group name if hidden.
- if ($row['group_type'] == GROUP_HIDDEN && !$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $user->data['user_id'])
- {
- $group_name = $user->lang['GROUP_UNDISCLOSED'];
- $u_group = '';
- }
- else
+ // Display group members.
+ if (!empty($group_users[$group_id]))
{
- $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
- $u_group = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']);
- }
+ foreach ($group_users[$group_id] as $user_id)
+ {
+ if (isset($user_ary[$user_id]))
+ {
+ $row = $user_ary[$user_id];
+ if (!$config['teampage_multiple'] && ($group_id != $groups_ary[$row['default_group']]['group_id']) && $groups_ary[$row['default_group']]['group_teampage'])
+ {
+ // Display users in their primary group, instead of the first group, when it is displayed on the teampage.
+ continue;
+ }
- $rank_title = $rank_img = '';
- get_user_rank($row['user_rank'], (($row['user_id'] == ANONYMOUS) ? false : $row['user_posts']), $rank_title, $rank_img, $rank_img_src);
+ $rank_title = $rank_img = $rank_img_src = '';
+ get_user_rank($row['user_rank'], (($row['user_id'] == ANONYMOUS) ? false : $row['user_posts']), $rank_title, $rank_img, $rank_img_src);
- $template->assign_block_vars($which_row, array(
- 'USER_ID' => $row['user_id'],
- 'FORUMS' => $s_forum_select,
- 'RANK_TITLE' => $rank_title,
- 'GROUP_NAME' => $group_name,
- 'GROUP_COLOR' => $row['group_colour'],
+ $template->assign_block_vars('group.user', array(
+ 'USER_ID' => $row['user_id'],
+ 'FORUMS' => $row['forums'],
+ 'FORUM_OPTIONS' => (isset($row['forums_options'])) ? true : false,
+ 'RANK_TITLE' => $rank_title,
- 'RANK_IMG' => $rank_img,
- 'RANK_IMG_SRC' => $rank_img_src,
+ 'GROUP_NAME' => $groups_ary[$row['default_group']]['group_name'],
+ 'GROUP_COLOR' => $groups_ary[$row['default_group']]['group_colour'],
+ 'U_GROUP' => $groups_ary[$row['default_group']]['u_group'],
+
+ 'RANK_IMG' => $rank_img,
+ 'RANK_IMG_SRC' => $rank_img_src,
- 'U_GROUP' => $u_group,
- 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($row['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '',
+ 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($row['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '',
- 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
- 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
- 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
- 'U_VIEW_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
- ));
+ 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
+ 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
+ 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
+ 'U_VIEW_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
+ ));
+
+ if (!$config['teampage_multiple'])
+ {
+ unset($user_ary[$user_id]);
+ }
+ }
+ }
+ }
}
- $db->sql_freeresult($result);
$template->assign_vars(array(
'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']))
@@ -1015,7 +1022,7 @@ 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 == 'searchuser' || sizeof(array_intersect(array_keys($_GET), $search_params)) > 0) && ($config['load_search'] || $auth->acl_get('a_')))
+ if (($mode == 'searchuser' || sizeof(array_intersect($request->variable_names(phpbb_request_interface::GET), $search_params)) > 0) && ($config['load_search'] || $auth->acl_get('a_')))
{
$username = request_var('username', '', true);
$email = strtolower(request_var('email', ''));
@@ -1072,14 +1079,9 @@ switch ($mode)
if (isset($find_key_match[$joined_select]) && sizeof($joined) == 3)
{
- // Before PHP 5.1 an error value -1 can be returned instead of false.
- // Theoretically gmmktime() can also legitimately return -1 as an actual timestamp.
- // But since we do not pass the $second parameter to gmmktime(),
- // an actual unix timestamp -1 cannot be returned in this case.
- // Thus we can check whether it is -1 and treat -1 as an error.
$joined_time = gmmktime(0, 0, 0, (int) $joined[1], (int) $joined[2], (int) $joined[0]);
- if ($joined_time !== false && $joined_time !== -1)
+ if ($joined_time !== false)
{
$sql_where .= " AND u.user_regdate " . $find_key_match[$joined_select] . ' ' . $joined_time;
}
@@ -1089,7 +1091,7 @@ switch ($mode)
{
$active_time = gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]);
- if ($active_time !== false && $active_time !== -1)
+ if ($active_time !== false)
{
$sql_where .= " AND u.user_lastvisit " . $find_key_match[$active_select] . ' ' . $active_time;
}
@@ -1753,5 +1755,3 @@ function _sort_last_active($first, $second)
return $lesser_than * (int) ($id_cache[$first]['last_visit'] - $id_cache[$second]['last_visit']);
}
}
-
-?> \ No newline at end of file