Gazelle/sections/inbox/conversation.php

171 lines
5.3 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'];
if(!$ConvID || !is_number($ConvID)) { error(404); }
$UserID = $LoggedUser['ID'];
$DB->query("SELECT InInbox, InSentbox FROM pm_conversations_users WHERE UserID='$UserID' AND ConvID='$ConvID'");
if($DB->record_count() == 0) {
error(403);
}
list($InInbox, $InSentbox) = $DB->next_record();
if (!$InInbox && !$InSentbox) {
error(404);
}
// Get information on the conversation
$DB->query("SELECT
c.Subject,
cu.Sticky,
cu.UnRead,
2012-03-28 08:00:20 +00:00
cu.ForwardedTo
2011-03-28 14:21:28 +00:00
FROM pm_conversations AS c
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
2012-03-28 08:00:20 +00:00
$DB->query("SELECT um.ID, Username
2011-03-28 14:21:28 +00:00
FROM pm_messages AS pm
JOIN users_main AS um ON um.ID=pm.SenderID
WHERE pm.ConvID='$ConvID'");
2012-03-28 08:00:20 +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';
if($UnRead=='1') {
$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);
}
2012-10-11 08:00:15 +00:00
View::show_header('View conversation '.$Subject, 'comments,inbox,bbcode');
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">
<h2><?=$Subject.($ForwardedID > 0 ? ' (Forwarded to '.$ForwardedName.')':'')?></h2>
<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>
<?
while(list($SentDate, $SenderID, $Body, $MessageID) = $DB->next_record()) { ?>
<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>
<?
}
$DB->query("SELECT UserID FROM pm_conversations_users WHERE UserID!='$LoggedUser[ID]' AND ConvID='$ConvID' AND (ForwardedTo=0 OR ForwardedTo=UserID)");
$ReceiverIDs = $DB->collect('UserID');
if(!empty($ReceiverIDs) && (empty($LoggedUser['DisablePM']) || array_intersect($ReceiverIDs, array_keys($StaffIDs)))) {
?>
<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-04-22 08:00:58 +00:00
<textarea id="quickpost" 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>
<input type="checkbox" id="sticky" name="sticky"<? if($Sticky) { echo ' checked="checked"'; } ?> />
</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();
if((check_perms('users_mod') || $FLS != "") && (!$ForwardedID || $ForwardedID == $LoggedUser['ID'])) {
?>
<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">
<?
foreach($StaffIDs as $StaffID => $StaffName) {
if($StaffID == $LoggedUser['ID'] || in_array($StaffID, $ReceiverIDs)) {
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
?>