! Provisional ability to perform silent updates. I don't have a testing environment of any kind that I can deploy this on, so it's possible this breaks a number of things, or doesn't work, but with a little luck... ah, you know the drill :P
gruffen

gruffen commited on 2011-06-17 05:29:12
Showing 7 changed files, with 23 additions and 1 deletions.

... ...
@@ -267,6 +267,7 @@ $txt['shd_back_to_ticket'] = 'Return to this ticket after posting';
267 267
 $txt['shd_disable_smileys_post'] = 'Turn off smileys in this post';
268 268
 $txt['shd_resolve_this_ticket'] = 'Mark this ticket as resolved';
269 269
 $txt['shd_override_cf'] = 'Override the custom fields requirements';
270
+$txt['shd_silent_update'] = 'Silent update (send no notifications)';
270 271
 $txt['shd_select_notifications'] = 'Select people to notify about this reply...';
271 272
 
272 273
 $txt['shd_ticket_assign_ticket'] = 'Assign Ticket';
... ...
@@ -113,6 +113,12 @@ $txt['permissionname_shd_singleton_email'] = 'Send a reply notification';
113 113
 $txt['permissionhelp_shd_singleton_email'] = 'This permission allows a user to select extra recipients when replying to a ticket, people who would not normally receive a notification of a reply but can be advised for special situations, or where it would be useful to do so.';
114 114
 //@}
115 115
 
116
+//! @name Ticket emails: allowing silent updates
117
+//@{
118
+$txt['permissionname_shd_silent_update'] = 'Silent update';
119
+$txt['permissionhelp_shd_silent_update'] = 'This permission allows a user to reply to a ticket and to suppress any notifications that would otherwise go out, even overriding monitoring.';
120
+//@}
121
+
116 122
 //! @name Ticket modification: resolution
117 123
 //@{
118 124
 $txt['permissionname_shd_resolve_ticket'] = 'Mark a ticket resolved';
... ...
@@ -541,6 +541,7 @@ function shd_view_ticket()
541 541
 	$context['shd_can_move_to_topic'] = empty($modSettings['shd_disable_tickettotopic']) && shd_allowed_to('shd_ticket_to_topic', $context['ticket']['dept']) && empty($modSettings['shd_helpdesk_only']);
542 542
 	$context['can_solve'] = !$context['ticket']['closed'] && !$context['ticket']['deleted'] && (shd_allowed_to('shd_resolve_ticket_any', $context['ticket']['dept']) || (shd_allowed_to('shd_resolve_ticket_own', $context['ticket']['dept']) && $context['ticket']['ticket_opener']));
543 543
 	$context['can_unsolve'] = $context['ticket']['closed'] && (shd_allowed_to('shd_unresolve_ticket_any', $context['ticket']['dept']) || (shd_allowed_to('shd_unresolve_ticket_own', $context['ticket']['dept']) && $context['ticket']['ticket_opener']));
544
+	$context['can_silent_update'] = $context['can_reply'] && shd_allowed_to('shd_silent_update', $context['ticket']['dept']);
544 545
 
545 546
 	// And off we go
546 547
 	$context['ticket_navigation'] = array();
... ...
@@ -101,6 +101,10 @@ function shd_notifications_notify_newreply(&$msgOptions, &$ticketOptions, &$post
101 101
 	if (empty($msgOptions['body']))
102 102
 		return;
103 103
 
104
+	// Alternatively, they might be doing a silent update.
105
+	if (!empty($_POST['silent_update']) && shd_allowed_to('shd_silent_update', $ticketOptions['dept']))
106
+		return;
107
+
104 108
 	// We're doing various things here, so grab some general details, not just what we may have been passed before.
105 109
 	$ticketinfo = shd_load_ticket($ticketOptions['id']);
106 110
 	// $staff is the sum total of staff + ticket starter, subject to visibility of the ticket.
... ...
@@ -794,6 +794,7 @@ function shd_post_reply()
794 794
 		'disable_smileys' => !$new_reply ? !empty($_REQUEST['no_smileys']) : ($ticketinfo['smileys_enabled'] == 0),
795 795
 	);
