From cdee3a77e9b263c7cc276460ec487dce3ed47dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Nicolaysen=20S=C3=B8rnes?= Date: Mon, 22 Oct 2007 17:59:40 +0200 Subject: [PATCH] Allow previewing versions --- include/version.php | 31 +++++++++++++++++++++---------- include/version_queue.php | 11 ++++++++++- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/include/version.php b/include/version.php index 0f91e7e..6da13c4 100644 --- a/include/version.php +++ b/include/version.php @@ -746,7 +746,13 @@ class version { } } - public function display($aVars) + public function objectShowPreview() + { + 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) { /* is this user supposed to view this version? */ if(!$_SESSION['current']->canViewVersion($this)) @@ -760,10 +766,6 @@ class version { if(!$oApp->iAppId) util_show_error_page_and_exit('Internal Database Access Error. No App found.'); - // Oops! Version not found or other error. do something - if(!$this->iVersionId) - util_show_error_page_and_exit('Internal Database Access Error. No Version Found.'); - // show Vote Menu if($_SESSION['current']->isLoggedIn()) apidb_sidebar_add("vote_menu"); @@ -976,10 +978,13 @@ class version { echo "\t
\n"; echo "\t\tSelected test results (selected in 'Test Results' table below)\n"; echo "\t
\n"; - $oTest = new testData($iTestingId); + + /* oTest may be passed by version_queue to allow previewing a version which does not exist in the database */ + if(!$oTest && $iTestingId) + $oTest = new testData($iTestingId); /* if $iTestingId wasn't valid then it won't be valid in $oTest */ - if(!$oTest->iTestingId) + if(!$oTest) { /* fetch a new test id for this version */ $iTestingId = testData::getNewestTestIdFromVersionId($this->iVersionId); @@ -999,9 +1004,14 @@ class version { // show the test results table if($oTest->iTestingId) { - $oTest->ShowVersionsTestingTable($this->objectMakeUrl()."&iTestingId=", - 5); + $oTest->ShowVersionsTestingTable($this->objectMakeUrl()."&iTestingId=", 5); + } else /* We are previewing the version */ + { + $oTable = $oTest->CreateTestTable(); + $oTable->AddRow($oTest->CreateTestTableRow(0, "")); + echo $oTable->GetString(); } + if($_SESSION['current']->isLoggedIn()) { echo '
iVersionId); + if($this->iVersionId) + Comment::view_app_comments($this->iVersionId); } public static function lookup_name($versionId) diff --git a/include/version_queue.php b/include/version_queue.php index 03fa3f1..e3eaa61 100644 --- a/include/version_queue.php +++ b/include/version_queue.php @@ -162,6 +162,7 @@ class version_queue function getOutputEditorValues($aClean) { + $this->oVersion->iAppId = $aClean['iAppId']; $this->oVersion->getOutputEditorValues($aClean); $this->oTestDataQueue->getOutputEditorValues($aClean); } @@ -214,9 +215,17 @@ class version_queue return $this->oVersion->objectGetTableRow(); } + public function objectShowPreview() + { + return $this->oVersion->objectShowPreview(); + } + function display() { - $this->oVersion->display(); + $aVars = array(); + $aVars['iTestingId'] = 0; + + $this->oVersion->display($aVars, $this->oTestDataQueue->oTestData); } function objectMakeUrl()