bugid = $newbugid; } // ################################################################### /** * 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 = '') { $array = ($orig ? 'original' : 'modified'); $prefix .= '.'; if ($exclude == false) { foreach ($fields AS $fname => $fdisplay) { if (is_numeric($fname)) { $fname = $fdisplay; } $this->{$array}["$prefix$fdisplay"] = array('name' => $fname, 'value' => $data["$fname"]); } } else { foreach ($data AS $fname => $value) { if (!in_array($fname, $fields)) { $this->{$array}["$prefix$fname"] = array('name' => $fname, 'value' => $value); } } } } // ################################################################### /** * 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() { $newfields = array_diff_assoc($this->modified, $this->original); $removedfields = array_diff_assoc($this->original, $this->modified); foreach ($this->modified AS $key => $value) { if ($this->original["$key"] != $value) { $this->compared["$key"] = array('old' => $this->original["$key"]['value'], 'new' => $this->modified["$key"]['value']); } } foreach ($newfields AS $field) { $this->compared["$field"] = array('old' => null, 'new' => $this->modified["$field"]['value']); } foreach ($removedfields AS $field) { $this->compared["$field"] = array('old' => $this->original["$field"]['value'], 'new' => null); } } // ################################################################### /** * Runs $this->compare_arrays() and then takes the result and prepares * it for insertion into the history database. * * @access public */ function update_history() { $this->compare_arrays(); } } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>