[ Index ]

PHP Cross Reference of phpBB-3.2.8-deutsch

title

Body

[close]

/ -> memberlist.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  /**
  15  * @ignore
  16  */
  17  define('IN_PHPBB', true);
  18  $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
  19  $phpEx = substr(strrchr(__FILE__, '.'), 1);
  20  include($phpbb_root_path . 'common.' . $phpEx);
  21  include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
  22  
  23  $mode = $request->variable('mode', '');
  24  
  25  if ($mode === 'contactadmin')
  26  {
  27      define('SKIP_CHECK_BAN', true);
  28      define('SKIP_CHECK_DISABLED', true);
  29  }
  30  
  31  // Start session management
  32  $user->session_begin();
  33  $auth->acl($user->data);
  34  $user->setup(array('memberlist', 'groups'));
  35  
  36  // Setting a variable to let the style designer know where he is...
  37  $template->assign_var('S_IN_MEMBERLIST', true);
  38  
  39  // Grab data
  40  $action        = $request->variable('action', '');
  41  $user_id    = $request->variable('u', ANONYMOUS);
  42  $username    = $request->variable('un', '', true);
  43  $group_id    = $request->variable('g', 0);
  44  $topic_id    = $request->variable('t', 0);
  45  
  46  // Redirect when old mode is used
  47  if ($mode == 'leaders')
  48  {
  49      send_status_line(301, 'Moved Permanently');
  50      redirect(append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=team'));
  51  }
  52  
  53  // Check our mode...
  54  if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'contactadmin', 'searchuser', 'team', 'livesearch')))
  55  {
  56      trigger_error('NO_MODE');
  57  }
  58  
  59  switch ($mode)
  60  {
  61      case 'email':
  62      case 'contactadmin':
  63      break;
  64  
  65      case 'livesearch':
  66          if (!$config['allow_live_searches'])
  67          {
  68              trigger_error('LIVE_SEARCHES_NOT_ALLOWED');
  69          }
  70          // No break
  71  
  72      default:
  73          // Can this user view profiles/memberlist?
  74          if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'))
  75          {
  76              if ($user->data['user_id'] != ANONYMOUS)
  77              {
  78                  send_status_line(403, 'Forbidden');
  79                  trigger_error('NO_VIEW_USERS');
  80              }
  81  
  82              login_box('', ((isset($user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)])) ? $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)] : $user->lang['LOGIN_EXPLAIN_MEMBERLIST']));
  83          }
  84      break;
  85  }
  86  
  87  /** @var \phpbb\group\helper $group_helper */
  88  $group_helper = $phpbb_container->get('group_helper');
  89  
  90  $start    = $request->variable('start', 0);
  91  $submit = (isset($_POST['submit'])) ? true : false;
  92  
  93  $default_key = 'c';
  94  $sort_key = $request->variable('sk', $default_key);
  95  $sort_dir = $request->variable('sd', 'a');
  96  
  97  $user_types = array(USER_NORMAL, USER_FOUNDER);
  98  if ($auth->acl_get('a_user'))
  99  {
 100      $user_types[] = USER_INACTIVE;
 101  }
 102  
 103  // What do you want to do today? ... oops, I think that line is taken ...
 104  switch ($mode)
 105  {
 106      case 'team':
 107          // Display a listing of board admins, moderators
 108          if (!function_exists('user_get_id_name'))
 109          {
 110              include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
 111          }
 112  
 113          $page_title = $user->lang['THE_TEAM'];
 114          $template_html = 'memberlist_team.html';
 115  
 116          $sql = 'SELECT *
 117              FROM ' . TEAMPAGE_TABLE . '
 118              ORDER BY teampage_position ASC';
 119          $result = $db->sql_query($sql, 3600);
 120          $teampage_data = $db->sql_fetchrowset($result);
 121          $db->sql_freeresult($result);
 122  
 123          $sql_ary = array(
 124              'SELECT'    => 'g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id as ug_user_id, t.teampage_id',
 125  
 126              'FROM'        => array(GROUPS_TABLE => 'g'),
 127  
 128              'LEFT_JOIN'    => array(
 129                  array(
 130                      'FROM'    => array(TEAMPAGE_TABLE => 't'),
 131                      'ON'    => 't.group_id = g.group_id',
 132                  ),
 133                  array(
 134                      'FROM'    => array(USER_GROUP_TABLE => 'ug'),
 135                      'ON'    => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . (int) $user->data['user_id'],
 136                  ),
 137              ),
 138          );
 139  
 140          $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));
 141  
 142          $group_ids = $groups_ary = array();
 143          while ($row = $db->sql_fetchrow($result))
 144          {
 145              if ($row['group_type'] == GROUP_HIDDEN && !$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $user->data['user_id'])
 146              {
 147                  $row['group_name'] = $user->lang['GROUP_UNDISCLOSED'];
 148                  $row['u_group'] = '';
 149              }
 150              else
 151              {
 152                  $row['group_name'] = $group_helper->get_name($row['group_name']);
 153                  $row['u_group'] = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']);
 154              }
 155  
 156              if ($row['teampage_id'])
 157              {
 158                  // Only put groups into the array we want to display.
 159                  // We are fetching all groups, to ensure we got all data for default groups.
 160                  $group_ids[] = (int) $row['group_id'];
 161              }
 162              $groups_ary[(int) $row['group_id']] = $row;
 163          }
 164          $db->sql_freeresult($result);
 165  
 166          $sql_ary = array(
 167              'SELECT'    => 'u.user_id, u.group_id as default_group, u.username, u.username_clean, u.user_colour, u.user_type, u.user_rank, u.user_posts, u.user_allow_pm, g.group_id',
 168  
 169              'FROM'        => array(
 170                  USER_GROUP_TABLE => 'ug',
 171              ),
 172  
 173              'LEFT_JOIN'    => array(
 174                  array(
 175                      'FROM'    => array(USERS_TABLE => 'u'),
 176                      'ON'    => 'ug.user_id = u.user_id',
 177                  ),
 178                  array(
 179                      'FROM'    => array(GROUPS_TABLE => 'g'),
 180                      'ON'    => 'ug.group_id = g.group_id',
 181                  ),
 182              ),
 183  
 184              'WHERE'        => $db->sql_in_set('g.group_id', $group_ids, false, true) . ' AND ug.user_pending = 0',
 185  
 186              'ORDER_BY'    => 'u.username_clean ASC',
 187          );
 188  
 189          /**
 190           * Modify the query used to get the users for the team page
 191           *
 192           * @event core.memberlist_team_modify_query
 193           * @var array    sql_ary            Array containing the query
 194           * @var array    group_ids        Array of group ids
 195           * @var array    teampage_data    The teampage data
 196           * @since 3.1.3-RC1
 197           */
 198          $vars = array(
 199              'sql_ary',
 200              'group_ids',
 201              'teampage_data',
 202          );
 203          extract($phpbb_dispatcher->trigger_event('core.memberlist_team_modify_query', compact($vars)));
 204  
 205          $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));
 206  
 207          $user_ary = $user_ids = $group_users = array();
 208          while ($row = $db->sql_fetchrow($result))
 209          {
 210              $row['forums'] = '';
 211              $row['forums_ary'] = array();
 212              $user_ary[(int) $row['user_id']] = $row;
 213              $user_ids[] = (int) $row['user_id'];
 214              $group_users[(int) $row['group_id']][] = (int) $row['user_id'];
 215          }
 216          $db->sql_freeresult($result);
 217  
 218          $user_ids = array_unique($user_ids);
 219  
 220          if (!empty($user_ids) && $config['teampage_forums'])
 221          {
 222              $template->assign_var('S_DISPLAY_MODERATOR_FORUMS', true);
 223              // Get all moderators
 224              $perm_ary = $auth->acl_get_list($user_ids, array('m_'), false);
 225  
 226              foreach ($perm_ary as $forum_id => $forum_ary)
 227              {
 228                  foreach ($forum_ary as $auth_option => $id_ary)
 229                  {
 230                      foreach ($id_ary as $id)
 231                      {
 232                          if (!$forum_id)
 233                          {
 234                              $user_ary[$id]['forums'] = $user->lang['ALL_FORUMS'];
 235                          }
 236                          else
 237                          {
 238                              $user_ary[$id]['forums_ary'][] = $forum_id;
 239                          }
 240                      }
 241                  }
 242              }
 243  
 244              $sql = 'SELECT forum_id, forum_name
 245                  FROM ' . FORUMS_TABLE;
 246              $result = $db->sql_query($sql);
 247  
 248              $forums = array();
 249              while ($row = $db->sql_fetchrow($result))
 250              {
 251                  $forums[$row['forum_id']] = $row['forum_name'];
 252              }
 253              $db->sql_freeresult($result);
 254  
 255              foreach ($user_ary as $user_id => $user_data)
 256              {
 257                  if (!$user_data['forums'])
 258                  {
 259                      foreach ($user_data['forums_ary'] as $forum_id)
 260                      {
 261                          $user_ary[$user_id]['forums_options'] = true;
 262                          if (isset($forums[$forum_id]))
 263                          {
 264                              if ($auth->acl_get('f_list', $forum_id))
 265                              {
 266                                  $user_ary[$user_id]['forums'] .= '<option value="">' . $forums[$forum_id] . '</option>';
 267                              }
 268                          }
 269                      }
 270                  }
 271              }
 272          }
 273  
 274          $parent_team = 0;
 275          foreach ($teampage_data as $team_data)
 276          {
 277              // If this team entry has no group, it's a category
 278              if (!$team_data['group_id'])
 279              {
 280                  $template->assign_block_vars('group', array(
 281                      'GROUP_NAME'  => $team_data['teampage_name'],
 282                  ));
 283  
 284                  $parent_team = (int) $team_data['teampage_id'];
 285                  continue;
 286              }
 287  
 288              $group_data = $groups_ary[(int) $team_data['group_id']];
 289              $group_id = (int) $team_data['group_id'];
 290  
 291              if (!$team_data['teampage_parent'])
 292              {
 293                  // If the group does not have a parent category, we display the groupname as category
 294                  $template->assign_block_vars('group', array(
 295                      'GROUP_NAME'    => $group_data['group_name'],
 296                      'GROUP_COLOR'    => $group_data['group_colour'],
 297                      'U_GROUP'        => $group_data['u_group'],
 298                  ));
 299              }
 300  
 301              // Display group members.
 302              if (!empty($group_users[$group_id]))
 303              {
 304                  foreach ($group_users[$group_id] as $user_id)
 305                  {
 306                      if (isset($user_ary[$user_id]))
 307                      {
 308                          $row = $user_ary[$user_id];
 309                          if ($config['teampage_memberships'] == 1 && ($group_id != $groups_ary[$row['default_group']]['group_id']) && $groups_ary[$row['default_group']]['teampage_id'])
 310                          {
 311                              // Display users in their primary group, instead of the first group, when it is displayed on the teampage.
 312                              continue;
 313                          }
 314  
 315                          $user_rank_data = phpbb_get_user_rank($row, (($row['user_id'] == ANONYMOUS) ? false : $row['user_posts']));
 316  
 317                          $template_vars = array(
 318                              'USER_ID'        => $row['user_id'],
 319                              'FORUMS'        => $row['forums'],
 320                              'FORUM_OPTIONS'    => (isset($row['forums_options'])) ? true : false,
 321                              'RANK_TITLE'    => $user_rank_data['title'],
 322  
 323                              'GROUP_NAME'    => $groups_ary[$row['default_group']]['group_name'],
 324                              'GROUP_COLOR'    => $groups_ary[$row['default_group']]['group_colour'],
 325                              'U_GROUP'        => $groups_ary[$row['default_group']]['u_group'],
 326  
 327                              'RANK_IMG'        => $user_rank_data['img'],
 328                              'RANK_IMG_SRC'    => $user_rank_data['img_src'],
 329  
 330                              'S_INACTIVE'    => $row['user_type'] == USER_INACTIVE,
 331  
 332                              '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']) : '',
 333  
 334                              'USERNAME_FULL'        => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
 335                              'USERNAME'            => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
 336                              'USER_COLOR'        => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
 337                              'U_VIEW_PROFILE'    => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
 338                          );
 339  
 340                          /**
 341                           * Modify the template vars for displaying the user in the groups on the teampage
 342                           *
 343                           * @event core.memberlist_team_modify_template_vars
 344                           * @var array    template_vars        Array containing the query
 345                           * @var array    row                    Array containing the action user row
 346                           * @var array    groups_ary            Array of groups with all users that should be displayed
 347                           * @since 3.1.3-RC1
 348                           */
 349                          $vars = array(
 350                              'template_vars',
 351                              'row',
 352                              'groups_ary',
 353                          );
 354                          extract($phpbb_dispatcher->trigger_event('core.memberlist_team_modify_template_vars', compact($vars)));
 355  
 356                          $template->assign_block_vars('group.user', $template_vars);
 357  
 358                          if ($config['teampage_memberships'] != 2)
 359                          {
 360                              unset($user_ary[$user_id]);
 361                          }
 362                      }
 363                  }
 364              }
 365          }
 366  
 367          $template->assign_vars(array(
 368              'PM_IMG'        => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']))
 369          );
 370      break;
 371  
 372      case 'contact':
 373  
 374          $page_title = $user->lang['IM_USER'];
 375          $template_html = 'memberlist_im.html';
 376  
 377          if (!$auth->acl_get('u_sendim'))
 378          {
 379              send_status_line(403, 'Forbidden');
 380              trigger_error('NOT_AUTHORISED');
 381          }
 382  
 383          $presence_img = '';
 384          switch ($action)
 385          {
 386              case 'jabber':
 387                  $lang = 'JABBER';
 388                  $sql_field = 'user_jabber';
 389                  $s_select = (@extension_loaded('xml') && $config['jab_enable']) ? 'S_SEND_JABBER' : 'S_NO_SEND_JABBER';
 390                  $s_action = append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&amp;action=$action&amp;u=$user_id");
 391              break;
 392  
 393              default:
 394                  trigger_error('NO_MODE', E_USER_ERROR);
 395              break;
 396          }
 397  
 398          // Grab relevant data
 399          $sql = "SELECT user_id, username, user_email, user_lang, $sql_field
 400              FROM " . USERS_TABLE . "
 401              WHERE user_id = $user_id
 402                  AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
 403          $result = $db->sql_query($sql);
 404          $row = $db->sql_fetchrow($result);
 405          $db->sql_freeresult($result);
 406  
 407          if (!$row)
 408          {
 409              trigger_error('NO_USER');
 410          }
 411          else if (empty($row[$sql_field]))
 412          {
 413              trigger_error('IM_NO_DATA');
 414          }
 415  
 416          // Post data grab actions
 417          switch ($action)
 418          {
 419              case 'jabber':
 420                  add_form_key('memberlist_messaging');
 421  
 422                  if ($submit && @extension_loaded('xml') && $config['jab_enable'])
 423                  {
 424                      if (check_form_key('memberlist_messaging'))
 425                      {
 426  
 427                          include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
 428  
 429                          $subject = sprintf($user->lang['IM_JABBER_SUBJECT'], $user->data['username'], $config['server_name']);
 430                          $message = $request->variable('message', '', true);
 431  
 432                          if (empty($message))
 433                          {
 434                              trigger_error('EMPTY_MESSAGE_IM');
 435                          }
 436  
 437                          $messenger = new messenger(false);
 438  
 439                          $messenger->template('profile_send_im', $row['user_lang']);
 440                          $messenger->subject(htmlspecialchars_decode($subject));
 441  
 442                          $messenger->replyto($user->data['user_email']);
 443                          $messenger->set_addresses($row);
 444  
 445                          $messenger->assign_vars(array(
 446                              'BOARD_CONTACT'    => phpbb_get_board_contact($config, $phpEx),
 447                              'FROM_USERNAME'    => htmlspecialchars_decode($user->data['username']),
 448                              'TO_USERNAME'    => htmlspecialchars_decode($row['username']),
 449                              'MESSAGE'        => htmlspecialchars_decode($message))
 450                          );
 451  
 452                          $messenger->send(NOTIFY_IM);
 453  
 454                          $s_select = 'S_SENT_JABBER';
 455                      }
 456                      else
 457                      {
 458                          trigger_error('FORM_INVALID');
 459                      }
 460                  }
 461              break;
 462          }
 463  
 464          // Send vars to the template
 465          $template->assign_vars(array(
 466              'IM_CONTACT'    => $row[$sql_field],
 467              'A_IM_CONTACT'    => addslashes($row[$sql_field]),
 468  
 469              'USERNAME'        => $row['username'],
 470              'CONTACT_NAME'    => $row[$sql_field],
 471              'SITENAME'        => $config['sitename'],
 472  
 473              'PRESENCE_IMG'        => $presence_img,
 474  
 475              'L_SEND_IM_EXPLAIN'    => $user->lang['IM_' . $lang],
 476              'L_IM_SENT_JABBER'    => sprintf($user->lang['IM_SENT_JABBER'], $row['username']),
 477  
 478              $s_select            => true,
 479              'S_IM_ACTION'        => $s_action)
 480          );
 481  
 482      break;
 483  
 484      case 'viewprofile':
 485          // Display a profile
 486          if ($user_id == ANONYMOUS && !$username)
 487          {
 488              trigger_error('NO_USER');
 489          }
 490  
 491          // Get user...
 492          $sql_array = array(
 493              'SELECT'    => 'u.*',
 494              'FROM'        => array(
 495                  USERS_TABLE        => 'u'
 496              ),
 497              'WHERE'        => (($username) ? "u.username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'" : "u.user_id = $user_id"),
 498          );
 499  
 500          /**
 501           * Modify user data SQL before member profile row is created
 502           *
 503           * @event core.memberlist_modify_viewprofile_sql
 504           * @var int        user_id                The user ID
 505           * @var string    username            The username
 506           * @var array    sql_array            Array containing the main query
 507           * @since 3.2.6-RC1
 508           */
 509          $vars = array(
 510              'user_id',
 511              'username',
 512              'sql_array',
 513          );
 514          extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_viewprofile_sql', compact($vars)));
 515  
 516          $sql = $db->sql_build_query('SELECT', $sql_array);
 517          $result = $db->sql_query($sql);
 518          $member = $db->sql_fetchrow($result);
 519          $db->sql_freeresult($result);
 520  
 521          if (!$member)
 522          {
 523              trigger_error('NO_USER');
 524          }
 525  
 526          // a_user admins and founder are able to view inactive users and bots to be able to manage them more easily
 527          // Normal users are able to see at least users having only changed their profile settings but not yet reactivated.
 528          if (!$auth->acl_get('a_user') && $user->data['user_type'] != USER_FOUNDER)
 529          {
 530              if ($member['user_type'] == USER_IGNORE)
 531              {
 532                  trigger_error('NO_USER');
 533              }
 534              else if ($member['user_type'] == USER_INACTIVE && $member['user_inactive_reason'] != INACTIVE_PROFILE)
 535              {
 536                  trigger_error('NO_USER');
 537              }
 538          }
 539  
 540          $user_id = (int) $member['user_id'];
 541  
 542          // Get group memberships
 543          // Also get visiting user's groups to determine hidden group memberships if necessary.
 544          $auth_hidden_groups = ($user_id === (int) $user->data['user_id'] || $auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? true : false;
 545          $sql_uid_ary = ($auth_hidden_groups) ? array($user_id) : array($user_id, (int) $user->data['user_id']);
 546  
 547          // Do the SQL thang
 548          $sql_ary = [
 549              'SELECT'    => 'g.group_id, g.group_name, g.group_type, ug.user_id',
 550  
 551              'FROM'        => [
 552                  GROUPS_TABLE => 'g',
 553              ],
 554  
 555              'LEFT_JOIN' => [
 556                  [
 557                      'FROM' => [USER_GROUP_TABLE => 'ug'],
 558                      'ON'   => 'g.group_id = ug.group_id',
 559                  ],
 560              ],
 561  
 562              'WHERE'        => $db->sql_in_set('ug.user_id', $sql_uid_ary) . '
 563                  AND ug.user_pending = 0',
 564          ];
 565  
 566          /**
 567          * Modify the query used to get the group data
 568          *
 569          * @event core.modify_memberlist_viewprofile_group_sql
 570          * @var array    sql_ary            Array containing the query
 571          * @since 3.2.6-RC1
 572          */
 573          $vars = array(
 574              'sql_ary',
 575          );
 576          extract($phpbb_dispatcher->trigger_event('core.modify_memberlist_viewprofile_group_sql', compact($vars)));
 577  
 578          $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));
 579  
 580          // Divide data into profile data and current user data
 581          $profile_groups = $user_groups = array();
 582          while ($row = $db->sql_fetchrow($result))
 583          {
 584              $row['user_id'] = (int) $row['user_id'];
 585              $row['group_id'] = (int) $row['group_id'];
 586  
 587              if ($row['user_id'] == $user_id)
 588              {
 589                  $profile_groups[] = $row;
 590              }
 591              else
 592              {
 593                  $user_groups[$row['group_id']] = $row['group_id'];
 594              }
 595          }
 596          $db->sql_freeresult($result);
 597  
 598          // Filter out hidden groups and sort groups by name
 599          $group_data = $group_sort = array();
 600          foreach ($profile_groups as $row)
 601          {
 602              if (!$auth_hidden_groups && $row['group_type'] == GROUP_HIDDEN && !isset($user_groups[$row['group_id']]))
 603              {
 604                  // Skip over hidden groups the user cannot see
 605                  continue;
 606              }
 607  
 608              $row['group_name'] = $group_helper->get_name($row['group_name']);
 609  
 610              $group_sort[$row['group_id']] = utf8_clean_string($row['group_name']);
 611              $group_data[$row['group_id']] = $row;
 612          }
 613          unset($profile_groups);
 614          unset($user_groups);
 615          asort($group_sort);
 616  
 617          /**
 618          * Modify group data before options is created and data is unset
 619          *
 620          * @event core.modify_memberlist_viewprofile_group_data
 621          * @var array    group_data            Array containing the group data
 622          * @var array    group_sort            Array containing the sorted group data
 623          * @since 3.2.6-RC1
 624          */
 625          $vars = array(
 626              'group_data',
 627              'group_sort',
 628          );
 629          extract($phpbb_dispatcher->trigger_event('core.modify_memberlist_viewprofile_group_data', compact($vars)));
 630  
 631          $group_options = '';
 632          foreach ($group_sort as $group_id => $null)
 633          {
 634              $row = $group_data[$group_id];
 635  
 636              $group_options .= '<option value="' . $row['group_id'] . '"' . (($row['group_id'] == $member['group_id']) ? ' selected="selected"' : '') . '>' . $row['group_name'] . '</option>';
 637          }
 638          unset($group_data);
 639          unset($group_sort);
 640  
 641          // What colour is the zebra
 642          $sql = 'SELECT friend, foe
 643              FROM ' . ZEBRA_TABLE . "
 644              WHERE zebra_id = $user_id
 645                  AND user_id = {$user->data['user_id']}";
 646  
 647          $result = $db->sql_query($sql);
 648          $row = $db->sql_fetchrow($result);
 649          $foe = ($row['foe']) ? true : false;
 650          $friend = ($row['friend']) ? true : false;
 651          $db->sql_freeresult($result);
 652  
 653          if ($config['load_onlinetrack'])
 654          {
 655              $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline
 656                  FROM ' . SESSIONS_TABLE . "
 657                  WHERE session_user_id = $user_id";
 658              $result = $db->sql_query($sql);
 659              $row = $db->sql_fetchrow($result);
 660              $db->sql_freeresult($result);
 661  
 662              $member['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0;
 663              $member['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] :    0;
 664              unset($row);
 665          }
 666  
 667          if ($config['load_user_activity'])
 668          {
 669              display_user_activity($member);
 670          }
 671  
 672          // Do the relevant calculations
 673          $memberdays = max(1, round((time() - $member['user_regdate']) / 86400));
 674          $posts_per_day = $member['user_posts'] / $memberdays;
 675          $percentage = ($config['num_posts']) ? min(100, ($member['user_posts'] / $config['num_posts']) * 100) : 0;
 676  
 677  
 678          if ($member['user_sig'])
 679          {
 680              $parse_flags = ($member['user_sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES;
 681              $member['user_sig'] = generate_text_for_display($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield'], $parse_flags, true);
 682          }
 683  
 684          // 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
 685          $zebra_enabled = $friends_enabled = $foes_enabled = $user_notes_enabled = $warn_user_enabled = false;
 686  
 687          // Only check if the user is logged in
 688          if ($user->data['is_registered'])
 689          {
 690              if (!class_exists('p_master'))
 691              {
 692                  include($phpbb_root_path . 'includes/functions_module.' . $phpEx);
 693              }
 694              $module = new p_master();
 695  
 696              $module->list_modules('ucp');
 697              $module->list_modules('mcp');
 698  
 699              $user_notes_enabled = ($module->loaded('mcp_notes', 'user_notes')) ? true : false;
 700              $warn_user_enabled = ($module->loaded('mcp_warn', 'warn_user')) ? true : false;
 701              $zebra_enabled = ($module->loaded('ucp_zebra')) ? true : false;
 702              $friends_enabled = ($module->loaded('ucp_zebra', 'friends')) ? true : false;
 703              $foes_enabled = ($module->loaded('ucp_zebra', 'foes')) ? true : false;
 704  
 705              unset($module);
 706          }
 707  
 708          // Custom Profile Fields
 709          $profile_fields = array();
 710          if ($config['load_cpf_viewprofile'])
 711          {
 712              /* @var $cp \phpbb\profilefields\manager */
 713              $cp = $phpbb_container->get('profilefields.manager');
 714              $profile_fields = $cp->grab_profile_fields_data($user_id);
 715              $profile_fields = (isset($profile_fields[$user_id])) ? $cp->generate_profile_fields_template_data($profile_fields[$user_id]) : array();
 716          }
 717  
 718          /**
 719          * Modify user data before we display the profile
 720          *
 721          * @event core.memberlist_view_profile
 722          * @var    array    member                    Array with user's data
 723          * @var    bool    user_notes_enabled        Is the mcp user notes module enabled?
 724          * @var    bool    warn_user_enabled        Is the mcp warnings module enabled?
 725          * @var    bool    zebra_enabled            Is the ucp zebra module enabled?
 726          * @var    bool    friends_enabled            Is the ucp friends module enabled?
 727          * @var    bool    foes_enabled            Is the ucp foes module enabled?
 728          * @var    bool    friend                    Is the user friend?
 729          * @var    bool    foe                        Is the user foe?
 730          * @var    array    profile_fields            Array with user's profile field data
 731          * @since 3.1.0-a1
 732          * @changed 3.1.0-b2 Added friend and foe status
 733          * @changed 3.1.0-b3 Added profile fields data
 734          */
 735          $vars = array(
 736              'member',
 737              'user_notes_enabled',
 738              'warn_user_enabled',
 739              'zebra_enabled',
 740              'friends_enabled',
 741              'foes_enabled',
 742              'friend',
 743              'foe',
 744              'profile_fields',
 745          );
 746          extract($phpbb_dispatcher->trigger_event('core.memberlist_view_profile', compact($vars)));
 747  
 748          $template->assign_vars(phpbb_show_profile($member, $user_notes_enabled, $warn_user_enabled));
 749  
 750          // If the user has m_approve permission or a_user permission, then list then display unapproved posts
 751          if ($auth->acl_getf_global('m_approve') || $auth->acl_get('a_user'))
 752          {
 753              $sql = 'SELECT COUNT(post_id) as posts_in_queue
 754                  FROM ' . POSTS_TABLE . '
 755                  WHERE poster_id = ' . $user_id . '
 756                      AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE));
 757              $result = $db->sql_query($sql);
 758              $member['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue');
 759              $db->sql_freeresult($result);
 760          }
 761          else
 762          {
 763              $member['posts_in_queue'] = 0;
 764          }
 765  
 766          // Define the main array of vars to assign to memberlist_view.html
 767          $template_ary = array(
 768              'L_POSTS_IN_QUEUE'            => $user->lang('NUM_POSTS_IN_QUEUE', $member['posts_in_queue']),
 769  
 770              'POSTS_DAY'                    => $user->lang('POST_DAY', $posts_per_day),
 771              'POSTS_PCT'                    => $user->lang('POST_PCT', $percentage),
 772  
 773              'SIGNATURE'                    => $member['user_sig'],
 774              'POSTS_IN_QUEUE'            => $member['posts_in_queue'],
 775  
 776              'PM_IMG'                    => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']),
 777              'L_SEND_EMAIL_USER'            => $user->lang('SEND_EMAIL_USER', $member['username']),
 778              'EMAIL_IMG'                    => $user->img('icon_contact_email', $user->lang['EMAIL']),
 779              'JABBER_IMG'                => $user->img('icon_contact_jabber', $user->lang['JABBER']),
 780              'SEARCH_IMG'                => $user->img('icon_user_search', $user->lang['SEARCH']),
 781  
 782              'S_PROFILE_ACTION'            => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group'),
 783              'S_GROUP_OPTIONS'            => $group_options,
 784              'S_CUSTOM_FIELDS'            => (isset($profile_fields['row']) && count($profile_fields['row'])) ? true : false,
 785  
 786              'U_USER_ADMIN'                => ($auth->acl_get('a_user')) ? append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&amp;mode=overview&amp;u=' . $user_id, true, $user->session_id) : '',
 787              'U_USER_BAN'                => ($auth->acl_get('m_ban') && $user_id != $user->data['user_id']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=ban&amp;mode=user&amp;u=' . $user_id, true, $user->session_id) : '',
 788              'U_MCP_QUEUE'                => ($auth->acl_getf_global('m_approve')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue', true, $user->session_id) : '',
 789  
 790              'U_SWITCH_PERMISSIONS'        => ($auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_id) ? append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=switch_perm&amp;u={$user_id}&amp;hash=" . generate_link_hash('switchperm')) : '',
 791              'U_EDIT_SELF'                => ($user_id == $user->data['user_id'] && $auth->acl_get('u_chgprofileinfo')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_profile&amp;mode=profile_info') : '',
 792  
 793              'S_USER_NOTES'                => ($user_notes_enabled) ? true : false,
 794              'S_WARN_USER'                => ($warn_user_enabled) ? true : false,
 795              'S_ZEBRA'                    => ($user->data['user_id'] != $user_id && $user->data['is_registered'] && $zebra_enabled) ? true : false,
 796              'U_ADD_FRIEND'                => (!$friend && !$foe && $friends_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&amp;add=' . urlencode(htmlspecialchars_decode($member['username']))) : '',
 797              'U_ADD_FOE'                    => (!$friend && !$foe && $foes_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&amp;mode=foes&amp;add=' . urlencode(htmlspecialchars_decode($member['username']))) : '',
 798              'U_REMOVE_FRIEND'            => ($friend && $friends_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&amp;remove=1&amp;usernames[]=' . $user_id) : '',
 799              'U_REMOVE_FOE'                => ($foe && $foes_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&amp;remove=1&amp;mode=foes&amp;usernames[]=' . $user_id) : '',
 800  
 801              'U_CANONICAL'                => generate_board_url() . '/' . append_sid("memberlist.$phpEx", 'mode=viewprofile&amp;u=' . $user_id, true, ''),
 802          );
 803  
 804          /**
 805          * Modify user's template vars before we display the profile
 806          *
 807          * @event core.memberlist_modify_view_profile_template_vars
 808          * @var    array    template_ary    Array with user's template vars
 809          * @since 3.2.6-RC1
 810          */
 811          $vars = array(
 812              'template_ary',
 813          );
 814          extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_view_profile_template_vars', compact($vars)));
 815  
 816          // Assign vars to memberlist_view.html
 817          $template->assign_vars($template_ary);
 818  
 819          if (!empty($profile_fields['row']))
 820          {
 821              $template->assign_vars($profile_fields['row']);
 822          }
 823  
 824          if (!empty($profile_fields['blockrow']))
 825          {
 826              foreach ($profile_fields['blockrow'] as $field_data)
 827              {
 828                  $template->assign_block_vars('custom_fields', $field_data);
 829              }
 830          }
 831  
 832          // Inactive reason/account?
 833          if ($member['user_type'] == USER_INACTIVE)
 834          {
 835              $user->add_lang('acp/common');
 836  
 837              $inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN'];
 838  
 839              switch ($member['user_inactive_reason'])
 840              {
 841                  case INACTIVE_REGISTER:
 842                      $inactive_reason = $user->lang['INACTIVE_REASON_REGISTER'];
 843                  break;
 844  
 845                  case INACTIVE_PROFILE:
 846                      $inactive_reason = $user->lang['INACTIVE_REASON_PROFILE'];
 847                  break;
 848  
 849                  case INACTIVE_MANUAL:
 850                      $inactive_reason = $user->lang['INACTIVE_REASON_MANUAL'];
 851                  break;
 852  
 853                  case INACTIVE_REMIND:
 854                      $inactive_reason = $user->lang['INACTIVE_REASON_REMIND'];
 855                  break;
 856              }
 857  
 858              $template->assign_vars(array(
 859                  'S_USER_INACTIVE'        => true,
 860                  'USER_INACTIVE_REASON'    => $inactive_reason)
 861              );
 862          }
 863  
 864          // Now generate page title
 865          $page_title = sprintf($user->lang['VIEWING_PROFILE'], $member['username']);
 866          $template_html = 'memberlist_view.html';
 867  
 868      break;
 869  
 870      case 'contactadmin':
 871      case 'email':
 872          if (!class_exists('messenger'))
 873          {
 874              include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
 875          }
 876  
 877          $user_id    = $request->variable('u', 0);
 878          $topic_id    = $request->variable('t', 0);
 879  
 880          if ($user_id)
 881          {
 882              $form_name = 'user';
 883          }
 884          else if ($topic_id)
 885          {
 886              $form_name = 'topic';
 887          }
 888          else if ($mode === 'contactadmin')
 889          {
 890              $form_name = 'admin';
 891          }
 892          else
 893          {
 894              trigger_error('NO_EMAIL');
 895          }
 896  
 897          /** @var $form \phpbb\message\form */
 898          $form = $phpbb_container->get('message.form.' . $form_name);
 899  
 900          $form->bind($request);
 901          $error = $form->check_allow();
 902          if ($error)
 903          {
 904              trigger_error($error);
 905          }
 906  
 907          if ($request->is_set_post('submit'))
 908          {
 909              $messenger = new messenger(false);
 910              $form->submit($messenger);
 911          }
 912  
 913          $page_title = $form->get_page_title();
 914          $template_html = $form->get_template_file();
 915          $form->render($template);
 916  
 917      break;
 918  
 919      case 'livesearch':
 920  
 921          $username_chars = $request->variable('username', '', true);
 922  
 923          $sql = 'SELECT username, user_id, user_colour
 924              FROM ' . USERS_TABLE . '
 925              WHERE ' . $db->sql_in_set('user_type', $user_types) . '
 926                  AND username_clean ' . $db->sql_like_expression(utf8_clean_string($username_chars) . $db->get_any_char());
 927          $result = $db->sql_query_limit($sql, 10);
 928          $user_list = array();
 929  
 930          while ($row = $db->sql_fetchrow($result))
 931          {
 932              $user_list[] = array(
 933                  'user_id'        => (int) $row['user_id'],
 934                  'result'        => $row['username'],
 935                  'username_full'    => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
 936                  'display'        => get_username_string('no_profile', $row['user_id'], $row['username'], $row['user_colour']),
 937              );
 938          }
 939          $db->sql_freeresult($result);
 940          $json_response = new \phpbb\json_response();
 941          $json_response->send(array(
 942              'keyword' => $username_chars,
 943              'results' => $user_list,
 944          ));
 945  
 946      break;
 947  
 948      case 'group':
 949      default:
 950          // The basic memberlist
 951          $page_title = $user->lang['MEMBERLIST'];
 952          $template_html = 'memberlist_body.html';
 953  
 954          /* @var $pagination \phpbb\pagination */
 955          $pagination = $phpbb_container->get('pagination');
 956  
 957          // Sorting
 958          $sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'c' => $user->lang['SORT_JOINED'], 'd' => $user->lang['SORT_POST_COUNT']);
 959          $sort_key_sql = array('a' => 'u.username_clean', 'c' => 'u.user_regdate', 'd' => 'u.user_posts');
 960  
 961          if ($config['jab_enable'])
 962          {
 963              $sort_key_text['k'] = $user->lang['JABBER'];
 964              $sort_key_sql['k'] = 'u.user_jabber';
 965          }
 966  
 967          if ($auth->acl_get('a_user'))
 968          {
 969              $sort_key_text['e'] = $user->lang['SORT_EMAIL'];
 970              $sort_key_sql['e'] = 'u.user_email';
 971          }
 972  
 973          if ($auth->acl_get('u_viewonline'))
 974          {
 975              $sort_key_text['l'] = $user->lang['SORT_LAST_ACTIVE'];
 976              $sort_key_sql['l'] = 'u.user_lastvisit';
 977          }
 978  
 979          $sort_key_text['m'] = $user->lang['SORT_RANK'];
 980          $sort_key_sql['m'] = 'u.user_rank';
 981  
 982          $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
 983  
 984          $s_sort_key = '';
 985          foreach ($sort_key_text as $key => $value)
 986          {
 987              $selected = ($sort_key == $key) ? ' selected="selected"' : '';
 988              $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
 989          }
 990  
 991          $s_sort_dir = '';
 992          foreach ($sort_dir_text as $key => $value)
 993          {
 994              $selected = ($sort_dir == $key) ? ' selected="selected"' : '';
 995              $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
 996          }
 997  
 998          // Additional sorting options for user search ... if search is enabled, if not
 999          // then only admins can make use of this (for ACP functionality)
1000          $sql_select = $sql_where_data = $sql_from = $sql_where = $order_by = '';
1001  
1002  
1003          $form            = $request->variable('form', '');
1004          $field            = $request->variable('field', '');
1005          $select_single     = $request->variable('select_single', false);
1006  
1007          // Search URL parameters, if any of these are in the URL we do a search
1008          $search_params = array('username', 'email', 'jabber', 'search_group_id', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'ip');
1009  
1010          // We validate form and field here, only id/class allowed
1011          $form = (!preg_match('/^[a-z0-9_-]+$/i', $form)) ? '' : $form;
1012          $field = (!preg_match('/^[a-z0-9_-]+$/i', $field)) ? '' : $field;
1013          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_')))
1014          {
1015              $username    = $request->variable('username', '', true);
1016              $email        = strtolower($request->variable('email', ''));
1017              $jabber        = $request->variable('jabber', '');
1018              $search_group_id    = $request->variable('search_group_id', 0);
1019  
1020              // when using these, make sure that we actually have values defined in $find_key_match
1021              $joined_select    = $request->variable('joined_select', 'lt');
1022              $active_select    = $request->variable('active_select', 'lt');
1023              $count_select    = $request->variable('count_select', 'eq');
1024  
1025              $joined            = explode('-', $request->variable('joined', ''));
1026              $active            = explode('-', $request->variable('active', ''));
1027              $count            = ($request->variable('count', '') !== '') ? $request->variable('count', 0) : '';
1028              $ipdomain        = $request->variable('ip', '');
1029  
1030              $find_key_match = array('lt' => '<', 'gt' => '>', 'eq' => '=');
1031  
1032              $find_count = array('lt' => $user->lang['LESS_THAN'], 'eq' => $user->lang['EQUAL_TO'], 'gt' => $user->lang['MORE_THAN']);
1033              $s_find_count = '';
1034              foreach ($find_count as $key => $value)
1035              {
1036                  $selected = ($count_select == $key) ? ' selected="selected"' : '';
1037                  $s_find_count .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
1038              }
1039  
1040              $find_time = array('lt' => $user->lang['BEFORE'], 'gt' => $user->lang['AFTER']);
1041              $s_find_join_time = '';
1042              foreach ($find_time as $key => $value)
1043              {
1044                  $selected = ($joined_select == $key) ? ' selected="selected"' : '';
1045                  $s_find_join_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
1046              }
1047  
1048              $s_find_active_time = '';
1049              foreach ($find_time as $key => $value)
1050              {
1051                  $selected = ($active_select == $key) ? ' selected="selected"' : '';
1052                  $s_find_active_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
1053              }
1054  
1055              $sql_where .= ($username) ? ' AND u.username_clean ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($username))) : '';
1056              $sql_where .= ($auth->acl_get('a_user') && $email) ? ' AND u.user_email ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), $email)) . ' ' : '';
1057              $sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), $jabber)) . ' ' : '';
1058              $sql_where .= (is_numeric($count) && isset($find_key_match[$count_select])) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : '';
1059  
1060              if (isset($find_key_match[$joined_select]) && count($joined) == 3)
1061              {
1062                  $joined_time = gmmktime(0, 0, 0, (int) $joined[1], (int) $joined[2], (int) $joined[0]);
1063  
1064                  if ($joined_time !== false)
1065                  {
1066                      $sql_where .= " AND u.user_regdate " . $find_key_match[$joined_select] . ' ' . $joined_time;
1067                  }
1068              }
1069  
1070              if (isset($find_key_match[$active_select]) && count($active) == 3 && $auth->acl_get('u_viewonline'))
1071              {
1072                  $active_time = gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]);
1073  
1074                  if ($active_time !== false)
1075                  {
1076                      if ($active_select === 'lt' && (int) $active[0] == 0 && (int) $active[1] == 0 && (int) $active[2] == 0)
1077                      {
1078                          $sql_where .= ' AND u.user_lastvisit = 0';
1079                      }
1080                      else if ($active_select === 'gt')
1081                      {
1082                          $sql_where .= ' AND u.user_lastvisit ' . $find_key_match[$active_select] . ' ' . $active_time;
1083                      }
1084                      else
1085                      {
1086                          $sql_where .= ' AND (u.user_lastvisit > 0 AND u.user_lastvisit < ' . $active_time . ')';
1087                      }
1088                  }
1089              }
1090  
1091              $sql_where .= ($search_group_id) ? " AND u.user_id = ug.user_id AND ug.group_id = $search_group_id AND ug.user_pending = 0 " : '';
1092  
1093              if ($search_group_id)
1094              {
1095                  $sql_from = ', ' . USER_GROUP_TABLE . ' ug ';
1096              }
1097  
1098              if ($ipdomain && $auth->acl_getf_global('m_info'))
1099              {
1100                  if (strspn($ipdomain, 'abcdefghijklmnopqrstuvwxyz'))
1101                  {
1102                      $hostnames = gethostbynamel($ipdomain);
1103  
1104                      if ($hostnames !== false)
1105                      {
1106                          $ips = "'" . implode('\', \'', array_map(array($db, 'sql_escape'), preg_replace('#([0-9]{1,3}\.[0-9]{1,3}[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#', "\\1", gethostbynamel($ipdomain)))) . "'";
1107                      }
1108                      else
1109                      {
1110                          $ips = false;
1111                      }
1112                  }
1113                  else
1114                  {
1115                      $ips = "'" . str_replace('*', '%', $db->sql_escape($ipdomain)) . "'";
1116                  }
1117  
1118                  if ($ips === false)
1119                  {
1120                      // A minor fudge but it does the job :D
1121                      $sql_where .= " AND u.user_id = 0";
1122                  }
1123                  else
1124                  {
1125                      $ip_forums = array_keys($auth->acl_getf('m_info', true));
1126  
1127                      $sql = 'SELECT DISTINCT poster_id
1128                          FROM ' . POSTS_TABLE . '
1129                          WHERE poster_ip ' . ((strpos($ips, '%') !== false) ? 'LIKE' : 'IN') . " ($ips)
1130                              AND " . $db->sql_in_set('forum_id', $ip_forums);
1131  
1132                      /**
1133                      * Modify sql query for members search by ip address / hostname
1134                      *
1135                      * @event core.memberlist_modify_ip_search_sql_query
1136                      * @var    string    ipdomain    The host name
1137                      * @var    string    ips            IP address list for the given host name
1138                      * @var    string    sql            The SQL query for searching members by IP address
1139                      * @since 3.1.7-RC1
1140                      */
1141                      $vars = array(
1142                          'ipdomain',
1143                          'ips',
1144                          'sql',
1145                      );
1146                      extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_ip_search_sql_query', compact($vars)));
1147  
1148                      $result = $db->sql_query($sql);
1149  
1150                      if ($row = $db->sql_fetchrow($result))
1151                      {
1152                          $ip_sql = array();
1153                          do
1154                          {
1155                              $ip_sql[] = $row['poster_id'];
1156                          }
1157                          while ($row = $db->sql_fetchrow($result));
1158  
1159                          $sql_where .= ' AND ' . $db->sql_in_set('u.user_id', $ip_sql);
1160                      }
1161                      else
1162                      {
1163                          // A minor fudge but it does the job :D
1164                          $sql_where .= " AND u.user_id = 0";
1165                      }
1166                      unset($ip_forums);
1167  
1168                      $db->sql_freeresult($result);
1169                  }
1170              }
1171          }
1172  
1173          $first_char = $request->variable('first_char', '');
1174  
1175          if ($first_char == 'other')
1176          {
1177              for ($i = 97; $i < 123; $i++)
1178              {
1179                  $sql_where .= ' AND u.username_clean NOT ' . $db->sql_like_expression(chr($i) . $db->get_any_char());
1180              }
1181          }
1182          else if ($first_char)
1183          {
1184              $sql_where .= ' AND u.username_clean ' . $db->sql_like_expression(substr($first_char, 0, 1) . $db->get_any_char());
1185          }
1186  
1187          // Are we looking at a usergroup? If so, fetch additional info
1188          // and further restrict the user info query
1189          if ($mode == 'group')
1190          {
1191              // We JOIN here to save a query for determining membership for hidden groups. ;)
1192              $sql = 'SELECT g.*, ug.user_id, ug.group_leader
1193                  FROM ' . GROUPS_TABLE . ' g
1194                  LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (ug.user_pending = 0 AND ug.user_id = ' . $user->data['user_id'] . " AND ug.group_id = $group_id)
1195                  WHERE g.group_id = $group_id";
1196              $result = $db->sql_query($sql);
1197              $group_row = $db->sql_fetchrow($result);
1198              $db->sql_freeresult($result);
1199  
1200              if (!$group_row)
1201              {
1202                  trigger_error('NO_GROUP');
1203              }
1204  
1205              switch ($group_row['group_type'])
1206              {
1207                  case GROUP_OPEN:
1208                      $group_row['l_group_type'] = 'OPEN';
1209                  break;
1210  
1211                  case GROUP_CLOSED:
1212                      $group_row['l_group_type'] = 'CLOSED';
1213                  break;
1214  
1215                  case GROUP_HIDDEN:
1216                      $group_row['l_group_type'] = 'HIDDEN';
1217  
1218                      // Check for membership or special permissions
1219                      if (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $group_row['user_id'] != $user->data['user_id'])
1220                      {
1221                          trigger_error('NO_GROUP');
1222                      }
1223                  break;
1224  
1225                  case GROUP_SPECIAL:
1226                      $group_row['l_group_type'] = 'SPECIAL';
1227                  break;
1228  
1229                  case GROUP_FREE:
1230                      $group_row['l_group_type'] = 'FREE';
1231                  break;
1232              }
1233  
1234              $avatar_img = phpbb_get_group_avatar($group_row);
1235  
1236              // ... same for group rank
1237              $group_rank_data = array(
1238                  'title'        => null,
1239                  'img'        => null,
1240                  'img_src'    => null,
1241              );
1242              if ($group_row['group_rank'])
1243              {
1244                  $group_rank_data = $group_helper->get_rank($group_row);
1245  
1246                  if ($group_rank_data['img'])
1247                  {
1248                      $group_rank_data['img'] .= '<br />';
1249                  }
1250              }
1251              // include modules for manage groups link display or not
1252              // need to ensure the module is active
1253              $can_manage_group = false;
1254              if ($user->data['is_registered'] && $group_row['group_leader'])
1255              {
1256                  if (!class_exists('p_master'))
1257                  {
1258                      include($phpbb_root_path . 'includes/functions_module.' . $phpEx);
1259                  }
1260                  $module = new p_master;
1261                  $module->list_modules('ucp');
1262  
1263                  if ($module->is_active('ucp_groups', 'manage'))
1264                  {
1265                      $can_manage_group = true;
1266                  }
1267                  unset($module);
1268              }
1269  
1270              $template->assign_vars(array(
1271                  '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']),
1272                  'GROUP_NAME'    => $group_helper->get_name($group_row['group_name']),
1273                  'GROUP_COLOR'    => $group_row['group_colour'],
1274                  'GROUP_TYPE'    => $user->lang['GROUP_IS_' . $group_row['l_group_type']],
1275                  'GROUP_RANK'    => $group_rank_data['title'],
1276  
1277                  'AVATAR_IMG'    => $avatar_img,
1278                  'RANK_IMG'        => $group_rank_data['img'],
1279                  'RANK_IMG_SRC'    => $group_rank_data['img_src'],
1280  
1281                  '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&amp;mode=compose&amp;g=' . $group_id) : '',
1282                  'U_MANAGE'        => ($can_manage_group) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_groups&amp;mode=manage') : false,)
1283              );
1284  
1285              $sql_select = ', ug.group_leader';
1286              $sql_from = ', ' . USER_GROUP_TABLE . ' ug ';
1287              $order_by = 'ug.group_leader DESC, ';
1288  
1289              $sql_where .= " AND ug.user_pending = 0 AND u.user_id = ug.user_id AND ug.group_id = $group_id";
1290              $sql_where_data = " AND u.user_id = ug.user_id AND ug.group_id = $group_id";
1291          }
1292  
1293          // Sorting and order
1294          if (!isset($sort_key_sql[$sort_key]))
1295          {
1296              $sort_key = $default_key;
1297          }
1298  
1299          $order_by .= $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC');
1300  
1301          // Unfortunately we must do this here for sorting by rank, else the sort order is applied wrongly
1302          if ($sort_key == 'm')
1303          {
1304              $order_by .= ', u.user_posts DESC';
1305          }
1306  
1307          /**
1308          * Modify sql query data for members search
1309          *
1310          * @event core.memberlist_modify_sql_query_data
1311          * @var    string    order_by        SQL ORDER BY clause condition
1312          * @var    string    sort_dir        The sorting direction
1313          * @var    string    sort_key        The sorting key
1314          * @var    array    sort_key_sql    Arraty with the sorting conditions data
1315          * @var    string    sql_from        SQL FROM clause condition
1316          * @var    string    sql_select        SQL SELECT fields list
1317          * @var    string    sql_where        SQL WHERE clause condition
1318          * @var    string    sql_where_data    SQL WHERE clause additional conditions data
1319          * @since 3.1.7-RC1
1320          */
1321          $vars = array(
1322              'order_by',
1323              'sort_dir',
1324              'sort_key',
1325              'sort_key_sql',
1326              'sql_from',
1327              'sql_select',
1328              'sql_where',
1329              'sql_where_data',
1330          );
1331          extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_sql_query_data', compact($vars)));
1332  
1333          // Count the users ...
1334          $sql = 'SELECT COUNT(u.user_id) AS total_users
1335              FROM ' . USERS_TABLE . " u$sql_from
1336              WHERE " . $db->sql_in_set('u.user_type', $user_types) . "
1337              $sql_where";
1338          $result = $db->sql_query($sql);
1339          $total_users = (int) $db->sql_fetchfield('total_users');
1340          $db->sql_freeresult($result);
1341  
1342          // Build a relevant pagination_url
1343          $params = $sort_params = array();
1344  
1345          // We do not use $request->variable() here directly to save some calls (not all variables are set)
1346          $check_params = array(
1347              'g'                => array('g', 0),
1348              'sk'            => array('sk', $default_key),
1349              'sd'            => array('sd', 'a'),
1350              'form'            => array('form', ''),
1351              'field'            => array('field', ''),
1352              'select_single'    => array('select_single', $select_single),
1353              'username'        => array('username', '', true),
1354              'email'            => array('email', ''),
1355              'jabber'        => array('jabber', ''),
1356              'search_group_id'    => array('search_group_id', 0),
1357              'joined_select'    => array('joined_select', 'lt'),
1358              'active_select'    => array('active_select', 'lt'),
1359              'count_select'    => array('count_select', 'eq'),
1360              'joined'        => array('joined', ''),
1361              'active'        => array('active', ''),
1362              'count'            => ($request->variable('count', '') !== '') ? array('count', 0) : array('count', ''),
1363              'ip'            => array('ip', ''),
1364              'first_char'    => array('first_char', ''),
1365          );
1366  
1367          $u_first_char_params = array();
1368          foreach ($check_params as $key => $call)
1369          {
1370              if (!isset($_REQUEST[$key]))
1371              {
1372                  continue;
1373              }
1374  
1375              $param = call_user_func_array(array($request, 'variable'), $call);
1376              // Encode strings, convert everything else to int in order to prevent empty parameters.
1377              $param = urlencode($key) . '=' . ((is_string($param)) ? urlencode($param) : (int) $param);
1378              $params[] = $param;
1379  
1380              if ($key != 'first_char')
1381              {
1382                  $u_first_char_params[] = $param;
1383              }
1384              if ($key != 'sk' && $key != 'sd')
1385              {
1386                  $sort_params[] = $param;
1387              }
1388          }
1389  
1390          $u_hide_find_member = append_sid("{$phpbb_root_path}memberlist.$phpEx", "start=$start" . (!empty($params) ? '&amp;' . implode('&amp;', $params) : ''));
1391  
1392          if ($mode)
1393          {
1394              $params[] = "mode=$mode";
1395              $u_first_char_params[] = "mode=$mode";
1396          }
1397          $sort_params[] = "mode=$mode";
1398  
1399          $u_first_char_params = implode('&amp;', $u_first_char_params);
1400          $u_first_char_params .= ($u_first_char_params) ? '&amp;' : '';
1401  
1402          $first_characters = array();
1403          $first_characters[''] = $user->lang['ALL'];
1404          for ($i = 97; $i < 123; $i++)
1405          {
1406              $first_characters[chr($i)] = chr($i - 32);
1407          }
1408          $first_characters['other'] = $user->lang['OTHER'];
1409  
1410          $first_char_block_vars = [];
1411  
1412          foreach ($first_characters as $char => $desc)
1413          {
1414              $first_char_block_vars[] = [
1415                  'DESC'            => $desc,
1416                  'VALUE'            => $char,
1417                  'S_SELECTED'    => ($first_char == $char) ? true : false,
1418                  'U_SORT'        => append_sid("{$phpbb_root_path}memberlist.$phpEx", $u_first_char_params . 'first_char=' . $char) . '#memberlist',
1419              ];
1420          }
1421  
1422          /**
1423           * Modify memberlist sort and pagination parameters
1424           *
1425           * @event core.memberlist_modify_sort_pagination_params
1426           * @var array    sort_params                Array with URL parameters for sorting
1427           * @var array    params                    Array with URL parameters for pagination
1428           * @var array    first_characters        Array that maps each letter in a-z, 'other' and the empty string to their display representation
1429           * @var string    u_first_char_params        Concatenated URL parameters for first character search links
1430           * @var array    first_char_block_vars    Template block variables for each first character
1431           * @var int        total_users                Total number of users found in this search
1432           * @since 3.2.6-RC1
1433           */
1434          $vars = [
1435              'sort_params',
1436              'params',
1437              'first_characters',
1438              'u_first_char_params',
1439              'first_char_block_vars',
1440              'total_users',
1441          ];
1442          extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_sort_pagination_params', compact($vars)));
1443  
1444          $template->assign_block_vars_array('first_char', $first_char_block_vars);
1445  
1446          $pagination_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&amp;', $params));
1447          $sort_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&amp;', $sort_params));
1448  
1449          unset($search_params, $sort_params);
1450  
1451          // Some search user specific data
1452          if (($mode == '' || $mode == 'searchuser') && ($config['load_search'] || $auth->acl_get('a_')))
1453          {
1454              $group_selected = $request->variable('search_group_id', 0);
1455              $s_group_select = '<option value="0"' . ((!$group_selected) ? ' selected="selected"' : '') . '>&nbsp;</option>';
1456              $group_ids = array();
1457  
1458              /**
1459              * @todo add this to a separate function (function is responsible for returning the groups the user is able to see based on the users group membership)
1460              */
1461  
1462              if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
1463              {
1464                  $sql = 'SELECT group_id, group_name, group_type
1465                      FROM ' . GROUPS_TABLE;
1466  
1467                  if (!$config['coppa_enable'])
1468                  {
1469                      $sql .= " WHERE group_name <> 'REGISTERED_COPPA'";
1470                  }
1471  
1472                  $sql .= ' ORDER BY group_name ASC';
1473              }
1474              else
1475              {
1476                  $sql = 'SELECT g.group_id, g.group_name, g.group_type
1477                      FROM ' . GROUPS_TABLE . ' g
1478                      LEFT JOIN ' . USER_GROUP_TABLE . ' ug
1479                          ON (
1480                              g.group_id = ug.group_id
1481                              AND ug.user_id = ' . $user->data['user_id'] . '
1482                              AND ug.user_pending = 0
1483                          )
1484                      WHERE (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')';
1485  
1486                  if (!$config['coppa_enable'])
1487                  {
1488                      $sql .= " AND g.group_name <> 'REGISTERED_COPPA'";
1489                  }
1490  
1491                  $sql .= ' ORDER BY g.group_name ASC';
1492              }
1493              $result = $db->sql_query($sql);
1494  
1495              while ($row = $db->sql_fetchrow($result))
1496              {
1497                  $group_ids[] = $row['group_id'];
1498                  $s_group_select .= '<option value="' . $row['group_id'] . '"' . (($group_selected == $row['group_id']) ? ' selected="selected"' : '') . '>' . $group_helper->get_name($row['group_name']) . '</option>';
1499              }
1500              $db->sql_freeresult($result);
1501  
1502              if ($group_selected !== 0 && !in_array($group_selected, $group_ids))
1503              {
1504                  trigger_error('NO_GROUP');
1505              }
1506  
1507              $template->assign_vars(array(
1508                  'USERNAME'    => $username,
1509                  'EMAIL'        => $email,
1510                  'JABBER'    => $jabber,
1511                  'JOINED'    => implode('-', $joined),
1512                  'ACTIVE'    => implode('-', $active),
1513                  'COUNT'        => $count,
1514                  'IP'        => $ipdomain,
1515  
1516                  'S_IP_SEARCH_ALLOWED'    => ($auth->acl_getf_global('m_info')) ? true : false,
1517                  'S_EMAIL_SEARCH_ALLOWED'=> ($auth->acl_get('a_user')) ? true : false,
1518                  'S_JABBER_ENABLED'        => $config['jab_enable'],
1519                  'S_IN_SEARCH_POPUP'        => ($form && $field) ? true : false,
1520                  'S_SEARCH_USER'            => ($mode == 'searchuser' || ($mode == '' && $submit)),
1521                  'S_FORM_NAME'            => $form,
1522                  'S_FIELD_NAME'            => $field,
1523                  'S_SELECT_SINGLE'        => $select_single,
1524                  'S_COUNT_OPTIONS'        => $s_find_count,
1525                  'S_SORT_OPTIONS'        => $s_sort_key,
1526                  'S_JOINED_TIME_OPTIONS'    => $s_find_join_time,
1527                  'S_ACTIVE_TIME_OPTIONS'    => $s_find_active_time,
1528                  'S_GROUP_SELECT'        => $s_group_select,
1529                  'S_USER_SEARCH_ACTION'    => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=searchuser&amp;form=$form&amp;field=$field"))
1530              );
1531          }
1532  
1533          $start = $pagination->validate_start($start, $config['topics_per_page'], $total_users);
1534  
1535          // Get us some users :D
1536          $sql = "SELECT u.user_id
1537              FROM " . USERS_TABLE . " u
1538                  $sql_from
1539              WHERE " . $db->sql_in_set('u.user_type', $user_types) . "
1540                  $sql_where
1541              ORDER BY $order_by";
1542          $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
1543  
1544          $user_list = array();
1545          while ($row = $db->sql_fetchrow($result))
1546          {
1547              $user_list[] = (int) $row['user_id'];
1548          }
1549          $db->sql_freeresult($result);
1550  
1551          // Load custom profile fields
1552          if ($config['load_cpf_memberlist'])
1553          {
1554              /* @var $cp \phpbb\profilefields\manager */
1555              $cp = $phpbb_container->get('profilefields.manager');
1556  
1557              $cp_row = $cp->generate_profile_fields_template_headlines('field_show_on_ml');
1558              foreach ($cp_row as $profile_field)
1559              {
1560                  $template->assign_block_vars('custom_fields', $profile_field);
1561              }
1562          }
1563  
1564          $leaders_set = false;
1565          // So, did we get any users?
1566          if (count($user_list))
1567          {
1568              // Session time?! Session time...
1569              $sql = 'SELECT session_user_id, MAX(session_time) AS session_time
1570                  FROM ' . SESSIONS_TABLE . '
1571                  WHERE session_time >= ' . (time() - $config['session_length']) . '
1572                      AND ' . $db->sql_in_set('session_user_id', $user_list) . '
1573                  GROUP BY session_user_id';
1574              $result = $db->sql_query($sql);
1575  
1576              $session_times = array();
1577              while ($row = $db->sql_fetchrow($result))
1578              {
1579                  $session_times[$row['session_user_id']] = $row['session_time'];
1580              }
1581              $db->sql_freeresult($result);
1582  
1583              // Do the SQL thang
1584              if ($mode == 'group')
1585              {
1586                  $sql_from_ary = explode(',', $sql_from);
1587                  $extra_tables = [];
1588                  foreach ($sql_from_ary as $entry)
1589                  {
1590                      $table_data = explode(' ', trim($entry));
1591  
1592                      if (empty($table_data[0]) || empty($table_data[1]))
1593                      {
1594                          continue;
1595                      }
1596  
1597                      $extra_tables[$table_data[0]] = $table_data[1];
1598                  }
1599  
1600                  $sql_array = array(
1601                      'SELECT'    => 'u.*' . $sql_select,
1602                      'FROM'        => array_merge([USERS_TABLE => 'u'], $extra_tables),
1603                      'WHERE'        => $db->sql_in_set('u.user_id', $user_list) . $sql_where_data . '',
1604                  );
1605              }
1606              else
1607              {
1608                  $sql_array = array(
1609                      'SELECT'    => 'u.*',
1610                      'FROM'        => array(
1611                          USERS_TABLE        => 'u'
1612                      ),
1613                      'WHERE'        => $db->sql_in_set('u.user_id', $user_list),
1614                  );
1615              }
1616  
1617              /**
1618               * Modify user data SQL before member row is created
1619               *
1620               * @event core.memberlist_modify_memberrow_sql
1621               * @var string    mode                Memberlist mode
1622               * @var string    sql_select            Additional select statement
1623               * @var string    sql_from            Additional from statement
1624               * @var array    sql_array            Array containing the main query
1625               * @var array    user_list            Array containing list of users
1626               * @since 3.2.6-RC1
1627               */
1628              $vars = array(
1629                  'mode',
1630                  'sql_select',
1631                  'sql_from',
1632                  'sql_array',
1633                  'user_list',
1634              );
1635              extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_memberrow_sql', compact($vars)));
1636  
1637              $sql = $db->sql_build_query('SELECT', $sql_array);
1638              $result = $db->sql_query($sql);
1639  
1640              $id_cache = array();
1641              while ($row = $db->sql_fetchrow($result))
1642              {
1643                  $row['session_time'] = (!empty($session_times[$row['user_id']])) ? $session_times[$row['user_id']] : 0;
1644                  $row['last_visit'] = (!empty($row['session_time'])) ? $row['session_time'] : $row['user_lastvisit'];
1645  
1646                  $id_cache[$row['user_id']] = $row;
1647              }
1648  
1649              $db->sql_freeresult($result);
1650  
1651              // Load custom profile fields if required
1652              if ($config['load_cpf_memberlist'])
1653              {
1654                  // Grab all profile fields from users in id cache for later use - similar to the poster cache
1655                  $profile_fields_cache = $cp->grab_profile_fields_data($user_list);
1656  
1657                  // Filter the fields we don't want to show
1658                  foreach ($profile_fields_cache as $user_id => $user_profile_fields)
1659                  {
1660                      foreach ($user_profile_fields as $field_ident => $profile_field)
1661                      {
1662                          if (!$profile_field['data']['field_show_on_ml'])
1663                          {
1664                              unset($profile_fields_cache[$user_id][$field_ident]);
1665                          }
1666                      }
1667                  }
1668              }
1669  
1670              // If we sort by last active date we need to adjust the id cache due to user_lastvisit not being the last active date...
1671              if ($sort_key == 'l')
1672              {
1673  //                uasort($id_cache, create_function('$first, $second', "return (\$first['last_visit'] == \$second['last_visit']) ? 0 : ((\$first['last_visit'] < \$second['last_visit']) ? $lesser_than : ($lesser_than * -1));"));
1674                  usort($user_list,  'phpbb_sort_last_active');
1675              }
1676  
1677              // do we need to display contact fields as such
1678              $use_contact_fields = false;
1679  
1680              /**
1681               * Modify list of users before member row is created
1682               *
1683               * @event core.memberlist_memberrow_before
1684               * @var array    user_list            Array containing list of users
1685               * @var bool    use_contact_fields    Should we display contact fields as such?
1686               * @since 3.1.7-RC1
1687               */
1688              $vars = array('user_list', 'use_contact_fields');
1689              extract($phpbb_dispatcher->trigger_event('core.memberlist_memberrow_before', compact($vars)));
1690  
1691              for ($i = 0, $end = count($user_list); $i < $end; ++$i)
1692              {
1693                  $user_id = $user_list[$i];
1694                  $row = $id_cache[$user_id];
1695                  $is_leader = (isset($row['group_leader']) && $row['group_leader']) ? true : false;
1696                  $leaders_set = ($leaders_set || $is_leader);
1697  
1698                  $cp_row = array();
1699                  if ($config['load_cpf_memberlist'])
1700                  {
1701                      $cp_row = (isset($profile_fields_cache[$user_id])) ? $cp->generate_profile_fields_template_data($profile_fields_cache[$user_id], $use_contact_fields) : array();
1702                  }
1703  
1704                  $memberrow = array_merge(phpbb_show_profile($row, false, false, false), array(
1705                      'ROW_NUMBER'        => $i + ($start + 1),
1706  
1707                      'S_CUSTOM_PROFILE'    => (isset($cp_row['row']) && count($cp_row['row'])) ? true : false,
1708                      'S_GROUP_LEADER'    => $is_leader,
1709                      'S_INACTIVE'        => $row['user_type'] == USER_INACTIVE,
1710  
1711                      'U_VIEW_PROFILE'    => get_username_string('profile', $user_id, $row['username']),
1712                  ));
1713  
1714                  if (isset($cp_row['row']) && count($cp_row['row']))
1715                  {
1716                      $memberrow = array_merge($memberrow, $cp_row['row']);
1717                  }
1718  
1719                  $template->assign_block_vars('memberrow', $memberrow);
1720  
1721                  if (isset($cp_row['blockrow']) && count($cp_row['blockrow']))
1722                  {
1723                      foreach ($cp_row['blockrow'] as $field_data)
1724                      {
1725                          $template->assign_block_vars('memberrow.custom_fields', $field_data);
1726                      }
1727                  }
1728  
1729                  unset($id_cache[$user_id]);
1730              }
1731          }
1732  
1733          $pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $total_users, $config['topics_per_page'], $start);
1734  
1735          // Generate page
1736          $template_vars = array(
1737              'TOTAL_USERS'    => $user->lang('LIST_USERS', (int) $total_users),
1738  
1739              'PROFILE_IMG'    => $user->img('icon_user_profile', $user->lang['PROFILE']),
1740              'PM_IMG'        => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']),
1741              'EMAIL_IMG'        => $user->img('icon_contact_email', $user->lang['EMAIL']),
1742              'JABBER_IMG'    => $user->img('icon_contact_jabber', $user->lang['JABBER']),
1743              'SEARCH_IMG'    => $user->img('icon_user_search', $user->lang['SEARCH']),
1744  
1745              'U_FIND_MEMBER'            => ($config['load_search'] || $auth->acl_get('a_')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser' . (($start) ? "&amp;start=$start" : '') . (!empty($params) ? '&amp;' . implode('&amp;', $params) : '')) : '',
1746              'U_HIDE_FIND_MEMBER'    => ($mode == 'searchuser' || ($mode == '' && $submit)) ? $u_hide_find_member : '',
1747              'U_LIVE_SEARCH'            => ($config['allow_live_searches']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=livesearch') : false,
1748              'U_SORT_USERNAME'        => $sort_url . '&amp;sk=a&amp;sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'),
1749              'U_SORT_JOINED'            => $sort_url . '&amp;sk=c&amp;sd=' . (($sort_key == 'c' && $sort_dir == 'd') ? 'a' : 'd'),
1750              'U_SORT_POSTS'            => $sort_url . '&amp;sk=d&amp;sd=' . (($sort_key == 'd' && $sort_dir == 'd') ? 'a' : 'd'),
1751              'U_SORT_EMAIL'            => $sort_url . '&amp;sk=e&amp;sd=' . (($sort_key == 'e' && $sort_dir == 'd') ? 'a' : 'd'),
1752              'U_SORT_ACTIVE'            => ($auth->acl_get('u_viewonline')) ? $sort_url . '&amp;sk=l&amp;sd=' . (($sort_key == 'l' && $sort_dir == 'd') ? 'a' : 'd') : '',
1753              'U_SORT_RANK'            => $sort_url . '&amp;sk=m&amp;sd=' . (($sort_key == 'm' && $sort_dir == 'd') ? 'a' : 'd'),
1754              'U_LIST_CHAR'            => $sort_url . '&amp;sk=a&amp;sd=' . (($sort_key == 'l' && $sort_dir == 'd') ? 'a' : 'd'),
1755  
1756              'S_SHOW_GROUP'        => ($mode == 'group') ? true : false,
1757              'S_VIEWONLINE'        => $auth->acl_get('u_viewonline'),
1758              'S_LEADERS_SET'        => $leaders_set,
1759              'S_MODE_SELECT'        => $s_sort_key,
1760              'S_ORDER_SELECT'    => $s_sort_dir,
1761              'S_MODE_ACTION'        => $pagination_url,
1762          );
1763  
1764          /**
1765           * Modify memberlist page template vars
1766           *
1767           * @event core.memberlist_modify_template_vars
1768           * @var array    params                Array containing URL parameters
1769           * @var string    sort_url            Sorting URL base
1770           * @var array    template_vars        Array containing template vars
1771           * @since 3.2.2-RC1
1772           */
1773          $vars = array('params', 'sort_url', 'template_vars');
1774          extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_template_vars', compact($vars)));
1775  
1776          $template->assign_vars($template_vars);
1777  }
1778  
1779  // Output the page
1780  page_header($page_title);
1781  
1782  $template->set_filenames(array(
1783      'body' => $template_html)
1784  );
1785  make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
1786  
1787  page_footer();


Generated: Sat Oct 26 11:28:42 2019 Cross-referenced by PHPXref 0.7.1