From 3410319f50d23a9e38d11995f48f97e6f07fd490 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 3 Jun 2006 20:36:51 +0000 Subject: [PATCH] r864: We now have all the notices worked out except newattach --- editreport.php | 6 +-- includes/class_notification.php | 71 ++++++++++++++++++++++++++++++++- 2 files changed, 72 insertions(+), 5 deletions(-) diff --git a/editreport.php b/editreport.php index cf1e31b..71ac01e 100644 --- a/editreport.php +++ b/editreport.php @@ -191,12 +191,12 @@ if ($_POST['do'] == 'update') // ------------------------------------------------------------------- // do diff history - $fields = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]"); - $log->add_data(false, $fields, array('bugid'), true, 'custom'); + $fieldsnew = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]"); + $log->add_data(false, $fieldsnew, array('bugid'), true, 'custom'); $log->update_history(); - $notif->send_bug_changes_notice($, $bugapi->values); + $notif->send_bug_changes_notice($fields, $fieldsnew); print_r($notif); diff --git a/includes/class_notification.php b/includes/class_notification.php index 32bd7e5..6eee92b 100644 --- a/includes/class_notification.php +++ b/includes/class_notification.php @@ -193,8 +193,11 @@ class NotificationCenter * with the differences. * * @access public + * + * @param array Original custom fields data + * @param array Modified custom fields data */ - function send_bug_changes_notice() + function send_bug_changes_notice($original, $modified) { if (!isset($this->modified['bugid'])) { @@ -226,6 +229,36 @@ class NotificationCenter { $this->notice_duplicates_change($this->original['duplicates'], $this->modified['duplicates']); } + + $dofields = array( + 'summary' => -1, + 'severity' => 'severityid', + 'dependency' => -1, + 'productid' => -1, + 'componentid' => -1, + 'versionid' => -1, + 'hidden' => -1, + 'priority' => 'priorityid' + ); + foreach ($dofields AS $field => $lookup) + { + if ($this->original["$field"] != $this->modified["$field"]) + { + $this->notice_other_change($field, $this->original["$field"], $this->modified["$field"]); + } + } + + foreach ($modified AS $field => $value) + { + if ($field == 'bugid') + { + continue; + } + if ($original["$field"] != $modified["$field"]) + { + $this->notice_other_change($field, $original["$field"], $modified["$field"]); + } + } } // ################################################################### @@ -326,7 +359,16 @@ $this->registry->lang->string('The resolution field has changed from "%1$s" to " */ function notice_duplicates_change($old, $new) { - + $userlist = $this->fetch_useres_with_on_bit('duplicates'); + foreach ($userlist AS $userid => $user) + { + $this->notices["$user[userid]"][] = sprintf( +$this->registry->lang->string('The duplicates list has changed from "%1$s" to %2$s".'), + + $old, + $new + ); + } } // ################################################################### @@ -356,6 +398,31 @@ $this->registry->lang->string('The following comment was added by %1$s on %2$s: } } + // ################################################################### + /** + * A notice for an individual field changing. + * + * @access private + * + * @param string Field name + * @param mixed Original value + * @param mixed Modified value + */ + function notice_other_change($name, $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 %1$s field changed from "%2$s" to "%3$s".'), + + $name, + $old, + $new + ); + } + } + // ################################################################### /** * Generates an array of users who have a given email notification flag -- 2.22.5