2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # All parts of this file are ©2002-[#]year[#] Iris Studios, Inc. No # ||
7 || # part of this file may be reproduced in any way: part or whole. # ||
8 || # --------------------------------------------------------------- # ||
9 || # ©2002 - [#]year[#] Iris Studios, Inc. | http://www.iris-studios.com # ||
10 || ################################################################### ||
11 \*=====================================================================*/
13 define('SVN', '$Id$');
15 $focus['showreport'] = 'focus';
17 require_once('./global.php');
19 $bug = $db->query_first("
20 SELECT bugvaluefill.*, bug.*, user.email, user.displayname, user.showemail
21 FROM " . TABLE_PREFIX
. "bug AS bug
22 LEFT JOIN " . TABLE_PREFIX
. "user AS user
23 ON (bug.userid = user.userid)
24 LEFT JOIN " . TABLE_PREFIX
. "bugvaluefill AS bugvaluefill
25 ON (bug.bugid = bugvaluefill.bugid)
26 WHERE bug.bugid = " . intval($bugsys->in
['bugid'])
29 if (!(((can_perform('caneditown', $bug['productid']) AND $bugsys->userinfo
['userid'] == $comment['userid']) OR can_perform('caneditothers', $bug['productid'])) AND can_perform('caneditinfo', $bug['productid'])) AND !can_perform('canpostcomments', $bug['productid']))
31 $message->error_permission();
36 $message->error($lang->getlex('error_invalid_id'));
39 if ($bug['hidden'] AND !can_perform('canviewhidden', $bug['productid']))
41 $message->error_permission();
45 require_once('./includes/class_history.php');
47 $log->bugid
= $bug['bugid'];
49 // ###################################################################
51 if ($_POST['do'] == 'update')
53 // -------------------------------------------------------------------
54 // process comment stuff
55 if (!(((can_perform('caneditown', $bug['productid']) AND $bugsys->userinfo
['userid'] == $comment['userid']) OR can_perform('caneditothers', $bug['productid'])) AND can_perform('caneditinfo', $bug['productid'])))
57 $hascomment = (!empty($bugsys->in
['comment'])) ? true
: false
;
59 if ($hascomment OR $autoaction['comment'])
61 if ($hascomment AND $autoaction['comment'])
63 $bugsys->in
['comment'] .= "\n\n" . $lang->string('--------------- AUTOMATIC RESPONSE ---------------') . "\n" . $autoaction['comment'];
65 else if (!$hascomment AND $autoaction['comment'])
67 $bugsys->in
['comment'] = $autoaction['comment'];
70 $bugsys->in
['comment_parsed'] = $bugsys->in
['comment'];
72 if (!$bugsys->options
['allowhtml'])
74 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
80 INSERT INTO " . TABLE_PREFIX
. "comment
81 (bugid, userid, dateline, comment, comment_parsed)
83 (" . intval($bugsys->in
['bugid']) . ", " . $bugsys->userinfo
['userid'] . ",
84 $time, '" . $bugsys->in
['comment'] . "',
85 '" . nl2br($bugsys->in
['comment_parsed']) . "'
89 $commentid = $db->insert_id();
92 UPDATE " . TABLE_PREFIX
. "bug
93 SET lastposttime = $time,
94 lastpostby = " . $bugsys->userinfo
['userid'] . ",
95 hiddenlastposttime = $time,
96 hiddenlastpostby = " . $bugsys->userinfo
['userid'] . "
97 WHERE bugid = " . intval($bugsys->in
['bugid'])
102 $log->arguments
= array($commentid);
108 if (!(((can_perform('caneditown', $bug['productid']) AND $bugsys->userinfo
['userid'] == $comment['userid']) OR can_perform('caneditothers', $bug['productid'])) AND can_perform('caneditinfo', $bug['productid'])))
110 $message->redirect($lang->string('Your reply has been added to the comment list.'), "showreport.php?bugid=$bug[bugid]");
113 // -------------------------------------------------------------------
115 $pcv = parse_pcv_select($bugsys->in
['pcv_select'], true
);
117 if (!$bugsys->in
['summary'])
119 $message->error($lang->string('You need to enter a summary for this bug.'));
123 $message->error($lang->string('Invalid product/component/version selected.'));
126 $hist[0] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
127 $hist2[0] = (array)$temp = $noinitialcustom = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
129 // -------------------------------------------------------------------
133 $autoaction = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = " . intval($bugsys->in
['autoaction']));
136 $autoaction['fields'] = unserialize($autoaction['fieldchanges']);
138 foreach ($autoaction['fields']['builtin'] AS $field => $value)
140 $bugsys->in
["$field"] = $value;
143 foreach ($autoaction['fields']['custom'] AS $field => $value)
145 $bugsys->in
["field$field"] = $value;
149 process_custom_fields($bug['bugid']);
151 $dependencies = preg_split('#([^0-9].*?)#', $bugsys->in
['dependency'], -1, PREG_SPLIT_NO_EMPTY
);
152 $dependencies = ((count($dependencies) < 1) ?
'' : implode(', ', $dependencies));
155 UPDATE " . TABLE_PREFIX
. "bug
156 SET summary = '" . $bugsys->in
['summary'] . "',
157 severity = " . intval($bugsys->in
['severity']) . "," .
158 (can_perform('canchangestatus', $bug['productid']) ?
"
159 priority = " . intval($bugsys->in
['priority']) . ",
160 status = " . intval($bugsys->in
['status']) . ",
161 resolution = " . intval($bugsys->in
['resolution']) . ","
163 " . (can_perform('canassign', $bug['productid']) ?
"assignedto = " . intval($bugsys->in
['assignedto']) . "," : '') . "
164 duplicateof = " . intval($bugsys->in
['duplicateof']) . ",
165 dependency = '$dependencies',
166 productid = " . $pcv['product'] . ",
167 componentid = " . $pcv['component'] . ",
168 versionid = " . $pcv['version'] . ",
169 hidden = " . intval($bugsys->in
['hidden']) . "
170 WHERE bugid = $bug[bugid]"
173 // -------------------------------------------------------------------
176 $hist[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
177 $hist2[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
179 $diff[0] = array_diff_assoc($hist[0], $hist[1]);
180 $diff[1] = array_diff_assoc($hist[1], $hist[0]);
182 $lookupindex = array(
183 'status' => 'status',
184 'severity' => 'severity',
185 'priority' => 'priority',
186 'versionid' => 'version',
187 'assignedto' => 'assignto',
188 'resolution' => 'resolution',
189 'productid' => 'product',
190 'componentid' => 'product'
193 foreach ($diff AS $num => $diffs)
195 foreach ($diffs AS $key => $value)
197 if (!isset($lookupindex["$key"]))
202 $ref = $lookupindex["$key"];
203 $temp =& $bugsys->datastore
["$ref"]["$value"];
204 $thevalue = $temp["$ref"];
205 $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
207 if ($key == 'assignedto')
209 $thevalue = (($temp['userid']) ?
construct_user_display($temp) : '');
212 else if ($key == 'productid' OR $key == 'componentid')
215 $thevalue = $temp['title'];
218 $diff["$num"]["$key"] = (($thevalue) ?
$thevalue . $idbit : '');
222 foreach ($diff[1] AS $key => $value)
224 $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"]));
227 $diff2[0] = array_diff_assoc($hist2[0], $hist2[1]);
228 $diff2[1] = array_diff_assoc($hist2[1], $hist2[0]);
230 if ($noinitialcustom === false
)
232 $canallowempty = true
;
233 $checkbox = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bugfield WHERE type = 'input_checkbox'");
234 while ($box = $db->fetch_array($checkbox))
236 $boxlist[] = 'field' . $box['fieldid'];
240 foreach ($diff2[1] AS $key => $value)
242 if (in_array($key, $boxlist) AND $canallowempty)
244 $log->allowempty
= true
;
248 $log->allowempty
= false
;
256 $log->log($log->diff('custom_' . $key, $diff2[0]["$key"], $diff2[1]["$key"]));
259 $log->allowempty
= false
;
261 // -------------------------------------------------------------------
263 $hascomment = (!empty($bugsys->in
['comment'])) ? true
: false
;
265 if ($hascomment OR $autoaction['comment'])
267 if ($hascomment AND $autoaction['comment'])
269 $bugsys->in
['comment'] .= "\n\n" . $lang->string('--------------- AUTOMATIC RESPONSE ---------------') . "\n" . $autoaction['comment'];
271 else if (!$hascomment AND $autoaction['comment'])
273 $bugsys->in
['comment'] = $autoaction['comment'];
276 $bugsys->in
['comment_parsed'] = $bugsys->in
['comment'];
278 if (!$bugsys->options
['allowhtml'])
280 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
286 INSERT INTO " . TABLE_PREFIX
. "comment
287 (bugid, userid, dateline, comment, comment_parsed)
289 (" . intval($bugsys->in
['bugid']) . ", " . $bugsys->userinfo
['userid'] . ",
290 $time, '" . $bugsys->in
['comment'] . "',
291 '" . nl2br($bugsys->in
['comment_parsed']) . "'
295 $commentid = $db->insert_id();
298 UPDATE " . TABLE_PREFIX
. "bug
299 SET lastposttime = $time,
300 lastpostby = " . $bugsys->userinfo
['userid'] . ",
301 hiddenlastposttime = $time,
302 hiddenlastpostby = " . $bugsys->userinfo
['userid'] . "
303 WHERE bugid = " . intval($bugsys->in
['bugid'])
308 $message->redirect($lang->string('Your changes to the bug have been saved.'), "showreport.php?bugid=$bug[bugid]");
311 /*=====================================================================*\
312 || ###################################################################
315 || ###################################################################
316 \*=====================================================================*/