2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
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
/class_notification
.php
');
29 require_once('./includes
/api_bug
.php
');
30 require_once('./includes
/api_comment
.php
');
32 require_once('./includes
/class_api_error
.php
');
33 APIError(array(new API_Error_Handler($message), 'user_cumulative
'));
35 $bug = $db->query_first("
36 SELECT bugvaluefill.*, bug.*, user.email, user.displayname, user.showemail
37 FROM " . TABLE_PREFIX . "bug AS bug
38 LEFT JOIN " . TABLE_PREFIX . "user AS user
39 ON (bug.userid = user.userid)
40 LEFT JOIN " . TABLE_PREFIX . "bugvaluefill AS bugvaluefill
41 ON (bug.bugid = bugvaluefill.bugid)
42 WHERE bug.bugid = " . $bugsys->input_clean('bugid
', TYPE_UINT)
47 $message->error($lang->getlex('error_invalid_id
'));
50 if ($bug['hidden
'] AND !can_perform('canviewhidden
', $bug['product
']))
52 $message->error_permission();
56 require_once('./includes
/class_logging
.php
');
58 $log->set_bugid($bug['bugid
']);
68 'version
' => 'version
',
69 'assignedto
' => 'assignto
',
71 'product
' => 'product
',
72 'component
' => 'component
'
75 $notif = new NotificationCenter;
77 $bugapi = new BugAPI($bugsys);
78 $bugapi->set('bugid
', $bugsys->in['bugid
']);
79 $bugapi->set_condition();
80 $bugapi->dorelations = array();
83 // ###################################################################
85 if ($_POST['do'] == 'kill
')
87 if (!can_perform('candeletedata
', $bug['product
']))
89 $message->error_permission();
94 $message->redirect($lang->string('The entire bug has been deleted
.'), 'index
.php
');
97 // ###################################################################
99 if ($_REQUEST['do'] == 'delete
')
101 if (!can_perform('candeletedata
', $bug['product
']))
103 $message->error_permission();
106 $message->confirm($lang->string('Are you sure you want to delete this bug
? Doing so will
<strong
>destroy
</strong
> all associated data
, including comments
, attachments
, and votes
. We strongly recommend only deleting span records
and nothing
else as users may wish to go back
and look at any bug to check its status
.'), 'editreport
.php
', 'kill
', $lang->string('Delete Bug Permanently
'), 'showreport
.php
?bugid
=' . $bug['bugid
'], array('bugid
' => $bug['bugid
']));
109 // ###################################################################
111 if ($_POST['do'] == 'update
')
113 if (!((can_perform('caneditown
', $bug['product
']) AND $bugsys->userinfo['userid
'] == $bug['userid
']) OR (can_perform('caneditother
', $bug['product
']) AND $bugsys->userinfo['userid
'] != $bug['userid
'])) AND !can_perform('canpostcomments
', $bug['product
']))
115 $message->error_permission();
118 $log->add_data(true, $bugapi->objdata, $bugfields);
120 // -------------------------------------------------------------------
122 $autoaction = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "autoaction WHERE actionid = " . $bugsys->input_clean('autoaction
', TYPE_UINT));
125 $autoaction['fields
'] = unserialize($autoaction['fieldchanges
']);
127 foreach ($autoaction['fields
']['builtin
'] AS $field => $value)
129 $bugsys->in["$field"] = $value;
132 foreach ($autoaction['fields
']['custom
'] AS $field => $value)
134 $bugsys->in["field$field"] = $value;
138 // -------------------------------------------------------------------
140 $pcv = parse_pcv_select($bugsys->in['pcv_select
'], true);
142 $dependencies = preg_split('#([^0-9].*?)#', $bugsys->in['dependency'], -1, PREG_SPLIT_NO_EMPTY);
143 $dependencies = ((sizeof($dependencies) < 1) ? '' : implode(', ', $dependencies));
145 $bugapi->set('summary', $bugsys->in
['summary']);
146 $bugapi->set('severity', $bugsys->in
['severity']);
147 $bugapi->set('duplicateof', $bugsys->in
['duplicateof']);
148 $bugapi->set('dependency', $dependencies);
149 $bugapi->set('product', $pcv['product']);
150 $bugapi->set('component', $pcv['component']);
151 $bugapi->set('version', $pcv['version']);
152 $bugapi->set('hidden', $bugsys->in
['hidden']);
154 if (can_perform('canchangestatus', $bug['product']))
156 $bugapi->set('priority', $bugsys->in
['priority']);
157 $bugapi->set('status', $bugsys->in
['status']);
158 $bugapi->set('resolution', $bugsys->in
['resolution']);
160 if (can_perform('canassign', $bug['product']))
162 $bugapi->set('assignedto', $bugsys->in
['assignedto']);
165 $notif->set_bug_data($bugapi->objdata
, $bugapi->values
);
167 // -------------------------------------------------------------------
168 // process comment stuff
169 if ($bugsys->in
['comment'])
171 if (!empty($bugsys->in
['comment']) AND $autoaction['comment'])
173 $commenttext = $bugsys->in
['comment'] . "\n\n" . $lang->string('--------------- AUTOMATIC RESPONSE ---------------') . "\n" . $autoaction['comment'];
175 else if (empty($bugsys->in
['comment']) AND $autoaction['comment'])
177 $commenttext = $autoaction['comment'];
181 $commenttext = $bugsys->in
['comment'];
184 $comment = new CommentAPI($bugsys);
185 $comment->set('bugid', $bugsys->in
['bugid']);
186 $comment->set('userid', $bugsys->userinfo
['userid']);
187 $comment->set('comment', $commenttext);
190 $notif->send_new_comment_notice($comment->values
);
192 $bugapi->set('lastposttime', $comment->values
['dateline']);
193 $bugapi->set('lastpostby', $bugsys->userinfo
['userid']);
194 $bugapi->set('lastpostbyname', $bugsys->userinfo
['displayname']);
195 $bugapi->set('hiddenlastposttime', $comment->values
['dateline']);
196 $bugapi->set('hiddenlastpostby', $bugsys->userinfo
['userid']);
197 $bugapi->set('hiddenlastpostbyname', $bugsys->userinfo
['displayname']);
199 if (!((can_perform('caneditown', $bug['product']) AND $bugsys->userinfo
['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['product']) AND $bugsys->userinfo
['userid'] != $bug['userid'])))
202 $message->redirect($lang->string('Your reply has been added to the comment list.'), "showreport.php?bugid=$bug[bugid]");
206 // -------------------------------------------------------------------
207 // handle logging and perform updates
209 if ($fields = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]"))
211 $log->add_data(true, $fields, array('bugid'), true, 'custom');
214 $log->add_data(false, $bugapi->values
, $bugfields);
216 process_custom_fields($bug['bugid']);
220 // -------------------------------------------------------------------
223 $fieldsnew = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
224 $log->add_data(false, $fieldsnew, array('bugid'), true, 'custom');
226 $log->update_history();
228 $notif->send_bug_changes_notice($fields, $fieldsnew);
232 $message->redirect($lang->string('Your changes to the bug have been saved.'), "showreport.php?bugid=$bug[bugid]");
235 /*=====================================================================*\
236 || ###################################################################
239 || ###################################################################
240 \*=====================================================================*/