From 46df59f06333ff2ac31b4c59dff86a590df7f317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Nicolaysen=20S=C3=B8rnes?= Date: Mon, 16 Apr 2007 23:10:08 +0000 Subject: [PATCH] Use objectManager for new test results --- include/distribution.php | 10 ++++-- include/testData.php | 36 +++++++++++----------- include/testData_queue.php | 62 ++++++++++++++++++++++++++++++++++++++ include/version.php | 4 ++- 4 files changed, 90 insertions(+), 22 deletions(-) create mode 100644 include/testData_queue.php diff --git a/include/distribution.php b/include/distribution.php index c6825f2..2f713af 100644 --- a/include/distribution.php +++ b/include/distribution.php @@ -347,12 +347,16 @@ class distribution { // Name echo 'Distribution Name',"\n"; - echo '',"\n"; + echo '',"\n"; // Url echo 'Distribution Url',"\n"; echo '',"\n"; - echo '',"\n"; + if($this->iDistributionId) + { + echo '',"\n"; + } echo "\n"; } @@ -362,7 +366,7 @@ class distribution { function GetOutputEditorValues($aValues) { $this->iDistributionId = $aValues['iDistributionId']; - $this->sName = $aValues['sName']; + $this->sName = $aValues['sDistribution']; $this->sUrl = $aValues['sUrl']; } diff --git a/include/testData.php b/include/testData.php index e257578..993ee0c 100644 --- a/include/testData.php +++ b/include/testData.php @@ -63,15 +63,6 @@ class testData{ // Creates a new Test Results. function create() { - // Security, if we are not an administrator or a maintainer the test result must be queued. - $oVersion = new Version($this->iVersionId); - if(!$_SESSION['current']->hasPriv("admin") && - !$_SESSION['current']->hasAppVersionModifyPermission($oVersion)) - $this->sQueued = 'true'; - else - $this->sQueued = 'false'; - - $hResult = query_parameters("INSERT INTO testResults (versionId, whatWorks, whatDoesnt,". "whatNotTested, testedDate, distributionId, testedRelease,". "installs, runs, testedRating, comments, submitterId, queued)". @@ -80,8 +71,9 @@ class testData{ $this->iVersionId, $this->shWhatWorks, $this->shWhatDoesnt, $this->shWhatNotTested, $this->sTestedDate, $this->iDistributionId, $this->sTestedRelease, $this->sInstalls, $this->sRuns, - $this->sTestedRating, $this->sComments, $_SESSION['current']->iUserId, - $this->sQueued); + $this->sTestedRating, $this->sComments, + $_SESSION['current']->iUserId, + $this->canEdit() ? "false" : "true"); if($hResult) { $this->iTestingId = mysql_insert_id(); @@ -489,8 +481,16 @@ class testData{ } // show the fields for editing - function outputEditor($sDistribution="", $bNewDist=false) + function outputEditor() { + global $aClean; + + /* Fill in some values */ + if(!$this->iVersionId) + $this->iVersionId = $aClean['iVersionId']; + if(!$this->sTestedDate) + $this->sTestedDate = date('Y-m-d H:i:s'); + HtmlAreaLoaderScript(array("Test1", "Test2", "Test3")); $sName = version::fullName($this->iVersionId); @@ -516,11 +516,11 @@ class testData{ echo '

YYYY-MM-DD HH:MM:SS',"\n"; // Distribution echo 'Distribution',"\n"; - if ($bNewDist) - { - echo '',"\n"; - echo '',"\n"; - } + + echo 'If yours is not on the list, please add it using the form '. + 'below',"\n"; + echo '',"\n"; + echo '',"\n"; distribution::make_distribution_list("iDistributionId", $this->iDistributionId); echo '',"\n"; @@ -823,7 +823,7 @@ class testData{ { if($_SESSION['current']->hasPriv("admin")) return TRUE; - else if($this->iTestingId) + else if($this->iVersionId) { $oVersion = new version($this->iVersionId); if($_SESSION['current']->hasAppVersionModifyPermission($oVersion)) diff --git a/include/testData_queue.php b/include/testData_queue.php new file mode 100644 index 0000000..59579a9 --- /dev/null +++ b/include/testData_queue.php @@ -0,0 +1,62 @@ +oTestData = new testData($iTestId); + $this->oDistribution = new distribution($this->oTestData->iDistributionId); + } + + function create() + { + if(!$this->oTestData->iDistributionId) + { + $this->oDistribution->create(); + $this->oTestData->iDistributionId = $this->oDistribution->iDistributionId; + } + $this->oTestData->create(); + } + + function update() + { + $this->oTestData->update(); + $this->oDistribution->update(); + } + + function outputEditor() + { + $this->oTestData->outputEditor(); + + /* If the testData is already associated with a distribution and the distribution is + un-queued, there is no need to display the distribution form here */ + if(!$this->oTestData->iDistributionId or $this->oDistributionId->sQueued != "false") + $this->oDistribution->outputEditor(); + } + + function getOutputEditorValues($aClean) + { + $this->oTestData->getOutputEditorValues($aClean); + $this->oDistribution->getOutputEditorValues($aClean); + } + + function checkOutputEditorInput($aClean) + { + return $this->oTestData->checkOutputEditorInput($aClean); + } + + function canEdit() + { + return $this->oTestData->canEdit(); + } + + function objectDisplayAddItemHelp() + { + $this->oTestData->objectDisplayAddItemHelp(); + } +} + +?> diff --git a/include/version.php b/include/version.php index a933621..53de2a4 100644 --- a/include/version.php +++ b/include/version.php @@ -897,7 +897,9 @@ class Version { } if($_SESSION['current']->isLoggedIn()) { - echo '

iVersionId.'>'; + echo 'iVersionId. + '&sTitle=Add+Test+Data>'; echo ''; echo '
'; } else