From 3d08e4e3251ad6f36910deaf206961da4c10a70f Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 9 Feb 2005 07:38:44 +0000 Subject: [PATCH] r52: Fixed bug in includes/functions.php with construct_pcv_select() that didn't create v correctly for components. Cleaned up newreport.php to use new selection mechanism. --- includes/functions.php | 3 +- newreport.php | 185 ++++++++++++----------------------------- 2 files changed, 56 insertions(+), 132 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index 7f63742..c294888 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -275,6 +275,7 @@ function can_perform($bitmask, $userinfo = null) // #################### Start construct_pcv_select ################### // constructs a product/component/version select with one go :-) +// NB: need to make sure we have the option to turn off just p/c selection without v function construct_pcv_select($type = 'radio', $prefix = '     ') { global $bugsys, $DB_sql, $tpl; @@ -343,7 +344,7 @@ function construct_pcv_select($type = 'radio', $prefix = '   &nbs foreach ($versions["$component[productid]"] AS $version) { $row['prefix'] = $prefix . $prefix; - $row['value'] = "$valuepfx$version[versionid]"; + $row['value'] = "{$valuepfx}v$version[versionid]"; $row['title'] = $version['version']; $row['description'] = ''; eval('$HTML .= "' . $tpl->fetch('pcv_select_row') . '";'); diff --git a/newreport.php b/newreport.php index 6591a71..d476048 100755 --- a/newreport.php +++ b/newreport.php @@ -35,9 +35,7 @@ if (empty($_REQUEST['do'])) if ($_POST['do'] == 'insert') { sanitize(array( - 'product' => INT, - 'component' => INT, - 'version' => INT, + 'pcv_select' => STR, 'summary' => STR_NOHTML, 'severity' => INT, 'priority' => INT, @@ -47,6 +45,7 @@ if ($_POST['do'] == 'insert') 'comment' => STR) ); + // ------------------------------------------------------------------- // check permissions on various input values if (!can_perform('canchangestatus')) { @@ -82,7 +81,15 @@ if ($_POST['do'] == 'insert') } } - if (!$vars['product'] OR !$vars['component'] OR !$vars['version']) + // ------------------------------------------------------------------- + // product/component/version stuff + $vars['pcv'] = parse_pcv_select($vars['pcv_select']); + + print_r($vars); + + // ------------------------------------------------------------------- + // sanity checks + if (!is_array($vars['pcv'])) { echo 'there was a problem selecting the product, component, or version'; exit; @@ -97,20 +104,23 @@ if ($_POST['do'] == 'insert') echo 'please enter a bug description'; exit; } - $product = $bugsys->datastore['product']["$vars[product]"]; + + // ------------------------------------------------------------------- + // pcv validation + $product = $bugsys->datastore['product'][ $vars['pcv']['product'] ]; if (!$product) { echo 'please select a valid product'; exit; } - $version = $bugsys->datastore['version']["$vars[version]"]; + $version = $bugsys->datastore['version'][ $vars['pcv']['version'] ]; if (!$version) { echo 'please select a valid version'; exit; } // no component - if ($vars['component'] == -1) + if ($vars['pcv']['component'] == 0) { // not global version and version.productid != product.productid if ($version['productid'] != 0 AND $version['productid'] != $product['productid']) @@ -122,7 +132,7 @@ if ($_POST['do'] == 'insert') // using a component else { - $component = $bugsys->datastore['product']["$vars[component]"]; + $component = $bugsys->datastore['product'][ $vars['pcv']['component'] ]; // component has the right mother if ($component['componentmother'] == $product['productid']) { @@ -140,6 +150,8 @@ if ($_POST['do'] == 'insert') } } + // ------------------------------------------------------------------- + // data clean and insert $vars['comment_parsed'] = $vars['comment']; if (!$bugsys->options['allowhtml']) @@ -152,7 +164,7 @@ if ($_POST['do'] == 'insert') 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], + (" . $bugsys->userinfo['userid'] . ", " . $vars['pcv']['product'] . ", " . $vars['pcv']['component'] . ", " . $vars['pcv']['version'] . ", '" . addslasheslike($vars['summary']) . "', $vars[severity], $vars[priority], $vars[status], $vars[assignedto], $vars[resolution] )" ); @@ -183,143 +195,54 @@ if ($_POST['do'] == 'insert') if ($_REQUEST['do'] == 'add') { - sanitize(array( - 'product' => INT, - 'component' => INT, - 'version' => INT) - ); - - $select['script'] = 'newreport'; - $select['do'] = 'add'; - - if (!$vars['product']) + foreach ($bugsys->datastore['severity'] AS $severity) { - $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') . '");'); + $value = $severity['severityid']; + $label = $severity['severity']; + eval('$select[severity] .= "' . $tpl->fetch('selectoption') . '";'); } - else if (!$vars['component']) + + $show['changestatus'] = iff(can_perform('canchangestatus'), true, false); + + if (can_perform('canchangestatus')) { - $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)) + foreach ($bugsys->datastore['priority'] AS $priority) { - $value = $component['productid']; - $label = $component['title']; - eval('$select[options] .= "' . $tpl->fetch('selectoption') . '";'); + $value = $priority['priorityid']; + $label = $priority['priority']; + eval('$select[priority] .= "' . $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)) + foreach ($bugsys->datastore['status'] AS $status) { - $versionlist["$version[productid]"][] = $version; - $lookup["$version[productid]"] = array('componentmother' => $version['componentmother'], 'productname' => $version['productname']); + $value = $status['statusid']; + $label = $status['status']; + eval('$select[status] .= "' . $tpl->fetch('selectoption') . '";'); } - foreach ($versionlist AS $productid => $versions) + foreach ($bugsys->datastore['resolution'] AS $resolution) { - $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 = ''; + $value = $resolution['resolutionid']; + $label = $resolution['resolution']; + eval('$select[resolution] .= "' . $tpl->fetch('selectoption') . '";'); } - - $select['display'] = 'Version'; - $select['name'] = 'version'; - eval('$tpl->flush("' . $tpl->fetch('productselect') . '");'); } - else + + $show['assign'] = iff(can_perform('canassign'), true, false); + + if (can_perform('canassign')) { - foreach ($bugsys->datastore['severity'] AS $severity) + foreach ($bugsys->datastore['assignto'] AS $dev) { - $value = $severity['severityid']; - $label = $severity['severity']; - eval('$select[severity] .= "' . $tpl->fetch('selectoption') . '";'); + $value = $dev['userid']; + $label = construct_user_display($dev, false); + eval('$select[dev] .= "' . $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') . '");'); - } + } + + $pcv_select = construct_pcv_select(); + + eval('$tpl->flush("' . $tpl->fetch('newreport') . '");'); } /*=====================================================================*\ -- 2.22.5