Use objectmanager to list queued/rejected versions

This commit is contained in:
Alexander Nicolaysen Sørnes
2007-04-07 20:42:08 +00:00
committed by WineHQ
parent ec0cb3dbbb
commit ff476b1b13
5 changed files with 171 additions and 107 deletions

View File

@@ -145,8 +145,7 @@ if ($aClean['sSub'])
} else
{
//error no Id!
addmsg("Application Not Found!", "red");
util_redirect_and_exit(apidb_fullurl("admin/adminAppQueue.php"));
util_show_error_page_and_exit("Application Not Found!");
}
// Get the Testing results if they exist
@@ -191,7 +190,14 @@ if ($aClean['sSub'])
downloadurl::processFormSingle($oVersion->iVersionId, $aClean, TRUE);
util_redirect_and_exit($_SERVER['PHP_SELF']);
if($oVersion->sQueued == "rejected")
$sIsRejected = "true";
else
$sIsRejected = "false";
util_redirect_and_exit(BASE."objectManager.php?sClass=".$aClean['sAppType'].
"&bIsQueue=true&bIsRejected=$sIsRejected&sTitle=".
$aClean['sAppType']."%20Queue");
}
else if ($aClean['sSub'] == 'duplicate')
{
@@ -208,7 +214,8 @@ if ($aClean['sSub'])
}
/* redirect back to the main page */
util_redirect_and_exit(apidb_fullurl("admin/adminAppQueue.php"));
util_redirect_and_exit(BASE."objectManager.php?sClass=application&".
"bIsQueue=true&sTitle=Application%20Queue");
}
else if ($aClean['sSub'] == 'movetest')
{
@@ -225,7 +232,8 @@ if ($aClean['sSub'])
}
// redirect back to the main page
util_redirect_and_exit(apidb_fullurl("admin/adminAppQueue.php"));
util_redirect_and_exit(BASE."objectManager.php?sClass=version&".
"bIsQueue=true&sTitle=Version%20Queue");
}
else if ($aClean['sSub'] == 'Delete')
{
@@ -244,7 +252,8 @@ if ($aClean['sSub'])
$oVersion->delete();
}
util_redirect_and_exit(apidb_fullurl("admin/adminAppQueue.php"));
util_redirect_and_exit(BASE."objectManager.php?sClass=".$aClean['sAppType'].
"&bIsQueue=true&sTitle=".$aClean['sAppType']."%20Queue");
}
else if ($aClean['sSub'] == 'Reject')
{
@@ -263,7 +272,8 @@ if ($aClean['sSub'])
$oVersion->reject();
$oTest->update(true);
$oTest->reject();
util_redirect_and_exit($_SERVER['PHP_SELF']);
util_redirect_and_exit(BASE."objectManager.php?sClass=".$aClean['sAppType'].
"&bIsQueue=true&sTitle=".$aClean['sAppType']."%20Queue");
}
//process according to sub flag
@@ -275,7 +285,13 @@ if ($aClean['sSub'])
echo '<form name="sQform" action="adminAppQueue.php" method="post" enctype="multipart/form-data">',"\n";
echo '<input type="hidden" name="sSub" value="add">',"\n";
echo html_back_link(1,'adminAppQueue.php');
if($oVersion->sQueued == "rejected")
$sIsRejected = "true";
else
$sIsRejected = "false";
echo html_back_link(1,BASE."objectManager.php?sClass=".$aClean['sAppType']."&bIsQueue=true&".
"bIsRejected=$sIsRejected&sTitle=".$aClean['sAppType']."%20Queue");
if (!$oApp) //app version
{
@@ -401,44 +417,15 @@ if ($aClean['sSub'])
echo '</table>',"\n";
echo '</form>',"\n";
echo html_frame_end();
echo html_back_link(1,'adminAppQueue.php');
echo html_back_link(1,BASE."objectManager.php?sClass=".$aClean['sAppType']."&bIsQueue=true&".
"bIsRejected=$sIsRejected&sTitle=".$aClean['sAppType']."%20Queue");
}
else
{
//error no sub!
addmsg("Internal Routine Not Found!!", "red");
util_redirect_and_exit(apidb_fullurl("admin/adminAppQueue.php"));
util_show_error_page_and_exit("Internal Routine Not Found!!");
}
}
else /* if ($aClean['sSub']) is not defined, display the main app queue page */
{
apidb_header("Admin App Queue");
// get queued versions (only versions where application are not queued already)
$hResult = $_SESSION['current']->getAppQueueQuery(false); /* query for the app version */
if(!$hResult || !mysql_num_rows($hResult))
{
//no apps in queue
echo html_frame_start("Version Queue","90%");
echo '<p><b>The Version Queue is empty.</b></p>',"\n";
echo html_frame_end("&nbsp;");
}
else
{
//help
echo "<div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td>\n\n";
echo "<p>This is the list of versions waiting for your approval, or to be rejected.</p>\n";
echo "<p>To view a submission, click on its name. From that page you can edit, delete or approve it into \n";
echo "the AppDB .<br>\n";
echo "<p>Note that versions linked to application that have not been yet approved are not displayed in this list.</p>\n";
echo "the AppDB.<br>\n";
echo "</td></tr></table></div>\n\n";
//show version list
Version::showList($hResult);
}
}
apidb_footer();
?>

