Module: appdb Branch: master Commit: 63ef4f4e951d9aac86ce6d38f95fcf09fe6968e2 URL: http://source.winehq.org/git/appdb.git/?a=commit;h=63ef4f4e951d9aac86ce6d38f...
Author: Alexander Nicolaysen Sørnes alex@thehandofagony.com Date: Tue Aug 5 17:16:22 2008 +0200
browse apps: More options for Wine version filter
---
include/application.php | 36 ++++++++++++++++++++++++++++++++---- include/util.php | 17 +++++++++++++++++ 2 files changed, 49 insertions(+), 4 deletions(-)
diff --git a/include/application.php b/include/application.php index a7ffa09..1d1fac6 100644 --- a/include/application.php +++ b/include/application.php @@ -953,10 +953,24 @@ class Application {
if($sWhereFilter || $aOptions['onlyDownloadable'] == 'true') { - $sExtraTables = ',appVersion'; + $sExtraTables = ",appVersion"; + $sBugzillaQuery = ''; + + /* We only query the bugzilla table when necessary; these queries + will hide apps without test results */ + if(strstr($sWhereFilter, 'versions.id')) + { + $sExtraTables .= ','.BUGZILLA_DB.'.versions'; + $sBugzillaQuery = ' AND versions.value = appVersion.ratingRelease + AND versions.product_id = '.BUGZILLA_PRODUCT_ID.' '; + } + if($sWhereFilter) $sWhereFilter = " AND $sWhereFilter"; - $sWhereFilter = " AND appVersion.state = 'accepted' AND appVersion.appId = appFamily.appId $sWhereFilter"; + $sWhereFilter = " AND appVersion.state = 'accepted' + AND appVersion.appId = appFamily.appId + $sBugzillaQuery + $sWhereFilter"; }
if($aOptions['onlyDownloadable'] == 'true') @@ -1032,9 +1046,10 @@ class Application {
$aLicenses = version::getLicenses(); $aWineVersions = get_bugzilla_versions(); + $aWineVersionIds = get_bugzilla_version_ids();
$oFilter->AddFilterInfo('appVersion.rating', 'Rating', array(FILTER_EQUALS), FILTER_VALUES_ENUM, array('Platinum', 'Gold', 'Silver', 'Bronze', 'Garbage')); - $oFilter->AddFilterInfo('appVersion.ratingRelease', 'Wine version', array(FILTER_EQUALS), FILTER_VALUES_ENUM, $aWineVersions); + $oFilter->AddFilterInfo('versions.id', 'Wine version', array(FILTER_EQUALS,FILTER_LESS_THAN,FILTER_GREATER_THAN), FILTER_VALUES_ENUM, $aWineVersionIds, $aWineVersions); $oFilter->AddFilterInfo('appFamily.catId', 'Category', array(FILTER_EQUALS), FILTER_VALUES_ENUM, $aCatIds, $aCatNames); $oFilter->AddFilterInfo('appVersion.license', 'License', array(FILTER_EQUALS), FILTER_VALUES_ENUM, $aLicenses); $oFilter->AddFilterInfo('appFamily.appName', 'Name', array(FILTER_CONTAINS, FILTER_STARTS_WITH, FILTER_ENDS_WITH), FILTER_VALUES_NORMAL); @@ -1186,9 +1201,22 @@ class Application { if($sWhereFilter || $aOptions['onlyDownloadable'] == 'true') { $sExtraTables = ',appVersion'; + $sBugzillaQuery = ''; + + /* We only query the bugzilla table when necessary; these queries + will hide apps without test results */ + if(strstr($sWhereFilter, 'versions.id')) + { + $sExtraTables .= ','.BUGZILLA_DB.'.versions'; + $sBugzillaQuery = ' AND versions.value = appVersion.ratingRelease + AND versions.product_id = '.BUGZILLA_PRODUCT_ID.' '; + } + if($sWhereFilter) $sWhereFilter = " AND $sWhereFilter"; - $sWhereFilter = " AND appVersion.appId = appFamily.appId $sWhereFilter"; + $sWhereFilter = " AND appVersion.appId = appFamily.appId + $sBugzillaQuery + $sWhereFilter"; }
if($aOptions['onlyDownloadable'] == 'true') diff --git a/include/util.php b/include/util.php index 3b6453d..028edb6 100644 --- a/include/util.php +++ b/include/util.php @@ -184,6 +184,23 @@ function get_bugzilla_versions() return $aVersions; }
+// Returns an array containing the IDs of the Wine versions stored in Bugzilla +function get_bugzilla_version_ids() +{ + $aIds = array(); + $hResult = query_bugzilladb("SELECT id FROM ".BUGZILLA_DB.".versions WHERE + product_id = '".BUGZILLA_PRODUCT_ID."' + ORDER BY id DESC LIMIT 6"); + + if(!$hResult) + return $aIds; + + while(list($sId) = mysql_fetch_row($hResult)) + $aIds[] = $sId; + + return $aIds; +} + // $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