gruffen commited on 2011-06-01 03:50:00
Showing 9 changed files, with 132 additions and 10 deletions.
... | ... |
@@ -430,6 +430,7 @@ $txt['shd_ticket_monitor_on_note'] = 'You can request an email for every reply, |
430 | 430 |
$txt['shd_ticket_monitor_off_note'] = 'You can turn off the email for every reply, and use your preferences instead:'; |
431 | 431 |
$txt['shd_ticket_monitor_on'] = 'Turn on monitoring'; |
432 | 432 |
$txt['shd_ticket_monitor_off'] = 'Turn off monitoring'; |
433 |
+$txt['shd_ticket_notify_me_never_note'] = 'You can request that all normal emails are turned off:'; |
|
433 | 434 |
$txt['shd_ticket_notify_me_never'] = 'You have asked for notifications on this ticket to be turned off.'; |
434 | 435 |
$txt['shd_ticket_notify_me_never_on'] = 'Ignore this ticket'; |
435 | 436 |
$txt['shd_ticket_notify_me_never_off'] = 'Unignore this ticket'; |
... | ... |
@@ -213,7 +213,7 @@ $txt['shd_logopt_permadelete'] = 'Log tickets and replies being permadeleted'; |
213 | 213 |
$txt['shd_logopt_relationships'] = 'Log any changes in ticket relationships'; |
214 | 214 |
$txt['shd_logopt_autoclose'] = 'Log tickets closed automatically by the helpdesk'; |
215 | 215 |
$txt['shd_logopt_move_dept'] = 'Log tickets being moved between two departments'; |
216 |
-$txt['shd_logopt_monitor'] = 'Log tickets being added to their monitor lists'; |
|
216 |
+$txt['shd_logopt_monitor'] = 'Log tickets being added to their monitor/ignore lists'; |
|
217 | 217 |
|
218 | 218 |
$txt['shd_notify_send_to'] = 'Will be sent to'; |
219 | 219 |
$txt['shd_notify_ticket_starter'] = 'the user who started the ticket (if set in their preferences)'; |
... | ... |
@@ -136,5 +136,7 @@ $txt['shd_log_unknown_user_1'] = '1 former user'; |
136 | 136 |
$txt['shd_log_unknown_user_n'] = '%1$d former users'; |
137 | 137 |
$txt['shd_log_monitor'] = 'Added "<a href="{scripturl}?action=helpdesk;sa=ticket;ticket={ticket}">{subject}</a>" to their monitor list.'; |
138 | 138 |
$txt['shd_log_unmonitor'] = 'Removed "<a href="{scripturl}?action=helpdesk;sa=ticket;ticket={ticket}">{subject}</a>" from their monitor list.'; |
139 |
+$txt['shd_log_ignore'] = 'Added "<a href="{scripturl}?action=helpdesk;sa=ticket;ticket={ticket}">{subject}</a>" to their do-not-notify (ignore) list.'; |
|
140 |
+$txt['shd_log_unignore'] = 'Removed "<a href="{scripturl}?action=helpdesk;sa=ticket;ticket={ticket}">{subject}</a>" from their do-not-notify (ignore) list.'; |
|
139 | 141 |
//@} |
140 | 142 |
?> |
141 | 143 |
\ No newline at end of file |
... | ... |
@@ -95,11 +95,15 @@ $txt['permissionname_shd_assign_ticket_own'] = 'To themselves'; |
95 | 95 |
$txt['permissionname_shd_assign_ticket_any'] = 'Any staff member'; |
96 | 96 |
//@} |
97 | 97 |
|
98 |
-//! @name Ticket modification: monitoring |
|
98 |
+//! @name Ticket modification: monitoring/ignoring |
|
99 | 99 |
$txt['permissionname_shd_monitor_ticket'] = 'Monitor a ticket'; |
100 |
-$txt['permissionhelp_shd_monitor_ticket'] = 'This permission allows users to monitor tickets, to be notified on any changes to the ticket in addition to any of the usual email notifications. Use for example, to be notified about a ticket without replying to it or turning on the preferences for all tickets.'; |
|
100 |
+$txt['permissionhelp_shd_monitor_ticket'] = 'This permission allows users to monitor tickets, to be notified on any replies to the ticket in addition to any of the usual email notifications. Use for example, to be notified about a ticket without replying to it or turning on the preferences for all tickets.'; |
|
101 | 101 |
$txt['permissionname_shd_monitor_ticket_own'] = 'Their own tickets'; |
102 | 102 |
$txt['permissionname_shd_monitor_ticket_any'] = 'Any tickets'; |
103 |
+$txt['permissionname_shd_ignore_ticket'] = 'Monitor a ticket'; |
|
104 |
+$txt['permissionhelp_shd_ignore_ticket'] = 'This permission allows users to expressly turn off notifications on a ticket. This would allow them to have preferences saying to notify on all replies, but to be able to selectively ignore an individual ticket\'s replies.'; |
|
105 |
+$txt['permissionname_shd_ignore_ticket_own'] = 'Their own tickets'; |
|
106 |
+$txt['permissionname_shd_ignore_ticket_any'] = 'Any tickets'; |
|
103 | 107 |
|
104 | 108 |
//! @name Ticket modification: resolution |
105 | 109 |
//@{ |
... | ... |
@@ -779,9 +779,9 @@ function shd_view_ticket() |
779 | 779 |
'show' => false, |
780 | 780 |
'preferences' => array(), |
781 | 781 |
'can_change' => shd_allowed_to('shd_view_profile', 0) && shd_allowed_to('shd_view_preferences', 0), // not department related |
782 |
- 'can_monitor' => shd_allowed_to('shd_monitor_ticket', $context['ticket']['dept']), |
|
782 |
+ 'can_monitor' => shd_allowed_to('shd_monitor_ticket_any', $context['ticket']['dept']) || ($context['ticket']['ticket_opener'] && shd_allowed_to('shd_monitor_ticket_own', $context['ticket']['dept'])), |
|
783 | 783 |
'is_monitoring' => false, |
784 |
- 'can_ignore' => false, |
|
784 |
+ 'can_ignore' => shd_allowed_to('shd_ignore_ticket_any', $context['ticket']['dept']) || ($context['ticket']['ticket_opener'] && shd_allowed_to('shd_ignore_ticket_own', $context['ticket']['dept'])), |
|
785 | 785 |
'is_ignoring' => false, |
786 | 786 |
); |
787 | 787 |
$notify_state = NOTIFY_PREFS; |
... | ... |
@@ -563,19 +563,48 @@ function shd_notify_ticket_options() |
563 | 563 |
if (empty($_REQUEST['notifyaction'])) |
564 | 564 |
$_REQUEST['notifyaction'] = ''; |
565 | 565 |
|
566 |
+ // Get any existing entry. |
|
567 |
+ $query = $smcFunc['db_query']('', ' |
|
568 |
+ SELECT notify_state |
|
569 |
+ FROM {db_prefix}helpdesk_notify_override |
|
570 |
+ WHERE id_member = {int:user} |
|
571 |
+ AND id_ticket = {int:ticket}', |
|
572 |
+ array( |
|
573 |
+ 'user' => $context['user']['id'], |
|
574 |
+ 'ticket' => $context['ticket_id'], |
|
575 |
+ ) |
|
576 |
+ ); |
|
577 |
+ if ($smcFunc['db_num_rows']($query) == 0) |
|
578 |
+ $old_state = NOTIFY_PREFS; |
|
579 |
+ else |
|
580 |
+ list($old_state) = $smcFunc['db_fetch_row']($query); |
|
581 |
+ $smcFunc['db_free_result']($query); |
|
582 |
+ |
|
566 | 583 |
switch ($_REQUEST['notifyaction']) |
567 | 584 |
{ |
568 | 585 |
case 'monitor_on'; |
569 | 586 |
if (!shd_allowed_to('shd_monitor_ticket', $ticketinfo['dept'])) |
570 | 587 |
fatal_lang_error('cannot_monitor_ticket', false); |
571 | 588 |
|
589 |
+ // Unlike turning it off, we might be turning it on from either just off, or ignored, so log that fact. |
|
590 |
+ if ($old_state == NOTIFY_ALWAYS) |
|
591 |
+ break; |
|
592 |
+ elseif ($old_state == NOTIFY_NEVER) |
|
593 |
+ // Log turning off ignore list first |
|
594 |
+ shd_log_action('unignore', |
|
595 |
+ array( |
|
596 |
+ 'ticket' => $context['ticket_id'], |
|
597 |
+ 'subject' => $ticketinfo['subject'], |
|
598 |
+ ) |
|
599 |
+ ); |
|
600 |
+ // Then add the new status. |
|
572 | 601 |
$smcFunc['db_insert']('replace', |
573 | 602 |
'{db_prefix}helpdesk_notify_override', |
574 | 603 |
array( |
575 | 604 |
'id_member' => 'int', 'id_ticket' => 'int', 'notify_state' => 'int', |
576 | 605 |
), |
577 | 606 |
array( |
578 |
- $context['user']['id'], $context['ticket_id'], $_REQUEST['notifyaction'] == 'monitor_on' ? NOTIFY_ALWAYS : NOTIFY_PREFS, |
|
607 |
+ $context['user']['id'], $context['ticket_id'], NOTIFY_ALWAYS, |
|
579 | 608 |
), |
580 | 609 |
array('id_member', 'id_ticket') |
581 | 610 |
); |
... | ... |
@@ -585,12 +614,11 @@ function shd_notify_ticket_options() |
585 | 614 |
'subject' => $ticketinfo['subject'], |
586 | 615 |
) |
587 | 616 |
); |
588 |
- redirectexit('action=helpdesk;sa=ticket;ticket=' . $context['ticket_id']); |
|
589 | 617 |
break; |
590 | 618 |
case 'monitor_off'; |
591 | 619 |
if (!shd_allowed_to('shd_monitor_ticket', $ticketinfo['dept'])) |
592 | 620 |
fatal_lang_error('cannot_unmonitor_ticket', false); |
593 |
- |
|
621 |
+ // Just delete the old status. |
|
594 | 622 |
$smcFunc['db_query']('', ' |
595 | 623 |
DELETE FROM {db_prefix}helpdesk_notify_override |
596 | 624 |
WHERE id_member = {int:member} |
... | ... |
@@ -606,15 +634,65 @@ function shd_notify_ticket_options() |
606 | 634 |
'subject' => $ticketinfo['subject'], |
607 | 635 |
) |
608 | 636 |
); |
609 |
- redirectexit('action=helpdesk;sa=ticket;ticket=' . $context['ticket_id']); |
|
610 | 637 |
break; |
611 | 638 |
case 'ignore_on'; |
639 |
+ if (!shd_allowed_to('shd_monitor_ticket', $ticketinfo['dept'])) |
|
640 |
+ fatal_lang_error('cannot_monitor_ticket', false); |
|
641 |
+ |
|
642 |
+ // Unlike turning it off, we might be turning it on from either just off, or ignored, so log that fact. |
|
643 |
+ if ($old_state == NOTIFY_NEVER) |
|
644 |
+ break; |
|
645 |
+ elseif ($old_state == NOTIFY_ALWAYS) |
|
646 |
+ // Log turning off ignore list first |
|
647 |
+ shd_log_action('unmonitor', |
|
648 |
+ array( |
|
649 |
+ 'ticket' => $context['ticket_id'], |
|
650 |
+ 'subject' => $ticketinfo['subject'], |
|
651 |
+ ) |
|
652 |
+ ); |
|
653 |
+ |
|
654 |
+ $smcFunc['db_insert']('replace', |
|
655 |
+ '{db_prefix}helpdesk_notify_override', |
|
656 |
+ array( |
|
657 |
+ 'id_member' => 'int', 'id_ticket' => 'int', 'notify_state' => 'int', |
|
658 |
+ ), |
|
659 |
+ array( |
|
660 |
+ $context['user']['id'], $context['ticket_id'], NOTIFY_NEVER, |
|
661 |
+ ), |
|
662 |
+ array('id_member', 'id_ticket') |
|
663 |
+ ); |
|
664 |
+ shd_log_action('ignore', |
|
665 |
+ array( |
|
666 |
+ 'ticket' => $context['ticket_id'], |
|
667 |
+ 'subject' => $ticketinfo['subject'], |
|
668 |
+ ) |
|
669 |
+ ); |
|
612 | 670 |
break; |
613 | 671 |
case 'ignore_off'; |
672 |
+ if (!shd_allowed_to('shd_monitor_ticket', $ticketinfo['dept'])) |
|
673 |
+ fatal_lang_error('cannot_unmonitor_ticket', false); |
|
674 |
+ |
|
675 |
+ $smcFunc['db_query']('', ' |
|
676 |
+ DELETE FROM {db_prefix}helpdesk_notify_override |
|
677 |
+ WHERE id_member = {int:member} |
|
678 |
+ AND id_ticket = {int:ticket}', |
|
679 |
+ array( |
|
680 |
+ 'member' => $context['user']['id'], |
|
681 |
+ 'ticket' => $context['ticket_id'], |
|
682 |
+ ) |
|
683 |
+ ); |
|
684 |
+ shd_log_action('unignore', |
|
685 |
+ array( |
|
686 |
+ 'ticket' => $context['ticket_id'], |
|
687 |
+ 'subject' => $ticketinfo['subject'], |
|
688 |
+ ) |
|
689 |
+ ); |
|
614 | 690 |
break; |
615 | 691 |
default: |
616 | 692 |
break; |
617 | 693 |
} |
694 |
+ |
|
695 |
+ redirectexit('action=helpdesk;sa=ticket;ticket=' . $context['ticket_id']); |
|
618 | 696 |
} |
619 | 697 |
|
620 | 698 |
function shd_query_monitor_list($ticket_id) |
... | ... |
@@ -479,6 +479,8 @@ function shd_log_action($action, $params, $do_last_update = true) |
479 | 479 |
'move_dept' => 'shd_logopt_move_dept', |
480 | 480 |
'monitor' => 'shd_logopt_monitor', |
481 | 481 |
'unmonitor' => 'shd_logopt_monitor', |
482 |
+ 'ignore' => 'shd_logopt_monitor', |
|
483 |
+ 'unignore' => 'shd_logopt_monitor', |
|
482 | 484 |
); |
483 | 485 |
|
484 | 486 |
if (empty($logopt[$action]) || empty($modSettings[$logopt[$action]])) |
... | ... |
@@ -77,6 +77,7 @@ function shd_load_all_permission_sets() |
77 | 77 |
'shd_alter_privacy' => array(true, 'ticketactions', 'log_markprivate.png'), |
78 | 78 |
'shd_assign_ticket' => array(true, 'ticketactions', 'log_assign.png'), |
79 | 79 |
'shd_monitor_ticket' => array(true, 'ticketactions', 'log_notify.png'), |
80 |
+ 'shd_ignore_ticket' => array(true, 'ticketactions', 'perm_deny.png'), |
|
80 | 81 |
|
81 | 82 |
'shd_view_attachment' => array(false, 'attachments', 'attachments.png'), |
82 | 83 |
'shd_post_attachment' => array(false, 'attachments', 'attachments_add.png'), |
... | ... |
@@ -165,6 +166,7 @@ function shd_load_role_templates() |
165 | 166 |
'shd_edit_reply_any' => ROLEPERM_ALLOW, |
166 | 167 |
'shd_post_proxy' => ROLEPERM_ALLOW, |
167 | 168 |
'shd_monitor_ticket_any' => ROLEPERM_ALLOW, |
169 |
+ 'shd_ignore_ticket_own' => ROLEPERM_ALLOW, |
|
168 | 170 |
'shd_view_attachment' => ROLEPERM_ALLOW, |
169 | 171 |
'shd_post_attachment' => ROLEPERM_ALLOW, |
170 | 172 |
'shd_resolve_ticket_any' => ROLEPERM_ALLOW, |
... | ... |
@@ -207,6 +209,7 @@ function shd_load_role_templates() |
207 | 209 |
'shd_post_proxy' => ROLEPERM_ALLOW, |
208 | 210 |
'shd_override_cf' => ROLEPERM_ALLOW, |
209 | 211 |
'shd_monitor_ticket_any' => ROLEPERM_ALLOW, |
212 |
+ 'shd_ignore_ticket_any' => ROLEPERM_ALLOW, |
|
210 | 213 |
'shd_view_attachment' => ROLEPERM_ALLOW, |
211 | 214 |
'shd_post_attachment' => ROLEPERM_ALLOW, |
212 | 215 |
'shd_delete_attachment' => ROLEPERM_ALLOW, |
... | ... |
@@ -496,8 +496,13 @@ function template_viewnotifications() |
496 | 496 |
<div class="windowbg2"> |
497 | 497 |
<div class="shd_attachmentbox">'; |
498 | 498 |
|
499 |
+ $displayed_something = false; |
|
500 |
+ |
|
501 |
+ if (!$context['display_notifications']['is_ignoring']) |
|
502 |
+ { |
|
499 | 503 |
if (!empty($context['display_notifications']['preferences'])) |
500 | 504 |
{ |
505 |
+ $displayed_something = true; |
|
501 | 506 |
echo ' |
502 | 507 |
', $txt['shd_ticket_notify_because'], ' |
503 | 508 |
<ul>'; |
... | ... |
@@ -520,7 +525,7 @@ function template_viewnotifications() |
520 | 525 |
|
521 | 526 |
if (!empty($context['display_notifications']['can_monitor'])) |
522 | 527 |
{ |
523 |
- if (!empty($context['display_notifications']['preferences']) || !empty($context['display_notifications']['can_change'])) |
|
528 |
+ if ($displayed_something) |
|
524 | 529 |
echo ' |
525 | 530 |
<br />'; |
526 | 531 |
|
... | ... |
@@ -538,6 +543,33 @@ function template_viewnotifications() |
538 | 543 |
<input type="hidden" name="notifyaction" value="monitor_off" /> |
539 | 544 |
<input type="submit" value="', $txt['shd_ticket_monitor_off'], '" class="button_submit" />'; |
540 | 545 |
|
546 |
+ echo ' |
|
547 |
+ <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" /> |
|
548 |
+ </form>'; |
|
549 |
+ $displayed_something = true; |
|
550 |
+ } |
|
551 |
+ } |
|
552 |
+ |
|
553 |
+ if (!empty($context['display_notifications']['can_ignore'])) |
|
554 |
+ { |
|
555 |
+ if ($displayed_something) |
|
556 |
+ echo ' |
|
557 |
+ <br />'; |
|
558 |
+ |
|
559 |
+ echo ' |
|
560 |
+ <form action="', $scripturl, '?action=helpdesk;sa=notify;ticket=', $context['ticket_id'], '" method="post">'; |
|
561 |
+ |
|
562 |
+ if (!$context['display_notifications']['is_ignoring']) |
|
563 |
+ echo ' |
|
564 |
+ <div>', $txt['shd_ticket_notify_me_never_note'], '</div> |
|
565 |
+ <input type="hidden" name="notifyaction" value="ignore_on" /> |
|
566 |
+ <input type="submit" value="', $txt['shd_ticket_notify_me_never_on'], '" class="button_submit" />'; |
|
567 |
+ else |
|
568 |
+ echo ' |
|
569 |
+ <div>', $txt['shd_ticket_notify_me_never'], '</div> |
|
570 |
+ <input type="hidden" name="notifyaction" value="ignore_off" /> |
|
571 |
+ <input type="submit" value="', $txt['shd_ticket_notify_me_never_off'], '" class="button_submit" />'; |
|
572 |
+ |
|
541 | 573 |
echo ' |
542 | 574 |
<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" /> |
543 | 575 |
</form>'; |
544 | 576 |