Oppaitime's version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functions.php 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?
  2. /**
  3. * Generate a table row for a staff member on staff.php
  4. *
  5. * @param $Row used for alternating row colors
  6. * @param $ID the user ID of the staff member
  7. * @param $Paranoia the user's paranoia
  8. * @param $Class the user class
  9. * @param $LastAccess datetime the user last browsed the site
  10. * @param $Remark the "Staff remark" or FLS' "Support for" text
  11. * @param $HiddenBy the text that is displayed when a staff member's
  12. * paranoia hides their LastAccess time
  13. * @return string $Row
  14. */
  15. function make_staff_row($ID, $Paranoia, $Class, $LastAccess, $Remark = '', $HiddenBy = 'Hidden by user') {
  16. echo "\t\t\t<tr class=\"row\">
  17. <td class=\"nobr\">
  18. " . Users::format_username($ID, false, false, false) . "
  19. </td>
  20. <td class=\"nobr\">
  21. "; //used for proper indentation of HTML
  22. if (check_paranoia('lastseen', $Paranoia, $Class)) {
  23. echo time_diff($LastAccess);
  24. } else {
  25. echo "$HiddenBy";
  26. }
  27. echo "\n\t\t\t\t</td>
  28. <td class=\"nobr\">"
  29. . Text::full_format($Remark) .
  30. "</td>
  31. </tr>\n"; // the "\n" is needed for pretty HTML
  32. // the foreach loop that calls this function needs to know the new value of $Row
  33. }
  34. function get_fls() {
  35. global $Cache, $DB;
  36. static $FLS;
  37. if (is_array($FLS)) {
  38. return $FLS;
  39. }
  40. if (($FLS = $Cache->get_value('fls')) === false) {
  41. $DB->query('
  42. SELECT
  43. m.ID,
  44. p.Level,
  45. m.Username,
  46. m.Paranoia,
  47. m.LastAccess,
  48. i.SupportFor
  49. FROM users_info AS i
  50. JOIN users_main AS m ON m.ID = i.UserID
  51. JOIN permissions AS p ON p.ID = m.PermissionID
  52. JOIN users_levels AS l ON l.UserID = i.UserID
  53. WHERE l.PermissionID = ' . FLS_TEAM . '
  54. ORDER BY m.Username');
  55. $FLS = $DB->to_array(false, MYSQLI_BOTH, array(3, 'Paranoia'));
  56. $Cache->cache_value('fls', $FLS, 180);
  57. }
  58. return $FLS;
  59. }
  60. /*
  61. * Build the SQL query that will be used for displaying staff members
  62. *
  63. * @param $StaffLevel a string for selecting the type of staff being queried
  64. * @return string the text of the generated SQL query
  65. */
  66. function generate_staff_query($StaffLevel) {
  67. global $Classes;
  68. if ($StaffLevel == 'forum_staff') {
  69. $PName = ''; // only needed for full staff
  70. $PLevel = 'p.Level < ' . $Classes[MOD]['Level'];
  71. } elseif ($StaffLevel == 'staff') {
  72. $PName = 'p.Name,';
  73. $PLevel = 'p.Level >= ' . $Classes[MOD]['Level'];
  74. }
  75. $SQL = "
  76. SELECT
  77. m.ID,
  78. p.Level,
  79. $PName
  80. m.Username,
  81. m.Paranoia,
  82. m.LastAccess,
  83. i.SupportFor
  84. FROM users_main AS m
  85. JOIN users_info AS i ON m.ID = i.UserID
  86. JOIN permissions AS p ON p.ID = m.PermissionID
  87. WHERE p.DisplayStaff = '1'
  88. AND $PLevel
  89. ORDER BY p.Level";
  90. if (check_perms('users_mod')) {
  91. $SQL .= ', m.LastAccess ASC';
  92. } else {
  93. $SQL .= ', m.Username';
  94. }
  95. return $SQL;
  96. }
  97. function get_forum_staff() {
  98. global $Cache, $DB;
  99. static $ForumStaff;
  100. if (is_array($ForumStaff)) {
  101. return $ForumStaff;
  102. }
  103. // sort the lists differently if the viewer is a staff member
  104. if (!check_perms('users_mod')) {
  105. if (($ForumStaff = $Cache->get_value('forum_staff')) === false) {
  106. $DB->query(generate_staff_query('forum_staff'));
  107. $ForumStaff = $DB->to_array(false, MYSQLI_BOTH, array(3, 'Paranoia'));
  108. $Cache->cache_value('forum_staff', $ForumStaff, 180);
  109. }
  110. } else {
  111. if (($ForumStaff = $Cache->get_value('forum_staff_mod_view')) === false) {
  112. $DB->query(generate_staff_query('forum_staff'));
  113. $ForumStaff = $DB->to_array(false, MYSQLI_BOTH, array(3, 'Paranoia'));
  114. $Cache->cache_value('forum_staff_mod_view', $ForumStaff, 180);
  115. }
  116. }
  117. return $ForumStaff;
  118. }
  119. function get_staff() {
  120. global $Cache, $DB;
  121. static $Staff;
  122. if (is_array($Staff)) {
  123. return $Staff;
  124. }
  125. // sort the lists differently if the viewer is a staff member
  126. if (!check_perms('users_mod')) {
  127. if (($Staff = $Cache->get_value('staff')) === false) {
  128. $DB->query(generate_staff_query('staff'));
  129. $Staff = $DB->to_array(false, MYSQLI_BOTH, array(4, 'Paranoia'));
  130. $Cache->cache_value('staff', $Staff, 180);
  131. }
  132. } else {
  133. if (($Staff = $Cache->get_value('staff_mod_view')) === false) {
  134. $DB->query(generate_staff_query('staff'));
  135. $Staff = $DB->to_array(false, MYSQLI_BOTH, array(4, 'Paranoia'));
  136. $Cache->cache_value('staff_mod_view', $Staff, 180);
  137. }
  138. }
  139. return $Staff;
  140. }
  141. function get_support() {
  142. return array(
  143. get_fls(),
  144. get_forum_staff(),
  145. get_staff(),
  146. 'fls' => get_fls(),
  147. 'forum_staff' => get_forum_staff(),
  148. 'staff' => get_staff()
  149. );
  150. }
  151. function printSectionDiv($ClassName) {
  152. ?>
  153. </div><br />
  154. <div class='box pad'>
  155. <h2 style='text-align: left;'><?=$ClassName?></h2>
  156. <?
  157. }