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') AND $bugsys->userinfo
['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')) AND !can_perform('canpostcomments'))
31 $message->error_permission();
36 $message->error('alert: bad bug');
39 if ($bug['hidden'] AND !can_perform('canviewhidden'))
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') AND $bugsys->userinfo
['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')))
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--------------- 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->language
= 'log_new_comment';
103 $log->arguments
= array($commentid);
109 if (!(((can_perform('caneditown') AND $bugsys->userinfo
['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')))
111 $message->redirect('inserted comment', "showreport.php?bugid=$bug[bugid]");
114 // -------------------------------------------------------------------
116 $pcv = parse_pcv_select($bugsys->in
['pcv_select'], true
);
118 if (!$bugsys->in
['summary'])
120 $message->error('you need to enter a summary');
124 $message->error('invalid product/component/version');
127 $hist[0] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
128 $hist2[0] = (array)$temp = $noinitialcustom = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
130 // -------------------------------------------------------------------
134 $autoaction = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = " . intval($bugsys->in
['autoaction']));
137 $autoaction['fields'] = unserialize($autoaction['fieldchanges']);
139 foreach ($autoaction['fields']['builtin'] AS $field => $value)
141 $bugsys->in
["$field"] = $value;
144 foreach ($autoaction['fields']['custom'] AS $field => $value)
146 $bugsys->in
["field$field"] = $value;
150 process_custom_fields($bug['bugid']);
152 $dependencies = preg_split('#([^0-9].*?)#', $bugsys->in
['dependency'], -1, PREG_SPLIT_NO_EMPTY
);
153 $dependencies = ((count($dependencies) < 1) ?
'' : implode(', ', $dependencies));
155 // #*# need to put in permission checks here because we do not show the fields the user has no permission to change in the edit section so they'll be blank on update
158 UPDATE " . TABLE_PREFIX
. "bug
159 SET summary = '" . $bugsys->in
['summary'] . "',
160 priority = " . intval($bugsys->in
['priority']) . ",
161 status = " . intval($bugsys->in
['status']) . ",
162 severity = " . intval($bugsys->in
['severity']) . ",
163 resolution = " . intval($bugsys->in
['resolution']) . ",
164 assignedto = " . intval($bugsys->in
['assignedto']) . ",
165 duplicateof = " . intval($bugsys->in
['duplicateof']) . ",
166 dependency = '$dependencies',
167 productid = " . $pcv['product'] . ",
168 componentid = " . $pcv['component'] . ",
169 versionid = " . $pcv['version'] . ",
170 hidden = " . intval($bugsys->in
['hidden']) . "
171 WHERE bugid = $bug[bugid]"
174 // -------------------------------------------------------------------
177 $hist[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
178 $hist2[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
180 $diff[0] = array_diff_assoc($hist[0], $hist[1]);
181 $diff[1] = array_diff_assoc($hist[1], $hist[0]);
183 $lookupindex = array(
184 'status' => 'status',
185 'severity' => 'severity',
186 'priority' => 'priority',
187 'versionid' => 'version',
188 'assignedto' => 'assignto',
189 'resolution' => 'resolution',
190 'productid' => 'product',
191 'componentid' => 'product'
194 $log->language
= 'log_update_bug';
196 foreach ($diff AS $num => $diffs)
198 foreach ($diffs AS $key => $value)
200 if (!isset($lookupindex["$key"]))
205 $ref = $lookupindex["$key"];
206 $temp =& $bugsys->datastore
["$ref"]["$value"];
207 $thevalue = $temp["$ref"];
208 $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
210 if ($key == 'assignedto')
212 $thevalue = (($temp['userid']) ?
construct_user_display($temp) : '');
215 else if ($key == 'productid' OR $key == 'componentid')
218 $thevalue = $temp['title'];
221 $diff["$num"]["$key"] = (($thevalue) ?
$thevalue . $idbit : '');
225 foreach ($diff[1] AS $key => $value)
227 $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"]));
230 $diff2[0] = array_diff_assoc($hist2[0], $hist2[1]);
231 $diff2[1] = array_diff_assoc($hist2[1], $hist2[0]);
233 if ($noinitialcustom === false
)
235 $canallowempty = true
;
236 $checkbox = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bugfield WHERE type = 'input_checkbox'");
237 while ($box = $db->fetch_array($checkbox))
239 $boxlist[] = 'field' . $box['fieldid'];
243 foreach ($diff2[1] AS $key => $value)
245 if (in_array($key, $boxlist) AND $canallowempty)
247 $log->allowempty
= true
;
251 $log->allowempty
= false
;
259 $log->log($log->diff('custom_' . $key, $diff2[0]["$key"], $diff2[1]["$key"]));
262 $log->allowempty
= false
;
264 $hascomment = (!empty($bugsys->in
['comment'])) ? true
: false
;
266 if ($hascomment OR $autoaction['comment'])
268 if ($hascomment AND $autoaction['comment'])
270 $bugsys->in
['comment'] .= "\n\n--------------- AUTOMATIC RESPONSE ---------------\n" . $autoaction['comment'];
272 else if (!$hascomment AND $autoaction['comment'])
274 $bugsys->in
['comment'] = $autoaction['comment'];
277 $bugsys->in
['comment_parsed'] = $bugsys->in
['comment'];
279 if (!$bugsys->options
['allowhtml'])
281 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
287 INSERT INTO " . TABLE_PREFIX
. "comment
288 (bugid, userid, dateline, comment, comment_parsed)
290 (" . intval($bugsys->in
['bugid']) . ", " . $bugsys->userinfo
['userid'] . ",
291 $time, '" . $bugsys->in
['comment'] . "',
292 '" . nl2br($bugsys->in
['comment_parsed']) . "'
296 $commentid = $db->insert_id();
299 UPDATE " . TABLE_PREFIX
. "bug
300 SET lastposttime = $time,
301 lastpostby = " . $bugsys->userinfo
['userid'] . ",
302 hiddenlastposttime = $time,
303 hiddenlastpostby = " . $bugsys->userinfo
['userid'] . "
304 WHERE bugid = " . intval($bugsys->in
['bugid'])
309 $log->language
= 'log_new_comment';
310 $log->arguments
= array($commentid);
316 $message->redirect('done with update bug', "showreport.php?bugid=$bug[bugid]");
319 /*=====================================================================*\
320 || ###################################################################
323 || ###################################################################
324 \*=====================================================================*/