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
/class_notification
.php
');
29 require_once('./includes
/api_bug
.php
');
30 require_once('./includes
/api_comment
.php
');
32 $bug = $db->query_first("
33 SELECT bugvaluefill.*, 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 LEFT JOIN " . TABLE_PREFIX . "bugvaluefill AS bugvaluefill
38 ON (bug.bugid = bugvaluefill.bugid)
39 WHERE bug.bugid = " . intval($bugsys->in['bugid
'])
42 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
']))
44 $message->error_permission();
49 $message->error($lang->getlex('error_invalid_id
'));
52 if ($bug['hidden
'] AND !can_perform('canviewhidden
', $bug['productid
']))
54 $message->error_permission();
58 require_once('./includes
/class_logging
.php
');
60 $log->set_bugid($bug['bugid
']);
70 'versionid
' => 'version
',
71 'assignedto
' => 'assignto
',
73 'productid
' => 'product
',
74 'componentid
' => 'component
'
77 $notif = new NotificationCenter;
79 // ###################################################################
81 if ($_POST['do'] == 'update
')
83 $bugapi = new BugAPI($bugsys);
84 $bugapi->set('bugid
', $bugsys->in['bugid
']);
85 $bugapi->set_condition();
86 $bugapi->dorelations = array();
89 $log->add_data(true, $bugapi->objdata, $bugfields);
91 // -------------------------------------------------------------------
93 $autoaction = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "autoaction WHERE actionid = " . $bugsys->input_clean('autoaction
', TYPE_UINT));
96 $autoaction['fields
'] = unserialize($autoaction['fieldchanges
']);
98 foreach ($autoaction['fields
']['builtin
'] AS $field => $value)
100 $bugsys->in["$field"] = $value;
103 foreach ($autoaction['fields
']['custom
'] AS $field => $value)
105 $bugsys->in["field$field"] = $value;
109 // -------------------------------------------------------------------
110 // process comment stuff
111 if ($bugsys->in['comment
'])
113 if (!empty($bugsys->in['comment
']) AND $autoaction['comment
'])
115 $commenttext = $bugsys->in['comment
'] . "\n\n" . $lang->string('--------------- AUTOMATIC RESPONSE
---------------') . "\n" . $autoaction['comment
'];
117 else if (empty($bugsys->in['comment
']) AND $autoaction['comment
'])
119 $commenttext = $autoaction['comment
'];
123 $commenttext = $bugsys->in['comment
'];
126 $comment = new CommentAPI($bugsys);
127 $comment->set('bugid
', $bugsys->in['bugid
']);
128 $comment->set('userid
', $bugsys->userinfo['userid
']);
129 $comment->set('comment
', $commenttext);
132 $notif->send_new_comment_notice($comment->values);
134 $bugapi->set('lastposttime
', $comment->values['dateline
']);
135 $bugapi->set('lastpostby
', $bugsys->userinfo['userid
']);
136 $bugapi->set('lastpostbyname
', $bugsys->userinfo['displayname
']);
137 $bugapi->set('hiddenlastposttime
', $comment->values['dateline
']);
138 $bugapi->set('hiddenlastpostby
', $bugsys->userinfo['userid
']);
139 $bugapi->set('hiddenlastpostbyname
', $bugsys->userinfo['displayname
']);
141 if (!((can_perform('caneditown
', $bug['productid
']) AND $bugsys->userinfo['userid
'] == $bug['userid
']) OR (can_perform('caneditother
', $bug['productid
']) AND $bugsys->userinfo['userid
'] != $bug['userid
'])))
144 $message->redirect($lang->string('Your reply has been added to the comment
list.'), "showreport.php?bugid=$bug[bugid]");
148 // -------------------------------------------------------------------
150 $pcv = parse_pcv_select($bugsys->in['pcv_select
'], true);
152 if ($fields = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]"))
154 $log->add_data(true, $fields, array('bugid
'), true, 'custom
');
157 // -------------------------------------------------------------------
160 process_custom_fields($bug['bugid
']);
162 $dependencies = preg_split('#([^0-9].*?)#', $bugsys->in['dependency'], -1, PREG_SPLIT_NO_EMPTY);
163 $dependencies = ((count($dependencies) < 1) ? '' : implode(', ', $dependencies));
165 $bugapi->set('summary', $bugsys->in
['summary']);
166 $bugapi->set('severity', $bugsys->in
['severity']);
167 $bugapi->set('duplicateof', $bugsys->in
['duplicateof']);
168 $bugapi->set('dependency', $dependencies);
169 $bugapi->set('productid', $pcv['product']);
170 $bugapi->set('componentid', $pcv['component']);
171 $bugapi->set('versionid', $pcv['version']);
172 $bugapi->set('hidden', $bugsys->in
['hidden']);
174 if (can_perform('canchangestatus', $bug['productid']))
176 $bugapi->set('priority', $bugsys->in
['priority']);
177 $bugapi->set('status', $bugsys->in
['status']);
178 $bugapi->set('resolution', $bugsys->in
['resolution']);
180 if (can_perform('canassign', $bug['productid']))
182 $bugapi->set('assignedto', $bugsys->in
['assignedto']);
185 $log->add_data(false, $bugapi->values
, $bugfields);
189 // -------------------------------------------------------------------
192 $fields = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bugvaluefill WHERE bugid = $bug[bugid]");
193 $log->add_data(false, $fields, array('bugid'), true, 'custom');
195 $log->update_history();
197 $notif->send_bug_changes_notice($bugapi->objdata
, $bugapi->values
);
201 $message->redirect($lang->string('Your changes to the bug have been saved.'), "showreport.php?bugid=$bug[bugid]");
204 /*=====================================================================*\
205 || ###################################################################
208 || ###################################################################
209 \*=====================================================================*/