From 7f4c5c2ac25eb655d62e64a0cafdfda9e33b0e12 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 16 Sep 2008 13:21:52 -0400 Subject: [PATCH] Update class_logging.php --- includes/class_logging.php | 185 ++++++++++++++++--------------------- 1 file changed, 79 insertions(+), 106 deletions(-) diff --git a/includes/class_logging.php b/includes/class_logging.php index 4612e12..d7dd0d0 100644 --- a/includes/class_logging.php +++ b/includes/class_logging.php @@ -27,122 +27,104 @@ DELETE FROM history WHERE field IN ('lastposttime', 'lastpostby', 'hiddenlastpos */ /** -* Bug Change Logging -* -* This class is used to record changes in a bug's fields, comments, and -* attachments. -* -* @author Blue Static -* @copyright Copyright ©2002 - 2007, Blue Static -* @version $Revision$ -* @package Bugdar -* -*/ + * Bug Change Logging + * + * This class is used to record changes in a bug's fields, comments, and + * attachments. + * + * @author Blue Static + * @copyright Copyright ©2002 - 2007, Blue Static + * @version $Revision$ + * @package Bugdar + * + */ class Logging { /** - * Bug ID - * @var integer - * @access private - */ - var $bugid = 0; + * Bug ID + * @var integer + */ + private $bugid = 0; /** - * Attachment ID - * @var integer - * @access private - */ - var $attachmentid = 0; + * Attachment ID + * @var integer + */ + private $attachmentid = 0; /** - * Comment ID - * @var integer - * @access private - */ - var $commentid = 0; + * Comment ID + * @var integer + */ + private $commentid = 0; /** - * The original data to compare against - * @var array - * @access private - */ - var $original = array(); + * The original data to compare against + * @var array + */ + private $original = array(); /** - * Modified data - * @var array - * @access private - */ - var $modified = array(); + * Modified data + * @var array + */ + private $modified = array(); /** - * Compared/diff'd data - * @var array - * @access private - */ - var $compared = array(); + * Compared/diff'd data + * @var array + */ + private $compared = array(); - // ################################################################### /** - * Sets the bug ID for the current logging instance - * - * @access public - * - * @param integer New bug ID - */ - function set_bugid($id) + * Sets the bug ID for the current logging instance + * + * @param integer New bug ID + */ + public function setBugId($id) { $this->bugid = BSApp::$input->clean($id, TYPE_UINT); } - // ################################################################### /** - * Sets the attachment ID for the current logging instance - * - * @access public - * - * @param integer New attachment ID - */ - function set_attachmentid($id) + * Sets the attachment ID for the current logging instance + * + * @param integer New attachment ID + */ + public function setAttachmentId($id) { $this->attachmentid = BSApp::$input->clean($id, TYPE_UINT); } - // ################################################################### /** - * Sets the current comment ID to be logged - * - * @access public - * - * @param integer New comment ID - */ - function set_commentid($id) + * Sets the current comment ID to be logged + * + * @param integer New comment ID + */ + public function setCommentId($id) { $this->commentid = BSApp::$input->clean($id, TYPE_UINT); } - // ################################################################### /** - * Assigns data into the $this->original or $this->modified array based - * on the passed arrays of information and the fields to add (and what - * name to add them under), and any prefix - * - * @access public - * - * @param bool TRUE for original, FALSE for modified - * @param array Data array - * @param array List of fields in the data array to add; in format of array('field name' => 'display name', 'display name 2', 'display name 3') - * @param bool If TRUE, then the list of fields is used to exclude, not include - * @param string Field prefix - */ - function add_data($orig, $data, $fields, $exclude = false, $prefix = '') + * Assigns data into the $this->original or $this->modified array based + * on the passed arrays of information and the fields to add (and what + * name to add them under), and any prefix + * + * @param bool TRUE for original, FALSE for modified + * @param array Data array + * @param array List of fields in the data array to add; in format of array('field name' => 'display name', 'display name 2', 'display name 3') + * @param bool If TRUE, then the list of fields is used to exclude, not include + * @param string Field prefix + */ + public function addData($orig, $data, $fields, $exclude = false, $prefix = '') { $array = ($orig ? 'original' : 'modified'); $prefix .= '.'; if ($exclude == false) { - foreach ($fields AS $fname => $fdisplay) + foreach ($fields as $fname => $fdisplay) { if (is_numeric($fname)) { @@ -154,7 +136,7 @@ class Logging } else { - foreach ($data AS $fname => $value) + foreach ($data as $fname => $value) { if (!in_array($fname, $fields)) { @@ -164,36 +146,30 @@ class Logging } } - // ################################################################### /** - * Populates the $this->compared array as a diff between the original - * and modified data. This is then used to create the databse queries. - * - * @access private - */ - function compare_arrays() + * Populates the $this->compared array as a diff between the original + * and modified data. This is then used to create the databse queries. + */ + private function _compareArrays() { foreach ($this->modified AS $key => $value) { - if ($this->original["$key"] != $value AND !($value['value'] == '' AND $this->original["$key"]['value'] == '0') AND !($this->original["$key"]['value'] == '' AND $value['value'] == '0')) + if ($this->original["$key"] != $value && !($value['value'] == '' && $this->original["$key"]['value'] == '0') && !($this->original["$key"]['value'] == '' && $value['value'] == '0')) { $this->compared["$key"] = array('old' => $this->original["$key"]['value'], 'new' => $this->modified["$key"]['value']); } } } - // ################################################################### /** - * Runs $this->compare_arrays() and then takes the result and prepares - * it for insertion into the history database. - * - * @access public - */ - function update_history() + * Runs $this->_compareArrays() and then takes the result and prepares + * it for insertion into the history database. + */ + public function updateHistory() { - $this->compare_arrays(); + $this->_compareArrays(); - foreach ($this->compared AS $field => $values) + foreach ($this->compared as $field => $values) { BSApp::$db->query(" INSERT INTO " . TABLE_PREFIX . "history @@ -208,15 +184,12 @@ class Logging } } - // ################################################################### /** - * Returns an array of the fields commonly ignored - * - * @access public - * - * @return array Fields ignored in logging - */ - function getCommonFields() + * Returns an array of the fields commonly ignored + * + * @return array Fields ignored in logging + */ + public function getCommonFields() { return array( 'bugid', -- 2.43.5