Module: appdb
Branch: master
Commit: dba90a092432b392eb3c98d59481821ba40018bb
URL: http://source.winehq.org/git/appdb.git/?a=commit;h=dba90a092432b392eb3c98d5…
Author: Alexander Nicolaysen Sørnes <alex(a)thehandofagony.com>
Date: Thu Oct 25 11:57:18 2007 +0200
Support previewing version when submitting application
---
include/application_queue.php | 44 ++++++++++++++++++++++++++++++++++++++--
include/version.php | 17 +++++++++++----
2 files changed, 53 insertions(+), 8 deletions(-)
diff --git a/include/application_queue.php b/include/application_queue.php
index 883e126..93e1171 100644
--- a/include/application_queue.php
+++ b/include/application_queue.php
@@ -160,7 +160,7 @@ class application_queue
return FALSE;
}
- function outputEditor()
+ function outputEditor($aClean = array())
{
/* We ask the user for the application name first so as to avoid duplicate
submissons; a list of potential duplicates is displayed on the next page */
@@ -203,6 +203,23 @@ class application_queue
$this->oVersionQueue->oVersion->iVersionId, $aClean);
$this->oVersionQueue->oTestDataQueue->outputEditor();
+
+ /* Allow the user to choose whether to preview the application view
+ or the version view. Application view is default */
+ echo html_frame_start("Select What to Preview");
+ $sPreviewVersion = $aClean['bPreviewVersion'] ? $aClean['bPreviewVersion'] : "";
+
+ $shPreviewApp = '';
+ $shPreviewVersion = '';
+
+ if($sPreviewVersion == "true")
+ $shPreviewVersion = ' checked="checked"';
+ else
+ $shPreviewApp = ' checked="checked"';
+
+ echo "<input type=\"radio\" name=\"bPreviewVersion\"$shPreviewApp value=\"false\" /> Preview application<br />\n";
+ echo "<input type=\"radio\" name=\"bPreviewVersion\"$shPreviewVersion value=\"true\" /> Preview version\n";
+ echo html_frame_end();
}
}
@@ -297,13 +314,34 @@ class application_queue
echo "</table>";
}
- function display()
+ function objectGetCustomVars($sAction)
+ {
+ switch($sAction)
+ {
+ case "preview":
+ return array("bPreviewVersion");
+
+ default:
+ return 0;
+ }
+ }
+
+ function display($aClean = array())
{
/* Cache the version object if it is not in the database */
if(!$this->oVersionQueue->objectGetId())
$this->oApp->aVersions = array($this->oVersionQueue->oVersion);
- $this->oApp->display();
+ $sPreviewVersion = $aClean['bPreviewVersion'] ? $aClean['bPreviewVersion'] : "";
+
+ if($sPreviewVersion == "true")
+ {
+ $this->oVersionQueue->oVersion->oApp = $this->oApp;
+ $this->oVersionQueue->display();
+ } else
+ {
+ $this->oApp->display();
+ }
}
function objectMakeUrl()
diff --git a/include/version.php b/include/version.php
index efa8b72..3b9bd2f 100644
--- a/include/version.php
+++ b/include/version.php
@@ -26,6 +26,7 @@ define("LICENSE_RETAIL", "Retail");
class version {
var $iVersionId;
var $iAppId;
+ var $oApp; /* Parento object */
var $sName;
var $sDescription;
var $sTestedRelease;
@@ -759,6 +760,16 @@ class version {
return TRUE;
}
+ /* Not standard OM function yet, but will be in the future */
+ public function objectGetParent()
+ {
+ /* No id so we can't query the DB, but perhaps an entry is cached? */
+ if(!$this->iAppId)
+ return $this->oApp;
+
+ return new application($this->iAppId);
+ }
+
public function display($aVars = array())
{
/* is this user supposed to view this version? */
@@ -767,11 +778,7 @@ class version {
$iTestingId = $aVars['iTestingId'] ? $aVars['iTestingId'] : 0;
- $oApp = new Application($this->iAppId);
-
- // Oops! application not found or other error. do something
- if(!$oApp->iAppId)
- util_show_error_page_and_exit('Internal Database Access Error. No App found.');
+ $oApp = $this->objectGetParent();
// show Vote Menu
if($_SESSION['current']->isLoggedIn())
Module: appdb
Branch: master
Commit: 69d584ed85e1fba3285015d472136cfca5c8dca2
URL: http://source.winehq.org/git/appdb.git/?a=commit;h=69d584ed85e1fba3285015d4…
Author: Alexander Nicolaysen Sørnes <alex(a)thehandofagony.com>
Date: Thu Oct 25 11:10:32 2007 +0200
version: Add and use aTestResults member
---
include/version.php | 42 ++++++++++++++++++++++++++++++------------
include/version_queue.php | 7 +++----
2 files changed, 33 insertions(+), 16 deletions(-)
diff --git a/include/version.php b/include/version.php
index 9d97553..efa8b72 100644
--- a/include/version.php
+++ b/include/version.php
@@ -34,6 +34,9 @@ class version {
var $iSubmitterId;
var $sQueued;
var $sLicense;
+ var $aTestResults; /* Array of test result objects. Especially useful when
+ we want to preview a version before submitting it;
+ in that case there is no data in the database */
var $iObsoleteBy; /* Whether this version is marked as obsolete, and if so which
version its votes should be moved to. */
var $iMaintainerRequest; /* Temporary variable for version submisson.
@@ -46,6 +49,7 @@ class version {
*/
public function Version($iVersionId = null, $oRow = null)
{
+ $this->aTestResults = array(); // should always be an array
// we are working on an existing version
if(!$iVersionId && !$oRow)
return;
@@ -755,14 +759,13 @@ class version {
return TRUE;
}
- /* $oTest can be passed by version_queue to allow previewing a version, in which case the test id may not be defined */
- public function display($aVars, $oTest = null)
+ public function display($aVars = array())
{
/* is this user supposed to view this version? */
if(!$_SESSION['current']->canViewVersion($this))
util_show_error_page_and_exit("Something went wrong with the application or version id");
- $iTestingId = $aVars['iTestingId'];
+ $iTestingId = $aVars['iTestingId'] ? $aVars['iTestingId'] : 0;
$oApp = new Application($this->iAppId);
@@ -983,16 +986,17 @@ class version {
echo "\t\tSelected test results <small><small>(selected in 'Test Results' table below)</small></small>\n";
echo "\t</div>\n";
- /* oTest may be passed by version_queue to allow previewing a version which does not exist in the database */
- if(!$oTest && $iTestingId)
+ /* Set if the use chose to display a particular test report */
+ if($iTestingId)
$oTest = new testData($iTestingId);
-
- /* if $iTestingId wasn't valid then it won't be valid in $oTest */
- if(!$oTest)
+ else if($this->iVersionId) /* Let's query for the latest rest report */
{
- /* fetch a new test id for this version */
$iTestingId = testData::getNewestTestIdFromVersionId($this->iVersionId);
$oTest = new testData($iTestingId);
+ } else /* Perhaps we have a cached entry? There should be */
+ {
+ $aTests = $this->getTestResults();
+ $oTest = $aTests[0];
}
echo "<div class='info_contents'>\n";
@@ -1577,9 +1581,14 @@ class version {
"From that page you can edit, delete or approve it into the AppDB.</p>\n";
}
- public function objectGetChildren()
+ public function getTestResults()
{
- $aChildren = array();
+ /* If we don't have an id we can query the database, but perhaps we
+ have some cached entries? */
+ if(!$this->iVersionId)
+ return $this->aTestResults;
+
+ $aTests = array();
/* Find test results */
$sQuery = "SELECT * FROM testResults WHERE versionId = '?'";
@@ -1589,8 +1598,17 @@ class version {
return FALSE;
while($oRow = mysql_fetch_object($hResult))
+ $aTests[] = new testData(0, $oRow);
+
+ return $aTests;
+ }
+
+ public function objectGetChildren()
+ {
+ $aChildren = array();
+
+ foreach($this->getTestResults() as $oTest)
{
- $oTest = new testData(0, $oRow);
$aChildren += $oTest->objectGetChildren();
$aChildren[] = $oTest;
}
diff --git a/include/version_queue.php b/include/version_queue.php
index e3eaa61..4451586 100644
--- a/include/version_queue.php
+++ b/include/version_queue.php
@@ -222,10 +222,9 @@ class version_queue
function display()
{
- $aVars = array();
- $aVars['iTestingId'] = 0;
-
- $this->oVersion->display($aVars, $this->oTestDataQueue->oTestData);
+ /* Cache the test result object as it's not in the DB */
+ $this->oVersion->aTestResults[] = $this->oTestDataQueue->oTestData;
+ $this->oVersion->display();
}
function objectMakeUrl()