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 $bugapi = new BugAPI($bugsys);
66 $bugapi->set('bugid', $bugsys->in
['bugid']);
67 $bugapi->set_condition();
68 $bugapi->dorelations
= array();
71 // -------------------------------------------------------------------
73 $autoaction = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = " . $bugsys->input_clean('autoaction', TYPE_UINT
));
76 $autoaction['fields'] = unserialize($autoaction['fieldchanges']);
78 foreach ($autoaction['fields']['builtin'] AS $field => $value)
80 $bugsys->in
["$field"] = $value;
83 foreach ($autoaction['fields']['custom'] AS $field => $value)
85 $bugsys->in
["field$field"] = $value;
89 // -------------------------------------------------------------------
90 // process comment stuff
91 if ($bugsys->in
['comment'])
93 if (!empty($bugsys->in
['comment']) AND $autoaction['comment'])
95 $commenttext = $bugsys->in
['comment'] . "\n\n" . $lang->string('--------------- AUTOMATIC RESPONSE ---------------') . "\n" . $autoaction['comment'];
97 else if (empty($bugsys->in
['comment']) AND $autoaction['comment'])
99 $commenttext = $autoaction['comment'];
103 $commenttext = $bugsys->in
['comment'];
106 $comment = new CommentAPI($bugsys);
107 $comment->set('bugid', $bugsys->in
['bugid']);
108 $comment->set('userid', $bugsys->userinfo
['userid']);
109 $comment->set('comment', $commenttext);
112 $bugapi->set('lastposttime', $comment->values
['dateline']);
113 $bugapi->set('lastpostby', $bugsys->userinfo
['userid']);
114 $bugapi->set('hiddenlastposttime', $comment->values
['dateline']);
115 $bugapi->set('hiddenlastpostby', $bugsys->userinfo
['userid']);
117 if (!((can_perform('caneditown', $bug['productid']) AND $bugsys->userinfo
['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['productid']) AND $bugsys->userinfo
['userid'] != $bug['userid'])))
120 $message->redirect($lang->string('Your reply has been added to the comment list.'), "showreport.php?bugid=$bug[bugid]");
124 // -------------------------------------------------------------------
126 $pcv = parse_pcv_select($bugsys->in
['pcv_select'], true
);
128 $hist2[0] = (array)$temp = $noinitialcustom = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
130 // -------------------------------------------------------------------
133 process_custom_fields($bug['bugid']);
135 $dependencies = preg_split('#([^0-9].*?)#', $bugsys->in
['dependency'], -1, PREG_SPLIT_NO_EMPTY
);
136 $dependencies = ((count($dependencies) < 1) ?
'' : implode(', ', $dependencies));
138 $bugapi->set('summary', $bugsys->in
['summary']);
139 $bugapi->set('severity', $bugsys->in
['severity']);
140 $bugapi->set('duplicateof', $bugsys->in
['duplicateof']);
141 $bugapi->set('dependency', $dependencies);
142 $bugapi->set('productid', $pcv['product']);
143 $bugapi->set('componentid', $pcv['component']);
144 $bugapi->set('versionid', $pcv['version']);
145 $bugapi->set('hidden', $bugsys->in
['hidden']);
147 if (can_perform('canchangestatus', $bug['productid']))
149 $bugapi->set('priority', $bugsys->in
['priority']);
150 $bugapi->set('status', $bugsys->in
['status']);
151 $bugapi->set('resolution', $bugsys->in
['resolution']);
153 if (can_perform('canassign', $bug['productid']))
155 $bugapi->set('assignedto', $bugsys->in
['assignedto']);
160 // -------------------------------------------------------------------
163 $hist2[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
165 $diff[0] = array_diff_assoc($bugapi->objdata
, $bugapi->values
);
166 $diff[1] = array_diff_assoc($bugapi->values
, $bugapi->objdata
);
168 $lookupindex = array(
169 'status' => 'status',
170 'severity' => 'severity',
171 'priority' => 'priority',
172 'versionid' => 'version',
173 'assignedto' => 'assignto',
174 'resolution' => 'resolution',
175 'productid' => 'product',
176 'componentid' => 'product'
179 foreach ($diff AS $num => $diffs)
181 foreach ($diffs AS $key => $value)
183 if (!isset($lookupindex["$key"]))
188 $ref = $lookupindex["$key"];
189 $temp =& $bugsys->datastore
["$ref"]["$value"];
190 $thevalue = $temp["$ref"];
191 $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
193 if ($key == 'assignedto')
195 $thevalue = (($temp['userid']) ?
construct_user_display($temp) : '');
198 else if ($key == 'productid' OR $key == 'componentid')
201 $thevalue = $temp['title'];
204 $diff["$num"]["$key"] = (($thevalue) ?
$thevalue . $idbit : '');
208 foreach ($diff[1] AS $key => $value)
210 $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"]));
213 $diff2[0] = array_diff_assoc($hist2[0], $hist2[1]);
214 $diff2[1] = array_diff_assoc($hist2[1], $hist2[0]);
216 if ($noinitialcustom === false
)
218 $canallowempty = true
;
219 $checkbox = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bugfield WHERE type = 'input_checkbox'");
220 while ($box = $db->fetch_array($checkbox))
222 $boxlist[] = 'field' . $box['fieldid'];
226 foreach ($diff2[1] AS $key => $value)
228 if (in_array($key, $boxlist) AND $canallowempty)
230 $log->allowempty
= true
;
234 $log->allowempty
= false
;
242 $log->log($log->diff('custom_' . $key, $diff2[0]["$key"], $diff2[1]["$key"]));
245 $log->allowempty
= false
;
247 $message->redirect($lang->string('Your changes to the bug have been saved.'), "showreport.php?bugid=$bug[bugid]");
250 /*=====================================================================*\
251 || ###################################################################
254 || ###################################################################
255 \*=====================================================================*/