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 $fetchtemplates = array(
18 define('SVN', '$Id$');
20 $focus['showreport
'] = 'focus
';
22 require_once('./global.php
');
24 $bug = $db->query_first("
25 SELECT bugvaluefill.*, bug.*, user.email, user.displayname, user.showemail
26 FROM " . TABLE_PREFIX . "bug AS bug
27 LEFT JOIN " . TABLE_PREFIX . "user AS user
28 ON (bug.userid = user.userid)
29 LEFT JOIN " . TABLE_PREFIX . "bugvaluefill AS bugvaluefill
30 ON (bug.bugid = bugvaluefill.bugid)
31 WHERE bug.bugid = " . intval($bugsys->in['bugid
'])
36 $message->error('alert
: bad bug
');
39 if (!(((can_perform('caneditown
') AND $bugsys->userinfo['userid
'] == $comment['userid
']) OR can_perform('caneditothers
')) AND can_perform('caneditinfo
')))
41 $message->error_permission();
44 if ($bug['hidden
'] AND !can_perform('canviewhidden
'))
46 $message->error_permission();
50 require_once('./includes
/class_history
.php
');
52 $log->bugid = $bug['bugid
'];
54 // ###################################################################
56 if (empty($_REQUEST['do']))
58 $_REQUEST['do'] = 'edit
';
61 // ###################################################################
63 if ($_POST['do'] == 'update
')
65 $pcv = parse_pcv_select($bugsys->in['pcv_select
'], true);
67 if (!$bugsys->in['summary
'])
69 $message->error('you need to enter a summary
');
73 $message->error('invalid product
/component
/version
');
76 $hist[0] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $bug[bugid]");
77 $hist2[0] = (array)$temp = $noinitialcustom = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]");
79 // -------------------------------------------------------------------
83 $autoaction = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "autoaction WHERE actionid = " . intval($bugsys->in['autoaction
']));
86 $autoaction['fields
'] = unserialize($autoaction['fieldchanges
']);
88 foreach ($autoaction['fields
']['builtin
'] AS $field => $value)
90 $bugsys->in["$field"] = $value;
93 foreach ($autoaction['fields
']['custom
'] AS $field => $value)
95 $bugsys->in["field$field"] = $value;
99 process_custom_fields($bug['bugid
']);
101 $dependencies = preg_split('#([^0-9].*?)#', $bugsys->in['dependency'], -1, PREG_SPLIT_NO_EMPTY);
102 $dependencies = ((count($dependencies) < 1) ? '' : implode(', ', $dependencies));
104 // #*# 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
107 UPDATE " . TABLE_PREFIX
. "bug
108 SET summary = '" . $bugsys->in
['summary'] . "',
109 priority = " . intval($bugsys->in
['priority']) . ",
110 status = " . intval($bugsys->in
['status']) . ",
111 severity = " . intval($bugsys->in
['severity']) . ",
112 resolution = " . intval($bugsys->in
['resolution']) . ",
113 assignedto = " . intval($bugsys->in
['assignedto']) . ",
114 duplicateof = " . intval($bugsys->in
['duplicateof']) . ",
115 dependency = '$dependencies',
116 productid = " . $pcv['product'] . ",
117 componentid = " . $pcv['component'] . ",
118 versionid = " . $pcv['version'] . ",
119 hidden = " . intval($bugsys->in
['hidden']) . "
120 WHERE bugid = $bug[bugid]"
123 // -------------------------------------------------------------------
126 $hist[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
127 $hist2[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
129 $diff[0] = array_diff_assoc($hist[0], $hist[1]);
130 $diff[1] = array_diff_assoc($hist[1], $hist[0]);
132 $lookupindex = array(
133 'status' => 'status',
134 'severity' => 'severity',
135 'priority' => 'priority',
136 'versionid' => 'version',
137 'assignedto' => 'assignto',
138 'resolution' => 'resolution',
139 'productid' => 'product',
140 'componentid' => 'product'
143 $log->language
= 'log_update_bug';
145 foreach ($diff AS $num => $diffs)
147 foreach ($diffs AS $key => $value)
149 if (!isset($lookupindex["$key"]))
154 $ref = $lookupindex["$key"];
155 $temp =& $bugsys->datastore
["$ref"]["$value"];
156 $thevalue = $temp["$ref"];
157 $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
159 if ($key == 'assignedto')
161 $thevalue = (($temp['userid']) ? construct_user_display($temp) : '');
164 else if ($key == 'productid' OR $key == 'componentid')
167 $thevalue = $temp['title'];
170 $diff["$num"]["$key"] = (($thevalue) ? $thevalue . $idbit : '');
174 foreach ($diff[1] AS $key => $value)
176 $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"]));
179 $diff2[0] = array_diff_assoc($hist2[0], $hist2[1]);
180 $diff2[1] = array_diff_assoc($hist2[1], $hist2[0]);
182 if ($noinitialcustom === false)
184 $canallowempty = true;
185 $checkbox = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bugfield WHERE type = 'input_checkbox'");
186 while ($box = $db->fetch_array($checkbox))
188 $boxlist[] = 'field' . $box['fieldid'];
192 foreach ($diff2[1] AS $key => $value)
194 if (in_array($key, $boxlist) AND $canallowempty)
196 $log->allowempty
= true;
200 $log->allowempty
= false;
208 $log->log($log->diff('custom_' . $key, $diff2[0]["$key"], $diff2[1]["$key"]));
211 $log->allowempty
= false;
213 // -------------------------------------------------------------------
214 // process comment stuff
216 if (!$bugsys->in
['firstcomment'])
218 $message->error('you need to enter some text in the first comment');
221 $bugsys->in
['comment_parsed'] = $bugsys->in
['firstcomment'];
223 if (!$bugsys->options
['allowhtml'])
225 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
228 // we could pass this as a GET param, but that's unsafe
229 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
232 UPDATE " . TABLE_PREFIX
. "comment
233 SET comment = '" . $bugsys->in
['firstcomment'] . "',
234 comment_parsed = '" . nl2br($bugsys->in
['comment_parsed']) . "'
235 WHERE commentid = $firstcomment[commentid]"
238 // -------------------------------------------------------------------
239 // auto action comment
241 if ($autoaction['comment'])
243 $comment = $autoaction['comment'];
244 if (!$bugsys->options
['allowhtml'])
246 $comment_parsed = $bugsys->sanitize($comment);
251 (bugid, userid, dateline, comment, comment_parsed)
253 ($bug[bugid], " . $bugsys->userinfo
['userid'] . ", " . LOG_TIME
. ",
254 '" . $bugsys->escape($comment) . "',
255 '" . $bugsys->escape($comment_parsed) . "'
260 UPDATE " . TABLE_PREFIX
. "bug
261 SET lastposttime = " . LOG_TIME
. ",
262 lastpostby = " . $bugsys->userinfo
['userid'] . ",
263 hiddenlastposttime = " . LOG_TIME
. ",
264 hiddenlastpostby = " . $bugsys->userinfo
['userid'] . "
265 WHERE bugid = $bug[bugid]"
269 $message->redirect('done with update bug', "showreport.php?bugid=$bug[bugid]");
272 // ###################################################################
274 if ($_REQUEST['do'] == 'edit')
276 $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid', $bug['severity']);
278 $show['changestatus'] = ((can_perform('canchangestatus')) ? true : false);
279 if (can_perform('canchangestatus'))
281 $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid', $bug['priority']);
282 $select['status'] = construct_datastore_select('status', 'status', 'statusid', $bug['status']);
283 $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid', $bug['resolution']);
286 $show['assign'] = ((can_perform('canassign')) ? true : false);
287 if (can_perform('canassign'))
289 foreach ($bugsys->datastore
['assignto'] AS $dev)
291 $value = $dev['userid'];
292 $selected = (($dev['userid'] == $bug['assignedto']) ? true : false);
293 $label = construct_user_display($dev, false);
294 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
298 $pcv_select = construct_pcv_select("p$bug[productid]c$bug[componentid]v$bug[versionid]");
300 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
302 $customfields = construct_custom_fields($bug);
304 if ($bug['duplicateof'])
306 $duplicate = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[duplicateof]");
309 if ($bug['dependency'])
311 $dependencies = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid IN ($bug[dependency])");
312 while ($dependency = $db->fetch_array($dependencies))
314 $depends[] = "<a href=\"showreport.php?bugid=$dependency[bugid]\" alt=\"$dependency[summary]\">$dependency[bugid]</a>";
316 $dependencies = implode(' ', $depends);
319 $actions = $db->query("SELECT * FROM " . TABLE_PREFIX
. "autoaction ORDER BY name ASC");
320 $select['autoactions'] = '';
321 $show['autoactions'] = false;
322 while ($action = $db->fetch_array($actions))
324 $label = $action['name'];
325 $value = $action['actionid'];
327 eval('$select[autoaction] .= "' . $bugsys->template
->fetch('selectoption') . '";');
328 $show['autoactions'] = true;
330 if ($show['autoactions'])
335 eval('$select[autoaction] = "' . $bugsys->template
->fetch('selectoption') . '" . $select[autoaction];');
338 eval('$template->flush("' . $template->fetch('editreport') . '");');
341 /*=====================================================================*\
342 || ###################################################################
345 || ###################################################################
346 \*=====================================================================*/