From 892f0952e6cc07dfeddcf36f47d4588b1e68b6c0 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 21 Dec 2004 06:43:34 +0000 Subject: [PATCH] r11: Basic bug reporting (new bug only) is done :-). --- newreport.php | 105 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 99 insertions(+), 6 deletions(-) diff --git a/newreport.php b/newreport.php index 1114297..b4b10f5 100755 --- a/newreport.php +++ b/newreport.php @@ -33,7 +33,7 @@ if ($_POST['do'] == 'insert') 'product' => INT, 'component' => INT, 'version' => INT, - 'summary' => STR, + 'summary' => STR_NOHTML, 'severity' => INT, 'priority' => INT, 'status' => INT, @@ -43,20 +43,37 @@ if ($_POST['do'] == 'insert') ); // check permissions on various input values - if (!$bugsys->userinfo['permissions'] & CANCHANGESTATUS) + if (!($bugsys->userinfo['permissions'] & CANCHANGESTATUS)) { - unset($vars['priority'], $vars['status'], $vars['resolution']); + $vars['priority'] = $bugsys->options['defaultpriority']; + $vars['status'] = $bugsys->options['defaultstatus']; + $vars['resolution'] = $bugsys->options['defaultresolve']; } - if (!$bugsys->userinfo['permissions'] & CANASSIGN) + 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 (!($bugsys->userinfo['permissions'] & CANASSIGN)) { - unset($vars['assignedto']); + $vars['assignedto'] = $bugsys->options['defaultassign']; } else { // assigned person is not a dev or a valid user if (!$bugsys->datastore['assignto']["$vars[assignedto]"]['userid']) { - unset($vars['assignedto']); + $vars['assignedto'] = $bugsys->options['defaultassign']; } } @@ -75,6 +92,78 @@ if ($_POST['do'] == 'insert') 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']) + { + echo 'invalid version specified'; + exit; + } + } + else + { + echo 'invalid component specified'; + exit; + } + } + + if (!$bugsys->options['allowhtml']) + { + $vars['comment'] = htmlspecialcharslike($vars['comment']); + } + + // create the bug report + $DB_sql->query(" + INSERT INTO " . TABLE_PREFIX . "bug + (userid, productid, componentid, versionid, summary, severity, priority, status, assignedto) + VALUES + (" . $bugsys->userinfo['userid'] . ", $vars[product], $vars[component], $vars[version], + '" . addslasheslike($vars['summary']) . "', $vars[severity], $vars[priority], $vars[status], $vars[assignedto] + )" + ); + + $bugid = $DB_sql->insert_id(); + + // insert the comment to the database + $DB_sql->query(" + INSERT INTO " . TABLE_PREFIX . "comment + (bugid, userid, dateline, comment ## comment_parsed -- not using, ATM ### + ) + VALUES + ($bugid, " . $bugsys->userinfo['userid'] . ", + " . time() . ", '" . addslasheslike($vars['comment']) . "' + )" + ); + + echo 'bug is done!'; } // ################################################################### @@ -217,6 +306,10 @@ if ($_REQUEST['do'] == 'add') } echo '
Detailed description:
'; + + echo ''; + echo ''; + echo ''; } echo '
'; -- 2.43.5