2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Renapsus [#]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 $fetchtemplates = array(
18 require_once('./global.php');
20 if (!can_perform('cansubmitbugs'))
26 // ###################################################################
28 if (empty($_REQUEST['do']))
30 $_REQUEST['do'] = 'add';
33 // ###################################################################
35 if ($_POST['do'] == 'insert')
41 'summary' => STR_NOHTML
,
50 // check permissions on various input values
51 if (!can_perform('canchangestatus'))
53 $vars['priority'] = $bugsys->options
['defaultpriority'];
54 $vars['status'] = $bugsys->options
['defaultstatus'];
55 $vars['resolution'] = $bugsys->options
['defaultresolve'];
59 if (!$bugsys->datastore
['priority']["$vars[priority]"])
61 $vars['priority'] = $bugsys->options
['defaultpriority'];
63 if (!$bugsys->datastore
['status']["$vars[status]"])
65 $vars['status'] = $bugsys->options
['defaultstatus'];
67 if (!$bugsys->datastore
['resolution']["$vars[resolution]"])
69 $vars['resolution'] = $bugsys->options
['defaultresolve'];
72 if (!can_perform('canassign'))
74 $vars['assignedto'] = $bugsys->options
['defaultassign'];
78 // assigned person is not a dev or a valid user
79 if (!$bugsys->datastore
['assignto']["$vars[assignedto]"]['userid'])
81 $vars['assignedto'] = $bugsys->options
['defaultassign'];
85 if (!$vars['product'] OR !$vars['component'] OR !$vars['version'])
87 echo 'there was a problem selecting the product, component, or version';
90 if (!$vars['summary'])
92 echo 'please enter a bug title';
95 if (!$vars['comment'])
97 echo 'please enter a bug description';
100 $product = $bugsys->datastore
['product']["$vars[product]"];
103 echo 'please select a valid product';
106 $version = $bugsys->datastore
['version']["$vars[version]"];
109 echo 'please select a valid version';
113 if ($vars['component'] == -1)
115 // not global version and version.productid != product.productid
116 if ($version['productid'] != 0 AND $version['productid'] != $product['productid'])
118 echo 'invalid version specified';
125 $component = $bugsys->datastore
['product']["$vars[component]"];
126 // component has the right mother
127 if ($component['componentmother'] == $product['productid'])
129 // version.productid != {component.productid | product.productid}
130 if (($version['productid'] != $component['productid'] AND $version['productid'] != $product['productid']) AND $version['productid'] != 0)
132 echo 'invalid version specified';
138 echo 'invalid component specified';
143 $vars['comment_parsed'] = $vars['comment'];
145 if (!$bugsys->options
['allowhtml'])
147 $vars['comment_parsed'] = htmlspecialcharslike($vars['comment_parsed']);
150 // create the bug report
152 INSERT INTO " . TABLE_PREFIX
. "bug
153 (userid, productid, componentid, versionid, summary, severity, priority, status, assignedto, resolution)
155 (" . $bugsys->userinfo
['userid'] . ", $vars[product], $vars[component], $vars[version],
156 '" . addslasheslike($vars['summary']) . "', $vars[severity], $vars[priority], $vars[status], $vars[assignedto], $vars[resolution]
160 $bugid = $DB_sql->insert_id();
164 // insert the comment to the database
166 INSERT INTO " . TABLE_PREFIX
. "comment
167 (bugid, userid, dateline, comment, comment_parsed)
169 ($bugid, " . $bugsys->userinfo
['userid'] . ",
170 $time, '" . addslasheslike($vars['comment']) . "',
171 '" . addslasheslike(nl2br($vars['comment_parsed'])) . "'
175 $initialreport = $DB_sql->insert_id();
177 $DB_sql->query("UPDATE " . TABLE_PREFIX
. "bug SET dateline = $time, initialreport = $initialreport, lastposttime = $time, lastpostby = " . $bugsys->userinfo
['userid'] . " WHERE bugid = $bugid");
179 echo "<a href=\"showreport.php?bugid=$bugid\">bug is done!</a>";
182 // ###################################################################
184 if ($_REQUEST['do'] == 'add')
192 $select['script'] = 'newreport';
193 $select['do'] = 'add';
195 if (!$vars['product'])
197 $products = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX
. "product WHERE !componentmother ORDER BY displayorder ASC");
198 while ($product = $DB_sql->fetch_array($products))
200 $value = $product['productid'];
201 $label = $product['title'];
202 eval('$select[options] .= "' . $tpl->fetch('selectoption') . '";');
205 $select['display'] = 'Product';
206 $select['name'] = 'product';
207 eval('$tpl->flush("' . $tpl->fetch('productselect') . '");');
209 else if (!$vars['component'])
212 $label = 'No Component';
213 eval('$select[options] .= "' . $tpl->fetch('selectoption') . '";');
214 $components = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX
. "product WHERE componentmother IN ($vars[product]) ORDER BY displayorder ASC");
215 while ($component = $DB_sql->fetch_array($components))
217 $value = $component['productid'];
218 $label = $component['title'];
219 eval('$select[options] .= "' . $tpl->fetch('selectoption') . '";');
222 $select['display'] = 'Component';
223 $select['name'] = 'component';
224 eval('$tpl->flush("' . $tpl->fetch('productselect') . '");');
226 else if (!$vars['version'])
228 $versions = $DB_sql->query("
229 SELECT version.*, product.componentmother, product.title AS productname
230 FROM " . TABLE_PREFIX
. "version AS version
231 LEFT JOIN " . TABLE_PREFIX
. "product ON (product.productid = version.productid)
232 WHERE version.productid IN (0, $vars[product]" . iff($vars['component'] != -1, ", $vars[component]", '') . ")
233 ORDER BY version.productid, version.displayorder ASC"
236 while ($version = $DB_sql->fetch_array($versions))
238 $versionlist["$version[productid]"][] = $version;
239 $lookup["$version[productid]"] = array('componentmother' => $version['componentmother'], 'productname' => $version['productname']);
242 foreach ($versionlist AS $productid => $versions)
248 $glabel = 'Global Versions';
251 else if ($lookup["$productid"]['componentmother'])
253 $glabel = $lookup["$productid"]['productname'];
257 $glabel = $lookup["$productid"]['productname'];
260 foreach ($versions AS $version)
262 $value = $version['versionid'];
263 $label = $prepend . $version['version'];
264 eval('$optbits .= "' . $tpl->fetch('selectoption') . '";');
266 eval('$select[options] .= "' . $tpl->fetch('selectoptgroup') . '";');
270 $select['display'] = 'Version';
271 $select['name'] = 'version';
272 eval('$tpl->flush("' . $tpl->fetch('productselect') . '");');
276 foreach ($bugsys->datastore
['severity'] AS $severity)
278 $value = $severity['severityid'];
279 $label = $severity['severity'];
280 eval('$select[severity] .= "' . $tpl->fetch('selectoption') . '";');
283 $show['changestatus'] = iff(can_perform('canchangestatus'), true
, false
);
285 if (can_perform('canchangestatus'))
287 foreach ($bugsys->datastore
['priority'] AS $priority)
289 $value = $priority['priorityid'];
290 $label = $priority['priority'];
291 eval('$select[priority] .= "' . $tpl->fetch('selectoption') . '";');
294 foreach ($bugsys->datastore
['status'] AS $status)
296 $value = $status['statusid'];
297 $label = $status['status'];
298 eval('$select[status] .= "' . $tpl->fetch('selectoption') . '";');
301 foreach ($bugsys->datastore
['resolution'] AS $resolution)
303 $value = $resolution['resolutionid'];
304 $label = $resolution['resolution'];
305 eval('$select[resolution] .= "' . $tpl->fetch('selectoption') . '";');
309 $show['assign'] = iff(can_perform('canassign'), true
, false
);
311 if (can_perform('canassign'))
313 foreach ($bugsys->datastore
['assignto'] AS $dev)
315 $value = $dev['userid'];
316 $label = construct_user_display($dev, false
);
317 eval('$select[dev] .= "' . $tpl->fetch('selectoption') . '";');
321 eval('$tpl->flush("' . $tpl->fetch('newreport') . '");');
325 /*=====================================================================*\
326 || ###################################################################
329 || ###################################################################
330 \*=====================================================================*/