[ Index ] |
PHP Cross Reference of MyBB 1.8.38 |
[Summary view] [Print] [Text view]
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 $leadlist = array(); 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 $forumlist = ''; 152 foreach($moderators[$user['uid']] as $forum) 153 { 154 if($forum_permissions[$forum['fid']]['canview'] == 1) 155 { 156 $forum_url = get_forum_link($forum['fid']); 157 eval("\$forumlist .= \"".$templates->get("showteam_moderators_forum")."\";"); 158 } 159 } 160 $user['forumlist'] = $forumlist; 161 $forumlist = ''; 162 $usergroups[6]['user_list'][$user['uid']] = $user; 163 } 164 165 if($mybb->settings['showgroupleaders'] && isset($usergroups[0]['user_list'])) 166 { 167 foreach($usergroups[0]['user_list'] as $uid => $userdetails) 168 { 169 if($user['uid'] == $uid) 170 { 171 $user['leaded'] = $usergroups[0]['user_list'][$uid]['leaded']; 172 $usergroups[0]['user_list'][$uid] = $user; 173 } 174 } 175 } 176 177 if($user['displaygroup'] == '6' || $user['usergroup'] == '6') 178 { 179 $usergroups[6]['user_list'][$user['uid']] = $user; 180 } 181 182 // Are they also in another group which is being shown on the list? 183 if($user['displaygroup'] != 0) 184 { 185 $group = $user['displaygroup']; 186 } 187 else 188 { 189 $group = $user['usergroup']; 190 } 191 192 if(isset($usergroups[$group]) && $group != 6) 193 { 194 $usergroups[$group]['user_list'][$user['uid']] = $user; 195 } 196 197 if($mybb->settings['showaddlgroups'] && $user['additionalgroups'] != '') 198 { 199 $adgroups = explode(',', $user['additionalgroups']); 200 foreach($adgroups as $adgroup) 201 { 202 if(in_array($adgroup, $visible_groups)) 203 { 204 $usergroups[$adgroup]['user_list'][$user['uid']] = $user; 205 } 206 } 207 } 208 } 209 210 // Now we have all of our user details we can display them. 211 $grouplist = ''; 212 foreach($usergroups as $usergroup) 213 { 214 $usergrouprows = $modrows = ''; 215 216 // If we have no users - don't show this group 217 if(!isset($usergroup['user_list'])) 218 { 219 continue; 220 } 221 222 $bgcolor = ''; 223 foreach($usergroup['user_list'] as $user) 224 { 225 $user['username'] = format_name(htmlspecialchars_uni($user['username']), $user['usergroup'], $user['displaygroup']); 226 $user['profilelink'] = get_profile_link($user['uid']); 227 228 // For the postbit templates 229 $post['uid'] = $user['uid']; 230 $emailcode = $pmcode = ''; 231 if($user['hideemail'] != 1) 232 { 233 eval("\$emailcode = \"".$templates->get("postbit_email")."\";"); 234 } 235 236 if($user['receivepms'] != 0 && $mybb->settings['enablepms'] != 0 && my_strpos(",".$user['ignorelist'].",", ",".$mybb->user['uid'].",") === false) 237 { 238 eval("\$pmcode = \"".$templates->get("postbit_pm")."\";"); 239 } 240 241 // For the online image 242 if($user['lastactive'] > $timecut && ($user['invisible'] == 0 || $mybb->usergroup['canviewwolinvis'] == 1) && $user['lastvisit'] != $user['lastactive']) 243 { 244 $status = "online"; 245 } 246 elseif($user['away'] == 1 && $mybb->settings['allowaway'] != 0) 247 { 248 $status = "away"; 249 } 250 else 251 { 252 $status = "offline"; 253 } 254 255 if($user['invisible'] == 1 && $mybb->usergroup['canviewwolinvis'] != 1 && $user['uid'] != $mybb->user['uid']) 256 { 257 if($user['lastactive']) 258 { 259 $user['lastvisit'] = $lang->lastvisit_hidden; 260 } 261 else 262 { 263 $user['lastvisit'] = $lang->lastvisit_never; 264 } 265 } 266 else 267 { 268 $user['lastvisit'] = my_date('relative', $user['lastactive']); 269 } 270 271 $bgcolor = alt_trow(); 272 273 $plugins->run_hooks('showteam_user'); 274 275 // If the current group is a moderator group 276 if(($usergroup['gid'] == 0 && !empty($user['leaded'])) || ($usergroup['gid'] == 6 && !empty($user['forumlist']))) 277 { 278 $scopelist = $usergroup['gid'] == 0 ? $user['leaded'] : $user['forumlist']; 279 eval("\$modrows .= \"".$templates->get("showteam_moderators_mod")."\";"); 280 } 281 else 282 { 283 eval("\$usergrouprows .= \"".$templates->get("showteam_usergroup_user")."\";"); 284 } 285 } 286 287 if($modrows && in_array($usergroup['gid'], array(0,6))) 288 { 289 $modscope = $usergroup['gid'] == 6 ? $lang->mod_forums : $lang->mod_groups; 290 eval("\$grouplist .= \"".$templates->get("showteam_moderators")."\";"); 291 } 292 293 if($usergrouprows) 294 { 295 eval("\$grouplist .= \"".$templates->get("showteam_usergroup")."\";"); 296 } 297 } 298 299 if(empty($grouplist)) 300 { 301 error($lang->error_noteamstoshow); 302 } 303 304 $plugins->run_hooks("showteam_end"); 305 306 eval("\$showteam = \"".$templates->get("showteam")."\";"); 307 output_page($showteam);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |