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 require_once('./global.php');
20 $bug = $db->query_first("
21 SELECT bugvaluefill.*, bug.*, user.email, user.displayname, user.showemail
22 FROM " . TABLE_PREFIX
. "bug AS bug
23 LEFT JOIN " . TABLE_PREFIX
. "user AS user
24 ON (bug.userid = user.userid)
25 LEFT JOIN " . TABLE_PREFIX
. "bugvaluefill AS bugvaluefill
26 ON (bug.bugid = bugvaluefill.bugid)
27 WHERE bug.bugid = " . intval($bugsys->in
['bugid'])
32 $message->error('alert: bad bug');
35 if (!(((can_perform('caneditown') AND $bugsys->userinfo
['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')))
37 $message->error_permission();
40 if ($bug['hidden'] AND !can_perform('canviewhidden'))
42 $message->error_permission();
46 require_once('./includes/class_history.php');
48 $log->bugid
= $bug['bugid'];
50 // ###################################################################
52 if (empty($_REQUEST['do']))
54 $_REQUEST['do'] = 'edit';
57 // ###################################################################
59 if ($_POST['do'] == 'update')
61 $pcv = parse_pcv_select($bugsys->in
['pcv_select'], true
);
63 if (!$bugsys->in
['summary'])
65 $message->error('you need to enter a summary');
69 $message->error('invalid product/component/version');
72 $hist[0] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
73 $hist2[0] = (array)$temp = $noinitialcustom = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
75 // -------------------------------------------------------------------
79 $autoaction = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = " . intval($bugsys->in
['autoaction']));
82 $autoaction['fields'] = unserialize($autoaction['fieldchanges']);
84 foreach ($autoaction['fields']['builtin'] AS $field => $value)
86 $bugsys->in
["$field"] = $value;
89 foreach ($autoaction['fields']['custom'] AS $field => $value)
91 $bugsys->in
["field$field"] = $value;
95 process_custom_fields($bug['bugid']);
97 $dependencies = preg_split('#([^0-9].*?)#', $bugsys->in
['dependency'], -1, PREG_SPLIT_NO_EMPTY
);
98 $dependencies = ((count($dependencies) < 1) ?
'' : implode(', ', $dependencies));
101 UPDATE " . TABLE_PREFIX
. "bug
102 SET summary = '" . $bugsys->in
['summary'] . "',
103 priority = " . intval($bugsys->in
['priority']) . ",
104 status = " . intval($bugsys->in
['status']) . ",
105 severity = " . intval($bugsys->in
['severity']) . ",
106 resolution = " . intval($bugsys->in
['resolution']) . ",
107 assignedto = " . intval($bugsys->in
['assignedto']) . ",
108 duplicateof = " . intval($bugsys->in
['duplicateof']) . ",
109 dependency = '$dependencies',
110 productid = " . $pcv['product'] . ",
111 componentid = " . $pcv['component'] . ",
112 versionid = " . $pcv['version'] . ",
113 hidden = " . intval($bugsys->in
['hidden']) . "
114 WHERE bugid = $bug[bugid]"
117 // -------------------------------------------------------------------
120 $hist[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
121 $hist2[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
123 $diff[0] = array_diff_assoc($hist[0], $hist[1]);
124 $diff[1] = array_diff_assoc($hist[1], $hist[0]);
126 $lookupindex = array(
127 'status' => 'status',
128 'severity' => 'severity',
129 'priority' => 'priority',
130 'versionid' => 'version',
131 'assignedto' => 'assignto',
132 'resolution' => 'resolution',
133 'productid' => 'product',
134 'componentid' => 'product'
137 $log->language
= 'log_update_bug';
139 foreach ($diff AS $num => $diffs)
141 foreach ($diffs AS $key => $value)
143 if (!isset($lookupindex["$key"]))
148 $ref = $lookupindex["$key"];
149 $temp =& $bugsys->datastore
["$ref"]["$value"];
150 $thevalue = $temp["$ref"];
151 $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
153 if ($key == 'assignedto')
155 $thevalue = (($temp['userid']) ?
construct_user_display($temp) : '');
158 else if ($key == 'productid' OR $key == 'componentid')
161 $thevalue = $temp['title'];
164 $diff["$num"]["$key"] = (($thevalue) ?
$thevalue . $idbit : '');
168 foreach ($diff[1] AS $key => $value)
170 $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"]));
173 $diff2[0] = array_diff_assoc($hist2[0], $hist2[1]);
174 $diff2[1] = array_diff_assoc($hist2[1], $hist2[0]);
176 if ($noinitialcustom === false
)
178 $canallowempty = true
;
179 $checkbox = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bugfield WHERE type = 'input_checkbox'");
180 while ($box = $db->fetch_array($checkbox))
182 $boxlist[] = 'field' . $box['fieldid'];
186 foreach ($diff2[1] AS $key => $value)
188 if (in_array($key, $boxlist) AND $canallowempty)
190 $log->allowempty
= true
;
194 $log->allowempty
= false
;
202 $log->log($log->diff('custom_' . $key, $diff2[0]["$key"], $diff2[1]["$key"]));
205 $log->allowempty
= false
;
207 // -------------------------------------------------------------------
208 // process comment stuff
210 if (!$bugsys->in
['firstcomment'])
212 $message->error('you need to enter some text in the first comment');
215 $bugsys->in
['comment_parsed'] = $bugsys->in
['firstcomment'];
217 if (!$bugsys->options
['allowhtml'])
219 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
222 // we could pass this as a GET param, but that's unsafe
223 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
226 UPDATE " . TABLE_PREFIX
. "comment
227 SET comment = '" . $bugsys->in
['firstcomment'] . "',
228 comment_parsed = '" . nl2br($bugsys->in
['comment_parsed']) . "'
229 WHERE commentid = $firstcomment[commentid]"
232 $message->redirect('done with update bug', "showreport.php?bugid=$bug[bugid]");
235 // ###################################################################
237 if ($_REQUEST['do'] == 'edit')
239 $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid', $bug['severity']);
241 $show['changestatus'] = ((can_perform('canchangestatus')) ? true
: false
);
242 if (can_perform('canchangestatus'))
244 $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid', $bug['priority']);
245 $select['status'] = construct_datastore_select('status', 'status', 'statusid', $bug['status']);
246 $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid', $bug['resolution']);
249 $show['assign'] = ((can_perform('canassign')) ? true
: false
);
250 if (can_perform('canassign'))
252 foreach ($bugsys->datastore
['assignto'] AS $dev)
254 $value = $dev['userid'];
255 $selected = (($dev['userid'] == $bug['assignedto']) ? true
: false
);
256 $label = construct_user_display($dev, false
);
257 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
261 $pcv_select = construct_pcv_select("p$bug[productid]c$bug[componentid]v$bug[versionid]");
263 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
265 $customfields = construct_custom_fields($bug);
267 if ($bug['duplicateof'])
269 $duplicate = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[duplicateof]");
272 if ($bug['dependency'])
274 $dependencies = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid IN ($bug[dependency])");
275 while ($dependency = $db->fetch_array($dependencies))
277 $depends[] = "<a href=\"showreport.php?bugid=$dependency[bugid]\" alt=\"$dependency[summary]\">$dependency[bugid]</a>";
279 $dependencies = implode(' ', $depends);
282 $actions = $db->query("SELECT * FROM " . TABLE_PREFIX
. "autoaction ORDER BY name ASC");
283 $select['autoactions'] = '';
284 $show['autoactions'] = false
;
285 while ($action = $db->fetch_array($actions))
287 $label = $action['name'];
288 $value = $action['actionid'];
290 eval('$select[autoaction] .= "' . $bugsys->template
->fetch('selectoption') . '";');
291 $show['autoactions'] = true
;
293 if ($show['autoactions'])
298 eval('$select[autoaction] = "' . $bugsys->template
->fetch('selectoption') . '" . $select[autoaction];');
301 eval('$template->flush("' . $template->fetch('editreport') . '");');
304 /*=====================================================================*\
305 || ###################################################################
308 || ###################################################################
309 \*=====================================================================*/