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 \*=====================================================================*/
22 define('SVN', '$Id$');
24 $focus['showreport'] = 'focus';
26 require_once('./global.php');
27 require_once('./includes/functions_product.php');
29 $bug = $db->query_first("
30 SELECT bugvaluefill.*, bug.*, user.email, user.displayname, user.showemail
31 FROM " . TABLE_PREFIX
. "bug AS bug
32 LEFT JOIN " . TABLE_PREFIX
. "user AS user
33 ON (bug.userid = user.userid)
34 LEFT JOIN " . TABLE_PREFIX
. "bugvaluefill AS bugvaluefill
35 ON (bug.bugid = bugvaluefill.bugid)
36 WHERE bug.bugid = " . intval($bugsys->in
['bugid'])
39 if (!((can_perform('caneditown', $bug['productid']) AND $bugsys->userinfo
['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['productid']) AND $bugsys->userinfo
['userid'] != $bug['userid'])) AND !can_perform('canpostcomments', $bug['productid']))
41 $message->error_permission();
46 $message->error($lang->getlex('error_invalid_id'));
49 if ($bug['hidden'] AND !can_perform('canviewhidden', $bug['productid']))
51 $message->error_permission();
55 require_once('./includes/class_history.php');
57 $log->bugid
= $bug['bugid'];
59 // ###################################################################
61 if ($_POST['do'] == 'update')
63 // -------------------------------------------------------------------
64 // process comment stuff
65 if (!((can_perform('caneditown', $bug['productid']) AND $bugsys->userinfo
['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['productid']) AND $bugsys->userinfo
['userid'] != $bug['userid'])))
67 $hascomment = (!empty($bugsys->in
['comment'])) ? true
: false
;
69 if ($hascomment OR $autoaction['comment'])
71 if ($hascomment AND $autoaction['comment'])
73 $bugsys->in
['comment'] .= "\n\n" . $lang->string('--------------- AUTOMATIC RESPONSE ---------------') . "\n" . $autoaction['comment'];
75 else if (!$hascomment AND $autoaction['comment'])
77 $bugsys->in
['comment'] = $autoaction['comment'];
80 $bugsys->in
['comment_parsed'] = $bugsys->in
['comment'];
82 if (!$bugsys->options
['allowhtml'])
84 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
90 INSERT INTO " . TABLE_PREFIX
. "comment
91 (bugid, userid, dateline, comment, comment_parsed)
93 (" . intval($bugsys->in
['bugid']) . ", " . $bugsys->userinfo
['userid'] . ",
94 $time, '" . $bugsys->in
['comment'] . "',
95 '" . nl2br($bugsys->in
['comment_parsed']) . "'
99 $commentid = $db->insert_id();
102 UPDATE " . TABLE_PREFIX
. "bug
103 SET lastposttime = $time,
104 lastpostby = " . $bugsys->userinfo
['userid'] . ",
105 hiddenlastposttime = $time,
106 hiddenlastpostby = " . $bugsys->userinfo
['userid'] . "
107 WHERE bugid = " . intval($bugsys->in
['bugid'])
112 $log->arguments
= array($commentid);
117 $message->redirect($lang->string('Your reply has been added to the comment list.'), "showreport.php?bugid=$bug[bugid]");
120 // -------------------------------------------------------------------
122 $pcv = parse_pcv_select($bugsys->in
['pcv_select'], true
);
124 if (!$bugsys->in
['summary'])
126 $message->error($lang->string('You need to enter a summary for this bug.'));
130 $message->error($lang->string('Invalid product/component/version selected.'));
133 $hist[0] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
134 $hist2[0] = (array)$temp = $noinitialcustom = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
136 // -------------------------------------------------------------------
140 $autoaction = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = " . intval($bugsys->in
['autoaction']));
143 $autoaction['fields'] = unserialize($autoaction['fieldchanges']);
145 foreach ($autoaction['fields']['builtin'] AS $field => $value)
147 $bugsys->in
["$field"] = $value;
150 foreach ($autoaction['fields']['custom'] AS $field => $value)
152 $bugsys->in
["field$field"] = $value;
156 process_custom_fields($bug['bugid']);
158 $dependencies = preg_split('#([^0-9].*?)#', $bugsys->in
['dependency'], -1, PREG_SPLIT_NO_EMPTY
);
159 $dependencies = ((count($dependencies) < 1) ?
'' : implode(', ', $dependencies));
162 UPDATE " . TABLE_PREFIX
. "bug
163 SET summary = '" . $bugsys->in
['summary'] . "',
164 severity = " . intval($bugsys->in
['severity']) . "," .
165 (can_perform('canchangestatus', $bug['productid']) ?
"
166 priority = " . intval($bugsys->in
['priority']) . ",
167 status = " . intval($bugsys->in
['status']) . ",
168 resolution = " . intval($bugsys->in
['resolution']) . ","
170 " . (can_perform('canassign', $bug['productid']) ?
"assignedto = " . intval($bugsys->in
['assignedto']) . "," : '') . "
171 duplicateof = " . intval($bugsys->in
['duplicateof']) . ",
172 dependency = '$dependencies',
173 productid = " . $pcv['product'] . ",
174 componentid = " . $pcv['component'] . ",
175 versionid = " . $pcv['version'] . ",
176 hidden = " . intval($bugsys->in
['hidden']) . "
177 WHERE bugid = $bug[bugid]"
180 // -------------------------------------------------------------------
183 $hist[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
184 $hist2[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
186 $diff[0] = array_diff_assoc($hist[0], $hist[1]);
187 $diff[1] = array_diff_assoc($hist[1], $hist[0]);
189 $lookupindex = array(
190 'status' => 'status',
191 'severity' => 'severity',
192 'priority' => 'priority',
193 'versionid' => 'version',
194 'assignedto' => 'assignto',
195 'resolution' => 'resolution',
196 'productid' => 'product',
197 'componentid' => 'product'
200 foreach ($diff AS $num => $diffs)
202 foreach ($diffs AS $key => $value)
204 if (!isset($lookupindex["$key"]))
209 $ref = $lookupindex["$key"];
210 $temp =& $bugsys->datastore
["$ref"]["$value"];
211 $thevalue = $temp["$ref"];
212 $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
214 if ($key == 'assignedto')
216 $thevalue = (($temp['userid']) ?
construct_user_display($temp) : '');
219 else if ($key == 'productid' OR $key == 'componentid')
222 $thevalue = $temp['title'];
225 $diff["$num"]["$key"] = (($thevalue) ?
$thevalue . $idbit : '');
229 foreach ($diff[1] AS $key => $value)
231 $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"]));
234 $diff2[0] = array_diff_assoc($hist2[0], $hist2[1]);
235 $diff2[1] = array_diff_assoc($hist2[1], $hist2[0]);
237 if ($noinitialcustom === false
)
239 $canallowempty = true
;
240 $checkbox = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bugfield WHERE type = 'input_checkbox'");
241 while ($box = $db->fetch_array($checkbox))
243 $boxlist[] = 'field' . $box['fieldid'];
247 foreach ($diff2[1] AS $key => $value)
249 if (in_array($key, $boxlist) AND $canallowempty)
251 $log->allowempty
= true
;
255 $log->allowempty
= false
;
263 $log->log($log->diff('custom_' . $key, $diff2[0]["$key"], $diff2[1]["$key"]));
266 $log->allowempty
= false
;
268 // -------------------------------------------------------------------
270 $hascomment = (!empty($bugsys->in
['comment'])) ? true
: false
;
272 if ($hascomment OR $autoaction['comment'])
274 if ($hascomment AND $autoaction['comment'])
276 $bugsys->in
['comment'] .= "\n\n" . $lang->string('--------------- AUTOMATIC RESPONSE ---------------') . "\n" . $autoaction['comment'];
278 else if (!$hascomment AND $autoaction['comment'])
280 $bugsys->in
['comment'] = $autoaction['comment'];
283 $bugsys->in
['comment_parsed'] = $bugsys->in
['comment'];
285 if (!$bugsys->options
['allowhtml'])
287 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
293 INSERT INTO " . TABLE_PREFIX
. "comment
294 (bugid, userid, dateline, comment, comment_parsed)
296 (" . intval($bugsys->in
['bugid']) . ", " . $bugsys->userinfo
['userid'] . ",
297 $time, '" . $bugsys->in
['comment'] . "',
298 '" . nl2br($bugsys->in
['comment_parsed']) . "'
302 $commentid = $db->insert_id();
305 UPDATE " . TABLE_PREFIX
. "bug
306 SET lastposttime = $time,
307 lastpostby = " . $bugsys->userinfo
['userid'] . ",
308 hiddenlastposttime = $time,
309 hiddenlastpostby = " . $bugsys->userinfo
['userid'] . "
310 WHERE bugid = " . intval($bugsys->in
['bugid'])
315 $message->redirect($lang->string('Your changes to the bug have been saved.'), "showreport.php?bugid=$bug[bugid]");
318 /*=====================================================================*\
319 || ###################################################################
322 || ###################################################################
323 \*=====================================================================*/