! Pinging notification now passes back on error and should be passed to the full reply regardless of whether the AJAX call was remade or not (so if you go to reply, pull up the form, tick some boxes and get thrown back at error, the list should still be saved, regardless of whether you re-open the list or not) [Feature 739] ! Notifications AJAX now formatted a bit more nicely. Might need more yet, but I'm happy with it for now. [Feature 739]
gruffen

gruffen commited on 2011-06-11 19:20:44
Showing 5 changed files, with 55 additions and 8 deletions.


And with this, I'm done. Not going to bother tagging SVN, but at this point, no new features, only bug fixes will be committed for the 2.0 release, and barring any new bugs, I'm looking at a release probably late next week.
... ...
@@ -413,6 +413,17 @@ h3.ticketheader img
413 413
 	margin-bottom: 10px;
414 414
 }
415 415
 
416
+.shd_ajax_head
417
+{
418
+	font-weight: bold;
419
+}
420
+.shd_ajaxnotify
421
+{
422
+	width: 40%;
423
+	margin-right: 5%;
424
+	float: left;
425
+}
426
+
416 427
 /**********************************
417 428
 * Attachment stuff				  *
418 429
 ***********************************/
... ...
@@ -789,17 +789,26 @@ function shd_ajax_notify()
789 789
 		ob_start();
790 790
 		echo '<notify><![C', 'DATA[';
791 791
 
792
+		$selected = array();
793
+		if (!empty($_GET['list']))
794
+		{
795
+			$_GET['list'] = explode(',', $_GET['list']);
796
+			foreach ($_GET['list'] as $id)
797
+				if ((int) $id > 0)
798
+					$selected[] = (int) $id;
799
+		}
800
+
792 801
 		if (!empty($notify_list['being_notified']))
793
-			echo $txt['shd_ping_already_' . (count($notify_list['being_notified']) == 1 ? '1' : 'n')], '<br />', implode(', ', $notify_list['being_notified']);
802
+			echo '<span class="shd_ajax_head">', $txt['shd_ping_already_' . (count($notify_list['being_notified']) == 1 ? '1' : 'n')], '</span><br />', implode(', ', $notify_list['being_notified']);
794 803
 
795 804
 		if (!empty($notify_list['optional']))
796 805
 		{
797 806
 			if (!empty($notify_list['being_notified']))
798 807
 				echo '<br /><br />';
799 808
 
800
-			echo $txt['shd_ping_' . (count($notify_list['optional']) == 1 ? '1' : 'n')], '<br />';
809
+			echo '<span class="shd_ajax_head">', $txt['shd_ping_' . (count($notify_list['optional']) == 1 ? '1' : 'n')], '</span><br />';
801 810
 			foreach ($notify_list['optional'] as $id => $member)
802
-				echo '<div class="shd_ajaxnotify"><input type="checkbox" name="notify[', $id, ']" value="', $id, '" class="input_check" /> ', $member, '</div>';
811
+				echo '<div class="shd_ajaxnotify"><input type="checkbox" name="notify[', $id, ']" value="', $id, '"', in_array($id, $selected) ? ' checked="checked"' : '', ' class="input_check" /> ', $member, '</div>';
803 812
 		}
804 813
 
805 814
 		if (!empty($notify_list['optional_butoff']))
... ...
@@ -807,9 +816,9 @@ function shd_ajax_notify()
807 816
 			if (!empty($notify_list['being_notified']) || !empty($notify_list['optional_butoff']))
808 817
 				echo '<br /><br />';
809 818
 
810
-			echo $txt['shd_ping_none_' . (count($notify_list['optional_butoff']) == 1 ? '1' : 'n')], '<br />';
819
+			echo '<span class="shd_ajax_head">', $txt['shd_ping_none_' . (count($notify_list['optional_butoff']) == 1 ? '1' : 'n')], '</span><br />';
811 820
 			foreach ($notify_list['optional_butoff'] as $id => $member)
812
-				echo '<div class="shd_ajaxnotify"><input type="checkbox" name="notify[', $id, ']" value="', $id, '" class="input_check" /> ', $member, '</div>';
821
+				echo '<div class="shd_ajaxnotify"><input type="checkbox" name="notify[', $id, ']" value="', $id, '"', in_array($id, $selected) ? ' checked="checked"' : '', ' class="input_check" /> ', $member, '</div>';
813 822
 		}
