r864: We now have all the notices worked out except newattach
authorRobert Sesek <rsesek@bluestatic.org>
Sat, 3 Jun 2006 20:36:51 +0000 (20:36 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Sat, 3 Jun 2006 20:36:51 +0000 (20:36 +0000)
editreport.php
includes/class_notification.php

index cf1e31baba54bed94af283c52d26a51f7fa41062..71ac01e471f160aea19bc7920211dc523534a2dc 100644 (file)
@@ -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);
        
index 32bd7e55d060ed63fdda5dd26c42bb6dd311d146..6eee92bc0d3500752f41f4e2236e059a97a89066 100644 (file)
@@ -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