r78: Fixed a problem where we were checking for the wrong variable in PCV sanity...
[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 echo 'NO permission';
23 exit;
24 }
25
26 // ###################################################################
27
28 if (empty($_REQUEST['do']))
29 {
30 $_REQUEST['do'] = 'add';
31 }
32
33 // ###################################################################
34
35 if ($_POST['do'] == 'insert')
36 {
37 // -------------------------------------------------------------------
38 // check permissions on various input values
39 if (!can_perform('canchangestatus'))
40 {
41 $bugsys->in['priority'] = $bugsys->options['defaultpriority'];
42 $bugsys->in['status'] = $bugsys->options['defaultstatus'];
43 $bugsys->in['resolution'] = $bugsys->options['defaultresolve'];
44 }
45 else
46 {
47 if (!$bugsys->datastore['priority'][ $bugsys->in['priority'] ])
48 {
49 $bugsys->in['priority'] = $bugsys->options['defaultpriority'];
50 }
51 if (!$bugsys->datastore['status'][ $bugsys->in['status'] ])
52 {
53 $bugsys->in['status'] = $bugsys->options['defaultstatus'];
54 }
55 if (!$bugsys->datastore['resolution'][ $bugsys->in['resolution'] ])
56 {
57 $bugsys->in['resolution'] = $bugsys->options['defaultresolve'];
58 }
59 }
60 if (!can_perform('canassign'))
61 {
62 $bugsys->in['assignedto'] = $bugsys->options['defaultassign'];
63 }
64 else
65 {
66 // assigned person is not a dev or a valid user
67 if (!$bugsys->datastore['assignto'][ $bugsys->in['assignedto'] ]['userid'])
68 {
69 $bugsys->in['assignedto'] = $bugsys->options['defaultassign'];
70 }
71 }
72
73 // -------------------------------------------------------------------
74 // product/component/version stuff
75 $pcv = parse_pcv_select($bugsys->in['pcv_select'], true);
76
77 print_r($vars);
78
79 // -------------------------------------------------------------------
80 // sanity checks
81 if (!$pcv)
82 {
83 echo 'there was a problem selecting the product, component, or version';
84 exit;
85 }
86 if (!$bugsys->in['summary'])
87 {
88 echo 'please enter a bug title';
89 exit;
90 }
91 if (!$bugsys->in['comment'])
92 {
93 echo 'please enter a bug description';
94 exit;
95 }
96
97 // -------------------------------------------------------------------
98 // data clean and insert
99 $bugsys->in['comment_parsed'] = $bugsys->in['comment'];
100
101 if (!$bugsys->options['allowhtml'])
102 {
103 $bugsys->in['comment_parsed'] = $bugsys->sanitize($bugsys->in['comment_parsed']);
104 }
105
106 // create the bug report
107 $db->query("
108 INSERT INTO " . TABLE_PREFIX . "bug
109 (userid, productid, componentid, versionid, summary, severity, priority, status, assignedto, resolution)
110 VALUES
111 (" . $bugsys->userinfo['userid'] . ", " . $pcv['product'] . ", " . $pcv['component'] . ", " . $pcv['version'] . ",
112 '" . $bugsys->in['summary'] . "', " . intval($bugsys->in['severity']) . ", " . intval($bugsys->in['priority']) . ",
113 " . intval($bugsys->in['status']) . ", " . intval($bugsys->in['assignedto']) . ", " . intval($bugsys->in['resolution']) . "
114 )"
115 );
116
117 $bugid = $db->insert_id();
118
119 $time = time();
120
121 // insert the comment to the database
122 $db->query("
123 INSERT INTO " . TABLE_PREFIX . "comment
124 (bugid, userid, dateline, comment, comment_parsed)
125 VALUES
126 ($bugid, " . $bugsys->userinfo['userid'] . ",
127 $time, '" . $bugsys->in['comment'] . "',
128 '" . nl2br($bugsys->in['comment_parsed']) . "'
129 )"
130 );
131
132 $initialreport = $db->insert_id();
133
134 $db->query("UPDATE " . TABLE_PREFIX . "bug SET dateline = $time, initialreport = $initialreport, lastposttime = $time, lastpostby = " . $bugsys->userinfo['userid'] . " WHERE bugid = $bugid");
135
136 echo "<a href=\"showreport.php?bugid=$bugid\">bug is done!</a>";
137 }
138
139 // ###################################################################
140
141 if ($_REQUEST['do'] == 'add')
142 {
143 foreach ($bugsys->datastore['severity'] AS $severity)
144 {
145 $value = $severity['severityid'];
146 $label = $severity['severity'];
147 eval('$select[severity] .= "' . $template->fetch('selectoption') . '";');
148 }
149
150 $show['changestatus'] = ((can_perform('canchangestatus')) ? true : false);
151
152 if (can_perform('canchangestatus'))
153 {
154 foreach ($bugsys->datastore['priority'] AS $priority)
155 {
156 $value = $priority['priorityid'];
157 $label = $priority['priority'];
158 eval('$select[priority] .= "' . $template->fetch('selectoption') . '";');
159 }
160
161 foreach ($bugsys->datastore['status'] AS $status)
162 {
163 $value = $status['statusid'];
164 $label = $status['status'];
165 eval('$select[status] .= "' . $template->fetch('selectoption') . '";');
166 }
167
168 foreach ($bugsys->datastore['resolution'] AS $resolution)
169 {
170 $value = $resolution['resolutionid'];
171 $label = $resolution['resolution'];
172 eval('$select[resolution] .= "' . $template->fetch('selectoption') . '";');
173 }
174 }
175
176 $show['assign'] = ((can_perform('canassign')) ? true : false);
177
178 if (can_perform('canassign'))
179 {
180 foreach ($bugsys->datastore['assignto'] AS $dev)
181 {
182 $value = $dev['userid'];
183 $label = construct_user_display($dev, false);
184 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
185 }
186 }
187
188 $pcv_select = construct_pcv_select();
189
190 eval('$template->flush("' . $template->fetch('newreport') . '");');
191 }
192
193 /*=====================================================================*\
194 || ###################################################################
195 || # $HeadURL$
196 || # $Id$
197 || ###################################################################
198 \*=====================================================================*/
199 ?>