Gazelle/sections/inbox/forward.php

52 lines
1.3 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
authorize();
$UserID = $LoggedUser['ID'];
$ConvID = $_POST['convid'];
$ReceiverID = $_POST['receiverid'];
2013-05-04 08:00:48 +00:00
if (!is_number($ConvID) || !is_number($ReceiverID)) {
error(404);
}
if (!check_perms('users_mod') && !isset($StaffIDs[$ReceiverID])) {
error(403);
}
$DB->query("
SELECT ConvID
FROM pm_conversations_users
2013-09-06 08:00:41 +00:00
WHERE UserID = '$UserID'
AND InInbox = '1'
AND (ForwardedTo = 0 OR ForwardedTo = UserID)
AND ConvID = '$ConvID'");
2013-07-10 00:08:53 +00:00
if (!$DB->has_results()) {
2013-05-04 08:00:48 +00:00
error(403);
}
2011-03-28 14:21:28 +00:00
2013-05-04 08:00:48 +00:00
$DB->query("
SELECT ConvID
FROM pm_conversations_users
2013-09-06 08:00:41 +00:00
WHERE UserID = '$ReceiverID'
2013-05-04 08:00:48 +00:00
AND (ForwardedTo = 0 OR ForwardedTo = UserID)
2013-09-06 08:00:41 +00:00
AND InInbox = '1'
AND ConvID = '$ConvID'");
2013-07-10 00:08:53 +00:00
if (!$DB->has_results()) {
2013-05-04 08:00:48 +00:00
$DB->query("
INSERT IGNORE INTO pm_conversations_users
(UserID, ConvID, InInbox, InSentbox, ReceivedDate)
2011-03-28 14:21:28 +00:00
VALUES ('$ReceiverID', '$ConvID', '1', '0', NOW())
2013-09-06 08:00:41 +00:00
ON DUPLICATE KEY UPDATE
ForwardedTo = 0,
UnRead = 1");
2013-06-05 08:01:01 +00:00
$DB->query("
UPDATE pm_conversations_users
2013-09-06 08:00:41 +00:00
SET ForwardedTo = '$ReceiverID'
WHERE ConvID = '$ConvID'
AND UserID = '$UserID'");
$Cache->delete_value("inbox_new_$ReceiverID");
2013-06-12 08:00:46 +00:00
header('Location: ' . Inbox::get_inbox_link());
2011-03-28 14:21:28 +00:00
} else {
error("$StaffIDs[$ReceiverID] already has this conversation in their inbox.");
2013-09-06 08:00:41 +00:00
header("Location: inbox.php?action=viewconv&id=$ConvID");
2011-03-28 14:21:28 +00:00
}
2012-10-11 08:00:15 +00:00
//View::show_footer();
2011-03-28 14:21:28 +00:00
?>