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 $fetchtemplates = array(
26 define('SVN', '$Id$');
28 $focus['newreport'] = 'focus';
30 require_once('./global.php');
31 require_once('./includes/functions_product.php');
32 require_once('./includes/class_notification.php');
33 require_once('./includes/api_bug.php');
34 require_once('./includes/api_comment.php');
36 require_once('./includes/class_api_error.php');
37 APIError(array(new API_Error_Handler($message), 'user_cumulative'));
39 $bugsys->input_clean('product', TYPE_UINT
);
40 if (!can_perform('cansubmitbugs', $bugsys->in
['product']))
42 $message->error_permission();
45 // ###################################################################
47 if (empty($_REQUEST['do']))
49 $_REQUEST['do'] = 'add';
52 // ###################################################################
54 if ($_POST['do'] == 'insert')
56 $bug = new BugAPI($bugsys);
57 $comment = new CommentAPI($bugsys);
59 $notif = new NotificationCenter
;
61 $bug->set('userid', $bugsys->userinfo
['userid']);
62 $bug->set('username', $bugsys->userinfo
['displayname']);
63 $bug->set('summary', $bugsys->in
['summary']);
64 $bug->set('severity', $bugsys->in
['severity']);
66 $comment->set('userid', $bugsys->userinfo
['userid']);
67 $comment->set('comment', $bugsys->in
['comment']);
69 // -------------------------------------------------------------------
70 // check permissions on various input values
71 if (!can_perform('canchangestatus', $bugsys->in
['product']))
73 $bug->set('priority', $bugsys->options
['defaultpriority']);
74 $bug->set('status', $bugsys->options
['defaultstatus']);
75 $bug->set('resolution', $bugsys->options
['defaultresolve']);
79 $bug->set('priority', $bugsys->in
['priority']);
80 $bug->set('status', $bugsys->in
['status']);
81 $bug->set('resolution', $bugsys->in
['resolution']);
83 if (!can_perform('canassign', $bugsys->in
['product']))
85 $bug->set('assignedto', $bugsys->options
['defaultassign']);
89 // assigned person is not a dev or a valid user
90 $bug->set('assignedto', $bugsys->in
['assignedto']);
93 // -------------------------------------------------------------------
94 // product/component/version stuff
95 $pcv = parse_pcv_select($bugsys->in
['pcv_select'], true
);
98 $message->add_error(_('Invalid product/component/version selected.'));
100 $bug->set('product', $pcv['product']);
101 $bug->set('component', $pcv['component']);
102 $bug->set('version', $pcv['version']);
104 $cfields = process_custom_fields(null
, $message, true
);
106 if (!$message->items
)
110 $comment->set('bugid', $bug->insertid
);
113 $notif->send_new_bug_notice($bug->values
, $comment->values
);
115 $bug = new BugAPI($bugsys); // need to destroy because update will think the insert fields need to be changed, too
116 $bug->dorelations
= array();
117 $bug->set('bugid', $comment->values
['bugid']);
118 $bug->set_condition();
120 $bug->set('dateline', $comment->values
['dateline']);
121 $bug->set('initialreport', $comment->insertid
);
122 $bug->set('lastposttime', $comment->values
['dateline']);
123 $bug->set('lastpostby', $bugsys->userinfo
['userid']);
124 $bug->set('lastpostbyname', $bugsys->userinfo
['displayname']);
125 $bug->set('hiddenlastposttime', $comment->values
['dateline']);
126 $bug->set('hiddenlastpostby', $bugsys->userinfo
['userid']);
127 $bug->set('hiddenlastpostbyname', $bugsys->userinfo
['displayname']);
130 $db->query(sprintf($cfields, $comment->values
['bugid']));
132 $notif->set_bug_data($bug->objdata
);
136 $message->redirect(_('The bug has been added to the database.'), ($bugsys->in
['submit_reload'] == '' ?
"showreport.php?bugid=" . $bug->values
['bugid'] : 'newreport.php'));
140 $show['errors'] = true
;
141 $_REQUEST['do'] = 'add';
142 $message->error_list_process();
146 // ###################################################################
148 if ($_REQUEST['do'] == 'add')
150 if (!is_array($bugsys->datastore
['product']))
152 $message->error(_('No products have been setup, therefore no bugs can be added.'));
154 if (!is_array($bugsys->datastore
['version']))
156 $message->error(_('No versions have been setup underneath your product(s), therefore no bugs can be added.'));
159 $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid', ($bugsys->in
['severity'] ?
$bugsys->in
['severity'] : $bugsys->options
['defaultseverity']));
161 $show['changestatus'] = ((can_perform('canchangestatus')) ? true
: false
);
163 if (can_perform('canchangestatus'))
165 $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid', ($bugsys->in
['priority'] ?
$bugsys->in
['priority'] : $bugsys->options
['defaultpriority']));
166 $select['status'] = construct_datastore_select('status', 'status', 'statusid', ($bugsys->in
['status'] ?
$bugsys->in
['status'] : $bugsys->options
['defaultstatus']));
167 $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid', ($bugsys->in
['resolution'] ?
$bugsys->in
['resolution'] : $bugsys->options
['defaultresolve']));
170 $show['assign'] = ((can_perform('canassign')) ? true
: false
);
172 if (can_perform('canassign'))
174 foreach ($bugsys->datastore
['assignto'] AS $dev)
176 $value = $dev['userid'];
177 $label = construct_user_display($dev, false
);
178 $selected = ($bugsys->in
['assignedto'] ?
($bugsys->in
['assignedto'] == $dev['userid']) : ($dev['userid'] == $bugsys->options
['defaultassign']));
179 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
184 $fields = construct_custom_fields($bugsys->in
, true
);
186 foreach ($fields AS $field)
190 $customfields['left'] .= $field;
194 $customfields['right'] .= $field;
199 $pcv_select = construct_pcv_select('cansubmitbugs', $bugsys->in
['pcv_select']);
201 $reporter = construct_user_display($bugsys->userinfo
);
203 eval('$template->flush("' . $template->fetch('newreport') . '");');
206 /*=====================================================================*\
207 || ###################################################################
210 || ###################################################################
211 \*=====================================================================*/