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 $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
');
38 $product = explode(',', $input->in['product
']);
39 if (!can_perform('cansubmitbugs
', $product[0]))
41 $message->errorPermission();
44 // ###################################################################
46 if (empty($_REQUEST['do']))
48 $_REQUEST['do'] = 'add
';
51 // ###################################################################
53 if ($_POST['do'] == 'insert
')
56 $comment = new CommentAPI();
58 $notif = new NotificationCenter();
60 $bug->set('userid
', bugdar::$userinfo['userid
']);
61 $bug->set('username
', bugdar::$userinfo['displayname
']);
62 $bug->set('summary
', $input->in['summary
']);
63 $bug->set('severity
', $input->in['severity
']);
65 $comment->set('userid
', bugdar::$userinfo['userid
']);
66 $comment->set('comment
', $input->in['comment
']);
67 $comment->set('parselinks
', $input->in['parselinks
']);
69 // -------------------------------------------------------------------
70 // check permissions on various input values
71 if (!can_perform('canchangestatus
', $input->in['product
']))
73 $bug->set('priority
', bugdar::$options['defaultpriority
']);
74 $bug->set('status
', bugdar::$options['defaultstatus
']);
75 $bug->set('resolution
', bugdar::$options['defaultresolve
']);
79 $bug->set('priority
', $input->in['priority
']);
80 $bug->set('status
', $input->in['status
']);
81 $bug->set('resolution
', $input->in['resolution
']);
83 if (!can_perform('canassign
', $input->in['product
']))
85 $bug->set('assignedto
', bugdar::$options['defaultassign
']);
89 // assigned person is not a dev or a valid user
90 $bug->set('assignedto
', $input->in['assignedto
']);
93 $product = explode(',', $input->in['product
']);
94 $bug->set('product
', $product[0]);
95 $bug->set('component
', $product[1]);
96 $bug->set('version
', $product[2]);
98 process_custom_fields($bug, $message, true);
100 if (!$message->hasErrors())
104 $comment->set('bugid
', $bug->insertid);
107 $notif->send_new_bug_notice($bug->values, $comment->values);
109 $bug = new BugAPI(); // need to destroy because update will think the insert fields need to be changed, too
110 $bug->set('bugid
', $comment->values['bugid
']);
112 $bug->set('dateline
', $comment->values['dateline
']);
113 $bug->set('initialreport
', $comment->insertid);
114 $bug->set('lastposttime
', $comment->values['dateline
']);
115 $bug->set('lastpostby
', bugdar::$userinfo['userid
']);
116 $bug->set('lastpostbyname
', bugdar::$userinfo['displayname
']);
117 $bug->set('hiddenlastposttime
', $comment->values['dateline
']);
118 $bug->set('hiddenlastpostby
', bugdar::$userinfo['userid
']);
119 $bug->set('hiddenlastpostbyname
', bugdar::$userinfo['displayname
']);
122 $notif->set_bug_data($bug->record);
126 $message->redirect(T('The bug has been added to the database
.'), ($input->in['submit_reload
'] == '' ? "showreport.php?bugid=" . $bug->values['bugid
'] : 'newreport
.php
'));
130 $show['errors
'] = true;
131 $_REQUEST['do'] = 'add
';
135 // ###################################################################
137 if ($_REQUEST['do'] == 'add
')
139 if (!is_array(bugdar::$datastore['product
']))
141 $message->error(T('No products have been setup
, therefore no bugs can be added
.'));
143 if (!is_array(bugdar::$datastore['version
']))
145 $message->error(T('No versions have been setup underneath your
product(s
), therefore no bugs can be added
.'));
148 $select['severity
'] = construct_datastore_select('severity
', 'severity
', 'severityid
', ($input->in['severity
'] ? $input->in['severity
'] : bugdar::$options['defaultseverity
']));
150 $show['changestatus
'] = can_perform('canchangestatus
');
152 if (can_perform('canchangestatus
'))
154 $select['priority
'] = construct_datastore_select('priority
', 'priority
', 'priorityid
', ($input->in['priority
'] ? $input->in['priority
'] : bugdar::$options['defaultpriority
']));
155 $select['status
'] = construct_datastore_select('status
', 'status
', 'statusid
', ($input->in['status
'] ? $input->in['status
'] : bugdar::$options['defaultstatus
']));
156 $select['resolution
'] = construct_datastore_select('resolution
', 'resolution
', 'resolutionid
', ($input->in['resolution
'] ? $input->in['resolution
'] : bugdar::$options['defaultresolve
']));
159 $show['assign
'] = can_perform('canassign
');
161 if (can_perform('canassign
'))
163 foreach (bugdar::$datastore['assignto
'] as $dev)
165 $tpl = new BSTemplate('selectoption
');
167 'value
' => $dev['userid
'],
168 'label
' => construct_user_display($dev, false),
169 'selected
' => ($input->in['assignedto
'] ? ($input->in['assignedto
'] == $dev['userid
']) : ($dev['userid
'] == bugdar::$options['defaultassign
']))
171 $select['dev
'] = $tpl->evaluate()->getTemplate();
176 $fields = construct_custom_fields($bugsys->in, true);
178 foreach ($fields AS $field)
182 $customfields['left
'] .= $field;
186 $customfields['right
'] .= $field;
191 $tpl = new BSTemplate('newreport
');
193 'reporter
' => construct_user_display(bugdar::$userinfo),
194 'productSelect
' => ConstructProductSelect('cansubmitbugs
', $input->in['product
'], false),
196 'customfields
' => $customfields
198 $tpl->evaluate()->flush();
201 /*=====================================================================*\
202 || ###################################################################
205 || ###################################################################
206 \*=====================================================================*/