2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
22 define('SVN', '$Id$');
24 $focus['showreport'] = 'focus';
26 require_once('./global.php');
27 require_once('./includes/functions_product.php');
28 require_once('./includes/api_bug.php');
29 require_once('./includes/api_comment.php');
31 $bug = $db->query_first("
32 SELECT bugvaluefill.*, bug.*, user.email, user.displayname, user.showemail
33 FROM " . TABLE_PREFIX
. "bug AS bug
34 LEFT JOIN " . TABLE_PREFIX
. "user AS user
35 ON (bug.userid = user.userid)
36 LEFT JOIN " . TABLE_PREFIX
. "bugvaluefill AS bugvaluefill
37 ON (bug.bugid = bugvaluefill.bugid)
38 WHERE bug.bugid = " . intval($bugsys->in
['bugid'])
41 if (!((can_perform('caneditown', $bug['productid']) AND $bugsys->userinfo
['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['productid']) AND $bugsys->userinfo
['userid'] != $bug['userid'])) AND !can_perform('canpostcomments', $bug['productid']))
43 $message->error_permission();
48 $message->error($lang->getlex('error_invalid_id'));
51 if ($bug['hidden'] AND !can_perform('canviewhidden', $bug['productid']))
53 $message->error_permission();
57 require_once('./includes/class_history.php');
59 $log->bugid
= $bug['bugid'];
61 // ###################################################################
63 if ($_POST['do'] == 'update')
65 // -------------------------------------------------------------------
66 // process comment stuff
67 if ($bugsys->in
['comment'] AND !((can_perform('caneditown', $bug['productid']) AND $bugsys->userinfo
['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['productid']) AND $bugsys->userinfo
['userid'] != $bug['userid'])))
69 $comment = new CommentAPI($bugsys);
70 $comment->set('bugid', $bugsys->in
['bugid']);
71 $comment->set('userid', $bugsys->userinfo
['userid']);
72 $comment->set('comment', $_POST['comment']);
75 $time = $comment->values
['dateline'];
76 $commentid = $comment->insertid
;
79 UPDATE " . TABLE_PREFIX
. "bug
80 SET lastposttime = $time,
81 lastpostby = " . $bugsys->userinfo
['userid'] . ",
82 hiddenlastposttime = $time,
83 hiddenlastpostby = " . $bugsys->userinfo
['userid'] . "
84 WHERE bugid = " . intval($bugsys->in
['bugid'])
89 $log->arguments
= array($commentid);
93 $message->redirect($lang->string('Your reply has been added to the comment list.'), "showreport.php?bugid=$bug[bugid]");
96 // -------------------------------------------------------------------
98 $pcv = parse_pcv_select($bugsys->in
['pcv_select'], true
);
100 $bugapi = new BugAPI($bugsys);
101 $bugapi->set('bugid', $bugsys->in
['bugid']);
102 $bugapi->set_condition();
103 $bugapi->dorelations
= array();
106 $hist2[0] = (array)$temp = $noinitialcustom = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
108 // -------------------------------------------------------------------
112 $autoaction = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = " . intval($bugsys->in
['autoaction']));
115 $autoaction['fields'] = unserialize($autoaction['fieldchanges']);
117 foreach ($autoaction['fields']['builtin'] AS $field => $value)
119 $bugsys->in
["$field"] = $value;
122 foreach ($autoaction['fields']['custom'] AS $field => $value)
124 $bugsys->in
["field$field"] = $value;
128 process_custom_fields($bug['bugid']);
130 $dependencies = preg_split('#([^0-9].*?)#', $bugsys->in
['dependency'], -1, PREG_SPLIT_NO_EMPTY
);
131 $dependencies = ((count($dependencies) < 1) ?
'' : implode(', ', $dependencies));
133 $bugapi->set('summary', $bugsys->in
['summary']);
134 $bugapi->set('severity', $bugsys->in
['severity']);
135 $bugapi->set('duplicateof', $bugsys->in
['duplicateof']);
136 $bugapi->set('dependency', $dependencies);
137 $bugapi->set('productid', $pcv['product']);
138 $bugapi->set('componentid', $pcv['component']);
139 $bugapi->set('versionid', $pcv['version']);
140 $bugapi->set('hidden', $bugsys->in
['hidden']);
142 if (can_perform('canchangestatus', $bug['productid']))
144 $bugapi->set('priority', $bugsys->in
['priority']);
145 $bugapi->set('status', $bugsys->in
['status']);
146 $bugapi->set('resolution', $bugsys->in
['resolution']);
148 if (can_perform('canassign', $bug['productid']))
150 $bugapi->set('assignedto', $bugsys->in
['assignedto']);
155 // -------------------------------------------------------------------
158 $hist2[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
160 $diff[0] = array_diff_assoc($bugapi->objdata
, $bugapi->values
);
161 $diff[1] = array_diff_assoc($bugapi->values
, $bugapi->objdata
);
163 $lookupindex = array(
164 'status' => 'status',
165 'severity' => 'severity',
166 'priority' => 'priority',
167 'versionid' => 'version',
168 'assignedto' => 'assignto',
169 'resolution' => 'resolution',
170 'productid' => 'product',
171 'componentid' => 'product'
174 foreach ($diff AS $num => $diffs)
176 foreach ($diffs AS $key => $value)
178 if (!isset($lookupindex["$key"]))
183 $ref = $lookupindex["$key"];
184 $temp =& $bugsys->datastore
["$ref"]["$value"];
185 $thevalue = $temp["$ref"];
186 $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
188 if ($key == 'assignedto')
190 $thevalue = (($temp['userid']) ?
construct_user_display($temp) : '');
193 else if ($key == 'productid' OR $key == 'componentid')
196 $thevalue = $temp['title'];
199 $diff["$num"]["$key"] = (($thevalue) ?
$thevalue . $idbit : '');
203 foreach ($diff[1] AS $key => $value)
205 $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"]));
208 $diff2[0] = array_diff_assoc($hist2[0], $hist2[1]);
209 $diff2[1] = array_diff_assoc($hist2[1], $hist2[0]);
211 if ($noinitialcustom === false
)
213 $canallowempty = true
;
214 $checkbox = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bugfield WHERE type = 'input_checkbox'");
215 while ($box = $db->fetch_array($checkbox))
217 $boxlist[] = 'field' . $box['fieldid'];
221 foreach ($diff2[1] AS $key => $value)
223 if (in_array($key, $boxlist) AND $canallowempty)
225 $log->allowempty
= true
;
229 $log->allowempty
= false
;
237 $log->log($log->diff('custom_' . $key, $diff2[0]["$key"], $diff2[1]["$key"]));
240 $log->allowempty
= false
;
242 // -------------------------------------------------------------------
244 $hascomment = (!empty($bugsys->in
['comment'])) ? true
: false
;
246 if ($hascomment OR $autoaction['comment'])
248 if ($hascomment AND $autoaction['comment'])
250 $bugsys->in
['comment'] .= "\n\n" . $lang->string('--------------- AUTOMATIC RESPONSE ---------------') . "\n" . $autoaction['comment'];
252 else if (!$hascomment AND $autoaction['comment'])
254 $bugsys->in
['comment'] = $autoaction['comment'];
257 $comment = new CommentAPI($bugsys);
258 $comment->set('bugid', $bugsys->in
['bugid']);
259 $comment->set('userid', $bugsys->userinfo
['userid']);
260 $comment->set('comment', $bugsys->in
['comment']);
263 $time = $comment->values
['dateline'];
264 $commentid = $comment->insertid
;
267 UPDATE " . TABLE_PREFIX
. "bug
268 SET lastposttime = $time,
269 lastpostby = " . $bugsys->userinfo
['userid'] . ",
270 hiddenlastposttime = $time,
271 hiddenlastpostby = " . $bugsys->userinfo
['userid'] . "
272 WHERE bugid = " . intval($bugsys->in
['bugid'])
277 $message->redirect($lang->string('Your changes to the bug have been saved.'), "showreport.php?bugid=$bug[bugid]");
280 /*=====================================================================*\
281 || ###################################################################
284 || ###################################################################
285 \*=====================================================================*/