2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
25 * This class is used to record changes in a bug's fields, comments, and
28 * @author Iris Studios, Inc.
29 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
44 * The original data to compare against
48 var $original = array();
55 var $modified = array();
57 // ###################################################################
59 * Sets the bug ID for the current logging instance
63 * @param integer New bug ID
65 function set_bugid($newbugid)
67 $this->bugid
= $newbugid;
70 // ###################################################################
72 * Assigns data into the $this->original or $this->modified array based
73 * on the passed arrays of information and the fields to add (and what
74 * name to add them under), the element they go into, and any prefix
78 * @param bool TRUE for original, FALSE for modified
79 * @param array Data array
80 * @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')
81 * @param string Element to add to
82 * @param string Field prefix
84 function add_data($orig, $data, $fields, $element = '', $prefix = '')
86 $array = ($orig ?
'original' : 'modified');
87 $prefix .= ($prefix != '' ?
'.' : '');
89 foreach ($fields AS $fname => $fdisplay)
91 if (is_numeric($fname))
96 $this->{$array}["$element"]["$prefix$fdisplay"] = $data["$fname"];
100 // ###################################################################
102 * Adds strings to the IDs so that it's human-readable and that's
103 * stored in the database so that if whatever value is deleted,
104 * the text still exists in the end. This takes the element and a list
105 * of fields to prossess in order to work.
109 * @param string Element name
110 * @param array List of fields to use
112 function process_fields($element, $fields)
114 foreach (array('original', 'modified') AS $array)
116 foreach ($this->{$array}["$element"] AS $display => $fname)
118 if (in_array($fname, $fields))
127 /*=====================================================================*\
128 || ###################################################################
131 || ###################################################################
132 \*=====================================================================*/