r816: - Finish implementing the Logging class
authorRobert Sesek <rsesek@bluestatic.org>
Wed, 10 May 2006 04:57:05 +0000 (04:57 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Wed, 10 May 2006 04:57:05 +0000 (04:57 +0000)
- Add attachmentid and commentid support
- Re-enable editing in editreport.php

editreport.php
includes/class_logging.php

index 73462b2ddf07e16acf82f257f2a319694f0bf9de..3a974626a68f6791467e7a384a0e4e973dcf3a17 100644 (file)
@@ -177,7 +177,7 @@ if ($_POST['do'] == 'update')
        
        $log->add_data(false, $bugapi->values, $bugfields);
        
-       //$bugapi->update();
+       $bugapi->update();
        
        // -------------------------------------------------------------------
        // do diff history
@@ -187,8 +187,6 @@ if ($_POST['do'] == 'update')
        
        $log->update_history();
        
-       print_r($log); exit;
-       
        $message->redirect($lang->string('Your changes to the bug have been saved.'), "showreport.php?bugid=$bug[bugid]");
 }
 
index 9e3798db34452fabfb3f7dd0eeecb2aef7d173d0..feec5beb06c0d2099aff3b964c869e5d88121ba5 100644 (file)
@@ -47,6 +47,20 @@ class Logging
        */
        var $bugid = 0;
        
+       /**
+       * Attachment ID
+       * @var  integer
+       * @access       private
+       */
+       var $attachmentid = 0;
+       
+       /**
+       * Comment ID
+       * @var  integer
+       * @access       private
+       */
+       var $commentid = 0;
+       
        /**
        * The original data to compare against
        * @var  array
@@ -81,6 +95,32 @@ class Logging
                $this->bugid = $newbugid;
        }
        
+       // ###################################################################
+       /**
+       * Sets the attachment ID for the current logging instance
+       *
+       * @access       public
+       *
+       * @param        integer New attachment ID
+       */
+       function set_attachmentid($id)
+       {
+               $this->attachmentid = $id;
+       }
+       
+       // ###################################################################
+       /**
+       * Sets the current comment ID to be logged
+       *
+       * @access       public
+       *
+       * @param        integer New comment ID
+       */
+       function set_commentid($id)
+       {
+               $this->commentid = $id;
+       }
+       
        // ###################################################################
        /**
        * Assigns data into the $this->original or $this->modified array based
@@ -164,7 +204,23 @@ class Logging
        */
        function update_history()
        {
+               global $bugsys;
+               
                $this->compare_arrays();
+               
+               foreach ($this->compared AS $field => $values)
+               {
+                       $bugsys->db->query("
+                               INSERT INTO " . TABLE_PREFIX . "history
+                                       (bugid, attachmentid, commentid, dateline, userid, field, original, changed)
+                               VALUES
+                                       (" . $bugsys->clean($this->bugid, TYPE_UINT) . ", " . $bugsys->clean($this->attachmentid, TYPE_UINT) . ",
+                                       " . $bugsys->clean($this->commentid, TYPE_UINT) . ", " . TIMENOW . ", " . $bugsys->userinfo['userid'] . ",
+                                       '" . $bugsys->db->escape_string($field) . "', '" . $bugsys->db->escape_string($values['old']) . "',
+                                       '" . $bugsys->db->escape_string($values['new']) . "'
+                               )
+                       ");
+               }
        }
 }