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 $vars['comment_parsed'] = $vars['comment'];
140 if (!$bugsys->options
['allowhtml'])
142 $vars['comment_parsed'] = htmlspecialcharslike($vars['comment_parsed']);
145 // create the bug report
147 INSERT INTO " . TABLE_PREFIX
. "bug
148 (userid, productid, componentid, versionid, summary, severity, priority, status, assignedto, resolution)
150 (" . $bugsys->userinfo
['userid'] . ", $vars[product], $vars[component], $vars[version],
151 '" . addslasheslike($vars['summary']) . "', $vars[severity], $vars[priority], $vars[status], $vars[assignedto], $vars[resolution]
155 $bugid = $DB_sql->insert_id();
157 // insert the comment to the database
159 INSERT INTO " . TABLE_PREFIX
. "comment
160 (bugid, userid, dateline, comment, comment_parsed
163 ($bugid, " . $bugsys->userinfo
['userid'] . ",
164 " . time() . ", '" . addslasheslike($vars['comment']) . "',
165 '" . addslasheslike(nl2br($vars['comment_parsed'])) . "'
172 // ###################################################################
174 if ($_REQUEST['do'] == 'add')
182 // the user can hit the back button without reposting data...
183 if (!$vars['product'] OR !$vars['component'] OR !$vars['version'])
192 echo '<form name="newbug" action="newreport.php" method="' . $method . '">';
196 if (!$vars['product'])
198 echo '<strong>Product:</strong> <select name="product">';
199 $products = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX
. "product WHERE !componentmother ORDER BY displayorder ASC");
200 while ($product = $DB_sql->fetch_array($products))
202 echo "<option value=\"$product[productid]\">$product[title]</option>";
206 else if (!$vars['component'])
208 echo '<strong>Component:</strong> <select name="component"><option value="-1">No Component</option>';
209 $components = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX
. "product WHERE componentmother IN ($vars[product]) ORDER BY displayorder ASC");
210 while ($component = $DB_sql->fetch_array($components))
212 echo "<option value=\"$component[productid]\">$component[title]</option>";
215 echo '<input type="hidden" name="product" value="' . $vars['product'] . '" />';
217 else if (!$vars['version'])
219 echo '<strong>Version:</strong> <select name="version">';
220 $versions = $DB_sql->query("
221 SELECT version.*, product.componentmother, product.title AS productname
222 FROM " . TABLE_PREFIX
. "version AS version
223 LEFT JOIN " . TABLE_PREFIX
. "product ON (product.productid = version.productid)
224 WHERE version.productid IN (0, $vars[product]" . iff($vars['component'] != -1, ", $vars[component]", '') . ")
225 ORDER BY version.productid, version.displayorder ASC"
228 while ($version = $DB_sql->fetch_array($versions))
230 $versionlist["$version[productid]"][] = $version;
231 $lookup["$version[productid]"] = array('componentmother' => $version['componentmother'], 'productname' => $version['productname']);
234 foreach ($versionlist AS $productid => $versions)
240 echo '<optgroup label="Global Versions">';
243 else if ($lookup["$productid"]['componentmother'])
245 echo '<optgroup label="' . $lookup["$productid"]['productname'] . '">';
249 echo '<optgroup label="' . $lookup["$productid"]['productname'] . '">';
252 foreach ($versions AS $version)
254 echo '<option value="' . $version['versionid'] . '">' . $prepend . $version['version'] . '</option>';
261 echo '<input type="hidden" name="product" value="' . $vars['product'] . '" />';
262 echo '<input type="hidden" name="component" value="' . $vars['component'] . '" />';
267 echo '<div><strong>Summary/Title:</strong> <input type="text" name="summary" size="25" /></div>';
269 echo '<div><strong>Severity:</strong> <select name="severity">';
270 foreach ($bugsys->datastore
['severity'] AS $severity)
272 echo '<option value="' . $severity['severityid'] . '">' . $severity['severity'] . '</option>';
274 echo '</select></div>';
276 if ($bugsys->userinfo
['permissions'] & CANCHANGESTATUS
)
278 echo '<div><strong>Priority:</strong> <select name="priority">';
279 foreach ($bugsys->datastore
['priority'] AS $priority)
281 echo '<option value="' . $priority['priorityid'] . '">' . $priority['priority'] . '</option>';
283 echo '</select></div>';
285 echo '<div><strong>Status:</strong> <select name="status">';
286 foreach ($bugsys->datastore
['status'] AS $status)
288 echo '<option value="' . $status['statusid'] . '">' . $status['status'] . '</option>';
290 echo '</select></div>';
292 echo '<div><strong>Resolution:</strong> <select name="resolution">';
293 foreach ($bugsys->datastore
['resolution'] AS $resolution)
295 echo '<option value="' . $resolution['resolutionid'] . '">' . $resolution['resolution'] . '</option>';
297 echo '</select></div>';
300 if ($bugsys->userinfo
['permissions'] & CANASSIGN
)
302 echo '<div><strong>Assigned to:</strong> <select name="assignedto"><option value="0">No Assignment</option>';
303 foreach ($bugsys->datastore
['assignto'] AS $dev)
305 fetch_user_display_name($dev);
306 echo '<option value="' . $dev['userid'] . '">' . $dev['displayname'] . iff($dev['showemail'], ' <' . $dev['email'] . '>', '') . '</option>';
308 echo '</select></div>';
311 echo '<div><strong>Detailed description:</strong><div><textarea name="comment" rows="15" cols="75"></textarea></div></div>';
313 echo '<input type="hidden" name="product" value="' . $vars['product'] . '" />';
314 echo '<input type="hidden" name="component" value="' . $vars['component'] . '" />';
315 echo '<input type="hidden" name="version" value="' . $vars['version'] . '" />';
318 echo '<div><input type="hidden" name="do" value="' . $do . '" /><input type="submit" name="submit" value=" Proceed " /></div>';
323 /*=====================================================================*\
324 || ###################################################################
327 || ###################################################################
328 \*=====================================================================*/