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 $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
/api_bug
.php
');
34 if (!can_perform('cansubmitbugs
', intval($bugsys->in['productid
'])))
36 $message->error_permission();
39 // ###################################################################
41 if (empty($_REQUEST['do']))
43 $_REQUEST['do'] = 'add
';
46 // ###################################################################
48 if ($_POST['do'] == 'insert
')
50 $bug = new BugAPI($bugsys);
52 // -------------------------------------------------------------------
53 // check permissions on various input values
54 if (!can_perform('canchangestatus
', intval($bugsys->in['productid
'])))
56 $bugsys->in['priority
'] = $bugsys->options['defaultpriority
'];
57 $bugsys->in['status
'] = $bugsys->options['defaultstatus
'];
58 $bugsys->in['resolution
'] = $bugsys->options['defaultresolve
'];
62 if (!$bugsys->datastore['priority
'][ $bugsys->in['priority
'] ])
64 $bugsys->in['priority
'] = $bugsys->options['defaultpriority
'];
66 if (!$bugsys->datastore['status
'][ $bugsys->in['status
'] ])
68 $bugsys->in['status
'] = $bugsys->options['defaultstatus
'];
70 if (!$bugsys->datastore['resolution
'][ $bugsys->in['resolution
'] ])
72 $bugsys->in['resolution
'] = $bugsys->options['defaultresolve
'];
75 if (!can_perform('canassign
', intval($bugsys->in['productid
'])))
77 $bugsys->in['assignedto
'] = $bugsys->options['defaultassign
'];
81 // assigned person is not a dev or a valid user
82 if (!$bugsys->datastore['assignto
'][ $bugsys->in['assignedto
'] ]['userid
'])
84 $bugsys->in['assignedto
'] = $bugsys->options['defaultassign
'];
88 // -------------------------------------------------------------------
89 // product/component/version stuff
90 $pcv = parse_pcv_select($bugsys->in['pcv_select
'], true);
92 // -------------------------------------------------------------------
96 $message->items[] = $lang->string('Invalid product
/component
/version selected
.');
98 if (!$bugsys->in['summary
'])
100 $message->items[] = $lang->string('Please enter a title
for the bug
');
102 if (!$bugsys->in['comment
'])
104 $message->items[] = $lang->string('Please fill in the bug\'s description field
');
107 if (!$message->items)
109 // -------------------------------------------------------------------
110 // data clean and insert
111 $bugsys->in['comment_parsed
'] = $bugsys->in['comment
'];
113 if (!$bugsys->options['allowhtml
'])
115 $bugsys->in['comment_parsed
'] = $bugsys->sanitize($bugsys->in['comment_parsed
']);
118 // create the bug report
120 INSERT INTO " . TABLE_PREFIX . "bug
121 (userid, productid, componentid, versionid, summary, severity, priority, status, assignedto, resolution)
123 (" . $bugsys->userinfo['userid
'] . ", " . $pcv['product
'] . ", " . $pcv['component
'] . ", " . $pcv['version
'] . ",
124 '" . $bugsys->in['summary'] . "', " . intval($bugsys->in['severity
']) . ", " . intval($bugsys->in['priority
']) . ",
125 " . intval($bugsys->in['status
']) . ", " . intval($bugsys->in['assignedto
']) . ", " . intval($bugsys->in['resolution
']) . "
129 $bugid = $db->insert_id();
131 $comment = new CommentAPI($bugsys);
132 $comment->set('bugid
', $bugid);
133 $comment->set('userid
', $bugsys->userinfo['userid
']);
134 $comment->set('comment
', $_POST['comment
']);
137 // insert the comment to the database
139 INSERT INTO " . TABLE_PREFIX . "comment
140 (bugid, userid, dateline, comment, comment_parsed)
142 ($bugid, " . $bugsys->userinfo['userid
'] . ",
143 $time, '" . $bugsys->in['comment'] . "',
144 '" . nl2br($bugsys->in['comment_parsed']) . "'
148 $time = $comment->values['dateline
'];
151 UPDATE " . TABLE_PREFIX . "bug
152 SET dateline = $time,
153 initialreport = " . $comment->insertid . ",
154 lastposttime = $time,
155 lastpostby = " . $bugsys->userinfo['userid
'] . ",
156 hiddenlastposttime = $time,
157 hiddenlastpostby = " . $bugsys->userinfo['userid
'] . "
158 WHERE bugid = $bugid"
161 $db->query("INSERT INTO " . TABLE_PREFIX . "vote (bugid, votefor, voteagainst) VALUES ($bugid, 0, 0)");
163 $message->redirect($lang->string('The bug has been added to the database
.'), ($bugsys->in['submit_reload
'] == '' ? "showreport.php?bugid=$bugid" : 'newreport
.php
'));
167 $show['errors
'] = true;
168 $_REQUEST['do'] = 'add
';
169 $message->error_list_process();
173 // ###################################################################
175 if ($_REQUEST['do'] == 'add
')
177 $select['severity
'] = construct_datastore_select('severity
', 'severity
', 'severityid
', ($bugsys->in['severity
'] ? $bugsys->in['severity
'] : $bugsys->options['defaultseverity
']));
179 $show['changestatus
'] = ((can_perform('canchangestatus
')) ? true : false);
181 if (can_perform('canchangestatus
'))
183 $select['priority
'] = construct_datastore_select('priority
', 'priority
', 'priorityid
', ($bugsys->in['priority
'] ? $bugsys->in['priority
'] : $bugsys->options['defaultpriority
']));
184 $select['status
'] = construct_datastore_select('status
', 'status
', 'statusid
', ($bugsys->in['status
'] ? $bugsys->in['status
'] : $bugsys->options['defaultstatus
']));
185 $select['resolution
'] = construct_datastore_select('resolution
', 'resolution
', 'resolutionid
', ($bugsys->in['resolution
'] ? $bugsys->in['resolution
'] : $bugsys->options['defaultresolve
']));
188 $show['assign
'] = ((can_perform('canassign
')) ? true : false);
190 if (can_perform('canassign
'))
192 foreach ($bugsys->datastore['assignto
'] AS $dev)
194 $value = $dev['userid
'];
195 $label = construct_user_display($dev, false);
196 $selected = ($bugsys->in['assignedto
'] ? ($bugsys->in['assignedto
'] == $dev['userid
']) : ($dev['userid
'] == $bugsys->options['defaultassign
']));
197 eval('$select[dev
] .= "' . $template->fetch('selectoption') . '";');
202 $fields = construct_custom_fields(null, true);
204 foreach ($fields AS $field)
208 $customfields['left
'] .= $field;
212 $customfields['right
'] .= $field;
217 $pcv_select = construct_pcv_select('cansubmitbugs
', $bugsys->in['pcv_select
']);
219 $reporter = construct_user_display($bugsys->userinfo);
221 eval('$template->flush("' . $template->fetch('newreport') . '");');
224 /*=====================================================================*\
225 || ###################################################################
228 || ###################################################################
229 \*=====================================================================*/