! Expose the poster of the ticket or reply (that spawned a notification) through {poster_name}.
gruffen

gruffen commited on 2011-05-27 07:08:43
Showing 1 changed files, with 7 additions and 1 deletions.

... ...
@@ -86,6 +86,7 @@ function shd_notifications_notify_newticket(&$msgOptions, &$ticketOptions, &$pos
86 86
 		'subject' => $ticketOptions['subject'],
87 87
 		'ticket' => $ticketOptions['id'],
88 88
 		'body' => $msgOptions['body'],
89
+		'poster_name' => $posterOptions['name'],
89 90
 	);
90 91
 
91 92
 	shd_notify_users($notify_data);
... ...
@@ -111,6 +112,7 @@ function shd_notifications_notify_newreply(&$msgOptions, &$ticketOptions, &$post
111 112
 		'ticket' => $ticketOptions['id'],
112 113
 		'msg' => $msgOptions['id'],
113 114
 		'body' => $msgOptions['body'],
115
+		'poster_name' => $posterOptions['name'],
114 116
 	);
115 117
 
116 118
 	$members = array(); // who should get what type of notification, preferences depending
... ...
@@ -336,6 +338,8 @@ function shd_notify_users($notify_data)
336 338
 		'{ticketlink}' => $notify_data['ticketlink'],
337 339
 	);
338 340
 
341
+	if (isset($notify_data['poster_name']))
342
+		$replacements['{poster_name}'] = $notify_data['poster_name'];
339 343
 	if (isset($notify_data['body']))
340 344
 		$replacements['{body}'] = trim(un_htmlspecialchars(strip_tags(strtr(shd_format_text($notify_data['body'], false), array('<br />' => "\n", '</div>' => "\n", '</li>' => "\n", '&#91;' => '[', '&#93;' => ']')))));
341 345
 	$withbody = isset($notify_data['body']) && !empty($modSettings['shd_notify_with_body']) ? 'bodyfull' : 'body';
... ...
@@ -425,9 +429,10 @@ function shd_notify_popup()
425 429
 		fatal_lang_error('no_access', false);
426 430
 
427 431
 	$query = $smcFunc['db_query']('', '
428
-		SELECT hdla.id_member, hdla.id_ticket, hdla.id_msg, hdla.extra, IFNULL(hdtr.body, {string:empty}) AS body
432
+		SELECT hdla.id_member, hdla.id_ticket, hdla.id_msg, hdla.extra, IFNULL(hdtr.body, {string:empty}) AS body, IFNULL(mem.real_name, hdtr.poster_name) AS poster_name
429 433
 		FROM {db_prefix}helpdesk_log_action AS hdla
430 434
 			LEFT JOIN {db_prefix}helpdesk_ticket_replies AS hdtr ON (hdla.id_msg = hdtr.id_msg)
435
+			LEFT JOIN {db_prefix}members AS mem ON (hdtr.id_member = mem.id_member)
431 436
 		WHERE id_action = {int:log}
432 437
 			AND action = {string:notify}',
433 438
 		array(
... ...
@@ -527,6 +532,7 @@ function shd_notify_popup()
527 532
 		'{subject}' => empty($row['extra']['subject']) ? $txt['no_subject'] : $row['extra']['subject'],
528 533
 		'{ticketlink}' => $scripturl . '?action=helpdesk;sa=ticket;ticket=' . $row['id_ticket'] . (empty($row['id_msg']) ? '.0' : '.msg' . $row['id_msg'] . '#msg' . $row['id_msg']),
529 534
 		'{body}' => $body,
535
+		'{poster_name}' => $row['poster_name'],
530 536
 	);
531 537
 
532 538
 	$email_subject = str_replace(array_keys($replacements), array_values($replacements), $txt['template_subject_notify_' . $email_type]);
533 539