Alexander Nicolaysen Sørnes : Let application::getVersions() optionally return only accepted versions

Chris Morgan cmorgan at winehq.org
Fri Jul 18 10:14:50 CDT 2008


Module: appdb
Branch: master
Commit: 64f3219c94e2d2806dd0ce866b0ad8e7917013c0
URL:    http://source.winehq.org/git/appdb.git/?a=commit;h=64f3219c94e2d2806dd0ce866b0ad8e7917013c0

Author: Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
Date:   Mon Jul 14 14:33:18 2008 +0200

Let application::getVersions() optionally return only accepted versions

---

 include/application.php |   24 ++++++++++++------------
 include/version.php     |    2 +-
 screenshots.php         |    2 +-
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/include/application.php b/include/application.php
index 6b2cd77..a7ffa09 100644
--- a/include/application.php
+++ b/include/application.php
@@ -101,20 +101,20 @@ class Application {
         }
     }
 
-    private function _internal_retrieve_all_versions($bIncludeObsolete = TRUE, $bIncludeDeleted = false)
+    private function _internal_retrieve_all_versions($bOnlyAccepted = false, $bIncludeObsolete = TRUE, $bIncludeDeleted = false)
     {
+        $sExtraTerms = '';
+
         if(!$bIncludeObsolete)
-            $sObsolete = " AND obsoleteBy = '0'";
-        else
-            $sObsolete = "";
+            $sExtraTerms .= " AND obsoleteBy = '0'";
 
-        if($bIncludeDeleted)
-            $sExcludeDeleted = "";
-        else
-            $sExcludeDeleted = " AND state != 'deleted'";
+        if($bOnlyAccepted)
+            $sExtraTerms .= " AND state = 'accepted'";
+        else if(!$bIncludeDeleted)
+            $sExtraTerms .= " AND state != 'deleted'";
 
         $sQuery = "SELECT versionId FROM appVersion WHERE
-                appId = '?'$sObsolete$sExcludeDeleted ORDER by versionName";
+                appId = '?'$sExtraTerms ORDER by versionName";
         $hResult  = query_parameters($sQuery, $this->iAppId);
         return $hResult;
     }
@@ -1224,7 +1224,7 @@ class Application {
         return $oRow->count;
     }
 
-    public function getVersions($bIncludeObsolete = TRUE, $bIncludeDeleted = false)
+    public function getVersions($bOnlyAccepted = false, $bIncludeObsolete = TRUE, $bIncludeDeleted = false)
     {
         /* If no id is set we cannot query for the versions, but perhaps objects are already cached? */
         if(!$this->iAppId)
@@ -1232,7 +1232,7 @@ class Application {
 
         $aVersions = array();
 
-        $hResult = $this->_internal_retrieve_all_versions($bIncludeObsolete, $bIncludeDeleted);
+        $hResult = $this->_internal_retrieve_all_versions($bOnlyAccepted, $bIncludeObsolete, $bIncludeDeleted);
 
         while($oRow = mysql_fetch_object($hResult))
             $aVersions[] = new version($oRow->versionId);
@@ -1268,7 +1268,7 @@ class Application {
         $aChildren = array();
 
         /* Get versions */
-                foreach($this->getVersions(true, $bIncludeDeleted) as $oVersion)
+                foreach($this->getVersions(false, true, $bIncludeDeleted) as $oVersion)
         {
             $aChildren += $oVersion->objectGetChildren($bIncludeDeleted);
             $aChildren[] = $oVersion;
diff --git a/include/version.php b/include/version.php
index e04955b..3526012 100644
--- a/include/version.php
+++ b/include/version.php
@@ -687,7 +687,7 @@ class version {
 
                 echo "<input type=\"hidden\" name=\"iObsoleteBy\" value=\"".
                      $oVersionInDB->iObsoleteBy."\" type=\"hidden\" >\n";
-            } else if(sizeof($oApp->getVersions(FALSE)) > 1)
+            } else if(sizeof($oApp->getVersions(TRUE, FALSE)) > 1)
             {
                 if($this->iObsoleteBy)
                     $sObsolete = "checked=\"checked\"";
diff --git a/screenshots.php b/screenshots.php
index aa55225..fdb1d0b 100644
--- a/screenshots.php
+++ b/screenshots.php
@@ -165,7 +165,7 @@ if($aClean['iVersionId'] && $_SESSION['current']->isLoggedIn())
     echo html_frame_start("Upload Screenshot", "30%");
     echo 'If you would like to submit screenshots, please select an application version below.<br>';
     echo '<ul>';
-    foreach($oApp->getVersions() as $oVersion)
+    foreach($oApp->getVersions(true) as $oVersion)
         echo '<li><a href="'.BASE.'screenshots.php?iVersionId='.$oVersion->objectGetId().'">'.$oVersion->sName.'</a></li>';
 
     echo '</ul>';




More information about the wine-cvs mailing list