r2: Changed Environment object to be BugTrack ($env --> $bugsys).. hopefully this...
[bugdar.git] / newreport.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # [#]app[#] [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # All parts of this file are ©2003-[#]year[#] Iris Studios, Inc. No # ||
7 || # part of this file may be reproduced in any way: part or whole. # ||
8 || # --------------------------------------------------------------- # ||
9 || # ©2003 - [#]year[#] Iris Studios, Inc. | http://www.iris-studios.com # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 require_once('./global.php');
14
15 if (!($bugsys->userinfo['permissions'] & CANSUBMITBUGS))
16 {
17 echo 'NO permission';
18 exit;
19 }
20
21 // ###################################################################
22
23 if (empty($_REQUEST['do']))
24 {
25 $_REQUEST['do'] = 'add';
26 }
27
28 // ###################################################################
29
30 if ($_POST['do'] == 'insert')
31 {
32 sanitize(array(
33 'product' => INT,
34 'component' => INT,
35 'version' => INT,
36 'summary' => STR,
37 'severity' => INT,
38 'priority' => INT,
39 'status' => INT,
40 'resolution' => INT,
41 'assignedto' => INT,
42 'comment' => STR)
43 );
44
45 // check permissions on various input values
46 if (!$bugsys->userinfo['permissions'] & CANCHANGESTATUS)
47 {
48 unset($vars['priority'], $vars['status'], $vars['resolution']);
49 }
50 if (!$bugsys->userinfo['permissions'] & CANASSIGN)
51 {
52 unset($vars['assignedto']);
53 }
54 else
55 {
56 // assigned person is not a dev or a valid user
57 if (!$bugsys->datastore['assignto']["$vars[assignedto]"]['userid'])
58 {
59 unset($vars['assignedto']);
60 }
61 }
62
63 if (!$vars['product'] OR !$vars['component'] OR !$vars['version'])
64 {
65 echo 'there was a problem selecting the product, component, or version';
66 exit;
67 }
68 if (!$vars['summary'])
69 {
70 echo 'please enter a bug title';
71 exit;
72 }
73 if (!$vars['comment'])
74 {
75 echo 'please enter a bug description';
76 exit;
77 }
78 }
79
80 // ###################################################################
81
82 if ($_REQUEST['do'] == 'add')
83 {
84 sanitize(array(
85 'product' => INT,
86 'component' => INT,
87 'version' => INT)
88 );
89
90 // the user can hit the back button without reposting data...
91 if (!$vars['product'] OR !$vars['component'] OR !$vars['version'])
92 {
93 $method = 'get';
94 }
95 else
96 {
97 $method = 'post';
98 }
99
100 echo '<form name="newbug" action="newreport.php" method="' . $method . '">';
101
102 $do = 'add';
103
104 if (!$vars['product'])
105 {
106 echo '<strong>Product:</strong> <select name="product">';
107 $products = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "product WHERE !componentmother ORDER BY displayorder ASC");
108 while ($product = $DB_sql->fetch_array($products))
109 {
110 echo "<option value=\"$product[productid]\">$product[title]</option>";
111 }
112 echo '</select>';
113 }
114 else if (!$vars['component'])
115 {
116 echo '<strong>Component:</strong> <select name="component"><option value="-1">No Component</option>';
117 $components = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "product WHERE componentmother IN ($vars[product]) ORDER BY displayorder ASC");
118 while ($component = $DB_sql->fetch_array($components))
119 {
120 echo "<option value=\"$component[productid]\">$component[title]</option>";
121 }
122 echo '</select>';
123 echo '<input type="hidden" name="product" value="' . $vars['product'] . '" />';
124 }
125 else if (!$vars['version'])
126 {
127 echo '<strong>Version:</strong> <select name="version">';
128 $versions = $DB_sql->query("
129 SELECT version.*, product.componentmother, product.title AS productname
130 FROM " . TABLE_PREFIX . "version AS version
131 LEFT JOIN " . TABLE_PREFIX . "product ON (product.productid = version.productid)
132 WHERE version.productid IN (0, $vars[product]" . iff($vars['component'] != -1, ", $vars[component]", '') . ")
133 ORDER BY version.productid, version.displayorder ASC"
134 );
135
136 while ($version = $DB_sql->fetch_array($versions))
137 {
138 $versionlist["$version[productid]"][] = $version;
139 $lookup["$version[productid]"] = array('componentmother' => $version['componentmother'], 'productname' => $version['productname']);
140 }
141
142 foreach ($versionlist AS $productid => $versions)
143 {
144 $prepend = '-- ';
145 // global version
146 if ($productid == 0)
147 {
148 echo '<optgroup label="Global Versions">';
149 }
150 // component
151 else if ($lookup["$productid"]['componentmother'])
152 {
153 echo '<optgroup label="' . $lookup["$productid"]['productname'] . '">';
154 }
155 else
156 {
157 echo '<optgroup label="' . $lookup["$productid"]['productname'] . '">';
158 }
159
160 foreach ($versions AS $version)
161 {
162 echo '<option value="' . $version['versionid'] . '">' . $prepend . $version['version'] . '</option>';
163 }
164
165 echo '</optgroup>';
166 }
167
168 echo '</select>';
169 echo '<input type="hidden" name="product" value="' . $vars['product'] . '" />';
170 echo '<input type="hidden" name="component" value="' . $vars['component'] . '" />';
171 }
172 else
173 {
174 $do = 'insert';
175 echo '<div><strong>Summary/Title:</strong> <input type="text" name="summary" size="25" /></div>';
176
177 echo '<div><strong>Severity:</strong> <select name="severity">';
178 foreach ($bugsys->datastore['severity'] AS $severity)
179 {
180 echo '<option value="' . $severity['severityid'] . '">' . $severity['severity'] . '</option>';
181 }
182 echo '</select></div>';
183
184 if ($bugsys->userinfo['permissions'] & CANCHANGESTATUS)
185 {
186 echo '<div><strong>Priority:</strong> <select name="priority">';
187 foreach ($bugsys->datastore['priority'] AS $priority)
188 {
189 echo '<option value="' . $priority['priorityid'] . '">' . $priority['priority'] . '</option>';
190 }
191 echo '</select></div>';
192
193 echo '<div><strong>Status:</strong> <select name="status">';
194 foreach ($bugsys->datastore['status'] AS $status)
195 {
196 echo '<option value="' . $status['statusid'] . '">' . $status['status'] . '</option>';
197 }
198 echo '</select></div>';
199
200 echo '<div><strong>Resolution:</strong> <select name="resolution">';
201 foreach ($bugsys->datastore['resolution'] AS $resolution)
202 {
203 echo '<option value="' . $resolution['resolutionid'] . '">' . $resolution['resolution'] . '</option>';
204 }
205 echo '</select></div>';
206 }
207
208 if ($bugsys->userinfo['permissions'] & CANASSIGN)
209 {
210 echo '<div><strong>Assigned to:</strong> <select name="assignedto"><option value="0">No Assignment</option>';
211 foreach ($bugsys->datastore['assignto'] AS $dev)
212 {
213 fetch_user_display_name($dev);
214 echo '<option value="' . $dev['userid'] . '">' . $dev['displayname'] . iff($dev['showemail'], ' <' . $dev['email'] . '>', '') . '</option>';
215 }
216 echo '</select></div>';
217 }
218
219 echo '<div><strong>Detailed description:</strong><div><textarea name="comment" rows="15" cols="75"></textarea></div></div>';
220 }
221
222 echo '<div><input type="hidden" name="do" value="' . $do . '" /><input type="submit" name="submit" value=" Proceed " /></div>';
223
224 echo '</form>';
225 }
226
227 /*=====================================================================*\
228 || ###################################################################
229 || # $HeadURL$
230 || # $Id$
231 || ###################################################################
232 \*=====================================================================*/
233 ?>