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 (!((can_perform('caneditown
', $bug['productid
']) AND $bugsys->userinfo['userid
'] == $bug['userid
']) OR (can_perform('caneditother
', $bug['productid
']) AND $bugsys->userinfo['userid
'] != $bug['userid
'])))
69 $hascomment = (!empty($bugsys->in['comment
'])) ? true : false;
71 if ($hascomment OR $autoaction['comment
'])
73 if ($hascomment AND $autoaction['comment
'])
75 $bugsys->in['comment
'] .= "\n\n" . $lang->string('--------------- AUTOMATIC RESPONSE
---------------') . "\n" . $autoaction['comment
'];
77 else if (!$hascomment AND $autoaction['comment
'])
79 $bugsys->in['comment
'] = $autoaction['comment
'];
82 $comment = new CommentAPI($bugsys);
83 $comment->set('bugid
', $bugsys->in['bugid
']);
84 $comment->set('userid
', $bugsys->userinfo['userid
']);
85 $comment->set('comment
', $_POST['comment
']);
88 $time = $comment->values['dateline
'];
89 $commentid = $comment->insertid;
92 UPDATE " . TABLE_PREFIX . "bug
93 SET lastposttime = $time,
94 lastpostby = " . $bugsys->userinfo['userid
'] . ",
95 hiddenlastposttime = $time,
96 hiddenlastpostby = " . $bugsys->userinfo['userid
'] . "
97 WHERE bugid = " . intval($bugsys->in['bugid
'])
102 $log->arguments = array($commentid);
107 $message->redirect($lang->string('Your reply has been added to the comment
list.'), "showreport.php?bugid=$bug[bugid]");
110 // -------------------------------------------------------------------
112 $pcv = parse_pcv_select($bugsys->in['pcv_select
'], true);
114 if (!$bugsys->in['summary
'])
116 $message->error($lang->string('You need to enter a summary
for this bug
.'));
120 $message->error($lang->string('Invalid product
/component
/version selected
.'));
123 $hist[0] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $bug[bugid]");
124 $hist2[0] = (array)$temp = $noinitialcustom = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]");
126 // -------------------------------------------------------------------
130 $autoaction = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "autoaction WHERE actionid = " . intval($bugsys->in['autoaction
']));
133 $autoaction['fields
'] = unserialize($autoaction['fieldchanges
']);
135 foreach ($autoaction['fields
']['builtin
'] AS $field => $value)
137 $bugsys->in["$field"] = $value;
140 foreach ($autoaction['fields
']['custom
'] AS $field => $value)
142 $bugsys->in["field$field"] = $value;
146 process_custom_fields($bug['bugid
']);
148 $dependencies = preg_split('#([^0-9].*?)#', $bugsys->in['dependency'], -1, PREG_SPLIT_NO_EMPTY);
149 $dependencies = ((count($dependencies) < 1) ? '' : implode(', ', $dependencies));
152 UPDATE " . TABLE_PREFIX
. "bug
153 SET summary = '" . $bugsys->in
['summary'] . "',
154 severity = " . intval($bugsys->in
['severity']) . "," .
155 (can_perform('canchangestatus', $bug['productid']) ? "
156 priority = " . intval($bugsys->in
['priority']) . ",
157 status = " . intval($bugsys->in
['status']) . ",
158 resolution = " . intval($bugsys->in
['resolution']) . ","
160 " . (can_perform('canassign', $bug['productid']) ? "assignedto = " . intval($bugsys->in
['assignedto']) . "," : '') . "
161 duplicateof = " . intval($bugsys->in
['duplicateof']) . ",
162 dependency = '$dependencies',
163 productid = " . $pcv['product'] . ",
164 componentid = " . $pcv['component'] . ",
165 versionid = " . $pcv['version'] . ",
166 hidden = " . intval($bugsys->in
['hidden']) . "
167 WHERE bugid = $bug[bugid]"
170 // -------------------------------------------------------------------
173 $hist[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = $bug[bugid]");
174 $hist2[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
176 $diff[0] = array_diff_assoc($hist[0], $hist[1]);
177 $diff[1] = array_diff_assoc($hist[1], $hist[0]);
179 $lookupindex = array(
180 'status' => 'status',
181 'severity' => 'severity',
182 'priority' => 'priority',
183 'versionid' => 'version',
184 'assignedto' => 'assignto',
185 'resolution' => 'resolution',
186 'productid' => 'product',
187 'componentid' => 'product'
190 foreach ($diff AS $num => $diffs)
192 foreach ($diffs AS $key => $value)
194 if (!isset($lookupindex["$key"]))
199 $ref = $lookupindex["$key"];
200 $temp =& $bugsys->datastore
["$ref"]["$value"];
201 $thevalue = $temp["$ref"];
202 $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
204 if ($key == 'assignedto')
206 $thevalue = (($temp['userid']) ? construct_user_display($temp) : '');
209 else if ($key == 'productid' OR $key == 'componentid')
212 $thevalue = $temp['title'];
215 $diff["$num"]["$key"] = (($thevalue) ? $thevalue . $idbit : '');
219 foreach ($diff[1] AS $key => $value)
221 $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"]));
224 $diff2[0] = array_diff_assoc($hist2[0], $hist2[1]);
225 $diff2[1] = array_diff_assoc($hist2[1], $hist2[0]);
227 if ($noinitialcustom === false)
229 $canallowempty = true;
230 $checkbox = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bugfield WHERE type = 'input_checkbox'");
231 while ($box = $db->fetch_array($checkbox))
233 $boxlist[] = 'field' . $box['fieldid'];
237 foreach ($diff2[1] AS $key => $value)
239 if (in_array($key, $boxlist) AND $canallowempty)
241 $log->allowempty
= true;
245 $log->allowempty
= false;
253 $log->log($log->diff('custom_' . $key, $diff2[0]["$key"], $diff2[1]["$key"]));
256 $log->allowempty
= false;
258 // -------------------------------------------------------------------
260 $hascomment = (!empty($bugsys->in
['comment'])) ? true : false;
262 if ($hascomment OR $autoaction['comment'])
264 if ($hascomment AND $autoaction['comment'])
266 $bugsys->in
['comment'] .= "\n\n" . $lang->string('--------------- AUTOMATIC RESPONSE ---------------') . "\n" . $autoaction['comment'];
268 else if (!$hascomment AND $autoaction['comment'])
270 $bugsys->in
['comment'] = $autoaction['comment'];
273 $comment = new CommentAPI($bugsys);
274 $comment->set('bugid', $bugsys->in
['bugid']);
275 $comment->set('userid', $bugsys->userinfo
['userid']);
276 $comment->set('comment', $bugsys->in
['comment']);
279 $time = $comment->values
['dateline'];
280 $commentid = $comment->insertid
;
283 UPDATE " . TABLE_PREFIX
. "bug
284 SET lastposttime = $time,
285 lastpostby = " . $bugsys->userinfo
['userid'] . ",
286 hiddenlastposttime = $time,
287 hiddenlastpostby = " . $bugsys->userinfo
['userid'] . "
288 WHERE bugid = " . intval($bugsys->in
['bugid'])
293 $message->redirect($lang->string('Your changes to the bug have been saved.'), "showreport.php?bugid=$bug[bugid]");
296 /*=====================================================================*\
297 || ###################################################################
300 || ###################################################################
301 \*=====================================================================*/