r808: Forgot closing ?>
[bugdar.git] / includes / class_logging.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
6 || #
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.
10 || #
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
14 || # more details.
15 || #
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 \*=====================================================================*/
21
22 /**
23 * Bug Change Logging
24 *
25 * This class is used to record changes in a bug's fields, comments, and
26 * attachments.
27 *
28 * @author Iris Studios, Inc.
29 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
30 * @version $Revision$
31 * @package Bugdar
32 *
33 */
34 class Logging
35 {
36 /**
37 * The original data to compare against
38 * @var array
39 * @access private
40 */
41 var $original = array();
42
43 /**
44 * Modified data
45 * @var array
46 * @access public
47 */
48 var $modified = array();
49
50 // ###################################################################
51 /**
52 * Assigns data into the $this->original or $this->modified array based
53 * on the passed arrays of information and the fields to add (and what
54 * name to add them under), the element they go into, and any prefix
55 *
56 * @access public
57 *
58 * @param bool TRUE for original, FALSE for modified
59 * @param array Data array
60 * @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')
61 * @param string Element to add to
62 * @param string Field prefix
63 */
64 function add_data($orig, $data, $fields, $element = '', $prefix = '')
65 {
66 $array = ($orig ? 'original' : 'modified');
67 $prefix .= ($prefix != '' ? '.' : '');
68
69 foreach ($fields AS $fname => $fdisplay)
70 {
71 if (is_numeric($fname))
72 {
73 $fname = $fdisplay;
74 }
75
76 $this->$array["$element"]["$prefix$fdisplay"] = $data["$fname"];
77 }
78 }
79 }
80
81 /*=====================================================================*\
82 || ###################################################################
83 || # $HeadURL$
84 || # $Id$
85 || ###################################################################
86 \*=====================================================================*/
87 ?>