r1: Initial import from CVS head.
[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 (!($env->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 (!$env->userinfo['permissions'] & CANCHANGESTATUS)
47 {
48 unset($vars['priority'], $vars['status'], $vars['resolution']);
49 }
50 if (!$env->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 (!$env->datastore['assignto']["$vars[assignedto]"]['userid'])
58 {
59 unset($vars['assignedto']);
60 }
61 }
62 }
63
64 // ###################################################################
65
66 if ($_REQUEST['do'] == 'add')
67 {
68 sanitize(array(
69 'product' => INT,
70 'component' => INT,
71 'version' => INT)
72 );
73
74 // the user can hit the back button without reposting data...
75 if (!$vars['product'] OR !$vars['component'] OR !$vars['version'])
76 {
77 $method = 'get';
78 }
79 else
80 {
81 $method = 'post';
82 }
83
84 echo '<form name="newbug" action="newreport.php" method="' . $method . '">';
85
86 $do = 'add';
87
88 if (!$vars['product'])
89 {
90 echo '<strong>Product:</strong> <select name="product">';
91 $products = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "product WHERE !componentmother ORDER BY displayorder ASC");
92 while ($product = $DB_sql->fetch_array($products))
93 {
94 echo "<option value=\"$product[productid]\">$product[title]</option>";
95 }
96 echo '</select>';
97 }
98 else if (!$vars['component'])
99 {
100 echo '<strong>Component:</strong> <select name="component"><option value="-1">No Component</option>';
101 $components = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "product WHERE componentmother IN ($vars[product]) ORDER BY displayorder ASC");
102 while ($component = $DB_sql->fetch_array($components))
103 {
104 echo "<option value=\"$component[productid]\">$component[title]</option>";
105 }
106 echo '</select>';
107 echo '<input type="hidden" name="product" value="' . $vars['product'] . '" />';
108 }
109 else if (!$vars['version'])
110 {
111 echo '<strong>Version:</strong> <select name="version">';
112 $versions = $DB_sql->query("
113 SELECT version.*, product.componentmother, product.title AS productname
114 FROM " . TABLE_PREFIX . "version AS version
115 LEFT JOIN " . TABLE_PREFIX . "product ON (product.productid = version.productid)
116 WHERE version.productid IN (0, $vars[product]" . iff($vars['component'] != -1, ", $vars[component]", '') . ")
117 ORDER BY version.productid, version.displayorder ASC"
118 );
119
120 while ($version = $DB_sql->fetch_array($versions))
121 {
122 $versionlist["$version[productid]"][] = $version;
123 $lookup["$version[productid]"] = array('componentmother' => $version['componentmother'], 'productname' => $version['productname']);
124 }
125
126 foreach ($versionlist AS $productid => $versions)
127 {
128 $prepend = '-- ';
129 // global version
130 if ($productid == 0)
131 {
132 echo '<optgroup label="Global Versions">';
133 }
134 // component
135 else if ($lookup["$productid"]['componentmother'])
136 {
137 echo '<optgroup label="' . $lookup["$productid"]['productname'] . '">';
138 }
139 else
140 {
141 echo '<optgroup label="' . $lookup["$productid"]['productname'] . '">';
142 }
143
144 foreach ($versions AS $version)
145 {
146 echo '<option value="' . $version['versionid'] . '">' . $prepend . $version['version'] . '</option>';
147 }
148
149 echo '</optgroup>';
150 }
151
152 echo '</select>';
153 echo '<input type="hidden" name="product" value="' . $vars['product'] . '" />';
154 echo '<input type="hidden" name="component" value="' . $vars['component'] . '" />';
155 }
156 else
157 {
158 $do = 'insert';
159 echo '<div><strong>Summary/Title:</strong> <input type="text" name="summary" size="25" /></div>';
160
161 echo '<div><strong>Severity:</strong> <select name="severity">';
162 foreach ($env->datastore['severity'] AS $severity)
163 {
164 echo '<option value="' . $severity['severityid'] . '">' . $severity['severity'] . '</option>';
165 }
166 echo '</select></div>';
167
168 if ($env->userinfo['permissions'] & CANCHANGESTATUS)
169 {
170 echo '<div><strong>Priority:</strong> <select name="priority">';
171 foreach ($env->datastore['priority'] AS $priority)
172 {
173 echo '<option value="' . $priority['priorityid'] . '">' . $priority['priority'] . '</option>';
174 }
175 echo '</select></div>';
176
177 echo '<div><strong>Status:</strong> <select name="status">';
178 foreach ($env->datastore['status'] AS $status)
179 {
180 echo '<option value="' . $status['statusid'] . '">' . $status['status'] . '</option>';
181 }
182 echo '</select></div>';
183
184 echo '<div><strong>Resolution:</strong> <select name="resolution">';
185 foreach ($env->datastore['resolution'] AS $resolution)
186 {
187 echo '<option value="' . $resolution['resolutionid'] . '">' . $resolution['resolution'] . '</option>';
188 }
189 echo '</select></div>';
190 }
191
192 if ($env->userinfo['permissions'] & CANASSIGN)
193 {
194 echo '<div><strong>Assigned to:</strong> <select name="assignedto"><option value="0">No Assignment</option>';
195 foreach ($env->datastore['assignto'] AS $dev)
196 {
197 fetch_user_display_name($dev);
198 echo '<option value="' . $dev['userid'] . '">' . $dev['displayname'] . iff($dev['showemail'], ' <' . $dev['email'] . '>', '') . '</option>';
199 }
200 echo '</select></div>';
201 }
202
203 echo '<div><strong>Detailed description:</strong><div><textarea name="comment" rows="15" cols="75"></textarea></div></div>';
204 }
205
206 echo '<div><input type="hidden" name="do" value="' . $do . '" /><input type="submit" name="submit" value=" Proceed " /></div>';
207
208 echo '</form>';
209 }
210
211 /*=====================================================================*\
212 || ###################################################################
213 || # $HeadURL$
214 || # $Id$
215 || ###################################################################
216 \*=====================================================================*/
217 ?>