]>
src.bluestatic.org Git - bugdar.git/blob - includes/class_history.php
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 \*=====================================================================*/
34 var $attachmentid = 0;
43 * Allow diff's that have an empty result (no change)
46 var $allowempty = false;
49 * Logs a field change into the database
51 * @param array Diff data produced by diff()
53 function log($diffdata = null)
57 $this->bugid
= intval($this->bugid
);
58 $this->attachmentid
= intval($this->attachmentid
);
59 $this->commentid
= intval($this->commentid
);
72 INSERT INTO " . TABLE_PREFIX
. "history
73 (bugid, attachmentid, commentid, dateline, userid, field, original, changed)
75 (" . $this->bugid
. ", " . $this->attachmentid
. ", " . $this->commentid
. ", " . TIMENOW
. ",
76 " . $bugsys->userinfo
['userid'] . ", '" . $bugsys->escape($diffdata['field']) . "',
77 '" . $bugsys->escape($diffdata['initial']) . "', '" . $bugsys->escape($diffdata['final']) . "'
83 * Compares two values and creates a report of their differences
85 * @param string Name of the field
86 * @param mixed Initial value
87 * @param mixed Final value
89 * @return array Difference report
91 function diff($field, $initial, $final)
93 $field = trim($field);
94 $initial = trim($initial);
95 $final = trim($final);
102 if (empty($initial) AND empty($final))
104 if (!$this->allowempty
)
110 if (!$this->allowempty
)
112 if ($initial === $final)
118 return array('field' => $field, 'initial' => $initial, 'final' => $final);
122 /*=====================================================================*\
123 || ###################################################################
126 || ###################################################################
127 \*=====================================================================*/