From c43563eca6e370ed39ee12e32cfd6fba488c0fe8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alexander=20Nicolaysen=20S=C3=B8rnes?=
Date: Thu, 19 Apr 2007 23:45:15 +0000
Subject: [PATCH] Fix testData::create() permissions. Separate the cases where
a user has edit rights from when he has the right to unqueue items
---
include/application.php | 4 +-
include/objectManager.php | 7 +-
include/sidebar_admin.php | 2 +-
include/sidebar_maintainer_admin.php | 2 +-
include/testData.php | 24 ++++-
include/version.php | 32 +++---
include/version_queue.php | 156 +++++++++++++++++++++++++++
objectManager.php | 4 +-
8 files changed, 201 insertions(+), 30 deletions(-)
create mode 100644 include/version_queue.php
diff --git a/include/application.php b/include/application.php
index b5f3c4a..f451b7a 100644
--- a/include/application.php
+++ b/include/application.php
@@ -697,7 +697,9 @@ class Application {
}
if($_SESSION['current']->isLoggedIn())
{
- echo '';
}
diff --git a/include/objectManager.php b/include/objectManager.php
index f843006..e51730c 100644
--- a/include/objectManager.php
+++ b/include/objectManager.php
@@ -361,7 +361,12 @@ class ObjectManager
function getIdFromInput($aClean)
{
$sId = "i".ucfirst($this->sClass)."Id";
- return $aClean[$sId];
+ $iId = $aClean['sId'];
+
+ if(!$iId)
+ $iId = $aClean['iId'];
+
+ return $iId;
}
/* Output headers for a table */
diff --git a/include/sidebar_admin.php b/include/sidebar_admin.php
index 5794040..176e637 100644
--- a/include/sidebar_admin.php
+++ b/include/sidebar_admin.php
@@ -13,7 +13,7 @@ function global_admin_menu() {
BASE."objectManager.php?sClass=application&bIsQueue=true&sTitle=".
"Application%20Queue");
$g->add("View Version Queue (".version::objectGetEntriesCount(true, false).")",
- BASE."objectManager.php?sClass=version&bIsQueue=true&sTitle=".
+ BASE."objectManager.php?sClass=version_queue&bIsQueue=true&sTitle=".
"Version%20Queue");
$g->add("View Screenshot Queue (".appData::objectGetEntriesCount("true",
false, "screenshot").")",
diff --git a/include/sidebar_maintainer_admin.php b/include/sidebar_maintainer_admin.php
index 41a0734..5d20ce9 100644
--- a/include/sidebar_maintainer_admin.php
+++ b/include/sidebar_maintainer_admin.php
@@ -8,7 +8,7 @@ function global_maintainer_admin_menu() {
$g = new htmlmenu("Maintainer Admin");
$g->add("View Version Queue (".version::objectGetEntriesCount(true, false).")",
- BASE."objectManager.php?sClass=version&bIsQueue=true&sTitle=".
+ BASE."objectManager.php?sClass=version_queue&bIsQueue=true&sTitle=".
"Version%20Queue");
$g->add("View Screenshot Queue (".appData::objectGetEntriesCount("true",
false, "screenshot").")",
diff --git a/include/testData.php b/include/testData.php
index b63968e..b746fc2 100644
--- a/include/testData.php
+++ b/include/testData.php
@@ -73,7 +73,7 @@ class testData{
$this->sTestedRelease, $this->sInstalls, $this->sRuns,
$this->sTestedRating, $this->sComments,
$_SESSION['current']->iUserId,
- $this->canEdit() ? "false" : "true");
+ $this->mustBeQueued() ? "false" : "true");
if($hResult)
{
$this->iTestingId = mysql_insert_id();
@@ -470,18 +470,19 @@ class testData{
}
/* retrieve the latest test result for a given version id */
- function getNewestTestIdFromVersionId($iVersionId)
+ function getNewestTestIdFromVersionId($iVersionId, $bQueued = false)
{
$sQuery = "SELECT testingId FROM testResults WHERE
versionId = '?'
AND
- queued = 'false'
+ queued = '?'
ORDER BY testedDate DESC limit 1";
- $hResult = query_parameters($sQuery, $iVersionId);
+ $hResult = query_parameters($sQuery, $iVersionId, $bQueued ? "true" : "false");
if(!$hResult)
return 0;
$oRow = mysql_fetch_object($hResult);
+
return $oRow->testingId;
}
@@ -876,6 +877,21 @@ class testData{
echo "distributions, please add it in the \n";
echo "provided field.
\n\n";
}
+
+ function mustBeQueued()
+ {
+ if($_SESSION['current']->hasPriv("admin"))
+ return TRUE;
+ else if($this->iVersionId)
+ {
+ $oVersion = new version($this->iVersionId);
+ if($oVersion->canEdit())
+ return TRUE;
+ else
+ return FALSE;
+ } else
+ return FALSE;
+ }
}
?>
diff --git a/include/version.php b/include/version.php
index 53de2a4..bef0e33 100644
--- a/include/version.php
+++ b/include/version.php
@@ -583,7 +583,7 @@ class Version {
/* if $editParentApplication is true that means we need to display fields */
/* to let the user change the parent application of this version */
/* otherwise, if $editParentAppliation is false, we leave them out */
- function outputEditor($editParentApplication, $editRatingAndRelease)
+ function outputEditor()
{
HtmlAreaLoaderScript(array("version_editor"));
echo html_frame_start("Version Form", "90%", "", 0);
@@ -591,7 +591,12 @@ class Version {
echo '';
- if($editParentApplication)
+ /* Fill in appId value */
+ global $aClean;
+ if(!$this->iAppId)
+ $this->iAppId = $aClean['iAppId'];
+
+ if($this->sQueued == "false" && $this->iVersionId)
{
// app parent
$x = new TableVE("view");
@@ -619,26 +624,11 @@ class Version {
echo $this->sDescription.'',"\n";
- /* Allow the user to apply as maintainer if this is a new version.
- If it is a new application as well, radio boxes will be displayed
- by the application class instead. */
- if(!$this->iVersionId && $_REQUEST['iAppId'])
- {
- if($this->iMaintainerRequest == MAINTAINER_REQUEST)
- $sRequestMaintainerChecked = 'checked="checked"';
- echo html_tr(array(
- array("Become maintainer?", "class=\"color0\""),
- " ".
- "Check this box to request being a maintainer for this version"),
- "","valign=\"top\"");
- }
-
echo '',"\n";
echo html_frame_end();
- if($editRatingAndRelease)
+ if($this->sQueued == "false" && $this->iVersionId)
{
echo html_frame_start("Info", "90%", "", 0);
echo "
\n";
@@ -1326,8 +1316,10 @@ class Version {
$this->sName);
if($this->canEdit())
- $aCells[] = "[ iVersionId\">$sEditLinkLabel ]";
+ {
+ $aCells[] = "[ makeUrl("edit",
+ $this->iVersionId)."\">$sEditLinkLabel ]";
+ }
echo html_tr($aCells, $sClass);
}
diff --git a/include/version_queue.php b/include/version_queue.php
new file mode 100644
index 0000000..7238325
--- /dev/null
+++ b/include/version_queue.php
@@ -0,0 +1,156 @@
+oVersion = new version($iVersionId);
+
+ if($iVersionId)
+ {
+ if($this->oVersion->sQueued == "true")
+ $bQueued = TRUE;
+ if($this->oVersion->sQueued == "false")
+ $bQueued = FALSE;
+ $iTestingId = testData::getNewestTestIdFromVersionId($iVersionId,
+ $bQueued);
+ }
+
+ $this->oTestDataQueue = new testData_queue($iTestingId);
+ $this->oDownloadUrl = new downloadurl();
+ }
+
+ function create()
+ {
+ global $aClean;
+ if(!$this->oVersion->create())
+ return FALSE;
+
+ $this->oTestDataQueue->oTestData->iVersionId = $this->oVersion->iVersionId;
+ $this->oTestDataQueue->create();
+ $this->oDownloadUrl->processFormSingle($this->oVersion->iVersionId,
+ $aClean,
+ $this->oVersion->canEdit());
+
+ return TRUE;
+ }
+
+ function reject()
+ {
+ $this->oVersion->reject();
+
+ if($this->oDownloadUrl->iId)
+ $this->oDownloadUrl->reject();
+
+ $this->oTestDataQueue->reject();
+ }
+
+ function update()
+ {
+ $this->oVersion->update();
+ $this->oTestDataQueue->update();
+ }
+
+ function delete()
+ {
+ return $this->oVersion->delete();
+ }
+
+ function unQueue()
+ {
+ $this->oVersion->unQueue();
+ $this->oTestDataQueue->unQueue();
+ }
+
+ function outputEditor()
+ {
+ $this->oVersion->outputEditor();
+
+ /* Allow the user to apply as maintainer if this is a new version.
+ If it is a new application as well, radio boxes will be displayed
+ by the application class instead. */
+ if(!$this->oVersion->iVersionId && $this->oVersion->iAppId)
+ {
+ echo html_frame_start("Become Maintainer", "90%");
+ echo "
";
+ if($this->oVersion->iMaintainerRequest == MAINTAINER_REQUEST)
+ $sRequestMaintainerChecked = 'checked="checked"';
+ echo html_tr(array(
+ array("Become maintainer?", "class=\"color0\""),
+ " ".
+ "Check this box to request being a maintainer for this version"),
+ "","valign=\"top\"");
+ echo "
";
+ echo html_frame_end();
+ }
+
+ echo $this->oDownloadUrl->outputEditorSingle($this->oVersion->iVersionId,
+ $aClean);
+ $this->oTestDataQueue->outputEditor();
+ }
+
+ function getOutputEditorValues($aClean)
+ {
+ $this->oVersion->getOutputEditorValues($aClean);
+ $this->oTestDataQueue->getOutputEditorValues($aClean);
+ }
+
+ function checkOutputEditorInput($aClean)
+ {
+ $sErrors = $this->oVersion->checkOutputEditorInput($aClean);
+ $sErrors .= $this->oTestDataQueue->checkOutputEditorInput($aClean);
+ return $sErrors;
+ }
+
+ function canEdit()
+ {
+ return $this->oVersion->canEdit();
+ }
+
+ function objectDisplayAddItemHelp()
+ {
+ /* $this->oVersion->displayAddItemHelp(); */
+ }
+
+ function objectGetEntries($bQueued, $bRejected)
+ {
+ return $this->oVersion->objectGetEntries($bQueued, $bRejected);
+ }
+
+ function objectGetHeader()
+ {
+ return $this->oVersion->objectGetHeader();
+ }
+
+ function objectGetInstanceFromRow($oRow)
+ {
+ return version::objectGetInstanceFromRow($oRow);
+ }
+
+ function objectOutputTableRow($oObject, $sClass, $sEditLinkLabel)
+ {
+ return $this->oVersion->objectOutputTableRow($oObject, $sClass, $sEditLinkLabel);
+ }
+
+ function display()
+ {
+ $this->oVersion->display();
+ }
+
+ function objectMakeUrl()
+ {
+ return TRUE;
+ }
+
+ function objectMakeLink()
+ {
+ return TRUE;
+ }
+}
+
+?>
diff --git a/objectManager.php b/objectManager.php
index b67e9cd..b841d50 100644
--- a/objectManager.php
+++ b/objectManager.php
@@ -19,8 +19,8 @@
require_once('path.php');
require_once(BASE.'include/incl.php');
require_once(BASE.'include/objectManager.php');
-/* require_once(BASE.'include/application_queue.php');
-require_once(BASE.'include/version_queue.php'); */
+/* require_once(BASE.'include/application_queue.php'); */
+require_once(BASE.'include/version_queue.php');
require_once(BASE.'include/testData_queue.php');
/* if we have no valid class name we should abort */