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 \*=====================================================================*/
23 $focus['showreport'] = 'focus';
25 require_once('./global.php');
26 require_once('./includes/functions_product.php');
27 require_once('./includes/class_notification.php');
28 require_once('./includes/api_bug.php');
29 require_once('./includes/api_comment.php');
31 $bug = $db->queryFirst("
32 SELECT 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 WHERE bug.bugid = " . $input->inputClean('bugid', TYPE_UINT
)
41 $message->error(L_INVALID_ID
);
44 if (!check_bug_permissions($bug))
46 $message->errorPermission();
50 require_once('./includes/class_logging.php');
52 $log->setBugId($bug['bugid']);
54 $notif = new NotificationCenter();
56 $bugapi = new BugAPI();
57 $bugapi->set('bugid', $input->in
['bugid']);
60 // ###################################################################
62 if ($_POST['do'] == 'kill')
64 if (!can_perform('candeletedata', $bug['product']))
66 $message->errorPermission();
71 $message->redirect(T('The entire bug has been deleted.'), 'index.php');
74 // ###################################################################
76 if ($_REQUEST['do'] == 'delete')
78 if (!can_perform('candeletedata', $bug['product']))
80 $message->errorPermission();
83 $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']));
86 // ###################################################################
88 if ($_POST['do'] == 'update')
90 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']))
92 $message->errorPermission();
95 $log->addData(true
, $bugapi->record
, $log->getCommonFields(), true
);
97 // -------------------------------------------------------------------
99 if ($input->in
['automation'])
101 $automation = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX
. "automation WHERE actionid = " . $input->inputClean('automation', TYPE_UINT
));
104 $automation['fields'] = unserialize($automation['fieldchanges']);
106 if (is_array($automation['fields']['builtin']))
108 foreach ($automation['fields']['builtin'] AS $field => $value)
110 $input->in
["$field"] = $value;
114 if (is_array($automation['fields']['custom']))
116 foreach ($automation['fields']['custom'] AS $field => $value)
118 $input->in
["custom$field"] = $value;
124 // -------------------------------------------------------------------
125 // process comment stuff
126 if ($input->in
['comment'] OR $automation['comment'])
128 if (!empty($input->in
['comment']) AND $automation['comment'])
130 $commenttext = $input->in
['comment'] . "\n\n" . T('--------------- AUTOMATIC RESPONSE ---------------') . "\n" . $automation['comment'];
132 else if (empty($input->in
['comment']) AND $automation['comment'])
134 $commenttext = $automation['comment'];
138 $commenttext = $input->in
['comment'];
141 $comment = new CommentAPI();
142 $comment->set('bugid', $input->in
['bugid']);
143 $comment->set('userid', bugdar
::$userinfo['userid']);
144 $comment->set('comment', $commenttext);
145 $comment->set('parselinks', $input->in
['parselinks']);
148 // we redefine the bug data later, but it needs to be here in order to generate the user list
149 $notif->setBugData($bugapi->record
);
150 $notif->sendNewCommentNotice($comment->values
);
152 $bugapi->set('lastposttime', $comment->values
['dateline']);
153 $bugapi->set('lastpostby', bugdar
::$userinfo['userid']);
154 $bugapi->set('lastpostbyname', bugdar
::$userinfo['displayname']);
155 $bugapi->set('hiddenlastposttime', $comment->values
['dateline']);
156 $bugapi->set('hiddenlastpostby', bugdar
::$userinfo['userid']);
157 $bugapi->set('hiddenlastpostbyname', bugdar
::$userinfo['displayname']);
159 if (!((can_perform('caneditown', $bug['product']) AND bugdar
::$userinfo['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['product']) AND bugdar
::$userinfo['userid'] != $bug['userid'])))
163 $message->redirect(T('Your reply has been added to the comment list.'), "showreport.php?bugid=$bug[bugid]");
167 // -------------------------------------------------------------------
169 $dependencies = preg_split('#([^0-9].*?)#', $input->in
['dependency'], -1, PREG_SPLIT_NO_EMPTY
);
170 $dependencies = ((sizeof($dependencies) < 1) ?
'' : implode(', ', $dependencies));
172 if ((can_perform('caneditown', $bug['product']) && bugdar
::$userinfo['userid'] == $bug['userid']) ||
(can_perform('caneditother', $bug['product']) && bugdar
::$userinfo['userid'] != $bug['userid']))
174 $bugapi->set('summary', $input->in
['summary']);
175 $bugapi->set('severity', $input->in
['severity']);
176 $bugapi->set('duplicateof', $input->in
['duplicateof']);
177 $bugapi->set('dependency', $dependencies);
178 $bugapi->set('hidden', $input->in
['hidden']);
180 $product = explode(',', $input->in
['product']);
181 $bugapi->set('product', $product[0]);
182 $bugapi->set('component', $product[1]);
183 $bugapi->set('version', $product[2]);
186 if (can_perform('canchangestatus', $bug['product']))
188 $bugapi->set('priority', $input->in
['priority']);
189 $bugapi->set('status', $input->in
['status']);
190 $bugapi->set('resolution', $input->in
['resolution']);
192 if (can_perform('canassign', $bug['product']))
194 $bugapi->set('assignedto', $input->in
['assignedto']);
197 process_custom_fields($bugapi, $message, false
);
199 // -------------------------------------------------------------------
200 // handle logging and perform updates
202 $notif->setBugData($bugapi->record
, array_merge($bugapi->record
, $bugapi->values
));
203 $log->addData(false
, $bugapi->values
, $log->getCommonFields(), true
);
205 if (!$message->hasErrors())
214 // -------------------------------------------------------------------
217 $log->updateHistory();
219 $notif->sendBugChangeNotice();
223 $message->redirect(T('Your changes to the bug have been saved.'), "showreport.php?bugid=$bug[bugid]");