gruffen commited on 2011-06-14 02:39:45
Showing 6 changed files, with 14 additions and 13 deletions.
... | ... |
@@ -735,7 +735,7 @@ function shd_maint_status() |
735 | 735 |
$tickets = array(); |
736 | 736 |
$tickets_modify = array(); |
737 | 737 |
$query = $smcFunc['db_query']('', ' |
738 |
- SELECT id_ticket, num_replies, id_member_started, id_member_updated, status |
|
738 |
+ SELECT id_ticket, num_replies, id_member_started, id_member_updated, status, id_dept |
|
739 | 739 |
FROM {db_prefix}helpdesk_tickets |
740 | 740 |
WHERE status IN ({array_int:open}) |
741 | 741 |
ORDER BY id_ticket ASC |
... | ... |
@@ -754,7 +754,7 @@ function shd_maint_status() |
754 | 754 |
{ |
755 | 755 |
foreach ($tickets as $ticket) |
756 | 756 |
{ |
757 |
- $new_status = shd_determine_status('reply', $ticket['id_member_started'], $ticket['id_member_updated'], $ticket['num_replies']); |
|
757 |
+ $new_status = shd_determine_status('reply', $ticket['id_member_started'], $ticket['id_member_updated'], $ticket['num_replies'], $ticket['dept']); |
|
758 | 758 |
if ($ticket['status'] != $new_status) |
759 | 759 |
$tickets_modify[$ticket['id_ticket']] = $new_status; |
760 | 760 |
} |
... | ... |
@@ -182,7 +182,7 @@ function shd_reply_delete() |
182 | 182 |
WHERE id_ticket = {int:ticket}', |
183 | 183 |
array( |
184 | 184 |
'ticket' => $context['ticket_id'], |
185 |
- 'status' => shd_determine_status('deletereply', $starter, $replier, $num_replies), |
|
185 |
+ 'status' => shd_determine_status('deletereply', $starter, $replier, $num_replies, $row['id_dept']), |
|
186 | 186 |
) |
187 | 187 |
); |
188 | 188 |
|
... | ... |
@@ -434,7 +434,7 @@ function shd_perma_delete() |
434 | 434 |
WHERE id_ticket = {int:ticket}', |
435 | 435 |
array( |
436 | 436 |
'ticket' => $context['ticket_id'], |
437 |
- 'status' => shd_determine_status('deletereply', $starter, $replier, $num_replies), |
|
437 |
+ 'status' => shd_determine_status('deletereply', $starter, $replier, $num_replies, $row['id_dept']), |
|
438 | 438 |
) |
439 | 439 |
); |
440 | 440 |
|
... | ... |
@@ -550,7 +550,7 @@ function shd_ticket_restore() |
550 | 550 |
AND {query_see_ticket}', |
551 | 551 |
array( |
552 | 552 |
'current_ticket' => $context['ticket_id'], |
553 |
- 'status_new' => shd_determine_status('restoreticket', $starter, $replier, $num_replies), |
|
553 |
+ 'status_new' => shd_determine_status('restoreticket', $starter, $replier, $num_replies, $row['id_dept']), |
|
554 | 554 |
) |
555 | 555 |
); |
556 | 556 |
|
... | ... |
@@ -646,7 +646,7 @@ function shd_reply_restore() |
646 | 646 |
WHERE id_ticket = {int:ticket}', |
647 | 647 |
array( |
648 | 648 |
'ticket' => $context['ticket_id'], |
649 |
- 'status' => shd_determine_status('restorereply', $starter, $replier, $num_replies), |
|
649 |
+ 'status' => shd_determine_status('restorereply', $starter, $replier, $num_replies, $row['id_dept']), |
|
650 | 650 |
) |
651 | 651 |
); |
652 | 652 |
|
... | ... |
@@ -129,7 +129,7 @@ function shd_ticket_resolve() |
129 | 129 |
fatal_lang_error('error_shd_cannot_resolve_children', false); |
130 | 130 |
} |
131 | 131 |
|
132 |
- $new = shd_determine_status($action, $row['id_member_started'], $row['id_member_updated'], $row['num_replies']); |
|
132 |
+ $new = shd_determine_status($action, $row['id_member_started'], $row['id_member_updated'], $row['num_replies'], $row['id_dept']); |
|
133 | 133 |
|
134 | 134 |
shd_db_query('', ' |
135 | 135 |
UPDATE {db_prefix}helpdesk_tickets |
... | ... |
@@ -1168,7 +1168,7 @@ function shd_save_reply() |
1168 | 1168 |
if ($new_reply) |
1169 | 1169 |
{ |
1170 | 1170 |
// So... what is the new status? |
1171 |
- $new_status = shd_determine_status('reply', $ticketinfo['starter_id'], $user_info['id']); |
|
1171 |
+ $new_status = shd_determine_status('reply', $ticketinfo['starter_id'], $user_info['id'], $context['ticket_form']['dept']); |
|
1172 | 1172 |
|
1173 | 1173 |
// Now to add the ticket details |
1174 | 1174 |
$posterOptions = array( |
... | ... |
@@ -1048,7 +1048,7 @@ function shd_topictoticket2() |
1048 | 1048 |
$smcFunc['db_free_result']($request); |
1049 | 1049 |
|
1050 | 1050 |
// Figure out what the status of the ticket should be. |
1051 |
- $status = shd_determine_status('topictoticket', $owner, $memberupdated, $numreplies); |
|
1051 |
+ $status = shd_determine_status('topictoticket', $owner, $memberupdated, $numreplies, $_REQUEST['dept']); |
|
1052 | 1052 |
|
1053 | 1053 |
// Are we changing the subject? |
1054 | 1054 |
$old_subject = $subject; |
... | ... |
@@ -986,12 +986,13 @@ function shd_image_url($filename) |
986 | 986 |
* @return int Returns an integer value that corresponds to the ticket's status, relating to one of the TICKET_STATUS states. |
987 | 987 |
* @since 1.0 |
988 | 988 |
*/ |
989 |
-function shd_determine_status($action, $starter_id = 0, $replier_id = 0, $replies = -1) |
|
989 |
+function shd_determine_status($action, $starter_id = 0, $replier_id = 0, $replies = -1, $dept = -1) |
|
990 | 990 |
{ |
991 |
+ global $context; |
|
991 | 992 |
static $staff = null; |
992 | 993 |
|
993 |
- if ($staff === null) |
|
994 |
- $staff = shd_members_allowed_to('shd_staff'); |
|
994 |
+ if (!isset($staff[$dept])) |
|
995 |
+ $staff[$dept] = shd_members_allowed_to('shd_staff', $dept); |
|
995 | 996 |
|
996 | 997 |
$known_states = array( |
997 | 998 |
'new', |
... | ... |
@@ -1026,7 +1027,7 @@ function shd_determine_status($action, $starter_id = 0, $replier_id = 0, $replie |
1026 | 1027 |
return TICKET_STATUS_NEW; |
1027 | 1028 |
else |
1028 | 1029 |
{ |
1029 |
- if (in_array($replier_id, $staff)) |
|
1030 |
+ if (in_array($replier_id, $staff[$dept])) |
|
1030 | 1031 |
$new_status = $starter_id == $replier_id ? TICKET_STATUS_PENDING_STAFF : TICKET_STATUS_PENDING_USER; // i.e. if they're staff but it's their own ticket they're replying to, it's not with user. |
1031 | 1032 |
else |
1032 | 1033 |
$new_status = TICKET_STATUS_PENDING_STAFF; |
1033 | 1034 |