Gazelle/sections/inbox/conversation.php

181 lines
5.4 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
include(SERVER_ROOT.'/classes/class_text.php');
$Text = new TEXT;
$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'];
$DB->query("SELECT InInbox, InSentbox FROM pm_conversations_users WHERE UserID='$UserID' AND ConvID='$ConvID'");
2013-05-04 08:00:48 +00:00
if ($DB->record_count() == 0) {
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-05-04 08:00:48 +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-05-04 08:00:48 +00:00
JOIN users_main AS um ON um.ID=pm.SenderID
2011-03-28 14:21:28 +00:00
WHERE pm.ConvID='$ConvID'");
2013-05-04 08:00:48 +00:00
while (list($PMUserID, $Username) = $DB->next_record()) {
2011-03-28 14:21:28 +00:00
$PMUserID = (int)$PMUserID;
2012-10-11 08:00:15 +00:00
$Users[$PMUserID]['UserStr'] = Users::format_username($PMUserID, true, true, true, true);
2011-03-28 14:21:28 +00:00
$Users[$PMUserID]['Username'] = $Username;
}
$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
$DB->query("UPDATE pm_conversations_users SET UnRead='0' WHERE ConvID='$ConvID' AND UserID='$UserID'");
// Clear the caches of the inbox and sentbox
$Cache->decrement('inbox_new_'.$UserID);
}
2013-05-21 08:01:09 +00:00
View::show_header('View conversation '.$Subject, 'comments,inbox,bbcode,jquery,jquery.validate,form_validate');
2011-03-28 14:21:28 +00:00
// Get messages
$DB->query("SELECT SentDate, SenderID, Body, ID FROM pm_messages AS m WHERE ConvID='$ConvID' ORDER BY ID");
?>
<div class="thin">
2013-05-04 08:00:48 +00:00
<h2><?=$Subject.($ForwardedID > 0 ? ' (Forwarded to '.$ForwardedName.')' : '')?></h2>
2011-03-28 14:21:28 +00:00
<div class="linkbox">
2013-02-09 08:01:01 +00:00
<a href="inbox.php" 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">
<div class="head">
2013-02-09 08:01:01 +00:00
<strong><?=$Users[(int)$SenderID]['UserStr']?></strong> <?=time_diff($SentDate)?> - <a href="#quickpost" onclick="Quote('<?=$MessageID?>','<?=$Users[(int)$SenderID]['Username']?>');" class="brackets">Quote</a>
2011-03-28 14:21:28 +00:00
</div>
<div class="body" id="message<?=$MessageID?>">
<?=$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
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']?>" />
<input type="hidden" name="toid" value="<?=implode(',',$ReceiverIDs)?>" />
<input type="hidden" name="convid" value="<?=$ConvID?>" />
2013-05-21 08:01:09 +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>
<?
$DB->query("SELECT SupportFor FROM users_info WHERE UserID = ".$LoggedUser['ID']);
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
?>