[ Index ]

PHP Cross Reference of MyBB

title

Body

[close]

/ -> showteam.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.6
   4   * Copyright 2010 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://mybb.com
   7   * License: http://mybb.com/about/license
   8   *
   9   * $Id$
  10   */
  11  
  12  define("IN_MYBB", 1);
  13  define('THIS_SCRIPT', 'showteam.php');
  14  
  15  $templatelist = 'showteam,postbit_email,postbit_pm,showteam_usergroup_user,showteam_usergroup,showteam_moderators_mod,showteam_moderators,showteam_moderators_forum';
  16  require_once  "./global.php";
  17  
  18  // Load global language phrases
  19  $lang->load('showteam');
  20  
  21  add_breadcrumb($lang->nav_showteam);
  22  
  23  $plugins->run_hooks('showteam_start');
  24  
  25  $usergroups = array();
  26  $moderators = array();
  27  $users = array();
  28  
  29  // Fetch the list of groups which are to be shown on the page
  30  $query = $db->simple_select("usergroups", "gid, title, usertitle", "showforumteam=1", array('order_by' => 'disporder'));
  31  while($usergroup = $db->fetch_array($query))
  32  {
  33      $usergroups[$usergroup['gid']] = $usergroup;
  34  }
  35  
  36  if(empty($usergroups))
  37  {
  38      error($lang->error_noteamstoshow);
  39  }
  40  
  41  // Fetch specific forum moderator details
  42  if($usergroups[6]['gid'])
  43  {
  44      $query = $db->query("
  45          SELECT m.*, f.name
  46          FROM ".TABLE_PREFIX."moderators m
  47          LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=m.id)
  48          LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=m.fid)
  49          WHERE f.active = 1 AND m.isgroup = 0
  50          ORDER BY u.username
  51      ");
  52      while($moderator = $db->fetch_array($query))
  53      {
  54          $moderators[$moderator['id']][] = $moderator;
  55      } 
  56  }
  57  
  58  // Now query the users of those specific groups
  59  $groups_in = implode(",", array_keys($usergroups));
  60  $users_in = implode(",", array_keys($moderators));
  61  if(!$groups_in)
  62  {
  63      $groups_in = 0;
  64  }
  65  if(!$users_in)
  66  {
  67      $users_in = 0;
  68  }
  69  $forum_permissions = forum_permissions();
  70  
  71  $query = $db->simple_select("users", "uid, username, displaygroup, usergroup, ignorelist, hideemail, receivepms", "displaygroup IN ($groups_in) OR (displaygroup='0' AND usergroup IN ($groups_in)) OR uid IN ($users_in)", array('order_by' => 'username'));
  72  while($user = $db->fetch_array($query))
  73  {
  74      // If this user is a moderator
  75      if(isset($moderators[$user['uid']]))
  76      {
  77          foreach($moderators[$user['uid']] as $forum)
  78          {
  79              if($forum_permissions[$forum['fid']]['canview'] == 1)
  80              {
  81                  $forum_url = get_forum_link($forum['fid']);
  82                  eval("\$forumlist .= \"".$templates->get("showteam_moderators_forum")."\";");
  83              }
  84          }
  85          $user['forumlist'] = $forumlist;
  86          $forumlist = '';
  87          $usergroups[6]['user_list'][$user['uid']] = $user;
  88      }
  89      
  90      if($user['displaygroup'] == '6' || $user['usergroup'] == '6')
  91      {
  92          $usergroups[6]['user_list'][$user['uid']] = $user;
  93      }
  94      
  95      // Are they also in another group which is being shown on the list?
  96      if($user['displaygroup'] != 0)
  97      {
  98          $group = $user['displaygroup'];
  99      }
 100      else
 101      {
 102          $group = $user['usergroup'];
 103      }
 104      
 105      if($usergroups[$group] && $group != 6)
 106      {
 107          $usergroups[$group]['user_list'][$user['uid']] = $user;
 108      }
 109  }
 110  
 111  // Now we have all of our user details we can display them.
 112  $grouplist = '';
 113  foreach($usergroups as $usergroup)
 114  {
 115      // If we have no users - don't show this group
 116      if(!isset($usergroup['user_list']))
 117      {
 118          continue;
 119      }
 120  
 121      $bgcolor = '';
 122      foreach($usergroup['user_list'] as $user)
 123      {
 124          $user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
 125          $user['profilelink'] = get_profile_link($user['uid']);
 126  
 127          // For the postbit templates
 128          $post['uid'] = $user['uid'];
 129          $emailcode = $pmcode = '';
 130          if($user['hideemail'] != 1)
 131          {
 132              eval("\$emailcode = \"".$templates->get("postbit_email")."\";");
 133          }
 134          
 135          if($user['receivepms'] != 0 && $mybb->settings['enablepms'] != 0 && my_strpos(",".$user['ignorelist'].",", ",".$mybb->user['uid'].",") === false)
 136          {
 137              eval("\$pmcode = \"".$templates->get("postbit_pm")."\";");
 138          }
 139          
 140          $bgcolor = alt_trow();
 141  
 142          // If the current group is a moderator group
 143          if($usergroup['gid'] == 6 && !empty($user['forumlist']))
 144          {
 145              $forumslist = $user['forumlist'];
 146              eval("\$modrows .= \"".$templates->get("showteam_moderators_mod")."\";");
 147          }
 148          else
 149          {
 150              eval("\$usergrouprows .= \"".$templates->get("showteam_usergroup_user")."\";");
 151          }    
 152      }
 153      
 154      if($modrows && $usergroup['gid'] == 6)
 155      {
 156          eval("\$grouplist .= \"".$templates->get("showteam_moderators")."\";");
 157      }
 158  
 159      if($usergrouprows)
 160      {
 161          eval("\$grouplist .= \"".$templates->get("showteam_usergroup")."\";");
 162      }
 163  
 164      $usergrouprows = $modrows = '';
 165  }
 166  
 167  if(empty($grouplist))
 168  {
 169      error($lang->error_noteamstoshow);
 170  }
 171  
 172  $plugins->run_hooks("showteam_end");
 173  
 174  eval("\$showteam = \"".$templates->get("showteam")."\";");
 175  output_page($showteam);
 176  ?>


Generated: Tue Oct 8 19:19:50 2013 Cross-referenced by PHPXref 0.7.1