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 require_once('./global.php');
22 $bug = $db->query_first("
23 SELECT bugvaluefill.*, bug.*, user.email, user.displayname, user.showemail
24 FROM " . TABLE_PREFIX
. "bug AS bug
25 LEFT JOIN " . TABLE_PREFIX
. "user AS user
26 ON (bug.userid = user.userid)
27 LEFT JOIN " . TABLE_PREFIX
. "bugvaluefill AS bugvaluefill
28 ON (bug.bugid = bugvaluefill.bugid)
29 WHERE bug.bugid = " . intval($bugsys->in
['bugid'])
34 $message->error('alert: bad bug');
37 if (!(((can_perform('caneditown') AND $bugsys->userinfo
['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')))
39 $message->error_permission();
42 if ($bug['hidden'] AND !can_perform('canviewhidden'))
44 $message->error_permission();
48 require_once('./includes/class_history.php');
50 $log->bugid
= $bug['bugid'];
52 // ###################################################################
54 if (empty($_REQUEST['do']))
56 $_REQUEST['do'] = 'edit';
59 // ###################################################################
61 if ($_POST['do'] == 'update')
63 $pcv = parse_pcv_select($bugsys->in
['pcv_select'], true
);
65 if (!$bugsys->in
['summary'])
67 $message->error('you need to enter a summary');
71 $message->error('invalid product/component/version');
74 $hist[0] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
75 $hist2[0] = (array)$temp = $noinitialcustom = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
77 // -------------------------------------------------------------------
81 $autoaction = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = " . intval($bugsys->in
['autoaction']));
84 $autoaction['fields'] = unserialize($autoaction['fieldchanges']);
86 foreach ($autoaction['fields']['builtin'] AS $field => $value)
88 $bugsys->in
["$field"] = $value;
91 foreach ($autoaction['fields']['custom'] AS $field => $value)
93 $bugsys->in
["field$field"] = $value;
97 process_custom_fields($bug['bugid']);
99 $dependencies = preg_split('#([^0-9].*?)#', $bugsys->in
['dependency'], -1, PREG_SPLIT_NO_EMPTY
);
100 $dependencies = ((count($dependencies) < 1) ?
'' : implode(', ', $dependencies));
102 // #*# 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
105 UPDATE " . TABLE_PREFIX
. "bug
106 SET summary = '" . $bugsys->in
['summary'] . "',
107 priority = " . intval($bugsys->in
['priority']) . ",
108 status = " . intval($bugsys->in
['status']) . ",
109 severity = " . intval($bugsys->in
['severity']) . ",
110 resolution = " . intval($bugsys->in
['resolution']) . ",
111 assignedto = " . intval($bugsys->in
['assignedto']) . ",
112 duplicateof = " . intval($bugsys->in
['duplicateof']) . ",
113 dependency = '$dependencies',
114 productid = " . $pcv['product'] . ",
115 componentid = " . $pcv['component'] . ",
116 versionid = " . $pcv['version'] . ",
117 hidden = " . intval($bugsys->in
['hidden']) . "
118 WHERE bugid = $bug[bugid]"
121 // -------------------------------------------------------------------
124 $hist[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
125 $hist2[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
127 $diff[0] = array_diff_assoc($hist[0], $hist[1]);
128 $diff[1] = array_diff_assoc($hist[1], $hist[0]);
130 $lookupindex = array(
131 'status' => 'status',
132 'severity' => 'severity',
133 'priority' => 'priority',
134 'versionid' => 'version',
135 'assignedto' => 'assignto',
136 'resolution' => 'resolution',
137 'productid' => 'product',
138 'componentid' => 'product'
141 $log->language
= 'log_update_bug';
143 foreach ($diff AS $num => $diffs)
145 foreach ($diffs AS $key => $value)
147 if (!isset($lookupindex["$key"]))
152 $ref = $lookupindex["$key"];
153 $temp =& $bugsys->datastore
["$ref"]["$value"];
154 $thevalue = $temp["$ref"];
155 $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
157 if ($key == 'assignedto')
159 $thevalue = (($temp['userid']) ?
construct_user_display($temp) : '');
162 else if ($key == 'productid' OR $key == 'componentid')
165 $thevalue = $temp['title'];
168 $diff["$num"]["$key"] = (($thevalue) ?
$thevalue . $idbit : '');
172 foreach ($diff[1] AS $key => $value)
174 $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"]));
177 $diff2[0] = array_diff_assoc($hist2[0], $hist2[1]);
178 $diff2[1] = array_diff_assoc($hist2[1], $hist2[0]);
180 if ($noinitialcustom === false
)
182 $canallowempty = true
;
183 $checkbox = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bugfield WHERE type = 'input_checkbox'");
184 while ($box = $db->fetch_array($checkbox))
186 $boxlist[] = 'field' . $box['fieldid'];
190 foreach ($diff2[1] AS $key => $value)
192 if (in_array($key, $boxlist) AND $canallowempty)
194 $log->allowempty
= true
;
198 $log->allowempty
= false
;
206 $log->log($log->diff('custom_' . $key, $diff2[0]["$key"], $diff2[1]["$key"]));
209 $log->allowempty
= false
;
211 // -------------------------------------------------------------------
212 // process comment stuff
214 if (!$bugsys->in
['firstcomment'])
216 $message->error('you need to enter some text in the first comment');
219 $bugsys->in
['comment_parsed'] = $bugsys->in
['firstcomment'];
221 if (!$bugsys->options
['allowhtml'])
223 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
226 // we could pass this as a GET param, but that's unsafe
227 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
230 UPDATE " . TABLE_PREFIX
. "comment
231 SET comment = '" . $bugsys->in
['firstcomment'] . "',
232 comment_parsed = '" . nl2br($bugsys->in
['comment_parsed']) . "'
233 WHERE commentid = $firstcomment[commentid]"
236 // -------------------------------------------------------------------
237 // auto action comment
239 if ($autoaction['comment'])
241 $comment = $autoaction['comment'];
242 if (!$bugsys->options
['allowhtml'])
244 $comment_parsed = $bugsys->sanitize($comment);
249 (bugid, userid, dateline, comment, comment_parsed)
251 ($bug[bugid], " . $bugsys->userinfo
['userid'] . ", " . LOG_TIME
. ",
252 '" . $bugsys->escape($comment) . "',
253 '" . $bugsys->escape($comment_parsed) . "'
258 UPDATE " . TABLE_PREFIX
. "bug
259 SET lastposttime = " . LOG_TIME
. ",
260 lastpostby = " . $bugsys->userinfo
['userid'] . ",
261 hiddenlastposttime = " . LOG_TIME
. ",
262 hiddenlastpostby = " . $bugsys->userinfo
['userid'] . "
263 WHERE bugid = $bug[bugid]"
267 $message->redirect('done with update bug', "showreport.php?bugid=$bug[bugid]");
270 // ###################################################################
272 if ($_REQUEST['do'] == 'edit')
274 $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid', $bug['severity']);
276 $show['changestatus'] = ((can_perform('canchangestatus')) ? true
: false
);
277 if (can_perform('canchangestatus'))
279 $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid', $bug['priority']);
280 $select['status'] = construct_datastore_select('status', 'status', 'statusid', $bug['status']);
281 $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid', $bug['resolution']);
284 $show['assign'] = ((can_perform('canassign')) ? true
: false
);
285 if (can_perform('canassign'))
287 foreach ($bugsys->datastore
['assignto'] AS $dev)
289 $value = $dev['userid'];
290 $selected = (($dev['userid'] == $bug['assignedto']) ? true
: false
);
291 $label = construct_user_display($dev, false
);
292 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
296 $pcv_select = construct_pcv_select("p$bug[productid]c$bug[componentid]v$bug[versionid]");
298 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
300 $customfields = construct_custom_fields($bug);
302 if ($bug['duplicateof'])
304 $duplicate = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[duplicateof]");
307 if ($bug['dependency'])
309 $dependencies = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid IN ($bug[dependency])");
310 while ($dependency = $db->fetch_array($dependencies))
312 $depends[] = "<a href=\"showreport.php?bugid=$dependency[bugid]\" alt=\"$dependency[summary]\">$dependency[bugid]</a>";
314 $dependencies = implode(' ', $depends);
317 $actions = $db->query("SELECT * FROM " . TABLE_PREFIX
. "autoaction ORDER BY name ASC");
318 $select['autoactions'] = '';
319 $show['autoactions'] = false
;
320 while ($action = $db->fetch_array($actions))
322 $label = $action['name'];
323 $value = $action['actionid'];
325 eval('$select[autoaction] .= "' . $bugsys->template
->fetch('selectoption') . '";');
326 $show['autoactions'] = true
;
328 if ($show['autoactions'])
333 eval('$select[autoaction] = "' . $bugsys->template
->fetch('selectoption') . '" . $select[autoaction];');
336 eval('$template->flush("' . $template->fetch('editreport') . '");');
339 /*=====================================================================*\
340 || ###################################################################
343 || ###################################################################
344 \*=====================================================================*/