From 6221e9b9211fdf71b1cccef176dfe65653ac97fd Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Sun, 17 Jun 2007 22:44:47 +0000 Subject: [PATCH] Cleanup make_bugzilla_version_list(). Use standard naming convention, add some documentation. Add a work around so a selected version, if not present, is added to the list and selected. This fixes the issue where editing an older test result leaves us in an unattainable position, we can't select the version since it was pruned from the list and we don't want to pick the wrong version for the results. --- include/util.php | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/include/util.php b/include/util.php index 3462e78..92e664e 100644 --- a/include/util.php +++ b/include/util.php @@ -154,11 +154,14 @@ function get_xml_tag ($file, $mode = null) } /* bugzilla functions */ -function make_bugzilla_version_list($varname, $cvalue) +// $sVarname - name of the selection array that this function will output +// this is the name to use to retrieve the selection on the form postback +// $sSelectedValue - the currently selected entry +function make_bugzilla_version_list($sVarname, $sSelectedValue) { - $table = BUGZILLA_DB.".versions"; - $where = "WHERE product_id=".BUGZILLA_PRODUCT_ID; - $sQuery = "SELECT value FROM $table $where"; + $sTable = BUGZILLA_DB.".versions"; + $sWhere = "WHERE product_id=".BUGZILLA_PRODUCT_ID; + $sQuery = "SELECT value FROM $sTable $sWhere"; $hResult = query_bugzilladb($sQuery); if(!$hResult) return; @@ -195,15 +198,29 @@ function make_bugzilla_version_list($varname, $cvalue) // build the selection array - echo "\n"; echo "\n"; + $bFoundSelectedValue = false; foreach($aVersions as $sKey => $sValue) { - if($sValue == $cvalue) + if($sValue == $sSelectedValue) + { echo "