diff --git a/admin/adminAppQueue.php b/admin/adminAppQueue.php index c3d5999..fa29690 100644 --- a/admin/adminAppQueue.php +++ b/admin/adminAppQueue.php @@ -8,6 +8,7 @@ require(BASE."include/incl.php"); require(BASE."include/tableve.php"); require(BASE."include/application.php"); require(BASE."include/mail.php"); +require_once(BASE."include/testResults.php"); function get_vendor_from_keywords($sKeywords) @@ -76,10 +77,11 @@ if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->isSuperMain errorpage("Insufficient privileges."); exit; } +$oTest = new testData($_REQUEST['iTestingId']); if ($_REQUEST['sub']) { - if(is_numeric($_REQUEST['appId'])) + if($_REQUEST['apptype'] == 'application') { /* make sure the user is authorized to view this application request */ if(!$_SESSION['current']->hasPriv("admin")) @@ -90,23 +92,16 @@ if ($_REQUEST['sub']) $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 */ + // if we are processing a queued application there MUST be an implicitly queued + // version to go along with it. $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'])) + + } + else if($_REQUEST['apptype'] == 'version') { /* make sure the user has permission to view this version */ if(!$_SESSION['current']->hasAppVersionModifyPermission($_REQUEST['versionId'])) @@ -123,6 +118,142 @@ if ($_REQUEST['sub']) redirect(apidb_fullurl("admin/adminAppQueue.php")); } + // Get the Testing results if they exist + $sQuery = "Select testingId from testResults where versionId='".$oVersion->iVersionId."';"; + $hResult = query_appdb($sQuery); + if($hResult) + { + $oRow = mysql_fetch_object($hResult); + $oTest = new testdata($oRow->testingId); + } + else + { + $oTest = new testResult(); + } + + 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(); + foreach($oVersion->aVersionIds as $iTestingId) + { + $oTest = new Version($iTestingId); + $oTest->GetOutputEditorValues(); + $oTest->iVersionId = $oVersion->iVersionId; + $oTest->iVersionId = $oVersion->iVersionId; + $oTest->Update(); + $oTest->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(); + } + foreach($oVersion->aVersionIds as $iTestingId) + { + $oTest = new Version($iTestingId); + $oTest->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(); + + } + foreach($oVersion->aVersionIds as $iTestingId) + { + $oTest = new Version($iTestingId); + $oTest->GetOutputEditorValues(); + $oTest->iVersionId = $oVersion->iVersionId; + $oTest->Update(); + $oTest->reject(); + } + + + redirect(apidb_fullurl("admin/adminAppQueue.php")); + } + //process according to sub flag if ($_REQUEST['sub'] == 'view') { @@ -229,6 +360,7 @@ if ($_REQUEST['sub']) { $oVersion->OutputEditor(false, false); } + $oTest->OutputEditor($_REQUEST['sDistribution']); echo html_frame_start("Reply text", "90%", "", 0); echo "\n"; @@ -254,102 +386,6 @@ if ($_REQUEST['sub']) 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! @@ -381,45 +417,8 @@ else /* if ($_REQUEST['sub']) is not defined, display the main app queue page */ echo "
\n\n"; //show applist - echo html_frame_start("","90%","",0); - echo " - - - - - - - "; - - $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 " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n\n"; - $c++; - } - echo "
Submission DateSubmitterVendorApplicationAction
".print_date(mysqltimestamp_to_unixtimestamp($oApp->sSubmitTime))."\n"; - echo $oSubmitter->sEmail ? "sEmail."\">":""; - echo $oSubmitter->sRealname; - echo $oSubmitter->sEmail ? "":""; - echo " ".$sVendor."".$oApp->sName."[iAppId."\">process]
\n\n"; - echo html_frame_end(" "); + showAppList($hResult); + } // get queued versions (only versions where application are not queued already) @@ -443,43 +442,8 @@ else /* if ($_REQUEST['sub']) is not defined, display the main app queue page */ echo "the AppDB.
\n"; echo "\n\n"; - //show applist - echo html_frame_start("","90%","",0); - echo " - - - - - - - - "; - - $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 " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n\n"; - $c++; - } - echo "
Submission DateSubmitterVendorApplicationVersionAction
".print_date(mysqltimestamp_to_unixtimestamp($oVersion->sSubmitTime))."\n"; - echo $oSubmitter->sEmail ? "sEmail."\">":""; - echo $oSubmitter->sRealname; - echo $oSubmitter->sEmail ? "":""; - echo " ".$sVendor."".$oApp->sName."".$oVersion->sName."[iVersionId.">process]
\n\n"; - echo html_frame_end(" "); + //show version list + showVersionList($hResult); } } diff --git a/appsubmit.php b/appsubmit.php index 5efcaa3..bbd16f6 100644 --- a/appsubmit.php +++ b/appsubmit.php @@ -1,89 +1,25 @@ isLoggedIn()) + +function get_vendor_from_keywords($sKeywords) { - // you must be logged in to submit app - apidb_header("Please login"); - echo "To submit an application to the database you must be logged in. Please login now or create a new account.","\n"; - exit; + $aKeywords = explode(" *** ",$sKeywords); + $iLastElt = (sizeOf($aKeywords)-1); + return($aKeywords[$iLastElt]); } -/* - * User submitted an application - */ -if (isset($_REQUEST['appName'])) +function newSubmition($errors) { - $errors = ""; - - // Check input and exit if we found errors - $oApplication = new Application(); - $errors .= $oApplication->CheckOutputEditorInput(); - - $oVersion = new Version(); - $errors .= $oVersion->CheckOutputEditorInput(); - - if(empty($errors)) - { - if($_REQUEST['appVendorName']) - { - $_REQUEST['vendorId']=""; - //FIXME: fix this when we fix vendor submission - if($_SESSION['current']->hasPriv("admin")) - { - $oVendor = new Vendor(); - $oVendor->create($_REQUEST['appVendorName'],$_REQUEST['appWebpage']); - } - } - $oApplication->GetOutputEditorValues(); /* load the values from $_REQUEST */ - - //FIXME: remove this when we fix vendor submission - $oApplication->sKeywords = $_REQUEST['appKeywords']." *** ".$_REQUEST['appVendorName']; - - $oApplication->create(); - - $oVersion->GetOutputEditorValues(); - $oVersion->iAppId = $oApplication->iAppId; /* get the iAppId from the application that was just created */ - $oVersion->create(); - - redirect(apidb_fullurl("index.php")); - } - -} - -/* - * User submitted a version - */ -elseif (isset($_REQUEST['versionName']) && is_numeric($_REQUEST['appId'])) -{ - // Check input and exit if we found errors - - $oVersion = new Version(); - $errors = $oVersion->CheckOutputEditorInput(); - - if(empty($errors)) - { - $oVersion->GetOutputEditorValues(); - $oVersion->create(); - redirect(apidb_fullurl("index.php")); - } -} - -/* - * User wants to submit an application or version - */ -if (isset($_REQUEST['apptype'])) -{ - // header - apidb_header("Submit Application"); - // show add to queue form echo '
'."\n"; echo "

This page is for submitting new applications to be added to this\n"; @@ -114,55 +50,393 @@ if (isset($_REQUEST['apptype'])) echo "If you can't see the in-browser editors below please try Firefox, Mozilla or Opera browsers.\n"; echo "

After your application has been added you'll be able to submit screenshots for it, post"; echo " messages in its forums or become a maintainer to help others trying to run the application.

"; - if(!empty($errors)) +} +//deny access if not logged on +if(!$_SESSION['current']->isLoggedIn()) +{ + errorpage("Insufficient privilages to create application. Are you sure you are logged in"); + exit; +} + + +if ($_REQUEST['sub']) +{ + if($_REQUEST['apptype'] == 'application') { - echo '',"\n"; - echo '

We found the following errors:

Please correct them.'; - echo '

',"\n"; - echo '

',"\n"; - } + $oApp = new Application($_REQUEST['appId']); + if($oApp->iAppId) + { + // 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); - if($_REQUEST['apptype'] == 1 && (trim(strip_tags($_REQUEST['appDescription']))=="")) + // make sure the user has permission to view this version + if(!$_SESSION['current']->hasPriv("admin") && + (($oApp->queued=="false")?true:false) && + !$_SESSION['current']->isVersionSubmitter($oApp->AppId)) + { + errorpage("Insufficient privileges."); + exit; + } + + $oVersion = new Version($oRow->versionId); + } else + { + $oVersion = new Version(); + } + + } + else if($_REQUEST['apptype'] == 'version') { - $_REQUEST['appDescription'] = GetDefaultApplicationDescription(); + $oVersion = new Version($_REQUEST['versionId']); + + // make sure the user has permission to view this version + if(!$_SESSION['current']->hasAppVersionModifyPermission($oVersion->versionId) && + (($oVersion->queued=="false")?true:false) && + !$_SESSION['current']->isVersionSubmitter($oVersion->versionId)) + { + errorpage("Insufficient privileges."); + exit; + } } - - if(trim(strip_tags($_REQUEST['versionDescription']))=="") - { - $_REQUEST['versionDescription'] = GetDefaultVersionDescription(); - } - - $oApp = new Application(); - $oApp->GetOutputEditorValues(); /* retrieve the values from the current $_REQUEST */ - $oVersion = new Version(); - $oVersion->GetOutputEditorValues(); /* retrieve the values from the current $_REQUEST */ - - /* output the appropriate editors depending on whether we are processing an */ - /* application and a version or just a version */ - if($_REQUEST['apptype'] == 1) - { - $oApp->OutputEditor($_REQUEST['appVendorName']); - } - - $oVersion->OutputEditor(false, false); /* don't let the user change the parent application, - don't display the rating and distribution dropdowns */ - - echo '',"\n"; - - // new application and version - if ($_REQUEST['apptype'] == 1) - { - echo '',"\n"; - echo ' ',"\n"; - } - // new version else { - echo '',"\n"; - echo ' ',"\n"; + //error no Id! + addmsg("Application Not Found!", "red"); + redirect($_SERVER['PHP_SELF']); } - echo '',"\n"; - echo "
"; + + // Get the Testing results if they exist + $sQuery = "Select testingId from testResults where versionId='".$oVersion->iVersionId."';"; + $hResult = query_appdb($sQuery); + if($hResult) + { + $oRow = mysql_fetch_object($hResult); + $oTest = new testdata($oRow->testingId); + } + else + { + $oTest = new testResult(); + } + + //process according to sub flag + if ($_REQUEST['sub'] == 'Submit') + { + $errors = ""; + $oVersion = new Version($_REQUEST['versionId']); + $oTest = new testData($_REQUEST['iTestingId']); + $errors .= $oVersion->CheckOutputEditorInput(); + $errors .= $oTest->CheckOutputEditorInput(); + $oVersion->GetOutputEditorValues(); + $oTest->GetOutputEditorValues(); + if ($_REQUEST['apptype'] == "application") // application + { + $oApp = new Application($_REQUEST['appId']); + $errors .= $oApp->CheckOutputEditorInput(); + $oApp->GetOutputEditorValues(); // load the values from $_REQUEST + + if(empty($errors)) + { + if($_REQUEST['appVendorName']) + { + $_REQUEST['vendorId']=""; + //FIXME: fix this when we fix vendor submission + if($_SESSION['current']->hasPriv("admin")) + { + $oVendor = new Vendor(); + $oVendor->create($_REQUEST['appVendorName'],$_REQUEST['appWebpage']); + } + } + //FIXME: remove this when we fix vendor submission + $oApp->sKeywords = $_REQUEST['appKeywords']." *** ".$_REQUEST['appVendorName']; + if(is_numeric($oApp->iAppId)) + { + $oApp->update(); + $oApp->ReQueue(); + } else + { + $oApp->create(); + } + $oVersion->iAppId = $oApp->iAppId; + } + } + + if(!empty($errors)) + { + addmsg("we've got Errors???:".$errors.":"); + $_REQUEST['sub'] = 'view'; + } + else + { + if(is_numeric($oVersion->iVersionId)) + { + $oVersion->update(); + $oVersion->ReQueue(); + } + else + { + $oVersion->create(); + } + + $sDistribution = trim($_REQUEST['sDistribution']); + if(!empty($sDistribution)) + { + $oDistribution = new distribution(); + $oDistribution->sName = $sDistribution; + $oDistribution->create(); + $oTest->iDistributionId = $oDistribution->iDistributionId; + } + $oTest->iVersionId = $oVersion->iVersionId; + if(is_numeric($oTest->iTestingId)) + { + $oTest->update(true); + $oTest->ReQueue(); + } else + { + $oTest->create(); + } + redirect($_SERVER['PHP_SELF']); + } + } + 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 = 'rejected';"; + $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($_SERVER['PHP_SELF']); + } + if ($_REQUEST['sub'] == 'view') + { + $x = new TableVE("view"); + apidb_header("Application Queue"); + + echo '
',"\n"; + echo '',"\n"; + + echo html_back_link(1,$_SERVER['PHP_SELF']); + + if($_REQUEST['apptype'] == 'application') // application + { + if ($oApp->sName != "") + { + echo html_frame_start("Potential duplicate applications in the database","90%","",0); + perform_search_and_output_results($oApp->sName); + echo html_frame_end(" "); + } + if(is_numeric($oApp->iAppId)) + { + + //help + echo "
\n\n"; + echo "

This is the full view of the rejected application. \n"; + echo "You need to pick a category before submitting \n"; + echo "it into the database.\n"; + echo "

Click delete to remove the selected item from the queue. An email will automatically be sent to the\n"; + echo "submitter to let them know the item was deleted.

\n\n"; + echo "
\n\n"; + } else + { + newSubmition(); + } + // vendor/alt vendor fields + // if user selected a predefined vendorId: + $iVendorId = $oApp->iVendorId; + + // If not, try for an exact match + // Use the first match if we found one and clear out the vendor field, + // otherwise don't pick a vendor + // N.B. The vendor string is the last word of the keywords field ! + if(!$iVendorId) + { + $sVendor = get_vendor_from_keywords($oApp->sKeywords); + $sQuery = "SELECT vendorId FROM vendor WHERE vendorname = '".$_REQUEST['appVendorName']."';"; + $hResult = query_appdb($sQuery); + if($hResult) + { + $oRow = mysql_fetch_object($hResult); + $iVendorId = $oRow->vendorId; + } + } + + // try for a partial match + if(!$iVendorId) + { + $sQuery = "select * from vendor where vendorname like '%".$_REQUEST['appVendorName']."%';"; + $hResult = query_appdb($sQuery); + if($hResult) + { + $oRow = mysql_fetch_object($hResult); + $iVendorId = $oRow->vendorId; + } + } + //vendor field + if($iVendorId) + $_REQUEST['appVendorName'] = ""; + } else //app version + { + if(is_numeric($oVersion->iVersionId)) + { + echo html_frame_start("Potential duplicate versions in the database","90%","",0); + $oAppForVersion = new Application($oVersion->iAppId); + display_versions($oAppForVersion->iAppId, $oAppForVersion->aVersionsIds); + echo html_frame_end(" "); + + //help + echo "
\n\n"; + echo "

This is the full view of the application version that has been Rejected. \n"; + + echo "App Version This type of application will be nested under the selected application parent.\n"; + echo "

Click delete to remove the selected item from the queue an email will automatically be sent to the\n"; + echo "submitter to let him know the item was deleted.

\n\n"; + echo "
\n\n"; + } else + { + newSubmition($errors); + } + } + if(!empty($errors)) + { + echo '',"\n"; + echo '

We found the following errors:

Please correct them.'; + echo '

',"\n"; + echo '

',"\n"; + } + if(!($oTest->sTestedDate)) + $oTest->sTestedDate = date('Y-m-d H:i:s'); + + if($_REQUEST['apptype'] == 'application') + { + $oApp->OutputEditor($_REQUEST['appVendorName']); + $oVersion->OutputEditor(false, false); + } else + { + $oVersion->OutputEditor(false, false); + } + + $oTest->OutputEditor($_REQUEST['sDistribution'],true); + + echo "\n"; + + if($_REQUEST['apptype'] == 'application') // application + { + echo ''; + if(is_numeric($oApp->iAppId)) + { + echo '',"\n"; + } + } else // version + { + echo ''; + echo ''; + if(is_numeric($oVersion->iVersionId)) + { + echo '',"\n"; + } + else + { + echo '',"\n"; + } + } + echo '
' ,"\n"; + echo ' ',"\n"; + echo '',"\n"; + } else + { + echo '
',"\n"; + echo '
' ,"\n"; + echo ' ',"\n"; + echo '
',"\n"; + echo '
',"\n"; + echo html_back_link(1, $_SERVER['PHP_SELF']); + echo html_frame_end(" "); + apidb_footer(); + } + else + { + // error no sub! + addmsg("Internal Routine Not Found!!", "red"); + redirect($_SERVER['PHP_SELF']); + } } -apidb_footer(); +else // if ($_REQUEST['sub']) is not defined, display the main app queue page +{ + apidb_header("Resubmit application"); + + // get queued apps that the current user should see + $hResult = $_SESSION['current']->getAppRejectQueueQuery(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 Resubmit Application Queue is empty.

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

This is the list of applications waiting for re-submition, or to be deleted.

\n"; + echo "

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

\n\n"; + + //show applist + showAppList($hResult); + } + + // get queued versions (only versions where application are not queued already) + $hResult = $_SESSION['current']->getAppRejectQueueQuery(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 Resubmit Version Queue is empty.

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

This is the list of versions waiting for re-submition or deletion.

\n"; + echo "

To view a submission, click on its name. From that page you can delete or edit and re-submit 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 + showVersionList($hResult); + + + } + apidb_footer(); +} + ?> diff --git a/appview.php b/appview.php index e1cfc62..777706a 100644 --- a/appview.php +++ b/appview.php @@ -286,7 +286,7 @@ if($_REQUEST['appId']) } if($_SESSION['current']->isLoggedIn()) { - echo '
'; + echo ''; echo ''; echo '
'; } diff --git a/include/application.php b/include/application.php index 682ddbe..d5d8d2e 100644 --- a/include/application.php +++ b/include/application.php @@ -257,10 +257,6 @@ class Application { if(!$_SESSION['current']->canUnQueueApplication()) return; - // If we are not in the queue, we can't move the application out of the queue. - if(!$this->sQueued == 'true') - return false; - $sUpdate = compile_update_string(array('queued' => "false", 'keywords'=> str_replace(" *** ","",$this->sKeywords) )); if(query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId)) @@ -298,11 +294,7 @@ class Application { } function ReQueue() { - if(!$_SESSION->canRequeueApplication()) - return false; - - // If we are not in the rejected, we can't move the application into the queue. - if(!$this->sQueued == 'rejected') + if(!$_SESSION['current']->canRequeueApplication($this)) return false; $sUpdate = compile_update_string(array('queued' => "true")); @@ -336,7 +328,7 @@ class Application { $sMsg = "The application you submitted (".$oApp->sName." ".$this->sName.") has been rejected."; $sMsg .= "Clicking on the link in this email will allow you to modify and resubmit the application. "; $sMsg .= "A link to your queue of applications and versions will also show up on the left hand side of the Appdb site once you have logged in. "; - $sMsg .= APPDB_ROOT."admin/resubmitRejectedApps.php?sub=view&appId=".$this->iAppId."\n"; + $sMsg .= APPDB_ROOT."appsubmit.php?sub=view&apptype=applicationappId=".$this->iAppId."\n"; $sMsg .= "Reason given:\n"; $sMsg .= $_REQUEST['replyText']."\n"; /* append the reply text, if there is any */ } @@ -562,4 +554,48 @@ function GetDefaultApplicationDescription() { return "

Enter a description of the application here

"; } + +function showAppList($hResult) +{ + //show applist + echo html_frame_start("","90%","",0); + echo " + + + + + + + "; + + $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 " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n\n"; + $c++; + } + echo "
Submission DateSubmitterVendorApplicationAction
".print_date(mysqltimestamp_to_unixtimestamp($oApp->sSubmitTime))."\n"; + echo $oSubmitter->sEmail ? "sEmail."\">":""; + echo $oSubmitter->sRealname; + echo $oSubmitter->sEmail ? "":""; + echo " ".$sVendor."".$oApp->sName."[iAppId.">process]
\n\n"; + echo html_frame_end(" "); +} ?> diff --git a/include/sidebar.php b/include/sidebar.php index 35dd9e3..f10d6fa 100644 --- a/include/sidebar.php +++ b/include/sidebar.php @@ -16,7 +16,7 @@ function global_sidebar_menu() { $g->add("Screenshots", BASE."viewScreenshots.php"); $g->add("Browse Apps", BASE."appbrowse.php"); $g->add("Top 25", BASE."votestats.php"); - $g->add("Submit Application", BASE."appsubmit.php?apptype=1"); + $g->add("Submit Application", BASE."appsubmit.php?sub=view&apptype=application"); $g->add("Help & Documentation", BASE."help/"); $g->add("AppDB Stats", BASE."appdbStats.php"); $g->add("View Distributions (".getNumberOfDistributions().")", BASE."distributionView.php"); diff --git a/include/sidebar_login.php b/include/sidebar_login.php index dbe7141..f56ff8d 100644 --- a/include/sidebar_login.php +++ b/include/sidebar_login.php @@ -34,7 +34,7 @@ function global_sidebar_login() { } $appsRejected = $_SESSION['current']->getAllRejectedApps(); if($appsRejected) - $g->addmisc("Review Rejected Apps", "center"); + $g->addmisc("Review Rejected Apps", "center"); } else diff --git a/include/user.php b/include/user.php index 0dd8f55..f3a9fae 100644 --- a/include/user.php +++ b/include/user.php @@ -805,9 +805,18 @@ class User { } /* Can this user Requeue an application? */ - function canRequeueApplication() + function canRequeueApplication($oApp) { - return $this->hasPriv("admin"); + if($oApp->sQueued == 'false') + return false; + + if($this->hasPriv("admin")) + return true; + + if(($oApp->sQueued != 'false') && ($oApp->iSubmitterId == $this->iUserId)) + return true; + + return false; } /* Can the user reject application? */ diff --git a/include/version.php b/include/version.php index 69b29e7..5bca2ee 100644 --- a/include/version.php +++ b/include/version.php @@ -8,6 +8,7 @@ require_once(BASE."include/comment.php"); require_once(BASE."include/url.php"); require_once(BASE."include/screenshot.php"); require_once(BASE."include/bugs.php"); +//require_once(BASE."include/testResults.php"); /** * Version class for handling versions. @@ -28,6 +29,7 @@ class Version { var $aScreenshotsIds; // an array that contains the screenshotId of every screenshot linked to this version var $aUrlsIds; // an array that contains the screenshotId of every url linked to this version var $aBuglinkIds; // an array that contains the buglinkId of every bug linked to this version + var $aTestingIds; // an array that contains the buglinkId of every bug linked to this version /** * constructor, fetches the data. @@ -130,6 +132,22 @@ class Version { $this->aBuglinkIds[] = $oRow->linkId; } } + + /* + * We fetch Test ResultsIds. + */ + $this->aTestingIds = array(); + $sQuery = "SELECT * + FROM testResults + WHERE versionId = ".$iVersionId." + ORDER BY testingId"; + if($hResult = query_appdb($sQuery)) + { + while($oRow = mysql_fetch_object($hResult)) + { + $this->aTestingIds[] = $oRow->linkId; + } + } } } @@ -160,7 +178,7 @@ class Version { if(query_appdb("INSERT INTO appVersion $sFields VALUES $sValues", "Error while creating a new version.")) { $this->iVersionId = mysql_insert_id(); - $this->version($this->iVersionId); + $this->Version($this->iVersionId); $this->SendNotificationMail(); return true; } @@ -173,8 +191,6 @@ class Version { /** * Update version. - * FIXME: Use compile_update_string instead of addslashes. - * Returns true on success and false on failure. */ function update() { @@ -393,7 +409,7 @@ class Version { $sMsg = "The version you submitted (".$oApp->sName." ".$this->sName.") has been rejected. "; $sMsg .= "Clicking on the link in this email will allow you to modify and resubmit the version. "; $sMsg .= "A link to your queue of applications and versions will also show up on the left hand side of the Appdb site once you have logged in. "; - $sMsg .= APPDB_ROOT."admin/resubmitRejectedApps.php?sub=view&versionId=".$this->iVersionId."\n"; + $sMsg .= APPDB_ROOT."appsubmit.php?sub=view&apptype=version&versionId=".$this->iVersionId."\n"; $sMsg .= "Reason given:\n"; $sMsg .= $_REQUEST['replyText']."\n"; /* append the reply text, if there is any */ } @@ -606,4 +622,47 @@ function GetDefaultVersionDescription() 3.2120040615yesyesBronze


"; } + +function showVersionList($hResult) +{ + //show applist + echo html_frame_start("","90%","",0); + echo " + + + + + + + + "; + + $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 " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n\n"; + $c++; + } + echo "
Submission DateSubmitterVendorApplicationVersionAction
".print_date(mysqltimestamp_to_unixtimestamp($oVersion->sSubmitTime))."\n"; + echo $oSubmitter->sEmail ? "sEmail."\">":""; + echo $oSubmitter->sRealname; + echo $oSubmitter->sEmail ? "":""; + echo " ".$sVendor."".$oApp->sName."".$oVersion->sName."[iVersionId.">process]
\n\n"; + echo html_frame_end(" "); + +} + ?>