diff --git a/admin/adminAppQueue.php b/admin/adminAppQueue.php index 43d5c68..fc4a56a 100644 --- a/admin/adminAppQueue.php +++ b/admin/adminAppQueue.php @@ -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 '
',"\n"; echo '',"\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 '',"\n"; echo '
',"\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 '

The Version Queue is empty.

',"\n"; - echo html_frame_end(" "); - } - else - { - //help - echo "
\n\n"; - echo "

This is the list of versions waiting for your approval, or to be rejected.

\n"; - echo "

To view a submission, click on its name. From that page you can edit, delete or approve it into \n"; - echo "the AppDB .
\n"; - echo "

Note that versions linked to application that have not been yet approved are not displayed in this list.

\n"; - echo "the AppDB.
\n"; - echo "
\n\n"; - - //show version list - Version::showList($hResult); - - } -} apidb_footer(); ?> diff --git a/include/sidebar_admin.php b/include/sidebar_admin.php index 91aa720..5794040 100644 --- a/include/sidebar_admin.php +++ b/include/sidebar_admin.php @@ -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&". diff --git a/include/sidebar_maintainer_admin.php b/include/sidebar_maintainer_admin.php index af45d4e..41a0734 100644 --- a/include/sidebar_maintainer_admin.php +++ b/include/sidebar_maintainer_admin.php @@ -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=". diff --git a/include/user.php b/include/user.php index 8a91bb1..fd598d9 100644 --- a/include/user.php +++ b/include/user.php @@ -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() */ diff --git a/include/version.php b/include/version.php index 673212e..67d7a48 100644 --- a/include/version.php +++ b/include/version.php @@ -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)) @@ -51,26 +51,28 @@ class Version { */ if(!$this->iVersionId) { - $sQuery = "SELECT * - FROM appVersion - WHERE versionId = '?'"; - if($hResult = query_parameters($sQuery, $iVersionId)) + if(!$oRow) { - $oRow = mysql_fetch_object($hResult); - if($oRow) - { - $this->iVersionId = $iVersionId; - $this->iAppId = $oRow->appId; - $this->iSubmitterId = $oRow->submitterId; - $this->sSubmitTime = $oRow->submitTime; - $this->sDate = $oRow->submitTime; - $this->sName = $oRow->versionName; - $this->sDescription = $oRow->description; - $this->sTestedRelease = $oRow->maintainer_release; - $this->sTestedRating = $oRow->maintainer_rating; - $this->sQueued = $oRow->queued; - $this->sLicense = $oRow->license; - } + $sQuery = "SELECT * + FROM appVersion + WHERE versionId = '?'"; + if($hResult = query_parameters($sQuery, $iVersionId)) + $oRow = mysql_fetch_object($hResult); + } + + if($oRow) + { + $this->iVersionId = $iVersionId; + $this->iAppId = $oRow->appId; + $this->iSubmitterId = $oRow->submitterId; + $this->sSubmitTime = $oRow->submitTime; + $this->sDate = $oRow->submitTime; + $this->sName = $oRow->versionName; + $this->sDescription = $oRow->description; + $this->sTestedRelease = $oRow->maintainer_release; + $this->sTestedRating = $oRow->maintainer_rating; + $this->sQueued = $oRow->queued; + $this->sLicense = $oRow->license; } } } @@ -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[] = "[ iVersionId\">$sEditLinkLabel ]"; + + echo html_tr($aCells, $sClass); + } + + function objectGetInstanceFromRow($oRow) + { + return new version($oRow->versionId, $oRow); + } + + function objectDisplayQueueProcessingHelp() + { + echo "

This is the list of versions waiting for your approval, ". + "or to be rejected.

\n"; + echo "

To view a submission, click on its name. ". + "From that page you can edit, delete or approve it into the AppDB.

\n"; } }