Abstracting the compose box for staffpms

Allow FLS to assign to staff or forum staff

Allow FLS to unresolve all FLS PMs
This commit is contained in:
What.CD 2011-07-12 08:00:07 +00:00
parent 805a6b55d1
commit dd04b95709
6 changed files with 61 additions and 52 deletions

View File

@ -3,6 +3,7 @@
show_header('Staff');
include(SERVER_ROOT.'/sections/staff/functions.php');
include(SERVER_ROOT.'/sections/staffpm/functions.php');
$SupportStaff = get_support();
list($FrontLineSupport, $ForumStaff, $Staff) = $SupportStaff;
@ -13,32 +14,12 @@
<div class="box pad" style="padding:0px 10px 10px 10px;">
<br />
<h3>Contact Staff</h3>
<div id="staff_inbox" class="hidden">
<form action="staffpm.php" method="post">
<input type="hidden" name="action" value="takepost" />
<label for="subject"><h3>Subject</h3></label>
<input size="95" type="text" name="subject" id="subject" />
<br />
<label for="message"><h3>Message</h3></label>
<textarea rows="10" cols="95" name="message" id="message"></textarea>
<br />
<strong>Send to: </strong>
<select name="level">
<option value="0" selected="selected">First Line Support</option>
<option value="650">Forum Moderators</option>
<option value="700">Staff</option>
</select>
<input type="submit" value="Send message" />
<input type="button" value="Hide" onClick="$('#staff_inbox').toggle();$('#below_box').toggle();return false;" />
</form>
</div>
<div id="below_box">
<p>If you are looking for help with a general question, we appreciate it if you would only message through the staff inbox, where we can all help you.</p>
<p>You can do that by <strong><a href="#" onClick="$('#staff_inbox').toggle();$('#below_box').toggle();return false;">sending a message to the Staff Inbox</a></strong>.</p>
<p>You can do that by <strong><a href="#" onClick="$('#compose').toggle();">sending a message to the Staff Inbox</a></strong>.</p>
</div>
<? print_compose_staff_pm(true); ?>
<br />
<h3>First-line Support</h3>
<p><strong>These users are not official staff members</strong> - they're users who have volunteered their time to help people in need. Please treat them with respect and read <a href="wiki.php?action=article&amp;id=260">this</a> before contacting them. </p>
<table class="staff" width="100%">

View File

@ -11,10 +11,25 @@
if ($Level == 0) {
// FLS conversation, assign to staff (moderator)
$DB->query("UPDATE staff_pm_conversations SET Level=650 WHERE ID=$ConvID");
header('Location: staffpm.php');
if(!empty($_GET['to'])) {
$Level = 0;
switch($_GET['to']) {
case 'forum' :
$Level = 650;
break;
case 'staff' :
$Level = 700;
break;
default :
error(404);
break;
}
$DB->query("UPDATE staff_pm_conversations SET Level=".$Level." WHERE ID=$ConvID");
header('Location: staffpm.php');
} else {
error(404);
}
} else {
// FLS trying to assign non-FLS conversation
error(403);

View File

@ -0,0 +1,25 @@
<?
function print_compose_staff_pm($Hidden = true) { ?>
<div id="compose" class="<?=($Hidden ? 'hidden' : '')?>">
<form action="staffpm.php" method="post">
<input type="hidden" name="action" value="takepost" />
<label for="subject"><h3>Subject</h3></label>
<input size="95" type="text" name="subject" id="subject" />
<br />
<label for="message"><h3>Message</h3></label>
<textarea rows="10" cols="95" name="message" id="message"></textarea>
<br />
<strong>Send to: </strong>
<select name="level">
<option value="0" selected="selected">First Line Support</option>
<option value="650">Forum Moderators</option>
<option value="700">Staff</option>
</select>
<input type="submit" value="Send message" />
<input type="button" value="Hide" onClick="$('#compose').toggle();return false;" />
</form>
</div>
<? } ?>

View File

@ -1,10 +1,14 @@
<?
if ($ID = (int)($_GET['id'])) {
// Check if conversation belongs to user
$DB->query("SELECT UserID, AssignedToUser FROM staff_pm_conversations WHERE ID=$ID");
list($UserID, $AssignedToUser) = $DB->next_record();
$DB->query("SELECT UserID, Level, AssignedToUser FROM staff_pm_conversations WHERE ID=$ID");
list($UserID, $Level, $AssignedToUser) = $DB->next_record();
if ($UserID == $LoggedUser['ID'] || $IsStaff || $AssignedToUser == $LoggedUser['ID']) {
if ($UserID == $LoggedUser['ID'] || $IsFLS || $AssignedToUser == $LoggedUser['ID']) {
if($Level != 0 && $IsStaff == false) {
error(403);
}
// Conversation belongs to user or user is staff, unresolve it
$DB->query("UPDATE staff_pm_conversations SET Status='Unanswered' WHERE ID=$ID");
// Clear cache for user

View File

@ -1,4 +1,7 @@
<?
include(SERVER_ROOT.'/sections/staffpm/functions.php');
show_header('Staff PMs', 'staffpm');
// Get messages
@ -26,27 +29,7 @@
<br />
<br />
</div>
<div id="compose" class="hidden">
<form action="staffpm.php" method="post">
<input type="hidden" name="action" value="takepost" />
<label for="subject"><h3>Subject</h3></label>
<input size="95" type="text" name="subject" id="subject" />
<br />
<label for="message"><h3>Message</h3></label>
<textarea rows="10" cols="95" name="message" id="message"></textarea>
<br />
<strong>Send to: </strong>
<select name="level">
<option value="0" selected="selected">First Line Support</option>
<option value="650">Staff</option>
</select>
<input type="submit" value="Send message" />
</form>
<br />
</div>
<? print_compose_staff_pm(true); ?>
<div class="box pad" id="inbox">
<?

View File

@ -206,7 +206,8 @@
<?
} elseif ($IsFLS) { // FLS assign button
?>
<input type="button" value="Assign to staff" onClick="location.href='staffpm.php?action=assign&convid=<?=$ConvID?>';" />
<input type="button" value="Assign to forum staff" onClick="location.href='staffpm.php?action=assign&to=forum&convid=<?=$ConvID?>';" />
<input type="button" value="Assign to staff" onClick="location.href='staffpm.php?action=assign&to=staff&convid=<?=$ConvID?>';" />
<?
}