appdb/include util.php
WineHQ
wineowner at wine.codeweavers.com
Sun Jun 17 17:44:47 CDT 2007
ChangeSet ID: 31219
CVSROOT: /opt/cvs-commit
Module name: appdb
Changes by: wineowner at winehq.org 2007/06/17 17:44:47
Modified files:
include : util.php
Log message:
Chris Morgan <cmorgan at alum.wpi.edu>
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.
Patch: http://cvs.winehq.org/patch.py?id=31219
Old revision New revision Changes Path
1.94 1.95 +25 -8 appdb/include/util.php
Index: appdb/include/util.php
diff -u -p appdb/include/util.php:1.94 appdb/include/util.php:1.95
--- appdb/include/util.php:1.94 17 Jun 2007 22:44:47 -0000
+++ appdb/include/util.php 17 Jun 2007 22:44:47 -0000
@@ -154,11 +154,14 @@ function get_xml_tag ($file, $mode = nul
}
/* bugzilla functions */
-function make_bugzilla_version_list($varname, $cvalue)
-{
- $table = BUGZILLA_DB.".versions";
- $where = "WHERE product_id=".BUGZILLA_PRODUCT_ID;
- $sQuery = "SELECT value FROM $table $where";
+// $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)
+{
+ $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($var
// build the selection array
- echo "<select name='$varname'>\n";
+ echo "<select name='$sVarname'>\n";
echo "<option value=\"\">Choose ...</option>\n";
+ $bFoundSelectedValue = false;
foreach($aVersions as $sKey => $sValue)
{
- if($sValue == $cvalue)
+ if($sValue == $sSelectedValue)
+ {
echo "<option value=$sValue selected>$sValue\n";
- else
+ $bFoundSelectedValue = true;
+ } else
+ {
echo "<option value=$sValue>$sValue\n";
+ }
}
+
+ // if we didn't find the selected value and the selected value isn't empty
+ // then we should add the selected value to the list because we could have pruned
+ // the version that is to be selected
+ if(!$bFoundSelectedValue && $sSelectedValue)
+ {
+ echo "<option value=$sSelectedValue selected>$sSelectedValue\n";
+ }
+
echo "</select>\n";
}
More information about the wine-cvs
mailing list