BioTorrents.de’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.

conversation.php 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <?php
  2. #declare(strict_types = 1);
  3. $ConvID = $_GET['id'];
  4. if (!$ConvID || !is_number($ConvID)) {
  5. error(404);
  6. }
  7. $UserID = $LoggedUser['ID'];
  8. $DB->query("
  9. SELECT InInbox, InSentbox
  10. FROM pm_conversations_users
  11. WHERE UserID = '$UserID'
  12. AND ConvID = '$ConvID'");
  13. if (!$DB->has_results()) {
  14. error(403);
  15. }
  16. list($InInbox, $InSentbox) = $DB->next_record();
  17. if (!$InInbox && !$InSentbox) {
  18. error(404);
  19. }
  20. // Get information on the conversation
  21. $DB->query("
  22. SELECT
  23. c.Subject,
  24. cu.Sticky,
  25. cu.UnRead,
  26. cu.ForwardedTo
  27. FROM pm_conversations AS c
  28. JOIN pm_conversations_users AS cu ON c.ID = cu.ConvID
  29. WHERE c.ID = '$ConvID'
  30. AND UserID = '$UserID'");
  31. list($Subject, $Sticky, $UnRead, $ForwardedID) = $DB->next_record();
  32. $DB->query("
  33. SELECT um.ID, Username
  34. FROM pm_messages AS pm
  35. JOIN users_main AS um ON um.ID = pm.SenderID
  36. WHERE pm.ConvID = '$ConvID'");
  37. $ConverstionParticipants = $DB->to_array();
  38. foreach ($ConverstionParticipants as $Participant) {
  39. $PMUserID = (int)$Participant['ID'];
  40. $Users[$PMUserID]['UserStr'] = Users::format_username($PMUserID, true, true, true, true);
  41. $Users[$PMUserID]['Username'] = $Participant['Username'];
  42. }
  43. $Users[0]['UserStr'] = 'System'; // in case it's a message from the system
  44. $Users[0]['Username'] = 'System';
  45. if ($UnRead == '1') {
  46. $DB->query("
  47. UPDATE pm_conversations_users
  48. SET UnRead = '0'
  49. WHERE ConvID = '$ConvID'
  50. AND UserID = '$UserID'");
  51. // Clear the caches of the inbox and sentbox
  52. $Cache->decrement("inbox_new_$UserID");
  53. }
  54. View::show_header(
  55. "View conversation $Subject",
  56. 'comments,inbox,bbcode,vendor/jquery.validate.min,form_validate,vendor/easymde.min',
  57. 'vendor/easymde.min'
  58. );
  59. // Get messages
  60. $DB->query("
  61. SELECT SentDate, SenderID, Body, ID
  62. FROM pm_messages
  63. WHERE ConvID = '$ConvID'
  64. ORDER BY ID");
  65. ?>
  66. <div>
  67. <h2><?=$Subject.($ForwardedID > 0 ? " (Forwarded to $ForwardedName)" : '')?>
  68. </h2>
  69. <div class="linkbox">
  70. <a href="<?=Inbox::get_inbox_link(); ?>" class="brackets">Back to
  71. inbox</a>
  72. </div>
  73. <?php
  74. while (list($SentDate, $SenderID, $Body, $MessageID) = $DB->next_record()) {
  75. $Body = apcu_exists('DBKEY') ? Crypto::decrypt($Body) : '[url=https://'.SITE_DOMAIN.'/wiki.php?action=article&name=databaseencryption][Encrypted][/url]'; ?>
  76. <div class="box vertical_space">
  77. <div class="head" style="overflow: hidden;">
  78. <div class="float_left">
  79. <strong><?=$Users[(int)$SenderID]['UserStr']?></strong>
  80. <?=time_diff($SentDate)?> - <a href="#quickpost"
  81. onclick="Quote('<?=$MessageID?>','<?=$Users[(int)$SenderID]['Username']?>');"
  82. class="brackets">Quote</a>
  83. </div>
  84. <div class="float_right"><a href="#">&uarr;</a> <a href="#messageform">&darr;</a></div>
  85. </div>
  86. <div class="body" id="message<?=$MessageID?>">
  87. <?=Text::full_format($Body)?>
  88. </div>
  89. </div>
  90. <?php
  91. }
  92. $DB->query("
  93. SELECT UserID
  94. FROM pm_conversations_users
  95. WHERE UserID != '$LoggedUser[ID]'
  96. AND ConvID = '$ConvID'
  97. AND (ForwardedTo = 0 OR ForwardedTo = UserID)");
  98. $ReceiverIDs = $DB->collect('UserID');
  99. if (!empty($ReceiverIDs) && (empty($LoggedUser['DisablePM']) || array_intersect($ReceiverIDs, array_keys($StaffIDs)))) {
  100. ?>
  101. <h3>Reply</h3>
  102. <form class="send_form" name="reply" action="inbox.php" method="post" id="messageform">
  103. <div class="box pad">
  104. <input type="hidden" name="action" value="takecompose" />
  105. <input type="hidden" name="auth"
  106. value="<?=$LoggedUser['AuthKey']?>" />
  107. <input type="hidden" name="toid"
  108. value="<?=implode(',', $ReceiverIDs)?>" />
  109. <input type="hidden" name="convid" value="<?=$ConvID?>" />
  110. <?php
  111. $Reply = new TEXTAREA_PREVIEW(
  112. $Name = 'body',
  113. $ID = 'quickpost',
  114. $Value = '',
  115. ); ?>
  116. <div id="buttons" class="center">
  117. <input type="button" value="Preview"
  118. class="hidden button_preview_<?=$Reply->getID()?>">
  119. <input type="submit" value="Send message">
  120. </div>
  121. </div>
  122. </form>
  123. <?php
  124. }
  125. ?>
  126. <h3>Manage conversation</h3>
  127. <form class="manage_form" name="messages" action="inbox.php" method="post">
  128. <div class="box pad">
  129. <input type="hidden" name="action" value="takeedit" />
  130. <input type="hidden" name="convid" value="<?=$ConvID?>" />
  131. <input type="hidden" name="auth"
  132. value="<?=$LoggedUser['AuthKey']?>" />
  133. <table class="layout" width="100%">
  134. <tr>
  135. <td class="label"><label for="sticky">Sticky</label></td>
  136. <td>
  137. <input type="checkbox" id="sticky" name="sticky" <?php if ($Sticky) {
  138. echo ' checked="checked"' ;
  139. } ?> />
  140. </td>
  141. <td class="label"><label for="mark_unread">Mark as unread</label></td>
  142. <td>
  143. <input type="checkbox" id="mark_unread" name="mark_unread" />
  144. </td>
  145. <td class="label"><label for="delete">Delete conversation</label></td>
  146. <td>
  147. <input type="checkbox" id="delete" name="delete" />
  148. </td>
  149. </tr>
  150. <tr>
  151. <td class="center" colspan="6"><input type="submit" value="Manage conversation" /></td>
  152. </tr>
  153. </table>
  154. </div>
  155. </form>
  156. <?php
  157. $DB->query("
  158. SELECT SupportFor
  159. FROM users_info
  160. WHERE UserID = ".$LoggedUser['ID']);
  161. list($FLS) = $DB->next_record();
  162. if ((check_perms('users_mod') || $FLS != '') && (!$ForwardedID || $ForwardedID == $LoggedUser['ID'])) {
  163. ?>
  164. <h3>Forward conversation</h3>
  165. <form class="send_form" name="forward" action="inbox.php" method="post">
  166. <div class="box pad">
  167. <input type="hidden" name="action" value="forward" />
  168. <input type="hidden" name="convid" value="<?=$ConvID?>" />
  169. <input type="hidden" name="auth"
  170. value="<?=$LoggedUser['AuthKey']?>" />
  171. <label for="receiverid">Forward to</label>
  172. <select id="receiverid" name="receiverid">
  173. <?php
  174. foreach ($StaffIDs as $StaffID => $StaffName) {
  175. if ($StaffID == $LoggedUser['ID'] || in_array($StaffID, $ReceiverIDs)) {
  176. continue;
  177. } ?>
  178. <option value="<?=$StaffID?>"><?=$StaffName?>
  179. </option>
  180. <?php
  181. } ?>
  182. </select>
  183. <input type="submit" value="Forward" />
  184. </div>
  185. </form>
  186. <?php
  187. }
  188. //And we're done!
  189. ?>
  190. </div>
  191. <?php View::show_footer();