\n\n";
$c = 0;
while($ob = mysql_fetch_object($hResult))
{
//skip if a NONAME
if ($ob->appName == "NONAME") { continue; }
//set row color
$bgcolor = ($c % 2) ? 'color0' : 'color1';
//count versions
$query = query_appdb("SELECT count(*) as versions FROM appVersion WHERE appId = $ob->appId AND versionName != 'NONAME'");
$y = mysql_fetch_object($query);
//display row
echo "
\n";
/* map the merging of the current app to the app we are displaying in the table */
echo " | ".html_ahref($ob->appName,"adminAppQueue.php?sub=duplicate&appId=".$currentAppId."&appIdMergeTo=".$ob->appId)." | \n";
echo " $y->versions versions | \n";
echo "
\n\n";
$c++;
//set row color
$bgcolor = ($c % 2) ? 'color0' : 'color1';
/* add the versions to the table */
$oApp = new Application($ob->appId);
foreach($oApp->aVersionsIds as $iVersionId)
{
$oVersion = new Version($iVersionId);
echo " | ".$oVersion->sName." |
\n";
}
$c++;
}
echo "\n\n";
echo html_frame_end();
}
}
//deny access if not logged in or not a super maintainer of any applications
if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->isSuperMaintainer())
{
errorpage("Insufficient privileges.");
exit;
}
if ($_REQUEST['sub'])
{
if(is_numeric($_REQUEST['appId']))
{
/* make sure the user is authorized to view this application request */
if(!$_SESSION['current']->hasPriv("admin"))
{
errorpage("Insufficient privileges.");
exit;
}
$oApp = new Application($_REQUEST['appId']);
/* if we are processing a queued application there MUST be an implicitly queued */
/* version to go along with it. Find this version so we can display its information */
/* during application processing so the admin can make a better choice about */
/* whether to accept or reject the overall application */
$sQuery = "Select versionId from appVersion where appId='".$_REQUEST['appId']."';";
$hResult = query_appdb($sQuery);
$oRow = mysql_fetch_object($hResult);
/* make sure the user has permission to view this version */
if(!$_SESSION['current']->hasAppVersionModifyPermission($oRow->versionId))
{
errorpage("Insufficient privileges.");
exit;
}
$oVersion = new Version($oRow->versionId);
} elseif(is_numeric($_REQUEST['versionId']))
{
/* make sure the user has permission to view this version */
if(!$_SESSION['current']->hasAppVersionModifyPermission($_REQUEST['versionId']))
{
errorpage("Insufficient privileges.");
exit;
}
$oVersion = new Version($_REQUEST['versionId']);
} else
{
//error no Id!
addmsg("Application Not Found!", "red");
redirect(apidb_fullurl("admin/adminAppQueue.php"));
}
//process according to sub flag
if ($_REQUEST['sub'] == 'view')
{
$x = new TableVE("view");
apidb_header("Admin App Queue");
echo '',"\n";
echo html_frame_end();
echo html_back_link(1,'adminAppQueue.php');
}
else if ($_REQUEST['sub'] == 'add')
{
if (($_REQUEST['apptype'] == "application") && is_numeric($_REQUEST['appId'])) // application
{
// add new vendor
if($_REQUEST['appVendorName'])
{
$oVendor = new Vendor();
$oVendor->create($_REQUEST['appVendorName'],$_REQUEST['appWebpage']);
}
$oApp = new Application($_REQUEST['appId']);
$oApp->GetOutputEditorValues();
$oApp->update();
$oApp->unQueue();
} else if(($_REQUEST['apptype'] == "version") && is_numeric($_REQUEST['versionId'])) // version
{
$oVersion = new Version($_REQUEST['versionId']);
$oVersion->GetOutputEditorValues();
$oVersion->update();
$oVersion->unQueue();
}
redirect(apidb_fullurl("admin/adminAppQueue.php"));
}
else if ($_REQUEST['sub'] == 'duplicate')
{
if(is_numeric($_REQUEST['appIdMergeTo']))
{
/* move this version submission under the existing app */
$oVersion->iAppId = $_REQUEST['appIdMergeTo'];
$oVersion->update();
/* delete the appId that is the duplicate */
$oApp->delete();
}
/* redirect back to the main page */
redirect(apidb_fullurl("admin/adminAppQueue.php"));
}
else if ($_REQUEST['sub'] == 'Delete')
{
if (($_REQUEST['apptype'] == "application") && is_numeric($_REQUEST['appId'])) // application
{
// get the queued versions that refers to the application entry we just removed
// and delete them as we implicitly added a version entry when adding a new application
$sQuery = "SELECT versionId FROM appVersion WHERE appVersion.appId = '".$_REQUEST['appId']."' AND appVersion.queued = 'true';";
$hResult = query_appdb($sQuery);
if($hResult)
{
while($oRow = mysql_fetch_object($hResult))
{
$oVersion = new Version($oRow->versionId);
$oVersion->delete();
}
}
// delete the application entry
$oApp = new Application($_REQUEST['appId']);
$oApp->delete();
} else if(($_REQUEST['apptype'] == "version") && is_numeric($_REQUEST['versionId'])) // version
{
$oVersion = new Version($_REQUEST['versionId']);
$oVersion->delete();
}
redirect(apidb_fullurl("admin/adminAppQueue.php"));
}
else if ($_REQUEST['sub'] == 'Reject')
{
if (($_REQUEST['apptype'] == "application") && is_numeric($_REQUEST['appId'])) // application
{
// get the queued versions that refers to the application entry we just removed
// and delete them as we implicitly added a version entry when adding a new application
$sQuery = "SELECT versionId FROM appVersion WHERE appVersion.appId = '".$_REQUEST['appId']."' AND appVersion.queued = 'true';";
$hResult = query_appdb($sQuery);
if($hResult)
{
while($oRow = mysql_fetch_object($hResult))
{
$oVersion = new Version($oRow->versionId);
$oVersion->reject(true);
}
}
// delete the application entry
$oApp = new Application($_REQUEST['appId']);
$oApp->reject();
} else if(($_REQUEST['apptype'] == "version") && is_numeric($_REQUEST['versionId'])) // version
{
$oVersion = new Version($_REQUEST['versionId']);
$oVersion->reject();
}
redirect(apidb_fullurl("admin/adminAppQueue.php"));
}
else
{
//error no sub!
addmsg("Internal Routine Not Found!!", "red");
redirect(apidb_fullurl("admin/adminAppQueue.php"));
}
}
else /* if ($_REQUEST['sub']) is not defined, display the main app queue page */
{
apidb_header("Admin App Queue");
// get queued apps that the current user should see
$hResult = $_SESSION['current']->getAppQueueQuery(true); /* query for the app family */
if(!$hResult || !mysql_num_rows($hResult))
{
//no apps in queue
echo html_frame_start("Application Queue","90%");
echo 'The Application Queue is empty.
',"\n";
echo html_frame_end(" ");
}
else
{
//help
echo "| \n\n";
echo " This is the list of applications 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 " |
\n\n";
//show applist
echo html_frame_start("","90%","",0);
echo "
| Submission Date |
Submitter |
Vendor |
Application |
Action |
";
$c = 1;
while($oRow = mysql_fetch_object($hResult))
{
$oApp = new Application($oRow->appId);
$oSubmitter = new User($oApp->iSubmitterId);
if($oApp->iVendorId)
{
$oVendor = new Vendor($oApp->iVendorId);
$sVendor = $oVendor->sName;
} else
{
$sVendor = get_vendor_from_keywords($oApp->sKeywords);
}
if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; }
echo "\n";
echo " | ".print_date(mysqltimestamp_to_unixtimestamp($oApp->sSubmitTime))." | \n";
echo " \n";
echo $oSubmitter->sEmail ? "sEmail."\">":"";
echo $oSubmitter->sRealname;
echo $oSubmitter->sEmail ? "":"";
echo " | \n";
echo " ".$sVendor." | \n";
echo " ".$oApp->sName." | \n";
echo " [iAppId."\">process] | \n";
echo "
\n\n";
$c++;
}
echo "
\n\n";
echo html_frame_end(" ");
}
// 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 applist
echo html_frame_start("","90%","",0);
echo "
| Submission Date |
Submitter |
Vendor |
Application |
Version |
Action |
";
$c = 1;
while($oRow = mysql_fetch_object($hResult))
{
$oVersion = new Version($oRow->versionId);
$oApp = new Application($oVersion->iAppId);
$oSubmitter = new User($oVersion->iSubmitterId);
$oVendor = new Vendor($oApp->iVendorId);
$sVendor = $oVendor->sName;
if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; }
echo "\n";
echo " | ".print_date(mysqltimestamp_to_unixtimestamp($oVersion->sSubmitTime))." | \n";
echo " \n";
echo $oSubmitter->sEmail ? "sEmail."\">":"";
echo $oSubmitter->sRealname;
echo $oSubmitter->sEmail ? "":"";
echo " | \n";
echo " ".$sVendor." | \n";
echo " ".$oApp->sName." | \n";
echo " ".$oVersion->sName." | \n";
echo " [iVersionId.">process] | \n";
echo "
\n\n";
$c++;
}
echo "
\n\n";
echo html_frame_end(" ");
}
}
apidb_footer();
?>