2011-12-04 08:00:16 +00:00
|
|
|
<?
|
|
|
|
if (!($IsFLS)) {
|
|
|
|
// Logged in user is not FLS or Staff
|
|
|
|
error(403);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($ConvID = (int)$_GET['convid']) {
|
|
|
|
// FLS, check level of conversation
|
2013-07-02 08:01:37 +00:00
|
|
|
$DB->query("
|
|
|
|
SELECT Level
|
|
|
|
FROM staff_pm_conversations
|
|
|
|
WHERE ID = $ConvID");
|
2011-12-04 08:00:16 +00:00
|
|
|
list($Level) = $DB->next_record;
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2011-12-04 08:00:16 +00:00
|
|
|
if ($Level == 0) {
|
|
|
|
// FLS conversation, assign to staff (moderator)
|
2013-04-17 08:00:58 +00:00
|
|
|
if (!empty($_GET['to'])) {
|
2011-12-04 08:00:16 +00:00
|
|
|
$Level = 0;
|
2013-04-17 08:00:58 +00:00
|
|
|
switch ($_GET['to']) {
|
2013-10-01 23:08:42 +00:00
|
|
|
case 'forum':
|
2011-12-04 08:00:16 +00:00
|
|
|
$Level = 650;
|
|
|
|
break;
|
2013-10-01 23:08:42 +00:00
|
|
|
case 'staff':
|
2011-12-04 08:00:16 +00:00
|
|
|
$Level = 700;
|
|
|
|
break;
|
2013-10-01 23:08:42 +00:00
|
|
|
default:
|
2011-12-04 08:00:16 +00:00
|
|
|
error(404);
|
|
|
|
break;
|
|
|
|
}
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2013-05-08 08:00:26 +00:00
|
|
|
$DB->query("
|
|
|
|
UPDATE staff_pm_conversations
|
2013-07-02 08:01:37 +00:00
|
|
|
SET Status = 'Unanswered',
|
|
|
|
Level = $Level
|
|
|
|
WHERE ID = $ConvID");
|
2011-12-04 08:00:16 +00:00
|
|
|
header('Location: staffpm.php');
|
|
|
|
} else {
|
|
|
|
error(404);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// FLS trying to assign non-FLS conversation
|
|
|
|
error(403);
|
|
|
|
}
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2011-12-04 08:00:16 +00:00
|
|
|
} elseif ($ConvID = (int)$_POST['convid']) {
|
2013-07-02 08:01:37 +00:00
|
|
|
// Staff (via AJAX), get current assign of conversation
|
|
|
|
$DB->query("
|
|
|
|
SELECT Level, AssignedToUser
|
|
|
|
FROM staff_pm_conversations
|
|
|
|
WHERE ID = $ConvID");
|
2011-12-04 08:00:16 +00:00
|
|
|
list($Level, $AssignedToUser) = $DB->next_record;
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2012-03-28 08:00:20 +00:00
|
|
|
if ($LoggedUser['EffectiveClass'] >= $Level || $AssignedToUser == $LoggedUser['ID']) {
|
2011-12-04 08:00:16 +00:00
|
|
|
// Staff member is allowed to assign conversation, assign
|
2013-07-02 08:01:37 +00:00
|
|
|
list($LevelType, $NewLevel) = explode('_', db_string($_POST['assign']));
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2011-12-04 08:00:16 +00:00
|
|
|
if ($LevelType == 'class') {
|
|
|
|
// Assign to class
|
2013-05-08 08:00:26 +00:00
|
|
|
$DB->query("
|
|
|
|
UPDATE staff_pm_conversations
|
2013-07-02 08:01:37 +00:00
|
|
|
SET Status = 'Unanswered',
|
|
|
|
Level = $NewLevel,
|
|
|
|
AssignedToUser = NULL
|
|
|
|
WHERE ID = $ConvID");
|
2011-12-04 08:00:16 +00:00
|
|
|
} else {
|
2012-10-11 08:00:15 +00:00
|
|
|
$UserInfo = Users::user_info($NewLevel);
|
2013-04-17 08:00:58 +00:00
|
|
|
$Level = $Classes[$UserInfo['PermissionID']]['Level'];
|
2012-02-04 08:00:25 +00:00
|
|
|
if (!$Level) {
|
2013-04-17 08:00:58 +00:00
|
|
|
error('Assign to user not found.');
|
2012-02-04 08:00:25 +00:00
|
|
|
}
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2011-12-04 08:00:16 +00:00
|
|
|
// Assign to user
|
2013-05-08 08:00:26 +00:00
|
|
|
$DB->query("
|
|
|
|
UPDATE staff_pm_conversations
|
2013-07-02 08:01:37 +00:00
|
|
|
SET Status = 'Unanswered',
|
|
|
|
AssignedToUser = $NewLevel,
|
|
|
|
Level = $Level
|
|
|
|
WHERE ID = $ConvID");
|
2013-05-16 16:15:57 +00:00
|
|
|
|
2011-12-04 08:00:16 +00:00
|
|
|
}
|
|
|
|
echo '1';
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2011-12-04 08:00:16 +00:00
|
|
|
} else {
|
|
|
|
// Staff member is not allowed to assign conversation
|
|
|
|
echo '-1';
|
|
|
|
}
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2011-12-04 08:00:16 +00:00
|
|
|
} else {
|
2013-04-17 08:00:58 +00:00
|
|
|
// No ID
|
2011-12-04 08:00:16 +00:00
|
|
|
header('Location: staffpm.php');
|
|
|
|
}
|
|
|
|
?>
|