Advertisement
Guest User

Showteam

a guest
May 10th, 2018
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.68 KB | None | 0 0
  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. add_breadcrumb($lang->nav_showteam);
  21.  
  22. $plugins->run_hooks('showteam_start');
  23.  
  24. $timecut = TIME_NOW - $mybb->settings['wolcutoff'];
  25.  
  26. $usergroups = array();
  27. $moderators = array();
  28. $users = array();
  29.  
  30. // Fetch the list of groups which are to be shown on the page
  31. $query = $db->simple_select("usergroups", "gid, title, usertitle", "showforumteam=1", array('order_by' => 'disporder'));
  32. while($usergroup = $db->fetch_array($query))
  33. {
  34.     $usergroups[$usergroup['gid']] = $usergroup;
  35. }
  36.  
  37. if(empty($usergroups))
  38. {
  39.     error($lang->error_noteamstoshow);
  40. }
  41.  
  42. // Fetch specific forum moderator details
  43. if($usergroups[6]['gid'])
  44. {
  45.     $query = $db->query("
  46.         SELECT m.*, f.name
  47.         FROM ".TABLE_PREFIX."moderators m
  48.         LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=m.id)
  49.         LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=m.fid)
  50.         WHERE f.active = 1 AND m.isgroup = 0
  51.         ORDER BY u.username
  52.     ");
  53.     while($moderator = $db->fetch_array($query))
  54.     {
  55.         $moderators[$moderator['id']][] = $moderator;
  56.     }
  57. }
  58.  
  59. // Now query the users of those specific groups
  60. $groups_in = implode(",", array_keys($usergroups));
  61. $users_in = implode(",", array_keys($moderators));
  62. if(!$groups_in)
  63. {
  64.     $groups_in = 0;
  65. }
  66. if(!$users_in)
  67. {
  68.     $users_in = 0;
  69. }
  70. $forum_permissions = forum_permissions();
  71.  
  72. $where = "uid IN ($users_in) OR usergroup IN ($groups_in)";
  73. if ($groups_in != 0)
  74. {
  75.     $groups = explode(',',$groups_in);
  76.     foreach ($groups as $group)
  77.     {
  78.         $where .= " OR {$group} IN (additionalgroups)";
  79.     }
  80. }
  81.  
  82. $query = $db->simple_select("users", "uid, username, displaygroup, if(avatar='', './images/default_avatar.png',avatar) as avatar, usergroup, ignorelist, hideemail, receivepms, lastactive, lastvisit, invisible, away", "displaygroup IN ($groups_in) OR (displaygroup='0' AND usergroup IN ($groups_in)) OR uid IN ($users_in)", array('order_by' => 'username'));
  83. while($user = $db->fetch_array($query))
  84. {
  85.     // If this user is a moderator
  86.     if(isset($moderators[$user['uid']]))
  87.     {
  88.         foreach($moderators[$user['uid']] as $forum)
  89.         {
  90.             if($forum_permissions[$forum['fid']]['canview'] == 1)
  91.             {
  92.                 $forum_url = get_forum_link($forum['fid']);
  93.                 eval("\$forumlist .= \"".$templates->get("showteam_moderators_forum")."\";");
  94.             }
  95.         }
  96.         $user['forumlist'] = $forumlist;
  97.         $forumlist = '';
  98.         $usergroups[6]['user_list'][$user['uid']] = $user;
  99.     }
  100.  
  101.     if($user['displaygroup'] == '6' || $user['usergroup'] == '6')
  102.     {
  103.         $usergroups[6]['user_list'][$user['uid']] = $user;
  104.     }
  105.  
  106.     // Are they also in another group which is being shown on the list?
  107.     if($user['displaygroup'] != 0)
  108.     {
  109.         $group = $user['displaygroup'];
  110.     }
  111.     else
  112.     {
  113.         $group = $user['usergroup'];
  114.     }
  115.  
  116.     if($usergroups[$group] && $group != 6)
  117.     {
  118.         $usergroups[$group]['user_list'][$user['uid']] = $user;
  119.     }
  120. }
  121.  
  122. // Now we have all of our user details we can display them.
  123. $grouplist = '';
  124. foreach($usergroups as $usergroup)
  125. {
  126.     $usergrouprows = $modrows = '';
  127.  
  128.     // If we have no users - don't show this group
  129.     if(!isset($usergroup['user_list']))
  130.     {
  131.         continue;
  132.     }
  133.  
  134.     $bgcolor = '';
  135.     foreach($usergroup['user_list'] as $user)
  136.     {
  137.         $user['username'] = format_name(htmlspecialchars_uni($user['username']), $user['usergroup'], $user['displaygroup']);
  138.         $user['profilelink'] = get_profile_link($user['uid']);
  139.  
  140.         // For the postbit templates
  141.         $post['uid'] = $user['uid'];
  142.         $emailcode = $pmcode = '';
  143.         if($user['hideemail'] != 1)
  144.         {
  145.             eval("\$emailcode = \"".$templates->get("postbit_email")."\";");
  146.         }
  147.  
  148.         if($user['receivepms'] != 0 && $mybb->settings['enablepms'] != 0 && my_strpos(",".$user['ignorelist'].",", ",".$mybb->user['uid'].",") === false)
  149.         {
  150.             eval("\$pmcode = \"".$templates->get("postbit_pm")."\";");
  151.         }
  152.  
  153.         // For the online image
  154.         if($user['lastactive'] > $timecut && ($user['invisible'] == 0 || $mybb->usergroup['canviewwolinvis'] == 1) && $user['lastvisit'] != $user['lastactive'])
  155.         {
  156.             $status = "online";
  157.         }
  158.         elseif($user['away'] == 1 && $mybb->settings['allowaway'] != 0)
  159.         {
  160.             $status = "away";
  161.         }
  162.         else
  163.         {
  164.             $status = "offline";
  165.         }
  166.  
  167.         if($user['invisible'] == 1 && $mybb->usergroup['canviewwolinvis'] != 1 && $user['uid'] != $mybb->user['uid'])
  168.         {
  169.             if($user['lastactive'])
  170.             {
  171.                 $user['lastvisit'] = $lang->lastvisit_hidden;
  172.             }
  173.             else
  174.             {
  175.                 $user['lastvisit'] = $lang->lastvisit_never;
  176.             }
  177.         }
  178.         else
  179.         {
  180.             $user['lastvisit'] = my_date('relative', $user['lastactive']);
  181.         }
  182.  
  183.         $bgcolor = alt_trow();
  184.  
  185.         $plugins->run_hooks('showteam_user');
  186.  
  187.         // If the current group is a moderator group
  188.         if($usergroup['gid'] == 6 && !empty($user['forumlist']))
  189.         {
  190.             $forumslist = $user['forumlist'];
  191.             eval("\$modrows .= \"".$templates->get("showteam_moderators_mod")."\";");
  192.         }
  193.         else
  194.         {
  195.             eval("\$usergrouprows .= \"".$templates->get("showteam_usergroup_user")."\";");
  196.         }
  197.     }
  198.  
  199.     if($modrows && $usergroup['gid'] == 6)
  200.     {
  201.         eval("\$grouplist .= \"".$templates->get("showteam_moderators")."\";");
  202.     }
  203.  
  204.     if($usergrouprows)
  205.     {
  206.         eval("\$grouplist .= \"".$templates->get("showteam_usergroup")."\";");
  207.     }
  208. }
  209.  
  210. if(empty($grouplist))
  211. {
  212.     error($lang->error_noteamstoshow);
  213. }
  214.  
  215. $plugins->run_hooks("showteam_end");
  216.  
  217. eval("\$showteam = \"".$templates->get("showteam")."\";");
  218. output_page($showteam);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement