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));
100 // #*# 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
103 UPDATE " . TABLE_PREFIX
. "bug
104 SET summary = '" . $bugsys->in
['summary'] . "',
105 priority = " . intval($bugsys->in
['priority']) . ",
106 status = " . intval($bugsys->in
['status']) . ",
107 severity = " . intval($bugsys->in
['severity']) . ",
108 resolution = " . intval($bugsys->in
['resolution']) . ",
109 assignedto = " . intval($bugsys->in
['assignedto']) . ",
110 duplicateof = " . intval($bugsys->in
['duplicateof']) . ",
111 dependency = '$dependencies',
112 productid = " . $pcv['product'] . ",
113 componentid = " . $pcv['component'] . ",
114 versionid = " . $pcv['version'] . ",
115 hidden = " . intval($bugsys->in
['hidden']) . "
116 WHERE bugid = $bug[bugid]"
119 // -------------------------------------------------------------------
122 $hist[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
123 $hist2[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
125 $diff[0] = array_diff_assoc($hist[0], $hist[1]);
126 $diff[1] = array_diff_assoc($hist[1], $hist[0]);
128 $lookupindex = array(
129 'status' => 'status',
130 'severity' => 'severity',
131 'priority' => 'priority',
132 'versionid' => 'version',
133 'assignedto' => 'assignto',
134 'resolution' => 'resolution',
135 'productid' => 'product',
136 'componentid' => 'product'
139 $log->language
= 'log_update_bug';
141 foreach ($diff AS $num => $diffs)
143 foreach ($diffs AS $key => $value)
145 if (!isset($lookupindex["$key"]))
150 $ref = $lookupindex["$key"];
151 $temp =& $bugsys->datastore
["$ref"]["$value"];
152 $thevalue = $temp["$ref"];
153 $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
155 if ($key == 'assignedto')
157 $thevalue = (($temp['userid']) ?
construct_user_display($temp) : '');
160 else if ($key == 'productid' OR $key == 'componentid')
163 $thevalue = $temp['title'];
166 $diff["$num"]["$key"] = (($thevalue) ?
$thevalue . $idbit : '');
170 foreach ($diff[1] AS $key => $value)
172 $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"]));
175 $diff2[0] = array_diff_assoc($hist2[0], $hist2[1]);
176 $diff2[1] = array_diff_assoc($hist2[1], $hist2[0]);
178 if ($noinitialcustom === false
)
180 $canallowempty = true
;
181 $checkbox = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bugfield WHERE type = 'input_checkbox'");
182 while ($box = $db->fetch_array($checkbox))
184 $boxlist[] = 'field' . $box['fieldid'];
188 foreach ($diff2[1] AS $key => $value)
190 if (in_array($key, $boxlist) AND $canallowempty)
192 $log->allowempty
= true
;
196 $log->allowempty
= false
;
204 $log->log($log->diff('custom_' . $key, $diff2[0]["$key"], $diff2[1]["$key"]));
207 $log->allowempty
= false
;
209 // -------------------------------------------------------------------
210 // process comment stuff
212 if (!$bugsys->in
['firstcomment'])
214 $message->error('you need to enter some text in the first comment');
217 $bugsys->in
['comment_parsed'] = $bugsys->in
['firstcomment'];
219 if (!$bugsys->options
['allowhtml'])
221 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
224 // we could pass this as a GET param, but that's unsafe
225 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
228 UPDATE " . TABLE_PREFIX
. "comment
229 SET comment = '" . $bugsys->in
['firstcomment'] . "',
230 comment_parsed = '" . nl2br($bugsys->in
['comment_parsed']) . "'
231 WHERE commentid = $firstcomment[commentid]"
234 // -------------------------------------------------------------------
235 // auto action comment
237 if ($autoaction['comment'])
239 $comment = $autoaction['comment'];
240 if (!$bugsys->options
['allowhtml'])
242 $comment_parsed = $bugsys->sanitize($comment);
247 (bugid, userid, dateline, comment, comment_parsed)
249 ($bug[bugid], " . $bugsys->userinfo
['userid'] . ", " . LOG_TIME
. ",
250 '" . $bugsys->escape($comment) . "',
251 '" . $bugsys->escape($comment_parsed) . "'
256 UPDATE " . TABLE_PREFIX
. "bug
257 SET lastposttime = " . LOG_TIME
. ",
258 lastpostby = " . $bugsys->userinfo
['userid'] . ",
259 hiddenlastposttime = " . LOG_TIME
. ",
260 hiddenlastpostby = " . $bugsys->userinfo
['userid'] . "
261 WHERE bugid = $bug[bugid]"
265 $message->redirect('done with update bug', "showreport.php?bugid=$bug[bugid]");
268 // ###################################################################
270 if ($_REQUEST['do'] == 'edit')
272 $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid', $bug['severity']);
274 $show['changestatus'] = ((can_perform('canchangestatus')) ? true
: false
);
275 if (can_perform('canchangestatus'))
277 $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid', $bug['priority']);
278 $select['status'] = construct_datastore_select('status', 'status', 'statusid', $bug['status']);
279 $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid', $bug['resolution']);
282 $show['assign'] = ((can_perform('canassign')) ? true
: false
);
283 if (can_perform('canassign'))
285 foreach ($bugsys->datastore
['assignto'] AS $dev)
287 $value = $dev['userid'];
288 $selected = (($dev['userid'] == $bug['assignedto']) ? true
: false
);
289 $label = construct_user_display($dev, false
);
290 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
294 $pcv_select = construct_pcv_select("p$bug[productid]c$bug[componentid]v$bug[versionid]");
296 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
298 $customfields = construct_custom_fields($bug);
300 if ($bug['duplicateof'])
302 $duplicate = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[duplicateof]");
305 if ($bug['dependency'])
307 $dependencies = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid IN ($bug[dependency])");
308 while ($dependency = $db->fetch_array($dependencies))
310 $depends[] = "<a href=\"showreport.php?bugid=$dependency[bugid]\" alt=\"$dependency[summary]\">$dependency[bugid]</a>";
312 $dependencies = implode(' ', $depends);
315 $actions = $db->query("SELECT * FROM " . TABLE_PREFIX
. "autoaction ORDER BY name ASC");
316 $select['autoactions'] = '';
317 $show['autoactions'] = false
;
318 while ($action = $db->fetch_array($actions))
320 $label = $action['name'];
321 $value = $action['actionid'];
323 eval('$select[autoaction] .= "' . $bugsys->template
->fetch('selectoption') . '";');
324 $show['autoactions'] = true
;
326 if ($show['autoactions'])
331 eval('$select[autoaction] = "' . $bugsys->template
->fetch('selectoption') . '" . $select[autoaction];');
334 eval('$template->flush("' . $template->fetch('editreport') . '");');
337 /*=====================================================================*\
338 || ###################################################################
341 || ###################################################################
342 \*=====================================================================*/