Fix testData::create() permissions. Separate the cases where a user has edit rights from
when he has the right to unqueue items
This commit is contained in:
committed by
WineHQ
parent
2a58cf59af
commit
c43563eca6
@@ -697,7 +697,9 @@ class Application {
|
||||
}
|
||||
if($_SESSION['current']->isLoggedIn())
|
||||
{
|
||||
echo '<form method="post" name="sMessage" action="appsubmit.php?iAppId='.$this->iAppId.'&sAppType=version&sub=view">';
|
||||
echo '<form method="post" name="sMessage" action="'.
|
||||
'objectManager.php?sClass=version_queue&iAppId='.$this->iAppId
|
||||
.'&sTitle=Submit+New+Version&sAction=add">';
|
||||
echo '<input type=submit value="Submit new version" class="button">';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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").")",
|
||||
|
||||
@@ -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").")",
|
||||
|
||||
@@ -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.</p>\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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -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 '<input type="hidden" name="iVersionId" value="'.$this->iVersionId.'" />';
|
||||
|
||||
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.'</textarea></p></td></tr>',"\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("<b>Become maintainer?</b>", "class=\"color0\""),
|
||||
"<input type=\"checkbox\" $sRequestMaintainerChecked".
|
||||
"name=\"iMaintainerRequest\" value=\"".MAINTAINER_REQUEST."\" /> ".
|
||||
"Check this box to request being a maintainer for this version"),
|
||||
"","valign=\"top\"");
|
||||
}
|
||||
|
||||
echo '</table>',"\n";
|
||||
|
||||
echo html_frame_end();
|
||||
|
||||
if($editRatingAndRelease)
|
||||
if($this->sQueued == "false" && $this->iVersionId)
|
||||
{
|
||||
echo html_frame_start("Info", "90%", "", 0);
|
||||
echo "<table border=0 cellpadding=2 cellspacing=0>\n";
|
||||
@@ -1326,8 +1316,10 @@ class Version {
|
||||
$this->sName);
|
||||
|
||||
if($this->canEdit())
|
||||
$aCells[] = "[ <a href=\"".BASE."admin/adminAppQueue.php?sAppType=".
|
||||
"version&sSub=view&iVersionId=$this->iVersionId\">$sEditLinkLabel</a> ]";
|
||||
{
|
||||
$aCells[] = "[ <a href=\"".$oObject->makeUrl("edit",
|
||||
$this->iVersionId)."\">$sEditLinkLabel</a> ]";
|
||||
}
|
||||
|
||||
echo html_tr($aCells, $sClass);
|
||||
}
|
||||
|
||||
156
include/version_queue.php
Normal file
156
include/version_queue.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
class version_queue
|
||||
{
|
||||
var $oTestDataQueue;
|
||||
var $oVersion;
|
||||
var $oDownloadUrl;
|
||||
|
||||
function version_queue($iVersionId = null)
|
||||
{
|
||||
$this->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 "<table>";
|
||||
if($this->oVersion->iMaintainerRequest == MAINTAINER_REQUEST)
|
||||
$sRequestMaintainerChecked = 'checked="checked"';
|
||||
echo html_tr(array(
|
||||
array("<b>Become maintainer?</b>", "class=\"color0\""),
|
||||
"<input type=\"checkbox\" $sRequestMaintainerChecked".
|
||||
"name=\"iMaintainerRequest\" value=\"".MAINTAINER_REQUEST."\" /> ".
|
||||
"Check this box to request being a maintainer for this version"),
|
||||
"","valign=\"top\"");
|
||||
echo "</table>";
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user