From a611e4557c750b7225c47a0ed69f765f5ba6af95 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 27 Jul 2006 04:33:31 +0000 Subject: [PATCH] r978: Fixing the notifications system so that pcv, severity, and priority now work --- includes/class_notification.php | 100 ++++++++++++++++++++++++++++---- 1 file changed, 90 insertions(+), 10 deletions(-) diff --git a/includes/class_notification.php b/includes/class_notification.php index b883180..5f45abf 100644 --- a/includes/class_notification.php +++ b/includes/class_notification.php @@ -204,6 +204,7 @@ class NotificationCenter return; } + // fields with custom mask information if ($this->original['assignedto'] != $this->modified['assignedto']) { if ($this->original['assignedto'] != '') @@ -215,30 +216,37 @@ class NotificationCenter $this->notice_now_assigned($this->modified['assignedto']); } } - if ($this->original['status'] != $this->modified['status']) { $this->notice_status_change($this->original['status'], $this->modified['status']); } - if ($this->original['resolution'] != $this->modified['resoultion']) + if ($this->original['resolution'] != $this->modified['resolution']) { $this->notice_resolution_change($this->original['resolution'], $this->modified['resolution']); } - if ($this->original['duplicates'] != $this->modified['duplicates']) { $this->notice_duplicates_change($this->original['duplicates'], $this->modified['duplicates']); } + // other standard fields that don't have custom masks + if ($this->original['severity'] != $this->modified['severity']) + { + $this->notice_severity_change($this->original['severity'], $this->modified['severity']); + } + if ($this->original['priority'] != $this->modified['priority']) + { + $this->notice_priority_change($this->original['priority'], $this->modified['priority']); + } + if (($this->original['product'] != $this->modified['product']) OR ($this->original['component'] != $this->modified['component']) OR ($this->original['version'] != $this->modified['version'])) + { + $this->notice_pcv_change(array($this->original['product'], $this->original['component'], $this->original['version']), array($this->modified['product'], $this->modified['component'], $this->modified['version'])); + } + $dofields = array( 'summary' => -1, - 'severity' => 'severityid', 'dependency' => -1, - 'productid' => -1, - 'componentid' => -1, - 'versionid' => -1, - 'hidden' => -1, - 'priority' => 'priorityid' + 'hidden' => -1 ); foreach ($dofields AS $field => $lookup) { @@ -248,6 +256,7 @@ class NotificationCenter } } + // custom field data foreach ($modified AS $field => $value) { if ($field == 'bugid') @@ -371,6 +380,77 @@ $this->registry->lang->string('The duplicates list has changed from "%1$s" to %2 } } + // ################################################################### + /** + * Sends an email to inform users that the severity has changed. + * + * @access private + * + * @param integer Old severity + * @param integer New severity + */ + function notice_severity_change($old, $new) + { + $userlist = $this->fetch_users_with_on_bit('otherfield'); + foreach ($userlist AS $userid => $user) + { + $this->notices["$user[userid]"][] = sprintf( +$this->registry->lang->string('The severity field has changed from "%1$s" to "%2$s".'), + + $this->registry->datastore['severity']["$old"]['severity'], + $this->registry->datastore['severity']["$new"]['severity'] + ); + } + } + + // ################################################################### + /** + * Informs users that the priority changed. + * + * @access private + * + * @param integer Old priority + * @param integer New priority + */ + function notice_priority_change($old, $new) + { + $userlist = $this->fetch_users_with_on_bit('otherfield'); + foreach ($userlist AS $userid => $user) + { + $this->notices["$user[userid]"][] = sprintf( +$this->registry->lang->string('The priority field has changed from "%1$s" to "%2$s".'), + + $this->registry->datastore['priority']["$old"]['priority'], + $this->registry->datastore['priority']["$new"]['priority'] + ); + } + } + + // ################################################################### + /** + * Sends an email telling users that the product, component, or version + * has changed. This is done all at once because you really need to see + * the whole thing in the notice. + * + * @access private + * + * @param array Original PCV + * @param array Modified PCV + */ + function notice_pcv_change($old, $new) + { + $userlist = $this->fetch_users_with_on_bit('otherfield'); + foreach ($userlist AS $userid => $user) + { + $this->notices["$user[userid]"][] = sprintf( +$this->registry->lang->string('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'] + ); + } + } + // ################################################################### /** * Sends the appropriate users information about a new comment being @@ -500,7 +580,7 @@ Initial report: $bug['bugid'], $bug['summary'], construct_user_display($this->registry->userinfo, false), - $this->registry->datastore['product']["$bug[productid]"]['title'] . '/' . (($bug['componentid']) ? $this->registry->datastore['product']["$bug[componentid]"]['title'] . '/' : '') . $this->registry->datastore['version']["$bug[versionid]"]['version'], + $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'] ); $this->users["$user[userid]"] = $user; -- 2.22.5