]> src.bluestatic.org Git - bugdar.git/blob - newreport.php
Fix the password reset email system
[bugdar.git] / newreport.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright ©2002-2007 Blue Static
6 || #
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.
10 || #
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
14 || # more details.
15 || #
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 \*=====================================================================*/
21
22 $fetchtemplates = array(
23 'newreport',
24 );
25
26 define('SVN', '$Id$');
27
28 $focus['newreport'] = 'focus';
29
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');
35
36
37 $product = explode(',', $input->in['product']);
38 if (!can_perform('cansubmitbugs', $product[0]))
39 {
40 $message->errorPermission();
41 }
42
43 // ###################################################################
44
45 if (empty($_REQUEST['do']))
46 {
47 $_REQUEST['do'] = 'add';
48 }
49
50 // ###################################################################
51
52 if ($_POST['do'] == 'insert')
53 {
54 $bug = new BugAPI();
55 $comment = new CommentAPI();
56
57 $notif = new NotificationCenter();
58
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']);
63
64 $comment->set('userid', bugdar::$userinfo['userid']);
65 $comment->set('comment', $input->in['comment']);
66 $comment->set('parselinks', $input->in['parselinks']);
67
68 // -------------------------------------------------------------------
69 // check permissions on various input values
70 if (!can_perform('canchangestatus', $input->in['product']))
71 {
72 $bug->set('priority', bugdar::$options['defaultpriority']);
73 $bug->set('status', bugdar::$options['defaultstatus']);
74 $bug->set('resolution', bugdar::$options['defaultresolve']);
75 }
76 else
77 {
78 $bug->set('priority', $input->in['priority']);
79 $bug->set('status', $input->in['status']);
80 $bug->set('resolution', $input->in['resolution']);
81 }
82 if (!can_perform('canassign', $input->in['product']))
83 {
84 $bug->set('assignedto', bugdar::$options['defaultassign']);
85 }
86 else
87 {
88 // assigned person is not a dev or a valid user
89 $bug->set('assignedto', $input->in['assignedto']);
90 }
91
92 $product = explode(',', $input->in['product']);
93 $bug->set('product', $product[0]);
94 $bug->set('component', $product[1]);
95 $bug->set('version', $product[2]);
96
97 process_custom_fields($bug, $message, true);
98
99 if (!$message->hasErrors())
100 {
101 $bug->insert();
102
103 $comment->set('bugid', $bug->insertid);
104 $comment->insert();
105
106 $notif->send_new_bug_notice($bug->values, $comment->values);
107
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']);
110 $bug->fetch();
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']);
119 $bug->update();
120
121 $notif->set_bug_data($bug->record);
122
123 $notif->finalize();
124
125 $message->redirect(T('The bug has been added to the database.'), ($input->in['submit_reload'] == '' ? "showreport.php?bugid=" . $bug->values['bugid'] : 'newreport.php'));
126 }
127 else
128 {
129 $show['errors'] = true;
130 $_REQUEST['do'] = 'add';
131 }
132 }
133
134 // ###################################################################
135
136 if ($_REQUEST['do'] == 'add')
137 {
138 if (!is_array(bugdar::$datastore['product']))
139 {
140 $message->error(T('No products have been setup, therefore no bugs can be added.'));
141 }
142 if (!is_array(bugdar::$datastore['version']))
143 {
144 $message->error(T('No versions have been setup underneath your product(s), therefore no bugs can be added.'));
145 }
146
147 $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid', ($input->in['severity'] ? $input->in['severity'] : bugdar::$options['defaultseverity']));
148
149 $show['changestatus'] = can_perform('canchangestatus');
150
151 if (can_perform('canchangestatus'))
152 {
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']));
156 }
157
158 $show['assign'] = can_perform('canassign');
159
160 if (can_perform('canassign'))
161 {
162 foreach (bugdar::$datastore['assignto'] as $dev)
163 {
164 $tpl = new BSTemplate('selectoption');
165 $tpl->vars = array(
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']))
169 );
170 $select['dev'] = $tpl->evaluate()->getTemplate();
171 }
172 }
173
174 // custom fields
175 $fields = construct_custom_fields($bugsys->in, true);
176 $i = 0;
177 foreach ($fields AS $field)
178 {
179 if ($i % 2 == 0)
180 {
181 $customfields['left'] .= $field;
182 }
183 else
184 {
185 $customfields['right'] .= $field;
186 }
187 $i++;
188 }
189
190 $tpl = new BSTemplate('newreport');
191 $tpl->vars = array(
192 'reporter' => construct_user_display(bugdar::$userinfo),
193 'productSelect' => ConstructProductSelect('cansubmitbugs', $input->in['product'], false),
194 'select' => $select,
195 'customfields' => $customfields
196 );
197 $tpl->evaluate()->flush();
198 }
199
200 /*=====================================================================*\
201 || ###################################################################
202 || # $HeadURL$
203 || # $Id$
204 || ###################################################################
205 \*=====================================================================*/
206 ?>