796 796
 	$context['can_solve'] = (shd_allowed_to('shd_resolve_ticket_any', $ticketinfo['dept']) || (shd_allowed_to('shd_resolve_ticket_own', $ticketinfo['dept']) && $ticketinfo['starter_id'] == $user_info['id']));
797
+	$context['can_silent_update'] = shd_allowed_to('shd_silent_update', $ticketinfo['dept']);	
797 798
 	shd_posting_additional_options();
798 799
 	shd_load_canned_replies();
799 800
 
... ...
@@ -1022,6 +1023,7 @@ function shd_save_reply()
1022 1023
 		'disable_smileys' => !empty($_REQUEST['no_smileys']),
1023 1024
 	);
1024 1025
 	$context['can_solve'] = (shd_allowed_to('shd_resolve_ticket_any', $ticketinfo['dept']) || (shd_allowed_to('shd_resolve_ticket_own', $ticketinfo['dept']) && $ticketinfo['starter_id'] == $user_info['id']));
1026
+	$context['can_silent_update'] = shd_allowed_to('shd_silent_update', $context['ticket']['dept']);
1025 1027
 	$context['log_action'] = $new_reply ? 'newreply' : 'editreply';
1026 1028
 	$context['log_params']['subject'] = $context['ticket_form']['subject'];
1027 1029
 	shd_posting_additional_options();
... ...
@@ -2012,6 +2014,11 @@ function shd_posting_additional_options()
2012 2014
 			'text' => $txt['shd_resolve_this_ticket'],
2013 2015
 			'show' => !empty($context['can_solve']),
2014 2016
 		),
2017
+		'silent_update' => array(
2018
+			'checked' => !empty($_POST['silent_update']),
2019
+			'text' => $txt['shd_silent_update'],
2020
+			'show' => !empty($context['can_silent_update']),
2021
+		),
2015 2022
 	);
2016 2023
 }
2017 2024
 
... ...
@@ -92,6 +92,7 @@ function shd_load_all_permission_sets()
92 92
 		'shd_monitor_ticket' => array(true, 'email', 'log_notify.png'),
93 93
 		'shd_ignore_ticket' => array(true, 'email', 'perm_deny.png'),
94 94
 		'shd_singleton_email' => array(false, 'email', 'live.png'),
95
+		'shd_silent_update' => array(false, 'email', 'silent_update.png'),
95 96
 
96 97
 		'shd_view_profile' => array(true, 'profile', 'profile.png'),
97 98
 		'shd_view_profile_log' => array(true, 'profile', 'log.png'),
... ...
@@ -171,6 +172,7 @@ function shd_load_role_templates()
171 172
 				'shd_monitor_ticket_any' => ROLEPERM_ALLOW,
172 173
 				'shd_singleton_email' => ROLEPERM_ALLOW,
173 174
 				'shd_ignore_ticket_own' => ROLEPERM_ALLOW,
175
+				'shd_silent_update' => ROLEPERM_ALLOW,
174 176
 				'shd_view_attachment' => ROLEPERM_ALLOW,
175 177
 				'shd_post_attachment' => ROLEPERM_ALLOW,
176 178
 				'shd_resolve_ticket_any' => ROLEPERM_ALLOW,
... ...
@@ -213,8 +215,9 @@ function shd_load_role_templates()
213 215
 				'shd_post_proxy' => ROLEPERM_ALLOW,
214 216
 				'shd_override_cf' => ROLEPERM_ALLOW,
215 217
 				'shd_monitor_ticket_any' => ROLEPERM_ALLOW,
216
-				'shd_ignore_ticket_any' => ROLEPERM_ALLOW,
217 218
 				'shd_singleton_email' => ROLEPERM_ALLOW,
219
+				'shd_ignore_ticket_any' => ROLEPERM_ALLOW,
220
+				'shd_silent_update' => ROLEPERM_ALLOW,
218 221
 				'shd_view_attachment' => ROLEPERM_ALLOW,
219 222
 				'shd_post_attachment' => ROLEPERM_ALLOW,
220 223
 				'shd_delete_attachment' => ROLEPERM_ALLOW,
221 224