Gazelle/sections/inbox/conversation.php

196 lines
5.6 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
$ConvID = $_GET['id'];
2013-05-04 08:00:48 +00:00
if (!$ConvID || !is_number($ConvID)) {
error(404);
}
2011-03-28 14:21:28 +00:00
$UserID = $LoggedUser['ID'];
2013-05-27 08:00:58 +00:00
$DB->query("
SELECT InInbox, InSentbox
FROM pm_conversations_users
2013-09-20 08:00:56 +00:00
WHERE UserID = '$UserID'
AND ConvID = '$ConvID'");
2013-07-10 00:08:53 +00:00
if (!$DB->has_results()) {
2011-03-28 14:21:28 +00:00
error(403);
}
list($InInbox, $InSentbox) = $DB->next_record();
if (!$InInbox && !$InSentbox) {
error(404);
}
// Get information on the conversation
2013-05-04 08:00:48 +00:00
$DB->query("
SELECT
c.Subject,
cu.Sticky,
cu.UnRead,
cu.ForwardedTo
2011-03-28 14:21:28 +00:00
FROM pm_conversations AS c
2013-09-20 08:00:56 +00:00
JOIN pm_conversations_users AS cu ON c.ID = cu.ConvID
WHERE c.ID = '$ConvID'
AND UserID = '$UserID'");
2012-03-28 08:00:20 +00:00
list($Subject, $Sticky, $UnRead, $ForwardedID) = $DB->next_record();
2011-03-28 14:21:28 +00:00
2013-02-08 08:00:46 +00:00
2013-05-04 08:00:48 +00:00
$DB->query("
SELECT um.ID, Username
2011-03-28 14:21:28 +00:00
FROM pm_messages AS pm
2013-09-20 08:00:56 +00:00
JOIN users_main AS um ON um.ID = pm.SenderID
WHERE pm.ConvID = '$ConvID'");
2011-03-28 14:21:28 +00:00
2013-08-28 23:08:41 +00:00
$ConverstionParticipants = $DB->to_array();
2013-09-20 08:00:56 +00:00
foreach ($ConverstionParticipants as $Participant) {
2013-10-30 08:01:19 +00:00
$PMUserID = (int)$Participant['ID'];
2012-10-11 08:00:15 +00:00
$Users[$PMUserID]['UserStr'] = Users::format_username($PMUserID, true, true, true, true);
2013-08-28 23:08:41 +00:00
$Users[$PMUserID]['Username'] = $Participant['Username'];
2011-03-28 14:21:28 +00:00
}
2013-08-28 23:08:41 +00:00
2011-03-28 14:21:28 +00:00
$Users[0]['UserStr'] = 'System'; // in case it's a message from the system
$Users[0]['Username'] = 'System';
2013-05-04 08:00:48 +00:00
if ($UnRead == '1') {
2011-03-28 14:21:28 +00:00
2013-05-27 08:00:58 +00:00
$DB->query("
UPDATE pm_conversations_users
2013-09-20 08:00:56 +00:00
SET UnRead = '0'
WHERE ConvID = '$ConvID'
AND UserID = '$UserID'");
2011-03-28 14:21:28 +00:00
// Clear the caches of the inbox and sentbox
2013-09-20 08:00:56 +00:00
$Cache->decrement("inbox_new_$UserID");
2011-03-28 14:21:28 +00:00
}
2013-09-20 08:00:56 +00:00
View::show_header("View conversation $Subject", 'comments,inbox,bbcode,jquery.validate,form_validate');
2011-03-28 14:21:28 +00:00
// Get messages
2013-05-27 08:00:58 +00:00
$DB->query("
SELECT SentDate, SenderID, Body, ID
2013-11-17 08:00:47 +00:00
FROM pm_messages
2013-09-20 08:00:56 +00:00
WHERE ConvID = '$ConvID'
2013-05-27 08:00:58 +00:00
ORDER BY ID");
2011-03-28 14:21:28 +00:00
?>
<div class="thin">
2013-09-20 08:00:56 +00:00
<h2><?=$Subject.($ForwardedID > 0 ? " (Forwarded to $ForwardedName)" : '')?></h2>
2011-03-28 14:21:28 +00:00
<div class="linkbox">
2013-06-12 08:00:46 +00:00
<a href="<?=Inbox::get_inbox_link(); ?>" class="brackets">Back to inbox</a>
2011-03-28 14:21:28 +00:00
</div>
<?
2013-05-06 08:00:32 +00:00
while (list($SentDate, $SenderID, $Body, $MessageID) = $DB->next_record()) { ?>
2011-03-28 14:21:28 +00:00
<div class="box vertical_space">
2013-06-13 08:01:05 +00:00
<div class="head" style="overflow: hidden;">
<div style="float: left;">
<strong><?=$Users[(int)$SenderID]['UserStr']?></strong> <?=time_diff($SentDate)?> - <a href="#quickpost" onclick="Quote('<?=$MessageID?>','<?=$Users[(int)$SenderID]['Username']?>');" class="brackets">Quote</a>
</div>
<div style="float: right;"><a href="#">&uarr;</a> <a href="#messageform">&darr;</a></div>
</div>
<div class="body" id="message<?=$MessageID?>">
2013-12-12 08:01:01 +00:00
<?=Text::full_format($Body)?>
</div>
2011-03-28 14:21:28 +00:00
</div>
<?
}
2013-05-06 08:00:32 +00:00
$DB->query("
SELECT UserID
FROM pm_conversations_users
2013-09-20 08:00:56 +00:00
WHERE UserID != '$LoggedUser[ID]'
AND ConvID = '$ConvID'
AND (ForwardedTo = 0 OR ForwardedTo = UserID)");
2011-03-28 14:21:28 +00:00
$ReceiverIDs = $DB->collect('UserID');
2013-05-04 08:00:48 +00:00
if (!empty($ReceiverIDs) && (empty($LoggedUser['DisablePM']) || array_intersect($ReceiverIDs, array_keys($StaffIDs)))) {
2011-03-28 14:21:28 +00:00
?>
<h3>Reply</h3>
2012-09-15 08:00:25 +00:00
<form class="send_form" name="reply" action="inbox.php" method="post" id="messageform">
2011-03-28 14:21:28 +00:00
<div class="box pad">
<input type="hidden" name="action" value="takecompose" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
2013-06-04 08:00:34 +00:00
<input type="hidden" name="toid" value="<?=implode(',', $ReceiverIDs)?>" />
2011-03-28 14:21:28 +00:00
<input type="hidden" name="convid" value="<?=$ConvID?>" />
2013-09-20 08:00:56 +00:00
<textarea id="quickpost" class="required" name="body" cols="90" rows="10" onkeyup="resize('quickpost');"></textarea> <br />
2011-03-28 14:21:28 +00:00
<div id="preview" class="box vertical_space body hidden"></div>
<div id="buttons" class="center">
2013-02-22 08:00:24 +00:00
<input type="button" value="Preview" onclick="Quick_Preview();" />
2011-03-28 14:21:28 +00:00
<input type="submit" value="Send message" />
</div>
</div>
</form>
<?
}
?>
<h3>Manage conversation</h3>
2012-09-15 08:00:25 +00:00
<form class="manage_form" name="messages" action="inbox.php" method="post">
2011-03-28 14:21:28 +00:00
<div class="box pad">
<input type="hidden" name="action" value="takeedit" />
<input type="hidden" name="convid" value="<?=$ConvID?>" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
2012-09-01 08:00:24 +00:00
<table class="layout" width="100%">
2011-03-28 14:21:28 +00:00
<tr>
<td class="label"><label for="sticky">Sticky</label></td>
<td>
2013-05-04 08:00:48 +00:00
<input type="checkbox" id="sticky" name="sticky"<? if ($Sticky) { echo ' checked="checked"'; } ?> />
2011-03-28 14:21:28 +00:00
</td>
<td class="label"><label for="mark_unread">Mark as unread</label></td>
<td>
<input type="checkbox" id="mark_unread" name="mark_unread" />
</td>
<td class="label"><label for="delete">Delete conversation</label></td>
<td>
<input type="checkbox" id="delete" name="delete" />
</td>
</tr>
<tr>
<td class="center" colspan="6"><input type="submit" value="Manage conversation" /></td>
</tr>
</table>
</div>
</form>
<?
2013-05-27 08:00:58 +00:00
$DB->query("
SELECT SupportFor
FROM users_info
WHERE UserID = ".$LoggedUser['ID']);
2011-03-28 14:21:28 +00:00
list($FLS) = $DB->next_record();
2013-05-04 08:00:48 +00:00
if ((check_perms('users_mod') || $FLS != '') && (!$ForwardedID || $ForwardedID == $LoggedUser['ID'])) {
2011-03-28 14:21:28 +00:00
?>
<h3>Forward conversation</h3>
2012-09-15 08:00:25 +00:00
<form class="send_form" name="forward" action="inbox.php" method="post">
2011-03-28 14:21:28 +00:00
<div class="box pad">
<input type="hidden" name="action" value="forward" />
<input type="hidden" name="convid" value="<?=$ConvID?>" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<label for="receiverid">Forward to</label>
<select id="receiverid" name="receiverid">
<?
2013-05-04 08:00:48 +00:00
foreach ($StaffIDs as $StaffID => $StaffName) {
if ($StaffID == $LoggedUser['ID'] || in_array($StaffID, $ReceiverIDs)) {
2011-03-28 14:21:28 +00:00
continue;
}
?>
<option value="<?=$StaffID?>"><?=$StaffName?></option>
<?
}
?>
</select>
<input type="submit" value="Forward" />
</div>
</form>
<?
}
//And we're done!
?>
</div>
<?
2012-10-11 08:00:15 +00:00
View::show_footer();
2011-03-28 14:21:28 +00:00
?>