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 define('SVN', '$Id$');
15 $focus['showreport'] = 'focus';
17 require_once('./global.php');
19 $bug = $db->query_first("
20 SELECT bugvaluefill.*, bug.*, user.email, user.displayname, user.showemail
21 FROM " . TABLE_PREFIX
. "bug AS bug
22 LEFT JOIN " . TABLE_PREFIX
. "user AS user
23 ON (bug.userid = user.userid)
24 LEFT JOIN " . TABLE_PREFIX
. "bugvaluefill AS bugvaluefill
25 ON (bug.bugid = bugvaluefill.bugid)
26 WHERE bug.bugid = " . intval($bugsys->in
['bugid'])
31 $message->error('alert: bad bug');
34 if (!(((can_perform('caneditown') AND $bugsys->userinfo
['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')))
36 $message->error_permission();
39 if ($bug['hidden'] AND !can_perform('canviewhidden'))
41 $message->error_permission();
45 require_once('./includes/class_history.php');
47 $log->bugid
= $bug['bugid'];
49 // ###################################################################
51 if (empty($_REQUEST['do']))
53 $_REQUEST['do'] = 'edit';
56 // ###################################################################
58 if ($_POST['do'] == 'update')
60 $pcv = parse_pcv_select($bugsys->in
['pcv_select'], true
);
62 if (!$bugsys->in
['summary'])
64 $message->error('you need to enter a summary');
68 $message->error('invalid product/component/version');
71 $hist[0] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
72 $hist2[0] = (array)$temp = $noinitialcustom = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
74 // -------------------------------------------------------------------
78 $autoaction = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = " . intval($bugsys->in
['autoaction']));
81 $autoaction['fields'] = unserialize($autoaction['fieldchanges']);
83 foreach ($autoaction['fields']['builtin'] AS $field => $value)
85 $bugsys->in
["$field"] = $value;
88 foreach ($autoaction['fields']['custom'] AS $field => $value)
90 $bugsys->in
["field$field"] = $value;
94 process_custom_fields($bug['bugid']);
96 $dependencies = preg_split('#([^0-9].*?)#', $bugsys->in
['dependency'], -1, PREG_SPLIT_NO_EMPTY
);
97 $dependencies = ((count($dependencies) < 1) ?
'' : implode(', ', $dependencies));
99 // #*# 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
102 UPDATE " . TABLE_PREFIX
. "bug
103 SET summary = '" . $bugsys->in
['summary'] . "',
104 priority = " . intval($bugsys->in
['priority']) . ",
105 status = " . intval($bugsys->in
['status']) . ",
106 severity = " . intval($bugsys->in
['severity']) . ",
107 resolution = " . intval($bugsys->in
['resolution']) . ",
108 assignedto = " . intval($bugsys->in
['assignedto']) . ",
109 duplicateof = " . intval($bugsys->in
['duplicateof']) . ",
110 dependency = '$dependencies',
111 productid = " . $pcv['product'] . ",
112 componentid = " . $pcv['component'] . ",
113 versionid = " . $pcv['version'] . ",
114 hidden = " . intval($bugsys->in
['hidden']) . "
115 WHERE bugid = $bug[bugid]"
118 // -------------------------------------------------------------------
121 $hist[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
122 $hist2[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
124 $diff[0] = array_diff_assoc($hist[0], $hist[1]);
125 $diff[1] = array_diff_assoc($hist[1], $hist[0]);
127 $lookupindex = array(
128 'status' => 'status',
129 'severity' => 'severity',
130 'priority' => 'priority',
131 'versionid' => 'version',
132 'assignedto' => 'assignto',
133 'resolution' => 'resolution',
134 'productid' => 'product',
135 'componentid' => 'product'
138 $log->language
= 'log_update_bug';
140 foreach ($diff AS $num => $diffs)
142 foreach ($diffs AS $key => $value)
144 if (!isset($lookupindex["$key"]))
149 $ref = $lookupindex["$key"];
150 $temp =& $bugsys->datastore
["$ref"]["$value"];
151 $thevalue = $temp["$ref"];
152 $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
154 if ($key == 'assignedto')
156 $thevalue = (($temp['userid']) ?
construct_user_display($temp) : '');
159 else if ($key == 'productid' OR $key == 'componentid')
162 $thevalue = $temp['title'];
165 $diff["$num"]["$key"] = (($thevalue) ?
$thevalue . $idbit : '');
169 foreach ($diff[1] AS $key => $value)
171 $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"]));
174 $diff2[0] = array_diff_assoc($hist2[0], $hist2[1]);
175 $diff2[1] = array_diff_assoc($hist2[1], $hist2[0]);
177 if ($noinitialcustom === false
)
179 $canallowempty = true
;
180 $checkbox = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bugfield WHERE type = 'input_checkbox'");
181 while ($box = $db->fetch_array($checkbox))
183 $boxlist[] = 'field' . $box['fieldid'];
187 foreach ($diff2[1] AS $key => $value)
189 if (in_array($key, $boxlist) AND $canallowempty)
191 $log->allowempty
= true
;
195 $log->allowempty
= false
;
203 $log->log($log->diff('custom_' . $key, $diff2[0]["$key"], $diff2[1]["$key"]));
206 $log->allowempty
= false
;
208 // -------------------------------------------------------------------
209 // process comment stuff
211 if (!$bugsys->in['firstcomment'])
213 $message->error('you need to enter some text in the first comment');
216 $bugsys->in['comment_parsed'] = $bugsys->in['firstcomment'];
218 if (!$bugsys->options['allowhtml'])
220 $bugsys->in['comment_parsed'] = $bugsys->sanitize($bugsys->in['comment_parsed']);
223 // we could pass this as a GET param, but that's unsafe
224 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
227 UPDATE " . TABLE_PREFIX . "comment
228 SET comment = '" . $bugsys->in['firstcomment'] . "',
229 comment_parsed = '" . nl2br($bugsys->in['comment_parsed']) . "'
230 WHERE commentid = $firstcomment[commentid]"
233 // -------------------------------------------------------------------
234 // auto action comment
236 if ($autoaction['comment'])
238 $comment = $autoaction['comment'];
239 if (!$bugsys->options
['allowhtml'])
241 $comment_parsed = $bugsys->sanitize($comment);
246 (bugid, userid, dateline, comment, comment_parsed)
248 ($bug[bugid], " . $bugsys->userinfo
['userid'] . ", " . LOG_TIME
. ",
249 '" . $bugsys->escape($comment) . "',
250 '" . $bugsys->escape($comment_parsed) . "'
255 UPDATE " . TABLE_PREFIX
. "bug
256 SET lastposttime = " . LOG_TIME
. ",
257 lastpostby = " . $bugsys->userinfo
['userid'] . ",
258 hiddenlastposttime = " . LOG_TIME
. ",
259 hiddenlastpostby = " . $bugsys->userinfo
['userid'] . "
260 WHERE bugid = $bug[bugid]"
264 $message->redirect('done with update bug', "showreport.php?bugid=$bug[bugid]");
267 /*=====================================================================*\
268 || ###################################################################
271 || ###################################################################
272 \*=====================================================================*/