\n\n";
$c = 0;
while($oRow = mysql_fetch_object($hResult))
{
//skip if a NONAME
if ($oRow->appName == "NONAME") { continue; }
//set row color
$sBgColor = ($c % 2) ? 'color0' : 'color1';
//count versions
$query = query_parameters("SELECT count(*) as versions FROM appVersion WHERE ".
"appId = '?' AND versionName != 'NONAME'",
$oRow->appId);
$oVersionCount = 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($oRow->appName,"adminAppQueue.php?sub=duplicate&apptype=application&appId=".$currentAppId."&appIdMergeTo=".$oRow->appId)." | \n";
echo " $oVersionCount->versions versions | \n";
echo "
\n\n";
$c++;
//set row color
$sBgColor = ($c % 2) ? 'color0' : 'color1';
/* add the versions to the table */
$oApp = new Application($oRow->appId);
foreach($oApp->aVersionsIds as $iVersionId)
{
$oVersion = new Version($iVersionId);
echo " | ".$oVersion->sName." |
\n";
}
$c++;
}
echo "\n\n";
echo html_frame_end();
}
}
function display_move_test_to_versions_table($aVersionsIds,$icurrentVersionId)
{
if ($aVersionsIds)
{
echo html_frame_start("","98%","",0);
echo "\n\n";
echo "\n";
echo " | Version | \n";
echo " Description | \n";
echo " Rating | \n";
echo " Wine version | \n";
echo " Comments | \n";
echo "
\n\n";
$c = 0;
foreach($aVersionsIds as $iVersionId)
{
$oVersion = new Version($iVersionId);
if ($oVersion->sQueued == 'false')
{
// set row color
$sBgColor = ($c % 2 == 0) ? "color0" : "color1";
//display row
echo "\n";
echo " | ".html_ahref($oVersion->sName,"adminAppQueue.php?sub=movetest&apptype=version&versionId=".$icurrentVersionId."&versionIdMergeTo=".$oVersion->iVersionId)." | \n";
echo " ".util_trim_description($oVersion->sDescription)." | \n";
echo " ".$oVersion->sTestedRating." | \n";
echo " ".$oVersion->sTestedRelease." | \n";
echo " ".sizeof($oVersion->aCommentsIds)." | \n";
echo "
\n\n";
$c++;
}
}
echo "
\n";
echo html_frame_end("Click the Version Name to view the details of that Version");
}
}
//deny access if not logged in or not a super maintainer of any applications
if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->isSuperMaintainer())
{
util_show_error_page("Insufficient privileges.");
exit;
}
$oTest = new testData($aClean['iTestingId']);
if ($aClean['sub'])
{
if($aClean['apptype'] == 'application')
{
/* make sure the user is authorized to view this application request */
if(!$_SESSION['current']->hasPriv("admin"))
{
util_show_error_page("Insufficient privileges.");
exit;
}
$oApp = new Application($aClean['appId']);
// if we are processing a queued application there MUST be an implicitly queued
// version to go along with it.
$hResult = query_parameters("SELECT versionId from appVersion where appId='?';", $aClean['appId']);
$oVersionRow = mysql_fetch_object($hResult);
$oVersion = new Version($oVersionRow->versionId);
}
else if($aClean['apptype'] == 'version')
{
/* make sure the user has permission to view this version */
$oVersion = new Version($aClean['versionId']);
if(!$_SESSION['current']->hasAppVersionModifyPermission($oVersion))
{
util_show_error_page("Insufficient privileges.");
exit;
}
} else
{
//error no Id!
addmsg("Application Not Found!", "red");
redirect(apidb_fullurl("admin/adminAppQueue.php"));
}
// Get the Testing results if they exist
$hResult = query_parameters("SELECT testingId from testResults where versionId='?'", $oVersion->iVersionId);
if($hResult)
{
$oRow = mysql_fetch_object($hResult);
$oTest = new testData($oRow->testingId);
}
else
{
$oTest = new testData();
}
if($aClean['sub'] == 'add')
{
$oVersion = new Version($aClean['versionId']);
$oTest = new testData($aClean['iTestingId']);
$oVersion->GetOutputEditorValues();
$oTest->GetOutputEditorValues();
if ($aClean['apptype'] == "application") // application
{
$oApp = new Application($aClean['appId']);
$oApp->GetOutputEditorValues(); // load the values from $_REQUEST
// add new vendor
if($aClean['appVendorName'] and !$aClean['appVendorId'])
{
$oVendor = new Vendor();
$oVendor->create($aClean['appVendorName'],$aClean['appWebpage']);
$oApp->iVendorId = $oVendor->iVendorId;
}
$oApp->update(true);
$oApp->unQueue();
}
$oVersion->update(true);
$oVersion->unQueue();
$oTest->update(true);
$oTest->unQueue();
redirect($_SERVER['PHP_SELF']);
}
else if ($aClean['sub'] == 'duplicate')
{
if(is_numeric($aClean['appIdMergeTo']))
{
/* move this version submission under the existing app */
$oVersion->iAppId = $aClean['appIdMergeTo'];
$oVersion->update();
/* delete the appId that is the duplicate */
$aClean['replyText'] = "Your Vesion information was moved to an existing Application";
$oAppDelete = new Application($oApp->iAppId);
$oAppDelete->delete();
}
/* redirect back to the main page */
redirect(apidb_fullurl("admin/adminAppQueue.php"));
}
else if ($aClean['sub'] == 'movetest')
{
if(is_numeric($aClean['versionIdMergeTo']))
{
// move this Test submission under the existing version
$oTest->iVersionId = $aClean['versionIdMergeTo'];
$oTest->update();
// delete the Version entry
$aClean['replyText'] = "Your Test results were moved to existing version";
$oVersion = new Version($aClean['versionId']);
$oVersion->delete();
}
// redirect back to the main page
redirect(apidb_fullurl("admin/adminAppQueue.php"));
}
else if ($aClean['sub'] == 'Delete')
{
if (($aClean['apptype'] == "application") && is_numeric($aClean['appId'])) // application
{
// delete the application entry
$oApp = new Application($aClean['appId']);
$oApp->delete();
} else if(($aClean['apptype'] == "version") && is_numeric($aClean['versionId'])) // version
{
// delete the Version entry
$oVersion = new Version($aClean['versionId']);
$oVersion->delete();
}
redirect(apidb_fullurl("admin/adminAppQueue.php"));
}
else if ($aClean['sub'] == 'Reject')
{
$oVersion = new Version($aClean['versionId']);
$oTest = new testData($aClean['iTestingId']);
$oVersion->GetOutputEditorValues();
$oTest->GetOutputEditorValues();
if ($aClean['apptype'] == "application") // application
{
$oApp = new Application($aClean['appId']);
$oApp->GetOutputEditorValues(); // load the values from $_REQUEST
$oApp->update(true);
$oApp->reject();
}
$oVersion->update(true);
$oVersion->reject();
$oTest->update(true);
$oTest->reject();
redirect($_SERVER['PHP_SELF']);
}
//process according to sub flag
if ($aClean['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
{
//error no sub!
addmsg("Internal Routine Not Found!!", "red");
redirect(apidb_fullurl("admin/adminAppQueue.php"));
}
}
else /* if ($aClean['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
Application::showList($hResult);
}
// 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();
?>