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 \*=====================================================================*/
13 require_once('./global.php');
15 if (!($bugsys->userinfo
['permissions'] & CANSUBMITBUGS
))
21 // ###################################################################
23 if (empty($_REQUEST['do']))
25 $_REQUEST['do'] = 'add';
28 // ###################################################################
30 if ($_POST['do'] == 'insert')
36 'summary' => STR_NOHTML
,
45 // check permissions on various input values
46 if (!($bugsys->userinfo
['permissions'] & CANCHANGESTATUS
))
48 $vars['priority'] = $bugsys->options
['defaultpriority'];
49 $vars['status'] = $bugsys->options
['defaultstatus'];
50 $vars['resolution'] = $bugsys->options
['defaultresolve'];
54 if (!$bugsys->datastore
['priority']["$vars[priority]"])
56 $vars['priority'] = $bugsys->options
['defaultpriority'];
58 if (!$bugsys->datastore
['status']["$vars[status]"])
60 $vars['status'] = $bugsys->options
['defaultstatus'];
62 if (!$bugsys->datastore
['resolution']["$vars[resolution]"])
64 $vars['resolution'] = $bugsys->options
['defaultresolve'];
67 if (!($bugsys->userinfo
['permissions'] & CANASSIGN
))
69 $vars['assignedto'] = $bugsys->options
['defaultassign'];
73 // assigned person is not a dev or a valid user
74 if (!$bugsys->datastore
['assignto']["$vars[assignedto]"]['userid'])
76 $vars['assignedto'] = $bugsys->options
['defaultassign'];
80 if (!$vars['product'] OR !$vars['component'] OR !$vars['version'])
82 echo 'there was a problem selecting the product, component, or version';
85 if (!$vars['summary'])
87 echo 'please enter a bug title';
90 if (!$vars['comment'])
92 echo 'please enter a bug description';
95 $product = $bugsys->datastore
['product']["$vars[product]"];
98 echo 'please select a valid product';
101 $version = $bugsys->datastore
['version']["$vars[version]"];
104 echo 'please select a valid version';
108 if ($vars['component'] == -1)
110 // not global version and version.productid != product.productid
111 if ($version['productid'] != 0 AND $version['productid'] != $product['productid'])
113 echo 'invalid version specified';
120 $component = $bugsys->datastore
['product']["$vars[component]"];
121 // component has the right mother
122 if ($component['componentmother'] == $product['productid'])
124 // version.productid != {component.productid | product.productid}
125 if ($version['productid'] != $component['productid'] AND $version['productid'] != $product['productid'])
127 echo 'invalid version specified';
133 echo 'invalid component specified';
138 if (!$bugsys->options
['allowhtml'])
140 $vars['comment'] = htmlspecialcharslike($vars['comment']);
143 // create the bug report
145 INSERT INTO " . TABLE_PREFIX
. "bug
146 (userid, productid, componentid, versionid, summary, severity, priority, status, assignedto, resolution)
148 (" . $bugsys->userinfo
['userid'] . ", $vars[product], $vars[component], $vars[version],
149 '" . addslasheslike($vars['summary']) . "', $vars[severity], $vars[priority], $vars[status], $vars[assignedto], $vars[resolution]
153 $bugid = $DB_sql->insert_id();
155 // insert the comment to the database
157 INSERT INTO " . TABLE_PREFIX
. "comment
158 (bugid, userid, dateline, comment ## comment_parsed -- not using, ATM ###
161 ($bugid, " . $bugsys->userinfo
['userid'] . ",
162 " . time() . ", '" . addslasheslike($vars['comment']) . "'
169 // ###################################################################
171 if ($_REQUEST['do'] == 'add')
179 // the user can hit the back button without reposting data...
180 if (!$vars['product'] OR !$vars['component'] OR !$vars['version'])
189 echo '<form name="newbug" action="newreport.php" method="' . $method . '">';
193 if (!$vars['product'])
195 echo '<strong>Product:</strong> <select name="product">';
196 $products = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX
. "product WHERE !componentmother ORDER BY displayorder ASC");
197 while ($product = $DB_sql->fetch_array($products))
199 echo "<option value=\"$product[productid]\">$product[title]</option>";
203 else if (!$vars['component'])
205 echo '<strong>Component:</strong> <select name="component"><option value="-1">No Component</option>';
206 $components = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX
. "product WHERE componentmother IN ($vars[product]) ORDER BY displayorder ASC");
207 while ($component = $DB_sql->fetch_array($components))
209 echo "<option value=\"$component[productid]\">$component[title]</option>";
212 echo '<input type="hidden" name="product" value="' . $vars['product'] . '" />';
214 else if (!$vars['version'])
216 echo '<strong>Version:</strong> <select name="version">';
217 $versions = $DB_sql->query("
218 SELECT version.*, product.componentmother, product.title AS productname
219 FROM " . TABLE_PREFIX
. "version AS version
220 LEFT JOIN " . TABLE_PREFIX
. "product ON (product.productid = version.productid)
221 WHERE version.productid IN (0, $vars[product]" . iff($vars['component'] != -1, ", $vars[component]", '') . ")
222 ORDER BY version.productid, version.displayorder ASC"
225 while ($version = $DB_sql->fetch_array($versions))
227 $versionlist["$version[productid]"][] = $version;
228 $lookup["$version[productid]"] = array('componentmother' => $version['componentmother'], 'productname' => $version['productname']);
231 foreach ($versionlist AS $productid => $versions)
237 echo '<optgroup label="Global Versions">';
240 else if ($lookup["$productid"]['componentmother'])
242 echo '<optgroup label="' . $lookup["$productid"]['productname'] . '">';
246 echo '<optgroup label="' . $lookup["$productid"]['productname'] . '">';
249 foreach ($versions AS $version)
251 echo '<option value="' . $version['versionid'] . '">' . $prepend . $version['version'] . '</option>';
258 echo '<input type="hidden" name="product" value="' . $vars['product'] . '" />';
259 echo '<input type="hidden" name="component" value="' . $vars['component'] . '" />';
264 echo '<div><strong>Summary/Title:</strong> <input type="text" name="summary" size="25" /></div>';
266 echo '<div><strong>Severity:</strong> <select name="severity">';
267 foreach ($bugsys->datastore
['severity'] AS $severity)
269 echo '<option value="' . $severity['severityid'] . '">' . $severity['severity'] . '</option>';
271 echo '</select></div>';
273 if ($bugsys->userinfo
['permissions'] & CANCHANGESTATUS
)
275 echo '<div><strong>Priority:</strong> <select name="priority">';
276 foreach ($bugsys->datastore
['priority'] AS $priority)
278 echo '<option value="' . $priority['priorityid'] . '">' . $priority['priority'] . '</option>';
280 echo '</select></div>';
282 echo '<div><strong>Status:</strong> <select name="status">';
283 foreach ($bugsys->datastore
['status'] AS $status)
285 echo '<option value="' . $status['statusid'] . '">' . $status['status'] . '</option>';
287 echo '</select></div>';
289 echo '<div><strong>Resolution:</strong> <select name="resolution">';
290 foreach ($bugsys->datastore
['resolution'] AS $resolution)
292 echo '<option value="' . $resolution['resolutionid'] . '">' . $resolution['resolution'] . '</option>';
294 echo '</select></div>';
297 if ($bugsys->userinfo
['permissions'] & CANASSIGN
)
299 echo '<div><strong>Assigned to:</strong> <select name="assignedto"><option value="0">No Assignment</option>';
300 foreach ($bugsys->datastore
['assignto'] AS $dev)
302 fetch_user_display_name($dev);
303 echo '<option value="' . $dev['userid'] . '">' . $dev['displayname'] . iff($dev['showemail'], ' <' . $dev['email'] . '>', '') . '</option>';
305 echo '</select></div>';
308 echo '<div><strong>Detailed description:</strong><div><textarea name="comment" rows="15" cols="75"></textarea></div></div>';
310 echo '<input type="hidden" name="product" value="' . $vars['product'] . '" />';
311 echo '<input type="hidden" name="component" value="' . $vars['component'] . '" />';
312 echo '<input type="hidden" name="version" value="' . $vars['version'] . '" />';
315 echo '<div><input type="hidden" name="do" value="' . $do . '" /><input type="submit" name="submit" value=" Proceed " /></div>';
320 /*=====================================================================*\
321 || ###################################################################
324 || ###################################################################
325 \*=====================================================================*/