2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright 2002-2007 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 2 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->queryFirst("
36 SELECT 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 WHERE bug.bugid = " . $input->inputClean('bugid
', TYPE_UINT)
45 $message->error(L_INVALID_ID);
48 if (!check_bug_permissions($bug))
50 $message->errorPermission();
54 require_once('./includes
/class_logging
.php
');
56 $log->set_bugid($bug['bugid
']);
58 $notif = new NotificationCenter;
60 $bugapi = new BugAPI($bugsys);
61 $bugapi->set('bugid
', $input->in['bugid
']);
62 $bugapi->set_condition();
63 $bugapi->dorelations = array();
66 // ###################################################################
68 if ($_POST['do'] == 'kill
')
70 if (!can_perform('candeletedata
', $bug['product
']))
72 $message->errorPermission();
77 $message->redirect(T('The entire bug has been deleted
.'), 'index
.php
');
80 // ###################################################################
82 if ($_REQUEST['do'] == 'delete
')
84 if (!can_perform('candeletedata
', $bug['product
']))
86 $message->errorPermission();
89 $message->confirm(T('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
', T('Delete Bug Permanently
'), 'showreport
.php
?bugid
=' . $bug['bugid
'], array('bugid
' => $bug['bugid
']));
92 // ###################################################################
94 if ($_POST['do'] == 'update
')
96 if (!((can_perform('caneditown
', $bug['product
']) AND bugdar::$userinfo['userid
'] == $bug['userid
']) OR (can_perform('caneditother
', $bug['product
']) AND bugdar::$userinfo['userid
'] != $bug['userid
'])) AND !can_perform('canpostcomments
', $bug['product
']))
98 $message->errorPermission();
101 $log->add_data(true, $bugapi->record, $log->getCommonFields(), true);
103 // -------------------------------------------------------------------
104 // handle automations
105 if ($input->in['automation
'])
107 $automation = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "automation WHERE actionid = " . $input->inputClean('automation
', TYPE_UINT));
110 $automation['fields
'] = unserialize($automation['fieldchanges
']);
112 if (is_array($automation['fields
']['builtin
']))
114 foreach ($automation['fields
']['builtin
'] AS $field => $value)
116 $input->in["$field"] = $value;
120 if (is_array($automation['fields
']['custom
']))
122 foreach ($automation['fields
']['custom
'] AS $field => $value)
124 $input->in["custom$field"] = $value;
130 // -------------------------------------------------------------------
131 // process comment stuff
132 if ($input->in['comment
'] OR $automation['comment
'])
134 if (!empty($input->in['comment
']) AND $automation['comment
'])
136 $commenttext = $input->in['comment
'] . "\n\n" . T('--------------- AUTOMATIC RESPONSE
---------------') . "\n" . $automation['comment
'];
138 else if (empty($input->in['comment
']) AND $automation['comment
'])
140 $commenttext = $automation['comment
'];
144 $commenttext = $input->in['comment
'];
147 $comment = new CommentAPI($bugsys);
148 $comment->set('bugid
', $input->in['bugid
']);
149 $comment->set('userid
', bugdar::$userinfo['userid
']);
150 $comment->set('comment
', $commenttext);
151 $comment->set('parselinks
', $input->in['parselinks
']);
154 // we redefine the bug data later, but it needs to be here in order to generate the user list
155 $notif->set_bug_data($bugapi->record);
156 $notif->send_new_comment_notice($comment->values);
158 $bugapi->set('lastposttime
', $comment->values['dateline
']);
159 $bugapi->set('lastpostby
', bugdar::$userinfo['userid
']);
160 $bugapi->set('lastpostbyname
', bugdar::$userinfo['displayname
']);
161 $bugapi->set('hiddenlastposttime
', $comment->values['dateline
']);
162 $bugapi->set('hiddenlastpostby
', bugdar::$userinfo['userid
']);
163 $bugapi->set('hiddenlastpostbyname
', bugdar::$userinfo['displayname
']);
165 if (!((can_perform('caneditown
', $bug['product
']) AND bugdar::$userinfo['userid
'] == $bug['userid
']) OR (can_perform('caneditother
', $bug['product
']) AND bugdar::$userinfo['userid
'] != $bug['userid
'])))
169 $message->redirect(T('Your reply has been added to the comment
list.'), "showreport.php?bugid=$bug[bugid]");
173 // -------------------------------------------------------------------
175 $dependencies = preg_split('#([^0-9].*?)#', $input->in['dependency'], -1, PREG_SPLIT_NO_EMPTY);
176 $dependencies = ((sizeof($dependencies) < 1) ? '' : implode(', ', $dependencies));
178 if ((can_perform('caneditown', $bug['product']) AND bugdar
::$userinfo['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['product']) AND bugdar
::$userinfo['userid'] != $bug['userid']))
180 $bugapi->set('summary', $input->in
['summary']);
181 $bugapi->set('severity', $input->in
['severity']);
182 $bugapi->set('duplicateof', $input->in
['duplicateof']);
183 $bugapi->set('dependency', $dependencies);
184 $bugapi->set('hidden', $input->in
['hidden']);
186 $product = explode(',', $input->in
['product']);
187 $bugapi->set('product', $product[0]);
188 $bugapi->set('component', $product[1]);
189 $bugapi->set('version', $product[2]);
192 if (can_perform('canchangestatus', $bug['product']))
194 $bugapi->set('priority', $input->in
['priority']);
195 $bugapi->set('status', $input->in
['status']);
196 $bugapi->set('resolution', $input->in
['resolution']);
198 if (can_perform('canassign', $bug['product']))
200 $bugapi->set('assignedto', $input->in
['assignedto']);
203 process_custom_fields($bugapi, $message, false);
205 // -------------------------------------------------------------------
206 // handle logging and perform updates
208 $notif->set_bug_data($bugapi->record
, array_merge($bugapi->record
, $bugapi->values
));
209 $log->add_data(false, $bugapi->values
, $log->getCommonFields(), true);
211 if (!$message->hasErrors())
220 // -------------------------------------------------------------------
223 $log->update_history();
225 $notif->send_bug_changes_notice();
229 $message->redirect(T('Your changes to the bug have been saved.'), "showreport.php?bugid=$bug[bugid]");
232 /*=====================================================================*\
233 || ###################################################################
236 || ###################################################################
237 \*=====================================================================*/