814 823
 
815 824
 		echo ']', ']></notify>';
... ...
@@ -209,13 +209,23 @@ function shd_notifications_notify_newreply(&$msgOptions, &$ticketOptions, &$post
209 209
 		unset($members[$member_id]);
210 210
 
211 211
 	// And now, finally, receive the list of possible cases from the notification doodad, and verify against a list of possible people.
212
-	if ($context['can_ping'] && !empty($_POST['notify']) && is_array($_POST['notify']))
212
+	if ($context['can_ping'])
213
+	{
214
+		if (!empty($_POST['notify']) && is_array($_POST['notify']))
213 215
 		{
214 216
 			$staff[] = $ticketinfo['starter_id']; // Add the ticket starter as a possible candidate.
215 217
 			foreach ($_POST['notify'] as $id)
216 218
 				if (in_array((int) $id, $staff))
217 219
 					$members[$id]['ping'] = true;
218 220
 		}
221
+		elseif (!empty($_REQUEST['list']))
222
+		{
223
+			$list = explode(',', $_REQUEST['list']);
224
+			foreach ($list as $id)
225
+				if (in_array((int) $id, $staff))
226
+					$members[$id]['ping'] = true;
227
+		}
228
+	}
219 229
 
220 230
 	// So, at this point, $members contains a list of the members and a sequence of the possible messages they could get. We need to make some sense of it.
221 231
 	$notify_data['members'] = array();
... ...
@@ -1131,6 +1131,17 @@ function shd_save_reply()
1131 1131
 		$context['page_title'] = $txt['shd_helpdesk'];
1132 1132
 		$context['sub_template'] = 'reply_post';
1133 1133
 
1134
+		// Oh, yeah, we need to look at the existing notifications pinging stuff, if appropriate, and reset that.
1135
+		if ($context['can_ping'] && !empty($_POST['notify']) && is_array($_POST['notify']))
1136
+		{
1137
+			$items = array();
1138
+			foreach ($_POST['notify'] as $item)
1139
+				if (!empty($item) && is_numeric($item))
1140
+					$items[] = $item;
1141
+			if (!empty($items))
1142
+				$context['notification_ping_list'] = implode(',', $items);
1143
+		}
1144
+
1134 1145
 		shd_check_attachments();
1135 1146
 
1136 1147
 		// Set up the fancy editor
... ...
@@ -758,7 +758,13 @@ function template_singleton_email()
758 758
 	{
759 759
 		echo '
760 760
 						<div id="shd_notifications_div" style="display:none;">
761
-							<a href="#" onclick="getAjaxNotifications(); return false;">', $txt['shd_select_notifications'], '</a>
761
+							<a href="#" onclick="getAjaxNotifications(); return false;">', $txt['shd_select_notifications'], '</a>';
762
+
763
+		if (!empty($context['notification_ping_list']))
764
+			echo '
765
+							<input type="hidden" name="list" value="', $context['notification_ping_list'], '" />';
766
+
767
+		echo '
762 768
 						</div>
763 769
 						<script type="text/javascript"><!-- // --><![CDATA[
764 770
 	document.getElementById("shd_notifications_div").style.display = "";
... ...
@@ -766,7 +772,7 @@ function template_singleton_email()
766 772
 	function getAjaxNotifications()
767 773
 	{
768 774
 		ajax_indicator(true);
769
-		getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + "action=helpdesk;sa=ajax;op=notify;ticket=', $context['ticket_id'], ';', $context['session_var'], '=', $context['session_id'], '", handleAjaxNotifications);
775
+		getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + "action=helpdesk;sa=ajax;op=notify;ticket=', $context['ticket_id'], ';', $context['session_var'], '=', $context['session_id'], !empty($context['notification_ping_list']) ? ';list=' . $context['notification_ping_list'] : '', '", handleAjaxNotifications);
770 776
 	}
771 777
 
772 778
 	function handleAjaxNotifications(XMLDoc)
773 779