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 ($_POST['do'] == 'update')
53 $pcv = parse_pcv_select($bugsys->in
['pcv_select'], true
);
55 if (!$bugsys->in
['summary'])
57 $message->error('you need to enter a summary');
61 $message->error('invalid product/component/version');
64 $hist[0] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
65 $hist2[0] = (array)$temp = $noinitialcustom = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
67 // -------------------------------------------------------------------
71 $autoaction = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = " . intval($bugsys->in
['autoaction']));
74 $autoaction['fields'] = unserialize($autoaction['fieldchanges']);
76 foreach ($autoaction['fields']['builtin'] AS $field => $value)
78 $bugsys->in
["$field"] = $value;
81 foreach ($autoaction['fields']['custom'] AS $field => $value)
83 $bugsys->in
["field$field"] = $value;
87 process_custom_fields($bug['bugid']);
89 $dependencies = preg_split('#([^0-9].*?)#', $bugsys->in
['dependency'], -1, PREG_SPLIT_NO_EMPTY
);
90 $dependencies = ((count($dependencies) < 1) ?
'' : implode(', ', $dependencies));
92 // #*# 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
95 UPDATE " . TABLE_PREFIX
. "bug
96 SET summary = '" . $bugsys->in
['summary'] . "',
97 priority = " . intval($bugsys->in
['priority']) . ",
98 status = " . intval($bugsys->in
['status']) . ",
99 severity = " . intval($bugsys->in
['severity']) . ",
100 resolution = " . intval($bugsys->in
['resolution']) . ",
101 assignedto = " . intval($bugsys->in
['assignedto']) . ",
102 duplicateof = " . intval($bugsys->in
['duplicateof']) . ",
103 dependency = '$dependencies',
104 productid = " . $pcv['product'] . ",
105 componentid = " . $pcv['component'] . ",
106 versionid = " . $pcv['version'] . ",
107 hidden = " . intval($bugsys->in
['hidden']) . "
108 WHERE bugid = $bug[bugid]"
111 // -------------------------------------------------------------------
114 $hist[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
115 $hist2[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
117 $diff[0] = array_diff_assoc($hist[0], $hist[1]);
118 $diff[1] = array_diff_assoc($hist[1], $hist[0]);
120 $lookupindex = array(
121 'status' => 'status',
122 'severity' => 'severity',
123 'priority' => 'priority',
124 'versionid' => 'version',
125 'assignedto' => 'assignto',
126 'resolution' => 'resolution',
127 'productid' => 'product',
128 'componentid' => 'product'
131 $log->language
= 'log_update_bug';
133 foreach ($diff AS $num => $diffs)
135 foreach ($diffs AS $key => $value)
137 if (!isset($lookupindex["$key"]))
142 $ref = $lookupindex["$key"];
143 $temp =& $bugsys->datastore
["$ref"]["$value"];
144 $thevalue = $temp["$ref"];
145 $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
147 if ($key == 'assignedto')
149 $thevalue = (($temp['userid']) ?
construct_user_display($temp) : '');
152 else if ($key == 'productid' OR $key == 'componentid')
155 $thevalue = $temp['title'];
158 $diff["$num"]["$key"] = (($thevalue) ?
$thevalue . $idbit : '');
162 foreach ($diff[1] AS $key => $value)
164 $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"]));
167 $diff2[0] = array_diff_assoc($hist2[0], $hist2[1]);
168 $diff2[1] = array_diff_assoc($hist2[1], $hist2[0]);
170 if ($noinitialcustom === false
)
172 $canallowempty = true
;
173 $checkbox = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bugfield WHERE type = 'input_checkbox'");
174 while ($box = $db->fetch_array($checkbox))
176 $boxlist[] = 'field' . $box['fieldid'];
180 foreach ($diff2[1] AS $key => $value)
182 if (in_array($key, $boxlist) AND $canallowempty)
184 $log->allowempty
= true
;
188 $log->allowempty
= false
;
196 $log->log($log->diff('custom_' . $key, $diff2[0]["$key"], $diff2[1]["$key"]));
199 $log->allowempty
= false
;
201 // -------------------------------------------------------------------
202 // process comment stuff
204 $hascomment = (!empty($bugsys->in
['comment'])) ? true
: false
;
206 if ($hascomment OR $autoaction['comment'])
208 if ($hascomment AND $autoaction['comment'])
210 $bugsys->in
['comment'] .= "\n\n--------------- AUTOMATIC RESPONSE ---------------\n" . $autoaction['comment'];
212 else if (!$hascomment AND $autoaction['comment'])
214 $bugsys->in
['comment'] = $autoaction['comment'];
217 $bugsys->in
['comment_parsed'] = $bugsys->in
['comment'];
219 if (!$bugsys->options
['allowhtml'])
221 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
227 INSERT INTO " . TABLE_PREFIX
. "comment
228 (bugid, userid, dateline, comment, comment_parsed)
230 (" . intval($bugsys->in
['bugid']) . ", " . $bugsys->userinfo
['userid'] . ",
231 $time, '" . $bugsys->in
['comment'] . "',
232 '" . nl2br($bugsys->in
['comment_parsed']) . "'
236 $commentid = $db->insert_id();
239 UPDATE " . TABLE_PREFIX
. "bug
240 SET lastposttime = $time,
241 lastpostby = " . $bugsys->userinfo
['userid'] . ",
242 hiddenlastposttime = $time,
243 hiddenlastpostby = " . $bugsys->userinfo
['userid'] . "
244 WHERE bugid = " . intval($bugsys->in
['bugid'])
249 $log->language
= 'log_new_comment';
250 $log->arguments
= array($commentid);
255 $message->redirect('done with update bug', "showreport.php?bugid=$bug[bugid]");
258 /*=====================================================================*\
259 || ###################################################################
262 || ###################################################################
263 \*=====================================================================*/