[ Index ]

PHP Cross Reference of MyBB 1.8.17

title

Body

[close]

/ -> showteam.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.8
   4   * Copyright 2014 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://www.mybb.com
   7   * License: http://www.mybb.com/about/license
   8   *
   9   */
  10  
  11  define("IN_MYBB", 1);
  12  define('THIS_SCRIPT', 'showteam.php');
  13  
  14  $templatelist = 'showteam,postbit_email,postbit_pm,showteam_usergroup_user,showteam_usergroup,showteam_moderators_mod,showteam_moderators,showteam_moderators_forum';
  15  require_once  "./global.php";
  16  
  17  // Load global language phrases
  18  $lang->load('showteam');
  19  
  20  if($mybb->settings['enableshowteam'] == 0)
  21  {
  22      error($lang->showteam_disabled);
  23  }
  24  
  25  add_breadcrumb($lang->nav_showteam);
  26  
  27  $plugins->run_hooks('showteam_start');
  28  
  29  $timecut = TIME_NOW - $mybb->settings['wolcutoff'];
  30  
  31  $usergroups = $moderators = $users = array();
  32  
  33  // Fetch the list of groups which are to be shown on the page
  34  $query = $db->simple_select("usergroups", "gid, title, usertitle", "showforumteam=1", array('order_by' => 'disporder'));
  35  while($usergroup = $db->fetch_array($query))
  36  {
  37      $usergroups[$usergroup['gid']] = $usergroup;
  38  }
  39  
  40  if(empty($usergroups))
  41  {
  42      error($lang->error_noteamstoshow);
  43  }
  44  
  45  // Fetch specific forum moderator details
  46  if($usergroups[6]['gid'])
  47  {
  48      $query = $db->query("
  49          SELECT m.*, f.name
  50          FROM ".TABLE_PREFIX."moderators m
  51          LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=m.id)
  52          LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=m.fid)
  53          WHERE f.active = 1 AND m.isgroup = 0
  54          ORDER BY u.username
  55      ");
  56      while($moderator = $db->fetch_array($query))
  57      {
  58          $moderators[$moderator['id']][] = $moderator;
  59      }
  60  }
  61  
  62  // Now query the users of those specific groups
  63  $visible_groups = array_keys($usergroups);
  64  
  65  $groups_in = implode(",", $visible_groups);
  66  $users_in = implode(",", array_keys($moderators));
  67  
  68  if(!$groups_in)
  69  {
  70      $groups_in = 0;
  71  }
  72  
  73  if(!$users_in)
  74  {
  75      $users_in = 0;
  76  }
  77  
  78  $forum_permissions = forum_permissions();
  79  $query_part = '';
  80  
  81  // Include additional groups if set to
  82  if($mybb->settings['showaddlgroups'])
  83  {
  84      foreach($visible_groups as $visible_group)
  85      {
  86          if($db->type == "pgsql")
  87          {
  88              $query_part .= "'$visible_group' = ANY (string_to_array(additionalgroups, ',')) OR ";
  89          }
  90          else
  91          {
  92              $query_part .= "FIND_IN_SET('$visible_group', additionalgroups) OR ";
  93          }
  94      }
  95  }
  96  
  97  // Include group leaders if set to
  98  if($mybb->settings['showgroupleaders'])
  99  {
 100      $leaders = $leadlist = $leaderlist = array();
 101  
 102      $query = $db->simple_select("groupleaders", "gid, uid");
 103      while($leader = $db->fetch_array($query))
 104      {
 105          $leaders[$leader['uid']][] = $leader['gid'];
 106      }
 107  
 108      if(!empty($leaders))
 109      {
 110          foreach($leaders as $uid => $gid)
 111          {
 112              $leaderlist[$uid] = $gid;
 113              $leadlist[] = implode(",", $gid);
 114          }
 115          $leadlist = implode(",", $leadlist);
 116  
 117          $query = $db->simple_select("usergroups", "gid, title, namestyle", "gid IN ($leadlist)");
 118          unset($leadlist);
 119  
 120          while($leaded_group = $db->fetch_array($query))
 121          {
 122              $leaded_groups[$leaded_group['gid']] = str_replace("{username}",$leaded_group['title'], $leaded_group['namestyle']);
 123          }
 124  
 125          // Create virtual usergroup container for leaders
 126          $usergroups[0] = array('gid' => 0, 'title' =>  $lang->group_leaders, 'usertitle' => $lang->group_leaders);
 127          foreach($leaderlist as $uid => $leaded)
 128          {
 129              foreach($leaded as $gid){
 130                  $leadlist[] = $leaded_groups[$gid];
 131              }
 132              $usergroups[0]['user_list'][$uid]['leaded'] = implode(", ",$leadlist);
 133              unset($leadlist);
 134          }
 135  
 136          $users_in = implode(",", array_keys(array_flip(explode(",", implode(",", array_keys($leaderlist)).",".$users_in))));
 137      }
 138  }
 139  
 140  $query = $db->simple_select("users", "uid, username, displaygroup, usergroup, additionalgroups, ignorelist, hideemail, receivepms, lastactive, lastvisit, invisible, away", $query_part."displaygroup IN ($groups_in) OR (displaygroup='0' AND usergroup IN ($groups_in)) OR uid IN ($users_in)", array('order_by' => 'username'));
 141  
 142  while($user = $db->fetch_array($query))
 143  {
 144      // If this user is a moderator
 145      if(isset($moderators[$user['uid']]))
 146      {
 147          foreach($moderators[$user['uid']] as $forum)
 148          {
 149              if($forum_permissions[$forum['fid']]['canview'] == 1)
 150              {
 151                  $forum_url = get_forum_link($forum['fid']);
 152                  eval("\$forumlist .= \"".$templates->get("showteam_moderators_forum")."\";");
 153              }
 154          }
 155          $user['forumlist'] = $forumlist;
 156          $forumlist = '';
 157          $usergroups[6]['user_list'][$user['uid']] = $user;
 158      }
 159  
 160      if($mybb->settings['showgroupleaders'] && isset($usergroups[0]['user_list']))
 161      {
 162          foreach($usergroups[0]['user_list'] as $uid => $userdetails)
 163          {
 164              if($user['uid'] == $uid)
 165              {
 166                  $user['leaded'] = $usergroups[0]['user_list'][$uid]['leaded'];
 167                  $usergroups[0]['user_list'][$uid] = $user;
 168              }
 169          }
 170      }
 171  
 172      if($user['displaygroup'] == '6' || $user['usergroup'] == '6')
 173      {
 174          $usergroups[6]['user_list'][$user['uid']] = $user;
 175      }
 176  
 177      // Are they also in another group which is being shown on the list?
 178      if($user['displaygroup'] != 0)
 179      {
 180          $group = $user['displaygroup'];
 181      }
 182      else
 183      {
 184          $group = $user['usergroup'];
 185      }
 186  
 187      if($usergroups[$group] && $group != 6)
 188      {
 189          $usergroups[$group]['user_list'][$user['uid']] = $user;
 190      }
 191  
 192      if($mybb->settings['showaddlgroups'] && $user['additionalgroups'] != '')
 193      {
 194          $adgroups = explode(',', $user['additionalgroups']);
 195          foreach($adgroups as $adgroup)
 196          {
 197              if(in_array($adgroup, $visible_groups))
 198              {
 199                  $usergroups[$adgroup]['user_list'][$user['uid']] = $user;
 200              }
 201          }
 202      }
 203  }
 204  
 205  // Now we have all of our user details we can display them.
 206  $grouplist = '';
 207  foreach($usergroups as $usergroup)
 208  {
 209      $usergrouprows = $modrows = '';
 210  
 211      // If we have no users - don't show this group
 212      if(!isset($usergroup['user_list']))
 213      {
 214          continue;
 215      }
 216  
 217      $bgcolor = '';
 218      foreach($usergroup['user_list'] as $user)
 219      {
 220          $user['username'] = format_name(htmlspecialchars_uni($user['username']), $user['usergroup'], $user['displaygroup']);
 221          $user['profilelink'] = get_profile_link($user['uid']);
 222  
 223          // For the postbit templates
 224          $post['uid'] = $user['uid'];
 225          $emailcode = $pmcode = '';
 226          if($user['hideemail'] != 1)
 227          {
 228              eval("\$emailcode = \"".$templates->get("postbit_email")."\";");
 229          }
 230  
 231          if($user['receivepms'] != 0 && $mybb->settings['enablepms'] != 0 && my_strpos(",".$user['ignorelist'].",", ",".$mybb->user['uid'].",") === false)
 232          {
 233              eval("\$pmcode = \"".$templates->get("postbit_pm")."\";");
 234          }
 235  
 236          // For the online image
 237          if($user['lastactive'] > $timecut && ($user['invisible'] == 0 || $mybb->usergroup['canviewwolinvis'] == 1) && $user['lastvisit'] != $user['lastactive'])
 238          {
 239              $status = "online";
 240          }
 241          elseif($user['away'] == 1 && $mybb->settings['allowaway'] != 0)
 242          {
 243              $status = "away";
 244          }
 245          else
 246          {
 247              $status = "offline";
 248          }
 249  
 250          if($user['invisible'] == 1 && $mybb->usergroup['canviewwolinvis'] != 1 && $user['uid'] != $mybb->user['uid'])
 251          {
 252              if($user['lastactive'])
 253              {
 254                  $user['lastvisit'] = $lang->lastvisit_hidden;
 255              }
 256              else
 257              {
 258                  $user['lastvisit'] = $lang->lastvisit_never;
 259              }
 260          }
 261          else
 262          {
 263              $user['lastvisit'] = my_date('relative', $user['lastactive']);
 264          }
 265  
 266          $bgcolor = alt_trow();
 267  
 268          $plugins->run_hooks('showteam_user');
 269  
 270          // If the current group is a moderator group
 271          if(($usergroup['gid'] == 0 && !empty($user['leaded'])) || ($usergroup['gid'] == 6 && !empty($user['forumlist'])))
 272          {
 273              $scopelist = $usergroup['gid'] == 0 ? $user['leaded'] : $user['forumlist'];
 274              eval("\$modrows .= \"".$templates->get("showteam_moderators_mod")."\";");
 275          }
 276          else
 277          {
 278              eval("\$usergrouprows .= \"".$templates->get("showteam_usergroup_user")."\";");
 279          }
 280      }
 281  
 282      if($modrows && in_array($usergroup['gid'], [0,6]))
 283      {
 284          $modscope = $usergroup['gid'] == 6 ? $lang->mod_forums : $lang->mod_groups;
 285          eval("\$grouplist .= \"".$templates->get("showteam_moderators")."\";");
 286      }
 287  
 288      if($usergrouprows)
 289      {
 290          eval("\$grouplist .= \"".$templates->get("showteam_usergroup")."\";");
 291      }
 292  }
 293  
 294  if(empty($grouplist))
 295  {
 296      error($lang->error_noteamstoshow);
 297  }
 298  
 299  $plugins->run_hooks("showteam_end");
 300  
 301  eval("\$showteam = \"".$templates->get("showteam")."\";");
 302  output_page($showteam);


2005 - 2018 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref 0.7.1