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 process_custom_field_names($hist2[0]);
76 process_custom_fields($bug['bugid']);
78 $dependencies = preg_split('#([^0-9].*?)#', $bugsys->in
['dependency'], -1, PREG_SPLIT_NO_EMPTY
);
79 $dependencies = ((count($dependencies) < 1) ?
'' : implode(', ', $dependencies));
82 UPDATE " . TABLE_PREFIX
. "bug
83 SET summary = '" . $bugsys->in
['summary'] . "',
84 priority = " . intval($bugsys->in
['priority']) . ",
85 status = " . intval($bugsys->in
['status']) . ",
86 severity = " . intval($bugsys->in
['severity']) . ",
87 resolution = " . intval($bugsys->in
['resolution']) . ",
88 assignedto = " . intval($bugsys->in
['assignedto']) . ",
89 duplicateof = " . intval($bugsys->in
['duplicateof']) . ",
90 dependency = '$dependencies',
91 productid = " . $pcv['product'] . ",
92 componentid = " . $pcv['component'] . ",
93 versionid = " . $pcv['version'] . ",
94 hidden = " . intval($bugsys->in
['hidden']) . "
95 WHERE bugid = $bug[bugid]"
98 // -------------------------------------------------------------------
101 $hist[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
102 $hist2[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
104 process_custom_field_names($hist2[1]);
106 $diff[0] = array_diff_assoc($hist[0], $hist[1]);
107 $diff[1] = array_diff_assoc($hist[1], $hist[0]);
109 $lookupindex = array(
110 'status' => 'status',
111 'severity' => 'severity',
112 'priority' => 'priority',
113 'versionid' => 'version',
114 'assignedto' => 'assignto',
115 'resolution' => 'resolution',
116 'productid' => 'product',
117 'componentid' => 'product'
120 $log->language
= 'log_update_bug';
122 foreach ($diff AS $num => $diffs)
124 foreach ($diffs AS $key => $value)
126 if (!isset($lookupindex["$key"]))
131 $ref = $lookupindex["$key"];
132 $temp =& $bugsys->datastore
["$ref"]["$value"];
133 $thevalue = $temp["$ref"];
134 $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
136 if ($key == 'assignedto')
138 $thevalue = (($temp['userid']) ?
construct_user_display($temp) : '');
141 else if ($key == 'productid' OR $key == 'componentid')
144 $thevalue = $temp['title'];
147 $diff["$num"]["$key"] = (($thevalue) ?
$thevalue . $idbit : '');
151 foreach ($diff[1] AS $key => $value)
153 $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"]));
156 $diff2[0] = array_diff_assoc($hist2[0], $hist2[1]);
157 $diff2[1] = array_diff_assoc($hist2[1], $hist2[0]);
159 if ($noinitialcustom === false
)
161 $canallowempty = true
;
162 $checkbox = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bugfield WHERE type = 'input_checkbox'");
163 while ($box = $db->fetch_array($checkbox))
165 $boxlist[] = $box['shortname'];
169 foreach ($diff2[1] AS $key => $value)
171 if (in_array($key, $boxlist) AND $canallowempty)
173 $log->allowempty
= true
;
177 $log->allowempty
= false
;
180 $log->log($log->diff('custom_' . $key, $diff2[0]["$key"], $diff2[1]["$key"]));
183 $log->allowempty
= false
;
185 // -------------------------------------------------------------------
186 // process comment stuff
188 if (!$bugsys->in
['firstcomment'])
190 $message->error('you need to enter some text in the first comment');
193 $bugsys->in
['comment_parsed'] = $bugsys->in
['firstcomment'];
195 if (!$bugsys->options
['allowhtml'])
197 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
200 // we could pass this as a GET param, but that's unsafe
201 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
204 UPDATE " . TABLE_PREFIX
. "comment
205 SET comment = '" . $bugsys->in
['firstcomment'] . "',
206 comment_parsed = '" . nl2br($bugsys->in
['comment_parsed']) . "'
207 WHERE commentid = $firstcomment[commentid]"
210 $message->redirect('done with update bug', "showreport.php?bugid=$bug[bugid]");
213 // ###################################################################
215 if ($_REQUEST['do'] == 'edit')
217 $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid', $bug['severity']);
219 $show['changestatus'] = ((can_perform('canchangestatus')) ? true
: false
);
220 if (can_perform('canchangestatus'))
222 $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid', $bug['priority']);
223 $select['status'] = construct_datastore_select('status', 'status', 'statusid', $bug['status']);
224 $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid', $bug['resolution']);
227 $show['assign'] = ((can_perform('canassign')) ? true
: false
);
228 if (can_perform('canassign'))
230 foreach ($bugsys->datastore
['assignto'] AS $dev)
232 $value = $dev['userid'];
233 $selected = (($dev['userid'] == $bug['assignedto']) ? true
: false
);
234 $label = construct_user_display($dev, false
);
235 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
239 $pcv_select = construct_pcv_select("p$bug[productid]c$bug[componentid]v$bug[versionid]");
241 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
243 $customfields = construct_custom_fields($bug);
245 if ($bug['duplicateof'])
247 $duplicate = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[duplicateof]");
250 if ($bug['dependency'])
252 $dependencies = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid IN ($bug[dependency])");
253 while ($dependency = $db->fetch_array($dependencies))
255 $depends[] = "<a href=\"showreport.php?bugid=$dependency[bugid]\" alt=\"$dependency[summary]\">$dependency[bugid]</a>";
257 $dependencies = implode(' ', $depends);
260 eval('$template->flush("' . $template->fetch('editreport') . '");');
263 /*=====================================================================*\
264 || ###################################################################
267 || ###################################################################
268 \*=====================================================================*/