2011-03-28 14:21:28 +00:00
|
|
|
<?
|
2013-05-05 08:00:31 +00:00
|
|
|
/**
|
|
|
|
* Generate a table row for a staff member on staff.php
|
|
|
|
*
|
|
|
|
* @param $Row used for alternating row colors
|
|
|
|
* @param $ID the user ID of the staff member
|
|
|
|
* @param $Paranoia the user's paranoia
|
|
|
|
* @param $Class the user class
|
|
|
|
* @param $LastAccess datetime the user last browsed the site
|
|
|
|
* @param $Remark the "Staff remark" or FLS' "Support for" text
|
|
|
|
* @param $HiddenBy the text that is displayed when a staff member's
|
|
|
|
* paranoia hides their LastAccess time
|
|
|
|
* @return string $Row
|
|
|
|
*/
|
|
|
|
function make_staff_row($Row, $ID, $Paranoia, $Class, $LastAccess, $Remark = '', $HiddenBy = 'Hidden by user') {
|
2013-10-25 08:00:59 +00:00
|
|
|
$Row = $Row === 'a' ? 'b' : 'a';
|
2013-05-05 08:00:31 +00:00
|
|
|
|
|
|
|
echo "\t\t\t<tr class=\"row$Row\">
|
|
|
|
<td class=\"nobr\">
|
|
|
|
" . Users::format_username($ID, false, false, false) . "
|
|
|
|
</td>
|
|
|
|
<td class=\"nobr\">
|
|
|
|
"; //used for proper indentation of HTML
|
|
|
|
if (check_paranoia('lastseen', $Paranoia, $Class)) {
|
|
|
|
echo time_diff($LastAccess);
|
|
|
|
} else {
|
|
|
|
echo "$HiddenBy";
|
|
|
|
}
|
|
|
|
echo "\n\t\t\t\t</td>
|
2013-07-29 08:00:49 +00:00
|
|
|
<td class=\"nobr\">"
|
2013-12-12 08:01:01 +00:00
|
|
|
. Text::full_format($Remark) .
|
2013-07-29 08:00:49 +00:00
|
|
|
"</td>
|
2013-05-05 08:00:31 +00:00
|
|
|
</tr>\n"; // the "\n" is needed for pretty HTML
|
|
|
|
// the foreach loop that calls this function needs to know the new value of $Row
|
|
|
|
return $Row;
|
|
|
|
}
|
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
function get_fls() {
|
|
|
|
global $Cache, $DB;
|
|
|
|
static $FLS;
|
2013-04-13 08:00:19 +00:00
|
|
|
if (is_array($FLS)) {
|
2011-03-28 14:21:28 +00:00
|
|
|
return $FLS;
|
|
|
|
}
|
2013-04-13 08:00:19 +00:00
|
|
|
if (($FLS = $Cache->get_value('fls')) === false) {
|
2013-05-05 08:00:31 +00:00
|
|
|
$DB->query('
|
|
|
|
SELECT
|
2013-04-13 08:00:19 +00:00
|
|
|
m.ID,
|
|
|
|
p.Level,
|
|
|
|
m.Username,
|
|
|
|
m.Paranoia,
|
|
|
|
m.LastAccess,
|
|
|
|
i.SupportFor
|
2011-03-28 14:21:28 +00:00
|
|
|
FROM users_info AS i
|
2013-09-17 08:00:49 +00:00
|
|
|
JOIN users_main AS m ON m.ID = i.UserID
|
|
|
|
JOIN permissions AS p ON p.ID = m.PermissionID
|
2013-04-13 08:00:19 +00:00
|
|
|
JOIN users_levels AS l ON l.UserID = i.UserID
|
2013-05-05 08:00:31 +00:00
|
|
|
WHERE l.PermissionID = ' . FLS_TEAM . '
|
|
|
|
ORDER BY m.Username');
|
2013-09-17 08:00:49 +00:00
|
|
|
$FLS = $DB->to_array(false, MYSQLI_BOTH, array(3, 'Paranoia'));
|
2011-03-28 14:21:28 +00:00
|
|
|
$Cache->cache_value('fls', $FLS, 180);
|
|
|
|
}
|
|
|
|
return $FLS;
|
|
|
|
}
|
|
|
|
|
2013-05-05 08:00:31 +00:00
|
|
|
/*
|
|
|
|
* Build the SQL query that will be used for displaying staff members
|
|
|
|
*
|
|
|
|
* @param $StaffLevel a string for selecting the type of staff being queried
|
|
|
|
* @return string the text of the generated SQL query
|
|
|
|
*/
|
|
|
|
function generate_staff_query($StaffLevel) {
|
2013-09-17 08:00:49 +00:00
|
|
|
global $Classes;
|
2013-05-05 08:00:31 +00:00
|
|
|
if ($StaffLevel == 'forum_staff') {
|
|
|
|
$PName = ''; // only needed for full staff
|
2013-09-17 08:00:49 +00:00
|
|
|
$PLevel = 'p.Level < ' . $Classes[MOD]['Level'];
|
2013-05-05 08:00:31 +00:00
|
|
|
} elseif ($StaffLevel == 'staff') {
|
|
|
|
$PName = 'p.Name,';
|
2013-09-17 08:00:49 +00:00
|
|
|
$PLevel = 'p.Level >= ' . $Classes[MOD]['Level'];
|
2011-07-10 08:00:06 +00:00
|
|
|
}
|
2013-05-05 08:00:31 +00:00
|
|
|
|
|
|
|
$SQL = "
|
2013-11-12 08:00:58 +00:00
|
|
|
SELECT
|
|
|
|
m.ID,
|
|
|
|
p.Level,
|
|
|
|
$PName
|
|
|
|
m.Username,
|
|
|
|
m.Paranoia,
|
|
|
|
m.LastAccess,
|
|
|
|
i.SupportFor
|
|
|
|
FROM users_main AS m
|
|
|
|
JOIN users_info AS i ON m.ID = i.UserID
|
|
|
|
JOIN permissions AS p ON p.ID = m.PermissionID
|
|
|
|
WHERE p.DisplayStaff = '1'
|
|
|
|
AND $PLevel
|
|
|
|
ORDER BY p.Level";
|
2013-05-05 08:00:31 +00:00
|
|
|
if (check_perms('users_mod')) {
|
2013-09-17 08:00:49 +00:00
|
|
|
$SQL .= ', m.LastAccess ASC';
|
2013-05-05 08:00:31 +00:00
|
|
|
} else {
|
2013-09-17 08:00:49 +00:00
|
|
|
$SQL .= ', m.Username';
|
2013-05-05 08:00:31 +00:00
|
|
|
}
|
|
|
|
return $SQL;
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_forum_staff() {
|
|
|
|
global $Cache, $DB;
|
|
|
|
static $ForumStaff;
|
|
|
|
if (is_array($ForumStaff)) {
|
|
|
|
return $ForumStaff;
|
|
|
|
}
|
|
|
|
|
|
|
|
// sort the lists differently if the viewer is a staff member
|
|
|
|
if (!check_perms('users_mod')) {
|
|
|
|
if (($ForumStaff = $Cache->get_value('forum_staff')) === false) {
|
|
|
|
$DB->query(generate_staff_query('forum_staff'));
|
2013-09-17 08:00:49 +00:00
|
|
|
$ForumStaff = $DB->to_array(false, MYSQLI_BOTH, array(3, 'Paranoia'));
|
2013-05-05 08:00:31 +00:00
|
|
|
$Cache->cache_value('forum_staff', $ForumStaff, 180);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (($ForumStaff = $Cache->get_value('forum_staff_mod_view')) === false) {
|
|
|
|
$DB->query(generate_staff_query('forum_staff'));
|
2013-09-17 08:00:49 +00:00
|
|
|
$ForumStaff = $DB->to_array(false, MYSQLI_BOTH, array(3, 'Paranoia'));
|
2013-05-05 08:00:31 +00:00
|
|
|
$Cache->cache_value('forum_staff_mod_view', $ForumStaff, 180);
|
|
|
|
}
|
2011-07-10 08:00:06 +00:00
|
|
|
}
|
|
|
|
return $ForumStaff;
|
|
|
|
}
|
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
function get_staff() {
|
|
|
|
global $Cache, $DB;
|
|
|
|
static $Staff;
|
2013-04-13 08:00:19 +00:00
|
|
|
if (is_array($Staff)) {
|
2011-03-28 14:21:28 +00:00
|
|
|
return $Staff;
|
|
|
|
}
|
2013-05-05 08:00:31 +00:00
|
|
|
|
|
|
|
// sort the lists differently if the viewer is a staff member
|
|
|
|
if (!check_perms('users_mod')) {
|
|
|
|
if (($Staff = $Cache->get_value('staff')) === false) {
|
|
|
|
$DB->query(generate_staff_query('staff'));
|
2013-09-17 08:00:49 +00:00
|
|
|
$Staff = $DB->to_array(false, MYSQLI_BOTH, array(4, 'Paranoia'));
|
2013-05-05 08:00:31 +00:00
|
|
|
$Cache->cache_value('staff', $Staff, 180);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (($Staff = $Cache->get_value('staff_mod_view')) === false) {
|
|
|
|
$DB->query(generate_staff_query('staff'));
|
2013-09-17 08:00:49 +00:00
|
|
|
$Staff = $DB->to_array(false, MYSQLI_BOTH, array(4, 'Paranoia'));
|
2013-05-05 08:00:31 +00:00
|
|
|
$Cache->cache_value('staff_mod_view', $Staff, 180);
|
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
return $Staff;
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_support() {
|
|
|
|
return array(
|
2011-07-10 08:00:06 +00:00
|
|
|
get_fls(),
|
|
|
|
get_forum_staff(),
|
|
|
|
get_staff(),
|
2011-03-28 14:21:28 +00:00
|
|
|
'fls' => get_fls(),
|
2011-07-10 08:00:06 +00:00
|
|
|
'forum_staff' => get_forum_staff(),
|
2011-03-28 14:21:28 +00:00
|
|
|
'staff' => get_staff()
|
|
|
|
);
|
|
|
|
}
|