r173: Renaming the error reporting stuff so it can also handle non-error messages...
[bugdar.git] / newreport.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 $fetchtemplates = array(
14 'newreport',
15 'pcv_select_row'
16 );
17
18 require_once('./global.php');
19
20 if (!can_perform('cansubmitbugs'))
21 {
22 $erorr->throw_permission();
23 }
24
25 // ###################################################################
26
27 if (empty($_REQUEST['do']))
28 {
29 $_REQUEST['do'] = 'add';
30 }
31
32 // ###################################################################
33
34 if ($_POST['do'] == 'insert')
35 {
36 // -------------------------------------------------------------------
37 // check permissions on various input values
38 if (!can_perform('canchangestatus'))
39 {
40 $bugsys->in['priority'] = $bugsys->options['defaultpriority'];
41 $bugsys->in['status'] = $bugsys->options['defaultstatus'];
42 $bugsys->in['resolution'] = $bugsys->options['defaultresolve'];
43 }
44 else
45 {
46 if (!$bugsys->datastore['priority'][ $bugsys->in['priority'] ])
47 {
48 $bugsys->in['priority'] = $bugsys->options['defaultpriority'];
49 }
50 if (!$bugsys->datastore['status'][ $bugsys->in['status'] ])
51 {
52 $bugsys->in['status'] = $bugsys->options['defaultstatus'];
53 }
54 if (!$bugsys->datastore['resolution'][ $bugsys->in['resolution'] ])
55 {
56 $bugsys->in['resolution'] = $bugsys->options['defaultresolve'];
57 }
58 }
59 if (!can_perform('canassign'))
60 {
61 $bugsys->in['assignedto'] = $bugsys->options['defaultassign'];
62 }
63 else
64 {
65 // assigned person is not a dev or a valid user
66 if (!$bugsys->datastore['assignto'][ $bugsys->in['assignedto'] ]['userid'])
67 {
68 $bugsys->in['assignedto'] = $bugsys->options['defaultassign'];
69 }
70 }
71
72 // -------------------------------------------------------------------
73 // product/component/version stuff
74 $pcv = parse_pcv_select($bugsys->in['pcv_select'], true);
75
76 print_r($vars);
77
78 // -------------------------------------------------------------------
79 // sanity checks
80 if (!$pcv)
81 {
82 $message->error('there was a problem selecting the product, component, or version');
83 }
84 if (!$bugsys->in['summary'])
85 {
86 $message->error('please enter a bug title');
87 }
88 if (!$bugsys->in['comment'])
89 {
90 $message->error('please enter a bug description');
91 }
92
93 // -------------------------------------------------------------------
94 // data clean and insert
95 $bugsys->in['comment_parsed'] = $bugsys->in['comment'];
96
97 if (!$bugsys->options['allowhtml'])
98 {
99 $bugsys->in['comment_parsed'] = $bugsys->sanitize($bugsys->in['comment_parsed']);
100 }
101
102 // create the bug report
103 $db->query("
104 INSERT INTO " . TABLE_PREFIX . "bug
105 (userid, productid, componentid, versionid, summary, severity, priority, status, assignedto, resolution)
106 VALUES
107 (" . $bugsys->userinfo['userid'] . ", " . $pcv['product'] . ", " . $pcv['component'] . ", " . $pcv['version'] . ",
108 '" . $bugsys->in['summary'] . "', " . intval($bugsys->in['severity']) . ", " . intval($bugsys->in['priority']) . ",
109 " . intval($bugsys->in['status']) . ", " . intval($bugsys->in['assignedto']) . ", " . intval($bugsys->in['resolution']) . "
110 )"
111 );
112
113 $bugid = $db->insert_id();
114
115 $time = time();
116
117 // insert the comment to the database
118 $db->query("
119 INSERT INTO " . TABLE_PREFIX . "comment
120 (bugid, userid, dateline, comment, comment_parsed)
121 VALUES
122 ($bugid, " . $bugsys->userinfo['userid'] . ",
123 $time, '" . $bugsys->in['comment'] . "',
124 '" . nl2br($bugsys->in['comment_parsed']) . "'
125 )"
126 );
127
128 $initialreport = $db->insert_id();
129
130 $db->query("UPDATE " . TABLE_PREFIX . "bug SET dateline = $time, initialreport = $initialreport, lastposttime = $time, lastpostby = " . $bugsys->userinfo['userid'] . " WHERE bugid = $bugid");
131
132 echo "<a href=\"showreport.php?bugid=$bugid\">bug is done!</a>";
133 }
134
135 // ###################################################################
136
137 if ($_REQUEST['do'] == 'add')
138 {
139 foreach ($bugsys->datastore['severity'] AS $severity)
140 {
141 $value = $severity['severityid'];
142 $label = $severity['severity'];
143 eval('$select[severity] .= "' . $template->fetch('selectoption') . '";');
144 }
145
146 $show['changestatus'] = ((can_perform('canchangestatus')) ? true : false);
147
148 if (can_perform('canchangestatus'))
149 {
150 foreach ($bugsys->datastore['priority'] AS $priority)
151 {
152 $value = $priority['priorityid'];
153 $label = $priority['priority'];
154 eval('$select[priority] .= "' . $template->fetch('selectoption') . '";');
155 }
156
157 foreach ($bugsys->datastore['status'] AS $status)
158 {
159 $value = $status['statusid'];
160 $label = $status['status'];
161 eval('$select[status] .= "' . $template->fetch('selectoption') . '";');
162 }
163
164 foreach ($bugsys->datastore['resolution'] AS $resolution)
165 {
166 $value = $resolution['resolutionid'];
167 $label = $resolution['resolution'];
168 eval('$select[resolution] .= "' . $template->fetch('selectoption') . '";');
169 }
170 }
171
172 $show['assign'] = ((can_perform('canassign')) ? true : false);
173
174 if (can_perform('canassign'))
175 {
176 foreach ($bugsys->datastore['assignto'] AS $dev)
177 {
178 $value = $dev['userid'];
179 $label = construct_user_display($dev, false);
180 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
181 }
182 }
183
184 $pcv_select = construct_pcv_select();
185
186 eval('$template->flush("' . $template->fetch('newreport') . '");');
187 }
188
189 /*=====================================================================*\
190 || ###################################################################
191 || # $HeadURL$
192 || # $Id$
193 || ###################################################################
194 \*=====================================================================*/
195 ?>