View File

@@ -13,7 +13,8 @@ function global_admin_menu() {
BASE."objectManager.php?sClass=application&bIsQueue=true&sTitle=".
"Application%20Queue");
$g->add("View Version Queue (".version::objectGetEntriesCount(true, false).")",
BASE."admin/adminAppQueue.php");
BASE."objectManager.php?sClass=version&bIsQueue=true&sTitle=".
"Version%20Queue");
$g->add("View Screenshot Queue (".appData::objectGetEntriesCount("true",
false, "screenshot").")",
BASE."objectManager.php?sClass=screenshot&bIsQueue=true&sTitle=".
@@ -46,7 +47,8 @@ function global_admin_menu() {
BASE."objectManager.php?sClass=application&bIsQueue=true&bIsRejected=true&".
"sTitle=Rejected%20Applications");
$g->add("View Rejected Versions (".version::objectGetEntriesCount(true, true).")",
BASE."appsubmit.php");
BASE."objectManager.php?sClass=version&bIsQueue=true&bIsRejected=true&".
"sTitle=Rejected%20Versions");
$g->add("View Rejected Test Results (".testData::objectGetEntriesCount(true,
true).")",
BASE."objectManager.php?sClass=testData&bIsQueue=true&bIsRejected=true&".

View File

@@ -8,7 +8,8 @@ function global_maintainer_admin_menu() {
$g = new htmlmenu("Maintainer Admin");
$g->add("View Version Queue (".version::objectGetEntriesCount(true, false).")",
BASE."admin/adminAppQueue.php");
BASE."objectManager.php?sClass=version&bIsQueue=true&sTitle=".
"Version%20Queue");
$g->add("View Screenshot Queue (".appData::objectGetEntriesCount("true",
false, "screenshot").")",
BASE."objectManager.php?sClass=screenshot&bIsQueue=true&sTitle=".

View File

@@ -389,48 +389,6 @@ class User {
return false;
}
/**
* Retrieve the list of applications in the app queue that this user can see
*/
function getAppQueueQuery($queryAppFamily)
{
/* escape input as we can't easily use query_parameters() */
$queryAppFamily = mysql_real_escape_string($queryAppFamily);
if($this->hasPriv("admin"))
{
if($queryAppFamily)
{
$sQuery = "SELECT appFamily.appId FROM appFamily WHERE queued = 'true' ORDER BY appId";
} else
{
$sQuery = "SELECT appVersion.versionId FROM appVersion, appFamily
WHERE appFamily.appId = appVersion.appId
AND appFamily.queued = 'false' AND appVersion.queued = 'true' ORDER BY versionId";
}
} else
{
if($queryAppFamily)
{
$sQuery = "SELECT appFamily.appId FROM appFamily, appMaintainers
WHERE appFamily.queued = 'true'
AND appFamily.appId = appMaintainers.appId
AND appMaintainers.superMaintainer = '1'
AND appMaintainers.userId = '".mysql_real_escape_string($this->iUserId)."';";
} else
{
$sQuery = "SELECT appVersion.versionId FROM appVersion, appFamily, appMaintainers
WHERE appFamily.appId = appVersion.appId
AND appFamily.queued = 'false' AND appVersion.queued = 'true'
AND appFamily.appId = appMaintainers.appId
AND appMaintainers.superMaintainer = '1'
AND appMaintainers.userId = '".mysql_real_escape_string($this->iUserId)."';";
}
}
return query_appdb($sQuery);
}
function getAppRejectQueueQuery($queryAppFamily)
{
/* escape input as we can't easily use query_parameters() */

View File

@@ -41,7 +41,7 @@ class Version {
/**
* constructor, fetches the data.
*/
function Version($iVersionId = null)
function Version($iVersionId = null, $oRow = null)
{
// we are working on an existing version
if(is_numeric($iVersionId))
@@ -50,13 +50,16 @@ class Version {
* We fetch the data related to this version.
*/
if(!$this->iVersionId)
{
if(!$oRow)
{
$sQuery = "SELECT *
FROM appVersion
WHERE versionId = '?'";
if($hResult = query_parameters($sQuery, $iVersionId))
{
$oRow = mysql_fetch_object($hResult);
}
if($oRow)
{
$this->iVersionId = $iVersionId;
@@ -74,7 +77,6 @@ class Version {
}
}
}
}
/**
@@ -1157,7 +1159,8 @@ class Version {
{
$sQueued = objectManager::getQueueString($bQueued, $bRejected);
if($bQueued && !version::canEdit())
$oVersion = new version();
if($bQueued && !$oVersion->canEdit())
{
/* Users should see their own rejected entries, but maintainers should
not be able to see rejected entries for versions they maintain */
@@ -1222,7 +1225,120 @@ class Version {
function canEdit()
{
return $_SESSION['current']->hasPriv("admin");
if($_SESSION['current']->hasPriv("admin"))
return TRUE;
else if($this->iVersionId &&
maintainer::isUserMaintainer($_SESSION['current'], $this->iVersionId))
return TRUE;
else
return FALSE;
}
function objectGetHeader()
{
$aCells = array(
"Submission Date",
"Submitter",
"Vendor",
"Application",
"Version");
return $aCells;
}
function objectGetEntries($bQueued, $bRejected)
{
$sQueued = objectManager::getQueueString($bQueued, $bRejected);
if($bQueued && !$this->canEdit())
{
/* Users should see their own rejected entries, but maintainers should
not be able to see rejected entries for versions they maintain */
if($bRejected)
$sQuery = "SELECT appVersion.* FROM
appVersion, appFamily WHERE
appFamily.appId = appVersion.appId
AND
appFamily.queued = 'false'
AND
appVersion.submitterId = '?'
AND
appVersion.queued = '?'";
else
$sQuery = "SELECT appVersion.* FROM
appVersion, appMaintainers, appFamily WHERE
appFamily.appId = appVersion.appId
AND
appFamily.queued = 'false'
AND
(
(
appMaintainers.appId = appVersion.appId
AND
superMaintainer = '1'
)
OR
(
appMaintainers.versionId = appVersion.versionId
AND
superMaintainer = '0'
)
)
AND
appMaintainers.userId = '?'
AND
appMaintainers.queued = 'false'
AND
appVersion.queued = '?'";
$hResult = query_parameters($sQuery, $_SESSION['current']->iUserId, $sQueued);
} else
{
$sQuery = "SELECT appVersion.*
FROM appVersion, appFamily WHERE
appFamily.appId = appVersion.appId
AND
appFamily.queued = 'false'
AND
appVersion.queued = '?'";
$hResult = query_parameters($sQuery, $sQueued);
}
if(!$hResult)
return FALSE;
return $hResult;
}
function objectOutputTableRow($oObject, $sClass, $sEditLinkLabel)
{
$oUser = new user($this->iSubmitterId);
$oApp = new application($this->iAppId);
$oVendor = new vendor($oApp->iVendorId);
$aCells = array(
print_date(mysqltimestamp_to_unixtimestamp($this->sSubmitTime)),
$oUser->objectMakeLink(),
$oVendor->objectMakeLink(),
$oApp->objectMakeLink(),
$this->sName);
if($this->canEdit())
$aCells[] = "[ <a href=\"".BASE."admin/adminAppQueue.php?sAppType=".
"version&sSub=view&iVersionId=$this->iVersionId\">$sEditLinkLabel</a> ]";
echo html_tr($aCells, $sClass);
}
function objectGetInstanceFromRow($oRow)
{
return new version($oRow->versionId, $oRow);
}
function objectDisplayQueueProcessingHelp()
{
echo "<p>This is the list of versions waiting for your approval, ".
"or to be rejected.</p>\n";
echo "<p>To view a submission, click on its name. ".
"From that page you can edit, delete or approve it into the AppDB.</p>\n";
}
}