From c9a8d365d1ab990657d53f2da60672b064a30792 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 10 May 2006 04:57:05 +0000 Subject: [PATCH] r816: - Finish implementing the Logging class - Add attachmentid and commentid support - Re-enable editing in editreport.php --- editreport.php | 4 +-- includes/class_logging.php | 56 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/editreport.php b/editreport.php index 73462b2..3a97462 100644 --- a/editreport.php +++ b/editreport.php @@ -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]"); } diff --git a/includes/class_logging.php b/includes/class_logging.php index 9e3798d..feec5be 100644 --- a/includes/class_logging.php +++ b/includes/class_logging.php @@ -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']) . "' + ) + "); + } } } -- 2.22.5