From f31984b50cadf75dbd854d43e03d298904160173 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 14 Feb 2007 19:18:15 +0000 Subject: [PATCH] r1406: Moving the rest of the email body texts (from class_notification.php) to templates --- includes/class_notification.php | 155 +++++---------------- templates/email/bugnotification.xml.tpl | 18 +++ templates/email/notice_assigned.part.tpl | 1 + templates/email/notice_attachment.part.tpl | 8 ++ templates/email/notice_comment.part.tpl | 4 + templates/email/notice_duplicates.part.tpl | 1 + templates/email/notice_new_bug.part.tpl | 11 ++ templates/email/notice_other.part.tpl | 1 + templates/email/notice_priority.part.tpl | 1 + templates/email/notice_product.part.tpl | 1 + templates/email/notice_resolution.part.tpl | 1 + templates/email/notice_severity.part.tpl | 1 + templates/email/notice_status.part.tpl | 1 + templates/email/notice_unassigned.part.tpl | 1 + 14 files changed, 83 insertions(+), 122 deletions(-) create mode 100644 templates/email/bugnotification.xml.tpl create mode 100644 templates/email/notice_assigned.part.tpl create mode 100644 templates/email/notice_attachment.part.tpl create mode 100644 templates/email/notice_comment.part.tpl create mode 100644 templates/email/notice_duplicates.part.tpl create mode 100644 templates/email/notice_new_bug.part.tpl create mode 100644 templates/email/notice_other.part.tpl create mode 100644 templates/email/notice_priority.part.tpl create mode 100644 templates/email/notice_product.part.tpl create mode 100644 templates/email/notice_resolution.part.tpl create mode 100644 templates/email/notice_severity.part.tpl create mode 100644 templates/email/notice_status.part.tpl create mode 100644 templates/email/notice_unassigned.part.tpl diff --git a/includes/class_notification.php b/includes/class_notification.php index 8eb062b..034b46d 100644 --- a/includes/class_notification.php +++ b/includes/class_notification.php @@ -287,11 +287,8 @@ class NotificationCenter { if ($this->users["$userid"]['options'][0] & $this->registry->emailoptions['notifications']['assignedto'] AND in_array($userid, $this->roles['-notapplicable-'])) { - $this->notices["$userid"][] = sprintf( -_('You are no longer assigned to this bug, per %1$s\'s changes.'), - - construct_user_display($this->registry->userinfo, false) - ); + $user = construct_user_display($this->registry->userinfo, false); + $this->notices["$userid"][] = eval('$part = "' . $this->registry->template->fetch('email/notice_unassigned.part') . '";'); } } @@ -307,11 +304,8 @@ _('You are no longer assigned to this bug, per %1$s\'s changes.'), { if ($this->users["$userid"]['options'][0] & $this->registry->emailoptions['notifications']['assignedto'] AND in_array($userid, $this->roles['-notapplicable-'])) { - $this->notices["$userid"][] = sprintf( -_('You have been assigned to this bug by %1$s.'), - - construct_user_display($this->registry->userinfo, false) - ); + $user = construct_user_display($this->registry->userinfo, false); + $this->notices["$userid"][] = eval('$email = "' . $this->registry->template->fetch('email/notice_assigned.part') . '";'); } } @@ -329,12 +323,7 @@ _('You have been assigned to this bug by %1$s.'), $userlist = $this->fetch_users_with_on_bit('statusresolve'); foreach ($userlist AS $userid => $user) { - $this->notices["$user[userid]"][] = sprintf( -_('The status of the bug is now "%2$s", from "%1$s".'), - - $this->registry->datastore['status']["$old"]['status'], - $this->registry->datastore['status']["$new"]['status'] - ); + $this->notices["$user[userid]"][] = eval('$email = "' . $this->registry->template->fetch('email/notice_status.part') . '";'); } } @@ -352,12 +341,7 @@ _('The status of the bug is now "%2$s", from "%1$s".'), $userlist = $this->fetch_users_with_on_bit('statusresolve'); foreach ($userlist AS $userid => $user) { - $this->notices["$user[userid]"][] = sprintf( -_('This bug has been resolved with resolution "%2$s", from "%1$s".'), - - $this->registry->datastore['resolution']["$old"]['resolution'], - $this->registry->datastore['resolution']["$new"]['resolution'] - ); + $this->notices["$user[userid]"][] = eval('$email = "' . $this->registry->template->fetch('email/notice_resolution.part') . '";'); } } @@ -375,12 +359,7 @@ _('This bug has been resolved with resolution "%2$s", from "%1$s".'), $userlist = $this->fetch_useres_with_on_bit('duplicates'); foreach ($userlist AS $userid => $user) { - $this->notices["$user[userid]"][] = sprintf( -_('The duplicates list has changed from "%1$s" to %2$s".'), - - $old, - $new - ); + $this->notices["$user[userid]"][] = eval('$email = "' . $this->registry->template->fetch('email/notice_duplicates.part') . '";'); } } @@ -398,12 +377,7 @@ _('The duplicates list has changed from "%1$s" to %2$s".'), $userlist = $this->fetch_users_with_on_bit('otherfield'); foreach ($userlist AS $userid => $user) { - $this->notices["$user[userid]"][] = sprintf( -_('The severity has been elevated from "%1$s" to "%2$s".'), - - $this->registry->datastore['severity']["$old"]['severity'], - $this->registry->datastore['severity']["$new"]['severity'] - ); + $this->notices["$user[userid]"][] = eval('$email = "' . $this->registry->template->fetch('email/notice_severity.part') . '";'); } } @@ -421,12 +395,7 @@ _('The severity has been elevated from "%1$s" to "%2$s".'), $userlist = $this->fetch_users_with_on_bit('otherfield'); foreach ($userlist AS $userid => $user) { - $this->notices["$user[userid]"][] = sprintf( -_('The priority has been elevatd from "%1$s" to "%2$s".'), - - $this->registry->datastore['priority']["$old"]['priority'], - $this->registry->datastore['priority']["$new"]['priority'] - ); + $this->notices["$user[userid]"][] = eval('$email = "' . $this->registry->template->fetch('email/notice_priority.part') . '";'); } } @@ -444,14 +413,13 @@ _('The priority has been elevatd from "%1$s" to "%2$s".'), function notice_pcv_change($old, $new) { $userlist = $this->fetch_users_with_on_bit('otherfield'); + + $old = $this->registry->datastore['product']["$old[0]"]['title'] . '/' . ($old[1] ? $this->registry->datastore['product']["$old[1]"]['title'] . '/' : '') . $this->registry->datastore['version']["$old[2]"]['version']; + $new = $this->registry->datastore['product']["$new[0]"]['title'] . '/' . ($new[1] ? $this->registry->datastore['product']["$new[1]"]['title'] . '/' : '') . $this->registry->datastore['version']["$new[2]"]['version']; + foreach ($userlist AS $userid => $user) { - $this->notices["$user[userid]"][] = sprintf( -_('The product, component, and version combination has changed from "%1$s" to "%2$s".'), - - $this->registry->datastore['product']["$old[0]"]['title'] . '/' . ($old[1] ? $this->registry->datastore['product']["$old[1]"]['title'] . '/' : '') . $this->registry->datastore['version']["$old[2]"]['version'], - $this->registry->datastore['product']["$new[0]"]['title'] . '/' . ($new[1] ? $this->registry->datastore['product']["$new[1]"]['title'] . '/' : '') . $this->registry->datastore['version']["$new[2]"]['version'] - ); + $this->notices["$user[userid]"][] = eval('$email = "' . $this->registry->template->fetch('email/notice_product.part') . '";'); } } @@ -469,16 +437,10 @@ _('The product, component, and version combination has changed from "%1$s" to "% $userlist = $this->fetch_users_with_on_bit('newcomment'); foreach ($userlist AS $userid => $user) { - $this->notices["$user[userid]"][] = sprintf( -_('The following comment was added by %1$s on %2$s: -============================================ -%3$s -============================================'), - - construct_user_display($this->registry->userinfo, false), - $this->registry->modules['date']->format($this->registry->options['dateformat'], $comment['dateline']), - $comment['comment'] - ); + $user = construct_user_display($this->registry->userinfo, false); + $date = $this->registry->modules['date']->format($this->registry->options['dateformat'], $comment['dateline']); + + $this->notices["$user[userid]"][] = eval('$email = "' . $this->registry->template->fetch('email/notice_comment.part') . '";'); } } @@ -497,13 +459,7 @@ _('The following comment was added by %1$s on %2$s: $userlist = $this->fetch_users_with_on_bit('otherfield'); foreach ($userlist AS $userid => $user) { - $this->notices["$user[userid]"][] = sprintf( -_('The %1$s field changed from "%2$s" to "%3$s".'), - - $name, - $old, - $new - ); + $this->notices["$user[userid]"][] = eval('$email = "' . $this->registry->template->fetch('email/notice_other.part') . '";'); } } @@ -523,23 +479,10 @@ _('The %1$s field changed from "%2$s" to "%3$s".'), $userlist = $this->fetch_users_with_on_bit('newattachment'); foreach ($userlist AS $userid => $user) { - $this->notices["$userid"][] = sprintf( -_('%1$s has uploaded a new attachment: -============================================ -File name: %2$s -Description: %3$s -File size: %4$s Bytes -Makes obsolete: %5$s -View: %6$s -============================================'), - - construct_user_display($this->registry->userinfo, false), - $attachment['filename'], - $attachment['description'], - $attachment['filesize'], - implode(', ', (array)$obsolete), - $this->registry->options['trackerurl'] . '/viewattachment.php?attachmentid=' . $id - ); + $user = construct_user_display($this->registry->userinfo, false); + $obsoletes = implode(', ', (array)$obsolete); + + $this->notices["$userid"][] = eval('$email = "' . $this->registry->template->fetch('email/notice_attachment.part') . '";'); } } @@ -568,25 +511,9 @@ View: %6$s { if (!is_array($this->users["$user[userid]"])) { - $this->notices["$user[userid]"][] = sprintf( -_(' -This bug has been added to the database: -============================================ -Bug ID: %1$s -Summary: %2$s -Reporter: %3$s -Product/Component/Version: %4$s -Initial report: --------------------------------------------- -%5$s --------------------------------------------- -============================================'), - $bug['bugid'], - $bug['summary'], - construct_user_display($this->registry->userinfo, false), - $this->registry->datastore['product']["$bug[product]"]['title'] . '/' . ($bug['component'] ? $this->registry->datastore['product']["$bug[component]"]['title'] . '/' : '') . $this->registry->datastore['version']["$bug[version]"]['version'], - $comment['comment'] - ); + $user = construct_user_display($this->registry->userinfo, false); + $product = $this->registry->datastore['product']["$bug[product]"]['title'] . '/' . ($bug['component'] ? $this->registry->datastore['product']["$bug[component]"]['title'] . '/' : '') . $this->registry->datastore['version']["$bug[version]"]['version']; + $this->notices["$user[userid]"][] = eval('$email = "' . $this->registry->template->fetch('email/notice_new_bug.part') . '";'); $this->users["$user[userid]"] = $user; unset($this->users["$user[userid]"]['mask'], $this->users["$user[userid]"]['relation']); } @@ -641,7 +568,6 @@ Initial report: { // get the current bug for permissions checks $bug = $this->registry->db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . $this->bug['bugid']); - $this->registry->mail->setSubject(sprintf(_('%1$s Bug Notification - %2$s'), $this->registry->options['trackertitle'], $this->bug['summary'])); foreach ($this->notices AS $userid => $noticelist) { if ($userid == $this->registry->userinfo['userid']) @@ -656,28 +582,13 @@ Initial report: continue; } - $this->registry->mail->setBodyText(sprintf(_('Hi %1$s, - -You are receiving this email because you have opted to get notifications for the %2$s bug tracker. - -The bug is "%5$s" (id: %6$s) located at %4$s/showreport.php?bugid=%6$s - -Here are the notices: -################################################################### - -%3$s - -################################################################### -If you no longer want to receive email from us, please log into your account and click the "My Controls" tab at the top of the screen to change email preferences. - -%4$s'), - $this->users["$userid"]['displayname'], - $this->registry->options['trackertitle'], - implode("\n\n", $noticelist), - $this->registry->options['trackerurl'], - $this->bug['summary'], - $this->bug['bugid'] - )); + $parts = implode("\n\n", $noticelist); + + eval('$email = "' . $this->registry->template->fetch('email/bugnotification.xml') . '";'); + $email = $this->registry->xml->parse($email); + $this->registry->mail->setSubject($email['email']['subject']['value']); + $this->registry->mail->setBodyText($email['email']['bodyText']['value']); + if (!empty($this->users["$userid"]['email'])) { $this->registry->mail->send($this->users["$userid"]['email'], $this->users["$userid"]['displayname']); diff --git a/templates/email/bugnotification.xml.tpl b/templates/email/bugnotification.xml.tpl new file mode 100644 index 0000000..7cf556d --- /dev/null +++ b/templates/email/bugnotification.xml.tpl @@ -0,0 +1,18 @@ + + {$this->registry->options['trackertitle']} Bug Notification - {$this->bug['summary']} + Hi {$this->users["$userid"]['displayname']}, + +You are receiving this email because you have opted to get notifications for the {$this->registry->options['trackertitle']} bug tracker. + +The bug is "{$this->bug['summary']}" (id: {$this->bug['bugid']}) located at {$this->registry->options['trackerurl']}/showreport.php?bugid={$this->bug['bugid']} + +Here are the notices: +################################################################### + +$parts + +################################################################### +If you no longer want to receive email from us, please log into your account and click the "My Controls" tab at the top of the screen to change email preferences. + +{$this->registry->options['trackerurl']} + \ No newline at end of file diff --git a/templates/email/notice_assigned.part.tpl b/templates/email/notice_assigned.part.tpl new file mode 100644 index 0000000..b99df20 --- /dev/null +++ b/templates/email/notice_assigned.part.tpl @@ -0,0 +1 @@ +You have been assigned to this bug by $user. \ No newline at end of file diff --git a/templates/email/notice_attachment.part.tpl b/templates/email/notice_attachment.part.tpl new file mode 100644 index 0000000..53fee41 --- /dev/null +++ b/templates/email/notice_attachment.part.tpl @@ -0,0 +1,8 @@ +$user has uploaded a new attachment: +============================================ +File name: $attachment[filename] +Description: $attachment[description] +File size: $attachment[filesize] Bytes +Makes obsolete: $obsoletes +View: {$this->registry->options['trackerurl']}/viewattachment.php?attachmentid=$id +============================================ \ No newline at end of file diff --git a/templates/email/notice_comment.part.tpl b/templates/email/notice_comment.part.tpl new file mode 100644 index 0000000..49e4c7e --- /dev/null +++ b/templates/email/notice_comment.part.tpl @@ -0,0 +1,4 @@ +The following comment was added by $user on $date: +============================================ +$comment[comment] +============================================ \ No newline at end of file diff --git a/templates/email/notice_duplicates.part.tpl b/templates/email/notice_duplicates.part.tpl new file mode 100644 index 0000000..8841d1a --- /dev/null +++ b/templates/email/notice_duplicates.part.tpl @@ -0,0 +1 @@ +The duplicates list has changed from "$old" to "$new". \ No newline at end of file diff --git a/templates/email/notice_new_bug.part.tpl b/templates/email/notice_new_bug.part.tpl new file mode 100644 index 0000000..362ddab --- /dev/null +++ b/templates/email/notice_new_bug.part.tpl @@ -0,0 +1,11 @@ +This bug has been added to the database: +============================================ +Bug ID: $bug[bugid] +Summary: $bug[summary] +Reporter: $user +Product/Component/Version: $product +Initial report: +-------------------------------------------- +$comment[comment] +-------------------------------------------- +============================================ \ No newline at end of file diff --git a/templates/email/notice_other.part.tpl b/templates/email/notice_other.part.tpl new file mode 100644 index 0000000..fa73394 --- /dev/null +++ b/templates/email/notice_other.part.tpl @@ -0,0 +1 @@ +The $name field changed from "$old" to "$new". \ No newline at end of file diff --git a/templates/email/notice_priority.part.tpl b/templates/email/notice_priority.part.tpl new file mode 100644 index 0000000..bf7d71e --- /dev/null +++ b/templates/email/notice_priority.part.tpl @@ -0,0 +1 @@ +The priority has been elevatd from "{$this->registry->datastore['priority']["$old"]['priority']}" to "{$this->registry->datastore['priority']["$new"]['priority']}". \ No newline at end of file diff --git a/templates/email/notice_product.part.tpl b/templates/email/notice_product.part.tpl new file mode 100644 index 0000000..d7038e7 --- /dev/null +++ b/templates/email/notice_product.part.tpl @@ -0,0 +1 @@ +The product, component, and version combination has changed from "$old" to "$new". \ No newline at end of file diff --git a/templates/email/notice_resolution.part.tpl b/templates/email/notice_resolution.part.tpl new file mode 100644 index 0000000..f023555 --- /dev/null +++ b/templates/email/notice_resolution.part.tpl @@ -0,0 +1 @@ +This bug has been resolved with resolution "{$this->registry->datastore['resolution']["$new"]['resolution']}", from "{$this->registry->datastore['resolution']["$old"]['resolution']}". \ No newline at end of file diff --git a/templates/email/notice_severity.part.tpl b/templates/email/notice_severity.part.tpl new file mode 100644 index 0000000..329e2ce --- /dev/null +++ b/templates/email/notice_severity.part.tpl @@ -0,0 +1 @@ +The severity has been elevated from "{$this->registry->datastore['severity']["$old"]['severity']}" to "{$this->registry->datastore['severity']["$new"]['severity']}". \ No newline at end of file diff --git a/templates/email/notice_status.part.tpl b/templates/email/notice_status.part.tpl new file mode 100644 index 0000000..ef990de --- /dev/null +++ b/templates/email/notice_status.part.tpl @@ -0,0 +1 @@ +The status of the bug is now "{$this->registry->datastore['status']["$new"]['status']}", from "{$this->registry->datastore['status']["$old"]['status']}". \ No newline at end of file diff --git a/templates/email/notice_unassigned.part.tpl b/templates/email/notice_unassigned.part.tpl new file mode 100644 index 0000000..72c9917 --- /dev/null +++ b/templates/email/notice_unassigned.part.tpl @@ -0,0 +1 @@ +You are no longer assigned to this bug, per $user's changes. \ No newline at end of file -- 2.22.5