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');
33 if (!can_perform('cansubmitbugs', intval($bugsys->in
['productid'])))
35 $message->error_permission();
38 // ###################################################################
40 if (empty($_REQUEST['do']))
42 $_REQUEST['do'] = 'add';
45 // ###################################################################
47 if ($_POST['do'] == 'insert')
49 // -------------------------------------------------------------------
50 // check permissions on various input values
51 if (!can_perform('canchangestatus', intval($bugsys->in
['productid'])))
53 $bugsys->in
['priority'] = $bugsys->options
['defaultpriority'];
54 $bugsys->in
['status'] = $bugsys->options
['defaultstatus'];
55 $bugsys->in
['resolution'] = $bugsys->options
['defaultresolve'];
59 if (!$bugsys->datastore
['priority'][ $bugsys->in
['priority'] ])
61 $bugsys->in
['priority'] = $bugsys->options
['defaultpriority'];
63 if (!$bugsys->datastore
['status'][ $bugsys->in
['status'] ])
65 $bugsys->in
['status'] = $bugsys->options
['defaultstatus'];
67 if (!$bugsys->datastore
['resolution'][ $bugsys->in
['resolution'] ])
69 $bugsys->in
['resolution'] = $bugsys->options
['defaultresolve'];
72 if (!can_perform('canassign', intval($bugsys->in
['productid'])))
74 $bugsys->in
['assignedto'] = $bugsys->options
['defaultassign'];
78 // assigned person is not a dev or a valid user
79 if (!$bugsys->datastore
['assignto'][ $bugsys->in
['assignedto'] ]['userid'])
81 $bugsys->in
['assignedto'] = $bugsys->options
['defaultassign'];
85 // -------------------------------------------------------------------
86 // product/component/version stuff
87 $pcv = parse_pcv_select($bugsys->in
['pcv_select'], true
);
89 // -------------------------------------------------------------------
93 $message->items
[] = $lang->string('Invalid product/component/version selected.');
95 if (!$bugsys->in
['summary'])
97 $message->items
[] = $lang->string('Please enter a title for the bug');
99 if (!$bugsys->in
['comment'])
101 $message->items
[] = $lang->string('Please fill in the bug\'s description field');
104 if (!$message->items
)
106 // -------------------------------------------------------------------
107 // data clean and insert
108 $bugsys->in
['comment_parsed'] = $bugsys->in
['comment'];
110 if (!$bugsys->options
['allowhtml'])
112 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
115 // create the bug report
117 INSERT INTO " . TABLE_PREFIX
. "bug
118 (userid, productid, componentid, versionid, summary, severity, priority, status, assignedto, resolution)
120 (" . $bugsys->userinfo
['userid'] . ", " . $pcv['product'] . ", " . $pcv['component'] . ", " . $pcv['version'] . ",
121 '" . $bugsys->in
['summary'] . "', " . intval($bugsys->in
['severity']) . ", " . intval($bugsys->in
['priority']) . ",
122 " . intval($bugsys->in
['status']) . ", " . intval($bugsys->in
['assignedto']) . ", " . intval($bugsys->in
['resolution']) . "
126 $bugid = $db->insert_id();
130 // insert the comment to the database
132 INSERT INTO " . TABLE_PREFIX
. "comment
133 (bugid, userid, dateline, comment, comment_parsed)
135 ($bugid, " . $bugsys->userinfo
['userid'] . ",
136 $time, '" . $bugsys->in
['comment'] . "',
137 '" . nl2br($bugsys->in
['comment_parsed']) . "'
141 $initialreport = $db->insert_id();
144 UPDATE " . TABLE_PREFIX
. "bug
145 SET dateline = $time,
146 initialreport = $initialreport,
147 lastposttime = $time,
148 lastpostby = " . $bugsys->userinfo
['userid'] . ",
149 hiddenlastposttime = $time,
150 hiddenlastpostby = " . $bugsys->userinfo
['userid'] . "
151 WHERE bugid = $bugid"
154 $db->query("INSERT INTO " . TABLE_PREFIX
. "vote (bugid, votefor, voteagainst) VALUES ($bugid, 0, 0)");
156 $message->redirect($lang->string('The bug has been added to the database.'), ($bugsys->in
['submit_reload'] == '' ?
"showreport.php?bugid=$bugid" : 'newreport.php'));
160 $show['errors'] = true
;
161 $_REQUEST['do'] = 'add';
162 $message->error_list_process();
166 // ###################################################################
168 if ($_REQUEST['do'] == 'add')
170 $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid', ($bugsys->in
['severity'] ?
$bugsys->in
['severity'] : $bugsys->options
['defaultseverity']));
172 $show['changestatus'] = ((can_perform('canchangestatus')) ? true
: false
);
174 if (can_perform('canchangestatus'))
176 $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid', ($bugsys->in
['priority'] ?
$bugsys->in
['priority'] : $bugsys->options
['defaultpriority']));
177 $select['status'] = construct_datastore_select('status', 'status', 'statusid', ($bugsys->in
['status'] ?
$bugsys->in
['status'] : $bugsys->options
['defaultstatus']));
178 $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid', ($bugsys->in
['resolution'] ?
$bugsys->in
['resolution'] : $bugsys->options
['defaultresolve']));
181 $show['assign'] = ((can_perform('canassign')) ? true
: false
);
183 if (can_perform('canassign'))
185 foreach ($bugsys->datastore
['assignto'] AS $dev)
187 $value = $dev['userid'];
188 $label = construct_user_display($dev, false
);
189 $selected = ($bugsys->in
['assignedto'] ?
($bugsys->in
['assignedto'] == $dev['userid']) : ($dev['userid'] == $bugsys->options
['defaultassign']));
190 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
195 $fields = construct_custom_fields(null
, true
);
197 foreach ($fields AS $field)
201 $customfields['left'] .= $field;
205 $customfields['right'] .= $field;
210 $pcv_select = construct_pcv_select('cansubmitbugs', $bugsys->in
['pcv_select']);
212 $reporter = construct_user_display($bugsys->userinfo
);
214 eval('$template->flush("' . $template->fetch('newreport') . '");');
217 /*=====================================================================*\
218 || ###################################################################
221 || ###################################################################
222 \*=====================================================================*/