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
');
33 require_once('./includes
/api_comment
.php
');
35 if (!can_perform('cansubmitbugs
', intval($bugsys->in['productid
'])))
37 $message->error_permission();
40 // ###################################################################
42 if (empty($_REQUEST['do']))
44 $_REQUEST['do'] = 'add
';
47 // ###################################################################
49 if ($_POST['do'] == 'insert
')
51 $bug = new BugAPI($bugsys);
53 // -------------------------------------------------------------------
54 // check permissions on various input values
55 if (!can_perform('canchangestatus
', intval($bugsys->in['productid
'])))
57 $bugsys->in['priority
'] = $bugsys->options['defaultpriority
'];
58 $bugsys->in['status
'] = $bugsys->options['defaultstatus
'];
59 $bugsys->in['resolution
'] = $bugsys->options['defaultresolve
'];
63 if (!$bugsys->datastore['priority
'][ $bugsys->in['priority
'] ])
65 $bugsys->in['priority
'] = $bugsys->options['defaultpriority
'];
67 if (!$bugsys->datastore['status
'][ $bugsys->in['status
'] ])
69 $bugsys->in['status
'] = $bugsys->options['defaultstatus
'];
71 if (!$bugsys->datastore['resolution
'][ $bugsys->in['resolution
'] ])
73 $bugsys->in['resolution
'] = $bugsys->options['defaultresolve
'];
76 if (!can_perform('canassign
', intval($bugsys->in['productid
'])))
78 $bugsys->in['assignedto
'] = $bugsys->options['defaultassign
'];
82 // assigned person is not a dev or a valid user
83 if (!$bugsys->datastore['assignto
'][ $bugsys->in['assignedto
'] ]['userid
'])
85 $bugsys->in['assignedto
'] = $bugsys->options['defaultassign
'];
89 // -------------------------------------------------------------------
90 // product/component/version stuff
91 $pcv = parse_pcv_select($bugsys->in['pcv_select
'], true);
93 // -------------------------------------------------------------------
97 $message->items[] = $lang->string('Invalid product
/component
/version selected
.');
99 if (!$bugsys->in['summary
'])
101 $message->items[] = $lang->string('Please enter a title
for the bug
');
103 if (!$bugsys->in['comment
'])
105 $message->items[] = $lang->string('Please fill in the bug\'s description field
');
108 if (!$message->items)
110 // -------------------------------------------------------------------
111 // data clean and insert
112 $bugsys->in['comment_parsed
'] = $bugsys->in['comment
'];
114 if (!$bugsys->options['allowhtml
'])
116 $bugsys->in['comment_parsed
'] = $bugsys->sanitize($bugsys->in['comment_parsed
']);
119 // create the bug report
121 INSERT INTO " . TABLE_PREFIX . "bug
122 (userid, productid, componentid, versionid, summary, severity, priority, status, assignedto, resolution)
124 (" . $bugsys->userinfo['userid
'] . ", " . $pcv['product
'] . ", " . $pcv['component
'] . ", " . $pcv['version
'] . ",
125 '" . $bugsys->in['summary'] . "', " . intval($bugsys->in['severity
']) . ", " . intval($bugsys->in['priority
']) . ",
126 " . intval($bugsys->in['status
']) . ", " . intval($bugsys->in['assignedto
']) . ", " . intval($bugsys->in['resolution
']) . "
130 $bugid = $db->insert_id();
132 $comment = new CommentAPI($bugsys);
133 $comment->set('bugid
', $bugid);
134 $comment->set('userid
', $bugsys->userinfo['userid
']);
135 $comment->set('comment
', $_POST['comment
']);
138 $time = $comment->values['dateline
'];
141 UPDATE " . TABLE_PREFIX . "bug
142 SET dateline = $time,
143 initialreport = " . $comment->insertid . ",
144 lastposttime = $time,
145 lastpostby = " . $bugsys->userinfo['userid
'] . ",
146 hiddenlastposttime = $time,
147 hiddenlastpostby = " . $bugsys->userinfo['userid
'] . "
148 WHERE bugid = $bugid"
151 $db->query("INSERT INTO " . TABLE_PREFIX . "vote (bugid, votefor, voteagainst) VALUES ($bugid, 0, 0)");
153 $message->redirect($lang->string('The bug has been added to the database
.'), ($bugsys->in['submit_reload
'] == '' ? "showreport.php?bugid=$bugid" : 'newreport
.php
'));
157 $show['errors
'] = true;
158 $_REQUEST['do'] = 'add
';
159 $message->error_list_process();
163 // ###################################################################
165 if ($_REQUEST['do'] == 'add
')
167 $select['severity
'] = construct_datastore_select('severity
', 'severity
', 'severityid
', ($bugsys->in['severity
'] ? $bugsys->in['severity
'] : $bugsys->options['defaultseverity
']));
169 $show['changestatus
'] = ((can_perform('canchangestatus
')) ? true : false);
171 if (can_perform('canchangestatus
'))
173 $select['priority
'] = construct_datastore_select('priority
', 'priority
', 'priorityid
', ($bugsys->in['priority
'] ? $bugsys->in['priority
'] : $bugsys->options['defaultpriority
']));
174 $select['status
'] = construct_datastore_select('status
', 'status
', 'statusid
', ($bugsys->in['status
'] ? $bugsys->in['status
'] : $bugsys->options['defaultstatus
']));
175 $select['resolution
'] = construct_datastore_select('resolution
', 'resolution
', 'resolutionid
', ($bugsys->in['resolution
'] ? $bugsys->in['resolution
'] : $bugsys->options['defaultresolve
']));
178 $show['assign
'] = ((can_perform('canassign
')) ? true : false);
180 if (can_perform('canassign
'))
182 foreach ($bugsys->datastore['assignto
'] AS $dev)
184 $value = $dev['userid
'];
185 $label = construct_user_display($dev, false);
186 $selected = ($bugsys->in['assignedto
'] ? ($bugsys->in['assignedto
'] == $dev['userid
']) : ($dev['userid
'] == $bugsys->options['defaultassign
']));
187 eval('$select[dev
] .= "' . $template->fetch('selectoption') . '";');
192 $fields = construct_custom_fields(null, true);
194 foreach ($fields AS $field)
198 $customfields['left
'] .= $field;
202 $customfields['right
'] .= $field;
207 $pcv_select = construct_pcv_select('cansubmitbugs
', $bugsys->in['pcv_select
']);
209 $reporter = construct_user_display($bugsys->userinfo);
211 eval('$template->flush("' . $template->fetch('newreport') . '");');
214 /*=====================================================================*\
215 || ###################################################################
218 || ###################################################################
219 \*=====================================================================*/