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.

viewconv.php 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <?
  2. if ($ConvID = (int)$_GET['id']) {
  3. // Get conversation info
  4. $DB->query("
  5. SELECT Subject, UserID, Level, AssignedToUser, Unread, Status
  6. FROM staff_pm_conversations
  7. WHERE ID = $ConvID");
  8. list($Subject, $UserID, $Level, $AssignedToUser, $Unread, $Status) = $DB->next_record();
  9. $LevelCap = 1000;
  10. $PMLevel = $Level;
  11. $Level = min($Level, $LevelCap);
  12. if (!(($UserID == $LoggedUser['ID'])
  13. || ($AssignedToUser == $LoggedUser['ID'])
  14. || (($Level > 0 && $Level <= $LoggedUser['EffectiveClass']) || ($Level == 0 && $IsFLS))
  15. )) {
  16. // User is trying to view someone else's conversation
  17. error(403);
  18. }
  19. // User is trying to view their own unread conversation, set it to read
  20. if ($UserID == $LoggedUser['ID'] && $Unread) {
  21. $DB->query("
  22. UPDATE staff_pm_conversations
  23. SET Unread = false
  24. WHERE ID = $ConvID");
  25. // Clear cache for user
  26. $Cache->delete_value("staff_pm_new_$LoggedUser[ID]");
  27. }
  28. View::show_header('Staff PM', 'staffpm,bbcode');
  29. $UserInfo = Users::user_info($UserID);
  30. $UserStr = Users::format_username($UserID, true, true, true, true);
  31. $OwnerID = $UserID;
  32. $OwnerName = $UserInfo['Username'];
  33. ?>
  34. <div class="thin">
  35. <div class="header">
  36. <h2>Staff PM - <?=display_str($Subject)?></h2>
  37. <div class="linkbox">
  38. <?
  39. // Staff only
  40. if ($IsStaff) {
  41. ?>
  42. <a href="staffpm.php" class="brackets">My unanswered</a>
  43. <?
  44. }
  45. // FLS/Staff
  46. if ($IsFLS) {
  47. ?>
  48. <a href="staffpm.php?view=unanswered" class="brackets">All unanswered</a>
  49. <a href="staffpm.php?view=open" class="brackets">Open</a>
  50. <a href="staffpm.php?view=resolved" class="brackets">Resolved</a>
  51. <?
  52. // User
  53. } else {
  54. ?>
  55. <a href="staffpm.php" class="brackets">Back to inbox</a>
  56. <?
  57. }
  58. ?> </div>
  59. </div>
  60. <br />
  61. <br />
  62. <div id="inbox">
  63. <?
  64. // Get messages
  65. $StaffPMs = $DB->query("
  66. SELECT UserID, SentDate, Message, ID
  67. FROM staff_pm_messages
  68. WHERE ConvID = $ConvID");
  69. while (list($UserID, $SentDate, $Message, $MessageID) = $DB->next_record()) {
  70. // Set user string
  71. if ($UserID == $OwnerID) {
  72. // User, use prepared string
  73. $UserString = $UserStr;
  74. $Username = $OwnerName;
  75. } else {
  76. // Staff/FLS
  77. $UserInfo = Users::user_info($UserID);
  78. $UserString = Users::format_username($UserID, true, true, true, true);
  79. $Username = $UserInfo['Username'];
  80. }
  81. ?>
  82. <div class="box vertical_space" id="post<?=$MessageID?>">
  83. <div class="head">
  84. <a class="postid" href="staffpm.php?action=viewconv&amp;id=<?=$ConvID?>#post<?=$MessageID?>">#<?=$MessageID?></a>
  85. <strong>
  86. <?=$UserString?>
  87. </strong>
  88. <?=time_diff($SentDate, 2, true)?>
  89. <? if ($Status != 'Resolved') { ?>
  90. - <a href="#quickpost" onclick="Quote('<?=$MessageID?>', '<?=$Username?>');" class="brackets">Quote</a>
  91. <? } ?>
  92. </div>
  93. <div class="body"><?=Text::full_format($Message)?></div>
  94. </div>
  95. <div align="center" style="display: none;"></div>
  96. <?
  97. $DB->set_query_id($StaffPMs);
  98. }
  99. // Common responses
  100. if ($IsFLS && $Status != 'Resolved') {
  101. ?>
  102. <div id="common_answers" class="hidden">
  103. <div class="box vertical_space">
  104. <div class="head">
  105. <strong>Preview</strong>
  106. </div>
  107. <div id="common_answers_body" class="body">Select an answer from the drop-down to view it.</div>
  108. </div>
  109. <br />
  110. <div class="center">
  111. <select id="common_answers_select" onchange="UpdateMessage();">
  112. <option id="first_common_response">Select a message</option>
  113. <?
  114. // List common responses
  115. $DB->query("
  116. SELECT ID, Name
  117. FROM staff_pm_responses");
  118. while (list($ID, $Name) = $DB->next_record()) {
  119. ?>
  120. <option value="<?=$ID?>"><?=$Name?></option>
  121. <? } ?>
  122. </select>
  123. <input type="button" value="Set message" onclick="SetMessage();" />
  124. <input type="button" value="Create new / Edit" onclick="location.href='staffpm.php?action=responses&amp;convid=<?=$ConvID?>';" />
  125. </div>
  126. </div>
  127. <?
  128. }
  129. // Ajax assign response div
  130. if ($IsStaff) {
  131. ?>
  132. <div id="ajax_message" class="hidden center alertbar"></div>
  133. <?
  134. }
  135. // Reply box and buttons
  136. ?>
  137. <h3>Reply</h3>
  138. <div class="box pad" id="reply_box">
  139. <div id="buttons" class="center">
  140. <form class="manage_form" name="staff_messages" action="staffpm.php" method="post" id="messageform">
  141. <input type="hidden" name="action" value="takepost" />
  142. <input type="hidden" name="convid" value="<?=$ConvID?>" id="convid" />
  143. <?
  144. if ($Status != 'Resolved') {
  145. $TextPrev = new TEXTAREA_PREVIEW('message', 'quickpost', '', 90, 10, true, false);
  146. }
  147. ?>
  148. <br />
  149. <?
  150. // Assign to
  151. if ($IsStaff) {
  152. // Staff assign dropdown
  153. ?>
  154. <select id="assign_to" name="assign">
  155. <optgroup label="User classes">
  156. <? // FLS "class"
  157. $Selected = ((!$AssignedToUser && $PMLevel == 0) ? ' selected="selected"' : '');
  158. ?>
  159. <option value="class_0"<?=$Selected?>>First Line Support</option>
  160. <? // Staff classes
  161. foreach ($ClassLevels as $Class) {
  162. // Create one <option> for each staff user class
  163. if ($Class['Level'] >= 650) {
  164. $Selected = ((!$AssignedToUser && ($PMLevel == $Class['Level'])) ? ' selected="selected"' : '');
  165. ?>
  166. <option value="class_<?=$Class['Level']?>"<?=$Selected?>><?=$Class['Name']?></option>
  167. <?
  168. }
  169. }
  170. ?>
  171. </optgroup>
  172. <optgroup label="Staff">
  173. <? // Staff members
  174. $DB->query("
  175. SELECT
  176. m.ID,
  177. m.Username
  178. FROM permissions AS p
  179. JOIN users_main AS m ON m.PermissionID = p.ID
  180. WHERE p.DisplayStaff = '1'
  181. ORDER BY p.Level DESC, m.Username ASC"
  182. );
  183. while (list($ID, $Name) = $DB->next_record()) {
  184. // Create one <option> for each staff member
  185. $Selected = (($AssignedToUser == $ID) ? ' selected="selected"' : '');
  186. ?>
  187. <option value="user_<?=$ID?>"<?=$Selected?>><?=$Name?></option>
  188. <? } ?>
  189. </optgroup>
  190. <optgroup label="First Line Support">
  191. <?
  192. // FLS users
  193. $DB->query("
  194. SELECT
  195. m.ID,
  196. m.Username
  197. FROM users_info AS i
  198. JOIN users_main AS m ON m.ID = i.UserID
  199. JOIN permissions AS p ON p.ID = m.PermissionID
  200. WHERE p.DisplayStaff != '1'
  201. AND i.SupportFor != ''
  202. ORDER BY m.Username ASC
  203. ");
  204. while (list($ID, $Name) = $DB->next_record()) {
  205. // Create one <option> for each FLS user
  206. $Selected = (($AssignedToUser == $ID) ? ' selected="selected"' : '');
  207. ?>
  208. <option value="user_<?=$ID?>"<?=$Selected?>><?=$Name?></option>
  209. <? } ?>
  210. </optgroup>
  211. </select>
  212. <input type="button" onclick="Assign();" value="Assign" />
  213. <? } elseif ($IsFLS) { // FLS assign button ?>
  214. <input type="button" value="Assign to staff" onclick="location.href='staffpm.php?action=assign&amp;to=staff&amp;convid=<?=$ConvID?>';" />
  215. <input type="button" value="Assign to forum staff" onclick="location.href='staffpm.php?action=assign&amp;to=forum&amp;convid=<?=$ConvID?>';" />
  216. <?
  217. }
  218. if ($Status != 'Resolved') { ?>
  219. <input type="button" value="Resolve" onclick="location.href='staffpm.php?action=resolve&amp;id=<?=$ConvID?>';" />
  220. <? if ($IsFLS) { //Moved by request ?>
  221. <input type="button" value="Common answers" toggle-target="#common_answers" />
  222. <? } ?>
  223. <input type="button" id="previewbtn" value="Preview" class="hidden button_preview_<?=$TextPrev->getID()?>" />
  224. <input type="submit" value="Send message" />
  225. <? } else { ?>
  226. <input type="button" value="Unresolve" onclick="location.href='staffpm.php?action=unresolve&amp;id=<?=$ConvID?>';" />
  227. <?
  228. }
  229. if (check_perms('users_give_donor')) { ?>
  230. <br />
  231. <input type="button" value="Make Donor" toggle-target="#make_donor_form" />
  232. <? } ?>
  233. </form>
  234. <? if (check_perms('users_give_donor')) { ?>
  235. <div id="make_donor_form" class="hidden">
  236. <form action="staffpm.php" method="post">
  237. <input type="hidden" name="action" value="make_donor" />
  238. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  239. <input type="hidden" name="id" value="<?=$ConvID?>" />
  240. <strong>Amount: </strong>
  241. <input type="text" name="donation_amount" onkeypress="return isNumberKey(event);" />
  242. <br />
  243. <strong>Reason: </strong>
  244. <input type="text" name="donation_reason" />
  245. <br />
  246. <select name="donation_source">
  247. <option value="Flattr">Flattr</option>
  248. </select>
  249. <select name="donation_currency">
  250. <option value="EUR">EUR</option>
  251. </select>
  252. <input type="submit" value="Submit" />
  253. </form>
  254. </div>
  255. <? } ?>
  256. </div>
  257. </div>
  258. </div>
  259. </div>
  260. <?
  261. View::show_footer();
  262. } else {
  263. // No ID
  264. header('Location: staffpm.php');
  265. }