r810: More logging stuff
[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 * Bug ID
38 * @var integer
39 * @access private
40 */
41 var $bugid = 0;
42
43 /**
44 * The original data to compare against
45 * @var array
46 * @access private
47 */
48 var $original = array();
49
50 /**
51 * Modified data
52 * @var array
53 * @access private
54 */
55 var $modified = array();
56
57 // ###################################################################
58 /**
59 * Sets the bug ID for the current logging instance
60 *
61 * @access public
62 *
63 * @param integer New bug ID
64 */
65 function set_bugid($newbugid)
66 {
67 $this->bugid = $newbugid;
68 }
69
70 // ###################################################################
71 /**
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
75 *
76 * @access public
77 *
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
83 */
84 function add_data($orig, $data, $fields, $element = '', $prefix = '')
85 {
86 $array = ($orig ? 'original' : 'modified');
87 $prefix .= ($prefix != '' ? '.' : '');
88
89 foreach ($fields AS $fname => $fdisplay)
90 {
91 if (is_numeric($fname))
92 {
93 $fname = $fdisplay;
94 }
95
96 $this->{$array}["$element"]["$prefix$fdisplay"] = $data["$fname"];
97 }
98 }
99
100 // ###################################################################
101 /**
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.
106 *
107 * @access public
108 *
109 * @param string Element name
110 * @param array List of fields to use
111 */
112 function process_fields($element, $fields)
113 {
114 foreach (array('original', 'modified') AS $array)
115 {
116 foreach ($this->{$array}["$element"] AS $display => $fname)
117 {
118 if (in_array($fname, $fields))
119 {
120
121 }
122 }
123 }
124 }
125 }
126
127 /*=====================================================================*\
128 || ###################################################################
129 || # $HeadURL$
130 || # $Id$
131 || ###################################################################
132 \*=====================================================================*/
133 ?>