Allow previewing versions

This commit is contained in:
Alexander Nicolaysen Sørnes
2007-10-22 17:59:40 +02:00
committed by Chris Morgan
parent 1753ff9757
commit cdee3a77e9
2 changed files with 31 additions and 11 deletions

View File

@@ -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<div class='title_class'>\n";
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)
$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 '<form method=post name=sMessage action=objectManager.php?'.
@@ -1040,6 +1050,7 @@ class version {
}
// Comments Section
if($this->iVersionId)
Comment::view_app_comments($this->iVersionId);
}

View File

@@ -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()