[ Index ]

PHP Cross Reference of MyBB 1.8.19

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 if($db->type == "sqlite")
  91          {
  92              $query_part .= "'$visible_group' IN (additionalgroups) OR ";
  93          }
  94          else
  95          {
  96              $query_part .= "FIND_IN_SET('$visible_group', additionalgroups) OR ";
  97          }
  98      }
  99  }
 100  
 101  // Include group leaders if set to
 102  if($mybb->settings['showgroupleaders'])
 103  {
 104      $leaders = $leadlist = $leaderlist = array();
 105  
 106      $query = $db->simple_select("groupleaders", "gid, uid");
 107      while($leader = $db->fetch_array($query))
 108      {
 109          $leaders[$leader['uid']][] = $leader['gid'];
 110      }
 111  
 112      if(!empty($leaders))
 113      {
 114          foreach($leaders as $uid => $gid)
 115          {
 116              $leaderlist[$uid] = $gid;
 117              $leadlist[] = implode(",", $gid);
 118          }
 119          $leadlist = implode(",", $leadlist);
 120  
 121          $query = $db->simple_select("usergroups", "gid, title, namestyle", "gid IN ($leadlist)");
 122          unset($leadlist);
 123  
 124          while($leaded_group = $db->fetch_array($query))
 125          {
 126              $leaded_groups[$leaded_group['gid']] = str_replace("{username}",$leaded_group['title'], $leaded_group['namestyle']);
 127          }
 128  
 129          // Create virtual usergroup container for leaders
 130          $usergroups[0] = array('gid' => 0, 'title' =>  $lang->group_leaders, 'usertitle' => $lang->group_leaders);
 131          foreach($leaderlist as $uid => $leaded)
 132          {
 133              foreach($leaded as $gid){
 134                  $leadlist[] = $leaded_groups[$gid];
 135              }
 136              $usergroups[0]['user_list'][$uid]['leaded'] = implode(", ",$leadlist);
 137              unset($leadlist);
 138          }
 139  
 140          $users_in = implode(",", array_keys(array_flip(explode(",", implode(",", array_keys($leaderlist)).",".$users_in))));
 141      }
 142  }
 143  
 144  $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'));
 145  
 146  while($user = $db->fetch_array($query))
 147  {
 148      // If this user is a moderator
 149      if(isset($moderators[$user['uid']]))
 150      {
 151          foreach($moderators[$user['uid']] as $forum)
 152          {
 153              if($forum_permissions[$forum['fid']]['canview'] == 1)
 154              {
 155                  $forum_url = get_forum_link($forum['fid']);
 156                  eval("\$forumlist .= \"".$templates->get("showteam_moderators_forum")."\";");
 157              }
 158          }
 159          $user['forumlist'] = $forumlist;
 160          $forumlist = '';
 161          $usergroups[6]['user_list'][$user['uid']] = $user;
 162      }
 163  
 164      if($mybb->settings['showgroupleaders'] && isset($usergroups[0]['user_list']))
 165      {
 166          foreach($usergroups[0]['user_list'] as $uid => $userdetails)
 167          {
 168              if($user['uid'] == $uid)
 169              {
 170                  $user['leaded'] = $usergroups[0]['user_list'][$uid]['leaded'];
 171                  $usergroups[0]['user_list'][$uid] = $user;
 172              }
 173          }
 174      }
 175  
 176      if($user['displaygroup'] == '6' || $user['usergroup'] == '6')
 177      {
 178          $usergroups[6]['user_list'][$user['uid']] = $user;
 179      }
 180  
 181      // Are they also in another group which is being shown on the list?
 182      if($user['displaygroup'] != 0)
 183      {
 184          $group = $user['displaygroup'];
 185      }
 186      else
 187      {
 188          $group = $user['usergroup'];
 189      }
 190  
 191      if($usergroups[$group] && $group != 6)
 192      {
 193          $usergroups[$group]['user_list'][$user['uid']] = $user;
 194      }
 195  
 196      if($mybb->settings['showaddlgroups'] && $user['additionalgroups'] != '')
 197      {
 198          $adgroups = explode(',', $user['additionalgroups']);
 199          foreach($adgroups as $adgroup)
 200          {
 201              if(in_array($adgroup, $visible_groups))
 202              {
 203                  $usergroups[$adgroup]['user_list'][$user['uid']] = $user;
 204              }
 205          }
 206      }
 207  }
 208  
 209  // Now we have all of our user details we can display them.
 210  $grouplist = '';
 211  foreach($usergroups as $usergroup)
 212  {
 213      $usergrouprows = $modrows = '';
 214  
 215      // If we have no users - don't show this group
 216      if(!isset($usergroup['user_list']))
 217      {
 218          continue;
 219      }
 220  
 221      $bgcolor = '';
 222      foreach($usergroup['user_list'] as $user)
 223      {
 224          $user['username'] = format_name(htmlspecialchars_uni($user['username']), $user['usergroup'], $user['displaygroup']);
 225          $user['profilelink'] = get_profile_link($user['uid']);
 226  
 227          // For the postbit templates
 228          $post['uid'] = $user['uid'];
 229          $emailcode = $pmcode = '';
 230          if($user['hideemail'] != 1)
 231          {
 232              eval("\$emailcode = \"".$templates->get("postbit_email")."\";");
 233          }
 234  
 235          if($user['receivepms'] != 0 && $mybb->settings['enablepms'] != 0 && my_strpos(",".$user['ignorelist'].",", ",".$mybb->user['uid'].",") === false)
 236          {
 237              eval("\$pmcode = \"".$templates->get("postbit_pm")."\";");
 238          }
 239  
 240          // For the online image
 241          if($user['lastactive'] > $timecut && ($user['invisible'] == 0 || $mybb->usergroup['canviewwolinvis'] == 1) && $user['lastvisit'] != $user['lastactive'])
 242          {
 243              $status = "online";
 244          }
 245          elseif($user['away'] == 1 && $mybb->settings['allowaway'] != 0)
 246          {
 247              $status = "away";
 248          }
 249          else
 250          {
 251              $status = "offline";
 252          }
 253  
 254          if($user['invisible'] == 1 && $mybb->usergroup['canviewwolinvis'] != 1 && $user['uid'] != $mybb->user['uid'])
 255          {
 256              if($user['lastactive'])
 257              {
 258                  $user['lastvisit'] = $lang->lastvisit_hidden;
 259              }
 260              else
 261              {
 262                  $user['lastvisit'] = $lang->lastvisit_never;
 263              }
 264          }
 265          else
 266          {
 267              $user['lastvisit'] = my_date('relative', $user['lastactive']);
 268          }
 269  
 270          $bgcolor = alt_trow();
 271  
 272          $plugins->run_hooks('showteam_user');
 273  
 274          // If the current group is a moderator group
 275          if(($usergroup['gid'] == 0 && !empty($user['leaded'])) || ($usergroup['gid'] == 6 && !empty($user['forumlist'])))
 276          {
 277              $scopelist = $usergroup['gid'] == 0 ? $user['leaded'] : $user['forumlist'];
 278              eval("\$modrows .= \"".$templates->get("showteam_moderators_mod")."\";");
 279          }
 280          else
 281          {
 282              eval("\$usergrouprows .= \"".$templates->get("showteam_usergroup_user")."\";");
 283          }
 284      }
 285  
 286      if($modrows && in_array($usergroup['gid'], array(0,6)))
 287      {
 288          $modscope = $usergroup['gid'] == 6 ? $lang->mod_forums : $lang->mod_groups;
 289          eval("\$grouplist .= \"".$templates->get("showteam_moderators")."\";");
 290      }
 291  
 292      if($usergrouprows)
 293      {
 294          eval("\$grouplist .= \"".$templates->get("showteam_usergroup")."\";");
 295      }
 296  }
 297  
 298  if(empty($grouplist))
 299  {
 300      error($lang->error_noteamstoshow);
 301  }
 302  
 303  $plugins->run_hooks("showteam_end");
 304  
 305  eval("\$showteam = \"".$templates->get("showteam")."\";");
 306  output_page($showteam);


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