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
');
37 $product = explode(',', $input->in['product
']);
38 if (!can_perform('cansubmitbugs
', $product[0]))
40 $message->errorPermission();
43 // ###################################################################
45 if (empty($_REQUEST['do']))
47 $_REQUEST['do'] = 'add
';
50 // ###################################################################
52 if ($_POST['do'] == 'insert
')
55 $comment = new CommentAPI();
57 $notif = new NotificationCenter();
59 $bug->set('userid
', bugdar::$userinfo['userid
']);
60 $bug->set('username
', bugdar::$userinfo['displayname
']);
61 $bug->set('summary
', $input->in['summary
']);
62 $bug->set('severity
', $input->in['severity
']);
64 $comment->set('userid
', bugdar::$userinfo['userid
']);
65 $comment->set('comment
', $input->in['comment
']);
66 $comment->set('parselinks
', $input->in['parselinks
']);
68 // -------------------------------------------------------------------
69 // check permissions on various input values
70 if (!can_perform('canchangestatus
', $input->in['product
']))
72 $bug->set('priority
', bugdar::$options['defaultpriority
']);
73 $bug->set('status
', bugdar::$options['defaultstatus
']);
74 $bug->set('resolution
', bugdar::$options['defaultresolve
']);
78 $bug->set('priority
', $input->in['priority
']);
79 $bug->set('status
', $input->in['status
']);
80 $bug->set('resolution
', $input->in['resolution
']);
82 if (!can_perform('canassign
', $input->in['product
']))
84 $bug->set('assignedto
', bugdar::$options['defaultassign
']);
88 // assigned person is not a dev or a valid user
89 $bug->set('assignedto
', $input->in['assignedto
']);
92 $product = explode(',', $input->in['product
']);
93 $bug->set('product
', $product[0]);
94 $bug->set('component
', $product[1]);
95 $bug->set('version
', $product[2]);
97 process_custom_fields($bug, $message, true);
99 if (!$message->hasErrors())
103 $comment->set('bugid
', $bug->insertid);
106 $notif->send_new_bug_notice($bug->values, $comment->values);
108 $bug = new BugAPI(); // need to destroy because update will think the insert fields need to be changed, too
109 $bug->set('bugid
', $comment->values['bugid
']);
111 $bug->set('dateline
', $comment->values['dateline
']);
112 $bug->set('initialreport
', $comment->insertid);
113 $bug->set('lastposttime
', $comment->values['dateline
']);
114 $bug->set('lastpostby
', bugdar::$userinfo['userid
']);
115 $bug->set('lastpostbyname
', bugdar::$userinfo['displayname
']);
116 $bug->set('hiddenlastposttime
', $comment->values['dateline
']);
117 $bug->set('hiddenlastpostby
', bugdar::$userinfo['userid
']);
118 $bug->set('hiddenlastpostbyname
', bugdar::$userinfo['displayname
']);
121 $notif->set_bug_data($bug->record);
125 $message->redirect(T('The bug has been added to the database
.'), ($input->in['submit_reload
'] == '' ? "showreport.php?bugid=" . $bug->values['bugid
'] : 'newreport
.php
'));
129 $show['errors
'] = true;
130 $_REQUEST['do'] = 'add
';
134 // ###################################################################
136 if ($_REQUEST['do'] == 'add
')
138 if (!is_array(bugdar::$datastore['product
']))
140 $message->error(T('No products have been setup
, therefore no bugs can be added
.'));
142 if (!is_array(bugdar::$datastore['version
']))
144 $message->error(T('No versions have been setup underneath your
product(s
), therefore no bugs can be added
.'));
147 $select['severity
'] = construct_datastore_select('severity
', 'severity
', 'severityid
', ($input->in['severity
'] ? $input->in['severity
'] : bugdar::$options['defaultseverity
']));
149 $show['changestatus
'] = can_perform('canchangestatus
');
151 if (can_perform('canchangestatus
'))
153 $select['priority
'] = construct_datastore_select('priority
', 'priority
', 'priorityid
', ($input->in['priority
'] ? $input->in['priority
'] : bugdar::$options['defaultpriority
']));
154 $select['status
'] = construct_datastore_select('status
', 'status
', 'statusid
', ($input->in['status
'] ? $input->in['status
'] : bugdar::$options['defaultstatus
']));
155 $select['resolution
'] = construct_datastore_select('resolution
', 'resolution
', 'resolutionid
', ($input->in['resolution
'] ? $input->in['resolution
'] : bugdar::$options['defaultresolve
']));
158 $show['assign
'] = can_perform('canassign
');
160 if (can_perform('canassign
'))
162 foreach (bugdar::$datastore['assignto
'] as $dev)
164 $tpl = new BSTemplate('selectoption
');
166 'value
' => $dev['userid
'],
167 'label
' => construct_user_display($dev, false),
168 'selected
' => ($input->in['assignedto
'] ? ($input->in['assignedto
'] == $dev['userid
']) : ($dev['userid
'] == bugdar::$options['defaultassign
']))
170 $select['dev
'] = $tpl->evaluate()->getTemplate();
175 $fields = construct_custom_fields($bugsys->in, true);
177 foreach ($fields AS $field)
181 $customfields['left
'] .= $field;
185 $customfields['right
'] .= $field;
190 $tpl = new BSTemplate('newreport
');
192 'reporter
' => construct_user_display(bugdar::$userinfo),
193 'productSelect
' => ConstructProductSelect('cansubmitbugs
', $input->in['product
'], false),
195 'customfields
' => $customfields
197 $tpl->evaluate()->flush();
200 /*=====================================================================*\
201 || ###################################################################
204 || ###################################################################
205 \*=====================================================================*/