Changeset 702 for trunk/forum/memberlist.php
- Timestamp:
- Mar 31, 2010, 6:32:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/memberlist.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : memberlist.php 9156 2008-12-02 18:48:25Z toonarmy$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 431 431 $user_id = (int) $member['user_id']; 432 432 433 // Get group memberships 434 // Also get visiting user's groups to determine hidden group memberships if necessary. 435 $auth_hidden_groups = ($user_id === (int) $user->data['user_id'] || $auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? true : false; 436 $sql_uid_ary = ($auth_hidden_groups) ? array($user_id) : array($user_id, (int) $user->data['user_id']); 437 433 438 // Do the SQL thang 434 $sql = 'SELECT g.group_id, g.group_name, g.group_type 435 FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug 436 WHERE ug.user_id = $user_id 437 AND g.group_id = ug.group_id" . ((!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? ' AND g.group_type <> ' . GROUP_HIDDEN : '') . ' 438 AND ug.user_pending = 0 439 ORDER BY g.group_type, g.group_name'; 439 $sql = 'SELECT g.group_id, g.group_name, g.group_type, ug.user_id 440 FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug 441 WHERE ' . $db->sql_in_set('ug.user_id', $sql_uid_ary) . ' 442 AND g.group_id = ug.group_id 443 AND ug.user_pending = 0'; 440 444 $result = $db->sql_query($sql); 441 445 446 // Divide data into profile data and current user data 447 $profile_groups = $user_groups = array(); 448 while ($row = $db->sql_fetchrow($result)) 449 { 450 $row['user_id'] = (int) $row['user_id']; 451 $row['group_id'] = (int) $row['group_id']; 452 453 if ($row['user_id'] == $user_id) 454 { 455 $profile_groups[] = $row; 456 } 457 else 458 { 459 $user_groups[$row['group_id']] = $row['group_id']; 460 } 461 } 462 $db->sql_freeresult($result); 463 464 // Filter out hidden groups and sort groups by name 465 $group_data = $group_sort = array(); 466 foreach ($profile_groups as $row) 467 { 468 if ($row['group_type'] == GROUP_SPECIAL) 469 { 470 // Lookup group name in language dictionary 471 if (isset($user->lang['G_' . $row['group_name']])) 472 { 473 $row['group_name'] = $user->lang['G_' . $row['group_name']]; 474 } 475 } 476 else if (!$auth_hidden_groups && $row['group_type'] == GROUP_HIDDEN && !isset($user_groups[$row['group_id']])) 477 { 478 // Skip over hidden groups the user cannot see 479 continue; 480 } 481 482 $group_sort[$row['group_id']] = utf8_clean_string($row['group_name']); 483 $group_data[$row['group_id']] = $row; 484 } 485 unset($profile_groups); 486 unset($user_groups); 487 asort($group_sort); 488 442 489 $group_options = ''; 443 while ($row = $db->sql_fetchrow($result)) 444 { 445 $group_options .= '<option value="' . $row['group_id'] . '"' . (($row['group_id'] == $member['group_id']) ? ' selected="selected"' : '') . '>' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>'; 446 } 447 $db->sql_freeresult($result); 490 foreach ($group_sort as $group_id => $null) 491 { 492 $row = $group_data[$group_id]; 493 494 $group_options .= '<option value="' . $row['group_id'] . '"' . (($row['group_id'] == $member['group_id']) ? ' selected="selected"' : '') . '>' . $row['group_name'] . '</option>'; 495 } 496 unset($group_data); 497 unset($group_sort); 448 498 449 499 // What colour is the zebra … … 501 551 $poster_avatar = get_user_avatar($member['user_avatar'], $member['user_avatar_type'], $member['user_avatar_width'], $member['user_avatar_height']); 502 552 503 $template->assign_vars(show_profile($member)); 553 // We need to check if the modules 'zebra' ('friends' & 'foes' mode), 'notes' ('user_notes' mode) and 'warn' ('warn_user' mode) are accessible to decide if we can display appropriate links 554 $zebra_enabled = $friends_enabled = $foes_enabled = $user_notes_enabled = $warn_user_enabled = false; 555 556 // Only check if the user is logged in 557 if ($user->data['is_registered']) 558 { 559 if (!class_exists('p_master')) 560 { 561 include($phpbb_root_path . 'includes/functions_module.' . $phpEx); 562 } 563 $module = new p_master(); 564 565 $module->list_modules('ucp'); 566 $module->list_modules('mcp'); 567 568 $user_notes_enabled = ($module->loaded('notes', 'user_notes')) ? true : false; 569 $warn_user_enabled = ($module->loaded('warn', 'warn_user')) ? true : false; 570 $zebra_enabled = ($module->loaded('zebra')) ? true : false; 571 $friends_enabled = ($module->loaded('zebra', 'friends')) ? true : false; 572 $foes_enabled = ($module->loaded('zebra', 'foes')) ? true : false; 573 574 unset($module); 575 } 576 577 $template->assign_vars(show_profile($member, $user_notes_enabled, $warn_user_enabled)); 504 578 505 579 // Custom Profile Fields … … 511 585 $profile_fields = $cp->generate_profile_fields_template('grab', $user_id); 512 586 $profile_fields = (isset($profile_fields[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user_id]) : array(); 513 }514 515 // We need to check if the module 'zebra' is accessible516 $zebra_enabled = false;517 518 if ($user->data['user_id'] != $user_id && $user->data['is_registered'])519 {520 include_once($phpbb_root_path . 'includes/functions_module.' . $phpEx);521 $module = new p_master();522 $module->list_modules('ucp');523 $module->set_active('zebra');524 525 $zebra_enabled = ($module->active_module === false) ? false : true;526 527 unset($module);528 587 } 529 588 … … 574 633 'U_MCP_QUEUE' => ($auth->acl_getf_global('m_approve')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue', true, $user->session_id) : '', 575 634 576 '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}") : '', 577 635 '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')) : '', 636 637 'S_USER_NOTES' => ($user_notes_enabled) ? true : false, 638 'S_WARN_USER' => ($warn_user_enabled) ? true : false, 578 639 'S_ZEBRA' => ($user->data['user_id'] != $user_id && $user->data['is_registered'] && $zebra_enabled) ? true : false, 579 'U_ADD_FRIEND' => (!$friend ) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&add=' . urlencode(htmlspecialchars_decode($member['username']))) : '',580 'U_ADD_FOE' => (!$f oe) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&mode=foes&add=' . urlencode(htmlspecialchars_decode($member['username']))) : '',581 'U_REMOVE_FRIEND' => ($friend ) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&remove=1&usernames[]=' . $user_id) : '',582 'U_REMOVE_FOE' => ($foe ) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&remove=1&mode=foes&usernames[]=' . $user_id) : '',640 'U_ADD_FRIEND' => (!$friend && !$foe && $friends_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', 641 'U_ADD_FOE' => (!$friend && !$foe && $foes_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&mode=foes&add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', 642 'U_REMOVE_FRIEND' => ($friend && $friends_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&remove=1&usernames[]=' . $user_id) : '', 643 'U_REMOVE_FOE' => ($foe && $foes_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&remove=1&mode=foes&usernames[]=' . $user_id) : '', 583 644 )); 584 645 … … 891 952 892 953 $template->assign_vars(array( 893 'ERROR_MESSAGE' => (sizeof($error)) ? implode('<br />', $error) : '') 954 'ERROR_MESSAGE' => (sizeof($error)) ? implode('<br />', $error) : '', 955 'SUBJECT' => $subject, 956 'MESSAGE' => $message, 957 ) 894 958 ); 895 959 … … 963 1027 $search_group_id = request_var('search_group_id', 0); 964 1028 1029 // when using these, make sure that we actually have values defined in $find_key_match 965 1030 $joined_select = request_var('joined_select', 'lt'); 966 1031 $active_select = request_var('active_select', 'lt'); 967 1032 $count_select = request_var('count_select', 'eq'); 1033 968 1034 $joined = explode('-', request_var('joined', '')); 969 1035 $active = explode('-', request_var('active', '')); … … 1003 1069 $sql_where .= ($msn) ? ' AND u.user_msnm ' . $db->sql_like_expression(str_replace('*', $db->any_char, $msn)) . ' ' : ''; 1004 1070 $sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->any_char, $jabber)) . ' ' : ''; 1005 $sql_where .= (is_numeric($count) ) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : '';1006 $sql_where .= (sizeof($joined) > 1 ) ? " AND u.user_regdate " . $find_key_match[$joined_select] . ' ' . gmmktime(0, 0, 0, intval($joined[1]), intval($joined[2]), intval($joined[0])) : '';1007 $sql_where .= ($auth->acl_get('u_viewonline') && sizeof($active) > 1 ) ? " AND u.user_lastvisit " . $find_key_match[$active_select] . ' ' . gmmktime(0, 0, 0, $active[1], intval($active[2]), intval($active[0])) : '';1071 $sql_where .= (is_numeric($count) && isset($find_key_match[$count_select])) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : ''; 1072 $sql_where .= (sizeof($joined) > 1 && isset($find_key_match[$joined_select])) ? " AND u.user_regdate " . $find_key_match[$joined_select] . ' ' . gmmktime(0, 0, 0, intval($joined[1]), intval($joined[2]), intval($joined[0])) : ''; 1073 $sql_where .= ($auth->acl_get('u_viewonline') && sizeof($active) > 1 && isset($find_key_match[$active_select])) ? " AND u.user_lastvisit " . $find_key_match[$active_select] . ' ' . gmmktime(0, 0, 0, $active[1], intval($active[2]), intval($active[0])) : ''; 1008 1074 $sql_where .= ($search_group_id) ? " AND u.user_id = ug.user_id AND ug.group_id = $search_group_id AND ug.user_pending = 0 " : ''; 1009 1075 … … 1236 1302 'active' => array('active', ''), 1237 1303 'count' => (request_var('count', '') !== '') ? array('count', 0) : array('count', ''), 1238 'ip domain'=> array('ip', ''),1304 'ip' => array('ip', ''), 1239 1305 'first_char' => array('first_char', ''), 1240 1306 ); … … 1520 1586 1521 1587 // Output the page 1522 page_header($page_title );1588 page_header($page_title, false); 1523 1589 1524 1590 $template->set_filenames(array( … … 1532 1598 * Prepare profile data 1533 1599 */ 1534 function show_profile($data )1600 function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = false) 1535 1601 { 1536 1602 global $config, $auth, $template, $user, $phpEx, $phpbb_root_path; … … 1618 1684 'S_JABBER_ENABLED' => ($config['jab_enable']) ? true : false, 1619 1685 1686 'S_WARNINGS' => ($auth->acl_getf_global('m_') || $auth->acl_get('m_warn')) ? true : false, 1687 1620 1688 'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$user_id&sr=posts") : '', 1621 'U_NOTES' => $auth->acl_getf_global('m_') ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $user_id, true, $user->session_id) : '',1622 'U_WARN' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $user_id, true, $user->session_id) : '',1689 '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) : '', 1690 '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) : '', 1623 1691 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($data['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $user_id) : '', 1624 1692 'U_EMAIL' => $email, 1625 1693 'U_WWW' => (!empty($data['user_website'])) ? $data['user_website'] : '', 1694 'U_SHORT_WWW' => (!empty($data['user_website'])) ? ((strlen($data['user_website']) > 55) ? substr($data['user_website'], 0, 39) . ' ... ' . substr($data['user_website'], -10) : $data['user_website']) : '', 1626 1695 'U_ICQ' => ($data['user_icq']) ? 'http://www.icq.com/people/webmsg.php?to=' . urlencode($data['user_icq']) : '', 1627 1696 'U_AIM' => ($data['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=aim&u=' . $user_id) : '',
Note:
See TracChangeset
for help on using the changeset viewer.