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 $bug = $db->queryFirst("
33 SELECT bug.*, user.email, user.displayname, user.showemail
34 FROM " . TABLE_PREFIX
. "bug AS bug
35 LEFT JOIN " . TABLE_PREFIX
. "user AS user
36 ON (bug.userid = user.userid)
37 WHERE bug.bugid = " . $input->inputClean('bugid', TYPE_UINT
)
42 $message->error(L_INVALID_ID
);
45 if (!check_bug_permissions($bug))
47 $message->errorPermission();
51 require_once('./includes/class_logging.php');
53 $log->set_bugid($bug['bugid']);
55 $notif = new NotificationCenter();
57 $bugapi = new BugAPI();
58 $bugapi->set('bugid', $input->in
['bugid']);
61 // ###################################################################
63 if ($_POST['do'] == 'kill')
65 if (!can_perform('candeletedata', $bug['product']))
67 $message->errorPermission();
72 $message->redirect(T('The entire bug has been deleted.'), 'index.php');
75 // ###################################################################
77 if ($_REQUEST['do'] == 'delete')
79 if (!can_perform('candeletedata', $bug['product']))
81 $message->errorPermission();
84 $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']));
87 // ###################################################################
89 if ($_POST['do'] == 'update')
91 if (!((can_perform('caneditown', $bug['product']) && bugdar
::$userinfo['userid'] == $bug['userid']) ||
(can_perform('caneditother', $bug['product']) && bugdar
::$userinfo['userid'] != $bug['userid'])) && !can_perform('canpostcomments', $bug['product']))
93 $message->errorPermission();
96 $log->add_data(true
, $bugapi->record
, $log->getCommonFields(), true
);
98 // -------------------------------------------------------------------
100 if ($input->in
['automation'])
102 $automation = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX
. "automation WHERE actionid = " . $input->inputClean('automation', TYPE_UINT
));
105 $automation['fields'] = unserialize($automation['fieldchanges']);
107 if (is_array($automation['fields']['builtin']))
109 foreach ($automation['fields']['builtin'] AS $field => $value)
111 $input->in
["$field"] = $value;
115 if (is_array($automation['fields']['custom']))
117 foreach ($automation['fields']['custom'] AS $field => $value)
119 $input->in
["custom$field"] = $value;
125 // -------------------------------------------------------------------
126 // process comment stuff
127 if ($input->in
['comment'] OR $automation['comment'])
129 if (!empty($input->in
['comment']) AND $automation['comment'])
131 $commenttext = $input->in
['comment'] . "\n\n" . T('--------------- AUTOMATIC RESPONSE ---------------') . "\n" . $automation['comment'];
133 else if (empty($input->in
['comment']) AND $automation['comment'])
135 $commenttext = $automation['comment'];
139 $commenttext = $input->in
['comment'];
142 $comment = new CommentAPI();
143 $comment->set('bugid', $input->in
['bugid']);
144 $comment->set('userid', bugdar
::$userinfo['userid']);
145 $comment->set('comment', $commenttext);
146 $comment->set('parselinks', $input->in
['parselinks']);
149 // we redefine the bug data later, but it needs to be here in order to generate the user list
150 $notif->setBugData($bugapi->record
);
151 $notif->sendNewCommentNotice($comment->values
);
153 $bugapi->set('lastposttime', $comment->values
['dateline']);
154 $bugapi->set('lastpostby', bugdar
::$userinfo['userid']);
155 $bugapi->set('lastpostbyname', bugdar
::$userinfo['displayname']);
156 $bugapi->set('hiddenlastposttime', $comment->values
['dateline']);
157 $bugapi->set('hiddenlastpostby', bugdar
::$userinfo['userid']);
158 $bugapi->set('hiddenlastpostbyname', bugdar
::$userinfo['displayname']);
160 if (!((can_perform('caneditown', $bug['product']) AND bugdar
::$userinfo['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['product']) AND bugdar
::$userinfo['userid'] != $bug['userid'])))
164 $message->redirect(T('Your reply has been added to the comment list.'), "showreport.php?bugid=$bug[bugid]");
168 // -------------------------------------------------------------------
170 $dependencies = preg_split('#([^0-9].*?)#', $input->in
['dependency'], -1, PREG_SPLIT_NO_EMPTY
);
171 $dependencies = ((sizeof($dependencies) < 1) ?
'' : implode(', ', $dependencies));
173 if ((can_perform('caneditown', $bug['product']) && bugdar
::$userinfo['userid'] == $bug['userid']) ||
(can_perform('caneditother', $bug['product']) && bugdar
::$userinfo['userid'] != $bug['userid']))
175 $bugapi->set('summary', $input->in
['summary']);
176 $bugapi->set('severity', $input->in
['severity']);
177 $bugapi->set('duplicateof', $input->in
['duplicateof']);
178 $bugapi->set('dependency', $dependencies);
179 $bugapi->set('hidden', $input->in
['hidden']);
181 $product = explode(',', $input->in
['product']);
182 $bugapi->set('product', $product[0]);
183 $bugapi->set('component', $product[1]);
184 $bugapi->set('version', $product[2]);
187 if (can_perform('canchangestatus', $bug['product']))
189 $bugapi->set('priority', $input->in
['priority']);
190 $bugapi->set('status', $input->in
['status']);
191 $bugapi->set('resolution', $input->in
['resolution']);
193 if (can_perform('canassign', $bug['product']))
195 $bugapi->set('assignedto', $input->in
['assignedto']);
198 process_custom_fields($bugapi, $message, false
);
200 // -------------------------------------------------------------------
201 // handle logging and perform updates
203 $notif->setBugData($bugapi->record
, array_merge($bugapi->record
, $bugapi->values
));
204 $log->add_data(false
, $bugapi->values
, $log->getCommonFields(), true
);
206 if (!$message->hasErrors())
215 // -------------------------------------------------------------------
218 $log->update_history();
220 $notif->sendBugChangeNotice();
224 $message->redirect(T('Your changes to the bug have been saved.'), "showreport.php?bugid=$bug[bugid]");
227 /*=====================================================================*\
228 || ###################################################################
231 || ###################################################################
232 \*=====================================================================*/