From 0207e6224a6cbc314269a4b6de9f07b68e65ea22 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 18 Feb 2005 07:07:50 +0000 Subject: [PATCH] r61: Changed product/component/version editing method from being tri-page selection to the single PCV selector. --- editreport.php | 183 ++++--------------------------- templates/default/editreport.tpl | 6 +- 2 files changed, 26 insertions(+), 163 deletions(-) diff --git a/editreport.php b/editreport.php index 0e81c09..54c681b 100644 --- a/editreport.php +++ b/editreport.php @@ -12,7 +12,7 @@ $fetchtemplates = array( 'editreport', - 'productselect' + 'pcv_select_row' ); require_once('./global.php'); @@ -71,15 +71,31 @@ if ($_POST['do'] == 'update') 'status' => INT, 'resolution' => INT, 'assignedto' => INT, - 'changeproduct' => STR) + 'pcv_select' => STR) ); + $vars['pcv'] = parse_pcv_select($vars['pcv_select'], true); + + if (!$vars['summary']) + { + echo 'you need to enter a summary'; + exit; + } + if (!$vars['pcv']) + { + echo 'invalid product/component/version'; + exit; + } + $DB_sql->query(" UPDATE " . TABLE_PREFIX . "bug SET summary = '" . addslasheslike($vars['summary']) . "', priority = $vars[priority], status = $vars[status], resolution = $vars[resolution], - assignedto = $vars[assignedto] + assignedto = $vars[assignedto], + productid = " . $vars['pcv']['product'] . ", + componentid = " . $vars['pcv']['component'] . ", + versionid = " . $vars['pcv']['version'] . " WHERE bugid = $bug[bugid]" ); @@ -145,166 +161,9 @@ if ($_REQUEST['do'] == 'edit') } } - eval('$tpl->flush("' . $tpl->fetch('editreport') . '");'); -} - -// ################################################################### - -if ($_POST['do'] == 'updateproduct') -{ - sanitize(array('product' => INT, 'component' => INT, 'version' => INT)); - - var_dump($vars); + $pcv_select = construct_pcv_select("p$bug[productid]c$bug[componentid]v$bug[versionid]"); - if (!$vars['product'] OR !$vars['component'] OR !$vars['version']) - { - echo 'there was a problem selecting the product, component, or version'; - 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; - } - } - - // good-to-go - $DB_sql->query("UPDATE " . TABLE_PREFIX . "bug SET productid = $vars[product], componentid = $vars[component], versionid = $vars[version] WHERE bugid = $bug[bugid]"); - - echo "changed product info"; -} - -// ################################################################### - -if ($_REQUEST['do'] == 'editproduct') -{ - sanitize(array('product' => INT, 'component' => INT, 'version' => INT)); - - $select['do'] = 'editproduct'; - $select['script'] = 'editreport'; - - 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']; - $selected = iff($product['productid'] == $bug['productid'], true, false); - $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'; - $selected = iff($bug['componentid'] == -1, true, false); - $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']; - $selected = iff($component['productid'] == $bug['componentid'], true, false); - $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']; - $selected = iff($version['versionid'] == $bug['versionid'], true, false); - $label = $prepend . $version['version']; - eval('$optbits .= "' . $tpl->fetch('selectoption') . '";'); - } - eval('$select[options] .= "' . $tpl->fetch('selectoptgroup') . '";'); - $optbits = ''; - } - - $select['display'] = 'Version'; - $select['name'] = 'version'; - $select['do'] = 'updateproduct'; - $select['method'] = 'post'; - - eval('$tpl->flush("' . $tpl->fetch('productselect') . '");'); - } + eval('$tpl->flush("' . $tpl->fetch('editreport') . '");'); } /*=====================================================================*\ diff --git a/templates/default/editreport.tpl b/templates/default/editreport.tpl index ebc74f0..c49cd59 100644 --- a/templates/default/editreport.tpl +++ b/templates/default/editreport.tpl @@ -16,5 +16,9 @@
Assigned to:
-
+
Product/Component/Version: +
$pcv_select
+
+ +
\ No newline at end of file -- 2.22.5