INT, 'component' => INT, 'version' => INT, 'summary' => STR_NOHTML, 'severity' => INT, 'priority' => INT, 'status' => INT, 'resolution' => INT, 'assignedto' => INT, 'comment' => STR) ); // check permissions on various input values if (!can_perform('canchangestatus')) { $vars['priority'] = $bugsys->options['defaultpriority']; $vars['status'] = $bugsys->options['defaultstatus']; $vars['resolution'] = $bugsys->options['defaultresolve']; } else { if (!$bugsys->datastore['priority']["$vars[priority]"]) { $vars['priority'] = $bugsys->options['defaultpriority']; } if (!$bugsys->datastore['status']["$vars[status]"]) { $vars['status'] = $bugsys->options['defaultstatus']; } if (!$bugsys->datastore['resolution']["$vars[resolution]"]) { $vars['resolution'] = $bugsys->options['defaultresolve']; } } if (!can_perform('canassign')) { $vars['assignedto'] = $bugsys->options['defaultassign']; } else { // assigned person is not a dev or a valid user if (!$bugsys->datastore['assignto']["$vars[assignedto]"]['userid']) { $vars['assignedto'] = $bugsys->options['defaultassign']; } } if (!$vars['product'] OR !$vars['component'] OR !$vars['version']) { echo 'there was a problem selecting the product, component, or version'; exit; } if (!$vars['summary']) { echo 'please enter a bug title'; exit; } if (!$vars['comment']) { echo 'please enter a bug description'; exit; } $product = $bugsys->datastore['product']["$vars[product]"]; if (!$product) { echo 'please select a valid product'; exit; } $version = $bugsys->datastore['version']["$vars[version]"]; if (!$version) { echo 'please select a valid version'; exit; } // no component if ($vars['component'] == -1) { // not global version and version.productid != product.productid if ($version['productid'] != 0 AND $version['productid'] != $product['productid']) { echo 'invalid version specified'; exit; } } // using a component else { $component = $bugsys->datastore['product']["$vars[component]"]; // component has the right mother if ($component['componentmother'] == $product['productid']) { // version.productid != {component.productid | product.productid} if (($version['productid'] != $component['productid'] AND $version['productid'] != $product['productid']) AND $version['productid'] != 0) { echo 'invalid version specified'; exit; } } else { echo 'invalid component specified'; exit; } } $vars['comment_parsed'] = $vars['comment']; if (!$bugsys->options['allowhtml']) { $vars['comment_parsed'] = htmlspecialcharslike($vars['comment_parsed']); } // create the bug report $DB_sql->query(" INSERT INTO " . TABLE_PREFIX . "bug (userid, productid, componentid, versionid, summary, severity, priority, status, assignedto, resolution) VALUES (" . $bugsys->userinfo['userid'] . ", $vars[product], $vars[component], $vars[version], '" . addslasheslike($vars['summary']) . "', $vars[severity], $vars[priority], $vars[status], $vars[assignedto], $vars[resolution] )" ); $bugid = $DB_sql->insert_id(); $time = time(); // insert the comment to the database $DB_sql->query(" INSERT INTO " . TABLE_PREFIX . "comment (bugid, userid, dateline, comment, comment_parsed) VALUES ($bugid, " . $bugsys->userinfo['userid'] . ", $time, '" . addslasheslike($vars['comment']) . "', '" . addslasheslike(nl2br($vars['comment_parsed'])) . "' )" ); $initialreport = $DB_sql->insert_id(); $DB_sql->query("UPDATE " . TABLE_PREFIX . "bug SET dateline = $time, initialreport = $initialreport, lastposttime = $time, lastpostby = " . $bugsys->userinfo['userid'] . " WHERE bugid = $bugid"); echo "bug is done!"; } // ################################################################### if ($_REQUEST['do'] == 'add') { sanitize(array( 'product' => INT, 'component' => INT, 'version' => INT) ); $select['script'] = 'newreport'; $select['do'] = 'add'; if (!$vars['product']) { $products = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "product WHERE !componentmother ORDER BY displayorder ASC"); while ($product = $DB_sql->fetch_array($products)) { $value = $product['productid']; $label = $product['title']; eval('$select[options] .= "' . $tpl->fetch('selectoption') . '";'); } $select['display'] = 'Product'; $select['name'] = 'product'; eval('$tpl->flush("' . $tpl->fetch('productselect') . '");'); } else if (!$vars['component']) { $value = '-1'; $label = 'No Component'; eval('$select[options] .= "' . $tpl->fetch('selectoption') . '";'); $components = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "product WHERE componentmother IN ($vars[product]) ORDER BY displayorder ASC"); while ($component = $DB_sql->fetch_array($components)) { $value = $component['productid']; $label = $component['title']; eval('$select[options] .= "' . $tpl->fetch('selectoption') . '";'); } $select['display'] = 'Component'; $select['name'] = 'component'; eval('$tpl->flush("' . $tpl->fetch('productselect') . '");'); } else if (!$vars['version']) { $versions = $DB_sql->query(" SELECT version.*, product.componentmother, product.title AS productname FROM " . TABLE_PREFIX . "version AS version LEFT JOIN " . TABLE_PREFIX . "product ON (product.productid = version.productid) WHERE version.productid IN (0, $vars[product]" . iff($vars['component'] != -1, ", $vars[component]", '') . ") ORDER BY version.productid, version.displayorder ASC" ); while ($version = $DB_sql->fetch_array($versions)) { $versionlist["$version[productid]"][] = $version; $lookup["$version[productid]"] = array('componentmother' => $version['componentmother'], 'productname' => $version['productname']); } foreach ($versionlist AS $productid => $versions) { $prepend = '-- '; // global version if ($productid == 0) { $glabel = 'Global Versions'; } // component else if ($lookup["$productid"]['componentmother']) { $glabel = $lookup["$productid"]['productname']; } else { $glabel = $lookup["$productid"]['productname']; } foreach ($versions AS $version) { $value = $version['versionid']; $label = $prepend . $version['version']; eval('$optbits .= "' . $tpl->fetch('selectoption') . '";'); } eval('$select[options] .= "' . $tpl->fetch('selectoptgroup') . '";'); $optbits = ''; } $select['display'] = 'Version'; $select['name'] = 'version'; eval('$tpl->flush("' . $tpl->fetch('productselect') . '");'); } else { foreach ($bugsys->datastore['severity'] AS $severity) { $value = $severity['severityid']; $label = $severity['severity']; eval('$select[severity] .= "' . $tpl->fetch('selectoption') . '";'); } $show['changestatus'] = iff(can_perform('canchangestatus'), true, false); if (can_perform('canchangestatus')) { foreach ($bugsys->datastore['priority'] AS $priority) { $value = $priority['priorityid']; $label = $priority['priority']; eval('$select[priority] .= "' . $tpl->fetch('selectoption') . '";'); } foreach ($bugsys->datastore['status'] AS $status) { $value = $status['statusid']; $label = $status['status']; eval('$select[status] .= "' . $tpl->fetch('selectoption') . '";'); } foreach ($bugsys->datastore['resolution'] AS $resolution) { $value = $resolution['resolutionid']; $label = $resolution['resolution']; eval('$select[resolution] .= "' . $tpl->fetch('selectoption') . '";'); } } $show['assign'] = iff(can_perform('canassign'), true, false); if (can_perform('canassign')) { foreach ($bugsys->datastore['assignto'] AS $dev) { $value = $dev['userid']; $label = construct_user_display($dev, false); eval('$select[dev] .= "' . $tpl->fetch('selectoption') . '";'); } } eval('$tpl->flush("' . $tpl->fetch('newreport') . '");'); } } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>