Use objectManager to submit and process applications. Remove now unused appsubmit.php
admin/adminAppQueue.php
This commit is contained in:
committed by
WineHQ
parent
3a3aa89f4e
commit
b11cce6711
@@ -10,6 +10,7 @@ require_once(BASE."include/url.php");
|
||||
require_once(BASE."include/util.php");
|
||||
require_once(BASE."include/mail.php");
|
||||
require_once(BASE."include/maintainer.php");
|
||||
require_once(BASE."include/tableve.php");
|
||||
|
||||
define("PLATINUM_RATING", "Platinum");
|
||||
define("GOLD_RATING", "Gold");
|
||||
@@ -377,7 +378,9 @@ class Application {
|
||||
$sMsg = "The application you submitted (".$this->sName.") has been rejected by ".$_SESSION['current']->sRealname.".";
|
||||
$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."appsubmit.php?sub=view&apptype=application&appId=".$this->iAppId."\n";
|
||||
$sMsg .= APPDB_ROOT."objectManager.php?sClass=application_queue".
|
||||
"&bIsQueue=true&bIsRejected=true&iId=".$this->iAppId."&sTitle=".
|
||||
"Edit+Application\n";
|
||||
$sMsg .= "Reason given:\n";
|
||||
break;
|
||||
case "delete":
|
||||
@@ -480,7 +483,9 @@ class Application {
|
||||
break;
|
||||
case "reject":
|
||||
$sSubject = $this->sName." has been rejected by ".$_SESSION['current']->sRealname;
|
||||
$sMsg .= APPDB_ROOT."appsubmit.php?sAppType=application&sSub=view&iAppId=".$this->iAppId."\n";
|
||||
$sMsg .= APPDB_ROOT."objectManager.php?sClass=application_queue".
|
||||
"&bIsQueue=true&bIsRejected=true&iId=".$this->iAppId."&sTitle=".
|
||||
"Edit+Application\n";
|
||||
|
||||
// if sReplyText is set we should report the reason the application was rejected
|
||||
if($aClean['sReplyText'])
|
||||
@@ -499,12 +504,16 @@ class Application {
|
||||
|
||||
|
||||
/* output a html table and this applications values to the fields for editing */
|
||||
function outputEditor($sVendorName)
|
||||
function outputEditor($sVendorName = "")
|
||||
{
|
||||
HtmlAreaLoaderScript(array("app_editor"));
|
||||
|
||||
echo '<input type="hidden" name="iAppId" value="'.$this->iAppId.'">';
|
||||
|
||||
/* Used to distinguish between the first step of entering an application
|
||||
name and the full editor displayed here */
|
||||
echo '<input type="hidden" name="bMainAppForm" value="true" />'."\n";
|
||||
|
||||
echo html_frame_start("Application Form", "90%", "", 0);
|
||||
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
|
||||
echo '<tr valign=top><td class="color0"><b>Application name</b></td>',"\n";
|
||||
@@ -518,12 +527,14 @@ class Application {
|
||||
|
||||
// vendor name
|
||||
echo '<tr valign=top><td class="color0"><b>Vendor</b></td>',"\n";
|
||||
echo '<td><input size="20" type=text name="sVendorName" value="'.$sVendorName.'"></td></tr>',"\n";
|
||||
echo '<td>If it is not on the list please add it using the form below</td></tr>',"\n";
|
||||
|
||||
// alt vendor
|
||||
$x = new TableVE("view");
|
||||
echo '<tr valign=top><td class="color0"> </td><td>',"\n";
|
||||
$x->make_option_list("iAppVendorId", $this->iVendorId,"vendor","vendorId","vendorName");
|
||||
$x->make_option_list("iAppVendorId",
|
||||
$this->iVendorId,"vendor","vendorId","vendorName",
|
||||
array("vendor.queued", "false"));
|
||||
echo '</td></tr>',"\n";
|
||||
|
||||
// url
|
||||
@@ -855,20 +866,11 @@ class Application {
|
||||
$sVendor,
|
||||
$this->sName);
|
||||
|
||||
/* If the user has global edit rights canEdit() will return true even if
|
||||
the appId is not defined, in which case he should use adminAppQueue.
|
||||
This will soon be replaced by a unified objectManager link */
|
||||
$oApp = new application();
|
||||
if($oApp->canEdit())
|
||||
/* Display an edit link if the user has proper permissions */
|
||||
if($this->canEdit())
|
||||
{
|
||||
$aCells[] = "[ <a href=\"".BASE."admin/adminAppQueue.php?sAppType=".
|
||||
"application&sSub=view&iAppId=$this->iAppId\">".
|
||||
"$sEditLinkLabel</a> ]";
|
||||
} else if($this->canEdit())
|
||||
{
|
||||
$aCells[] = "[ <a href=\"".BASE."appsubmit.php?sAppType=".
|
||||
"application&sSub=view&iAppId=$this->iAppId\">".
|
||||
"$sEditLinkLabel</a> ]";
|
||||
$aCells[] = "[ <a href=\"".$oObject->makeUrl("edit", $this->iAppId,
|
||||
"Edit Application")."\">$sEditLinkLabel</a> ]";
|
||||
}
|
||||
|
||||
echo html_tr($aCells, $sClass);
|
||||
@@ -911,6 +913,38 @@ class Application {
|
||||
"From that page you can edit, delete or approve it into the AppDB.</p>\n";
|
||||
}
|
||||
|
||||
function objectDisplayAddItemHelp()
|
||||
{
|
||||
/* We don't display the full help on the page where you only input the app name */
|
||||
if(!$this->sName)
|
||||
{
|
||||
echo "<p>First, please enter the name of the application you wish to add. ";
|
||||
echo "This will allow you to determine whether there is already ";
|
||||
echo "an entry for it in the database.</p>\n";
|
||||
} else
|
||||
{
|
||||
echo "<p>This page is for submitting new applications to be added to the\n";
|
||||
echo "database. The application will be reviewed by an AppDB Administrator,\n";
|
||||
echo "and you will be notified via e-mail if it is added to the database or rejected.</p>\n";
|
||||
echo "<p><h2>Before continuing, please ensure that you have</h2>\n";
|
||||
echo "<ul>\n";
|
||||
echo " <li>Entered a valid version for this application. This is the application\n";
|
||||
echo " version, NOT the Wine version (which goes in the test results section of the template)</li>\n";
|
||||
echo " <li>Tested this application under Wine. There are tens of thousands of applications\n";
|
||||
echo " for Windows, we do not need placeholder entries in the database. Please enter as complete \n";
|
||||
echo " as possible test results in the version template provided below</li>\n";
|
||||
echo "</ul></p>";
|
||||
echo "<p>Please do not forget to mention which Wine version you used, how well it worked\n";
|
||||
echo "and if any workarounds were needed. Having app descriptions just sponsoring the app\n";
|
||||
echo "(yes, some vendors want to use the appdb for this) or saying ‘I haven’t tried this app with Wine’ ";
|
||||
echo "will not help Wine development or Wine users.</p>\n";
|
||||
echo "<b><span style=\"color:red\">Please only submit applications/versions that you have tested.\n";
|
||||
echo "Submissions without test information or not using the provided template will be rejected.\n";
|
||||
echo "If you are unable to see the in-browser editors below, please try Firefox, Mozilla or Opera browsers.\n</span></b>";
|
||||
echo "<p>After your application has been added, you will 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.</p>";
|
||||
}
|
||||
}
|
||||
function objectGetEntriesCount($bQueued, $bRejected)
|
||||
{
|
||||
$sQueued = objectManager::getQueueString($bQueued, $bRejected);
|
||||
@@ -941,6 +975,25 @@ class Application {
|
||||
|
||||
return $oRow->count;
|
||||
}
|
||||
|
||||
function objectMoveChildren($iNewId)
|
||||
{
|
||||
/* Keep track of how many children we have moved */
|
||||
$iCount = 0;
|
||||
|
||||
foreach($this->aVersionsIds as $iVersionId)
|
||||
{
|
||||
$oVersion = new version($iVersionId);
|
||||
$oVersion->iAppId = $iNewId;
|
||||
if($oVersion->update())
|
||||
$iCount++;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* If no errors occured we return the number of moved children */
|
||||
return $iCount;
|
||||
}
|
||||
}
|
||||
|
||||
function get_vendor_from_keywords($sKeywords)
|
||||
|
||||
313
include/application_queue.php
Normal file
313
include/application_queue.php
Normal file
@@ -0,0 +1,313 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class for submitting/processing applications
|
||||
*/
|
||||
|
||||
class application_queue
|
||||
{
|
||||
var $oVersionQueue;
|
||||
var $oApp;
|
||||
var $oVendor;
|
||||
|
||||
function application_queue($iAppId = null)
|
||||
{
|
||||
$this->oApp = new application($iAppId);
|
||||
|
||||
/* If this is an existing application then there must be a version
|
||||
accompanying it */
|
||||
if($iAppId)
|
||||
{
|
||||
/* Normal users do not get a aVersionsIds property, so we have to fetch
|
||||
the versionId manually. Normal users only have access to rejected
|
||||
applications */
|
||||
if($_SESSION['current']->hasPriv("admin"))
|
||||
{
|
||||
$iVersionId = $this->oApp->aVersionsIds[0];
|
||||
} else if($this->oApp->sQueued == "rejected")
|
||||
{
|
||||
$sQuery = "SELECT versionId FROM appVersion WHERE appId = '?' LIMIT 1";
|
||||
$hResult = query_parameters($sQuery, $this->oApp->iAppId);
|
||||
if($hResult)
|
||||
{
|
||||
if($oRow = mysql_fetch_object($hResult))
|
||||
$iVersionId = $oRow->versionId;
|
||||
}
|
||||
}
|
||||
$iVendorId = $this->oApp->iVendorId;
|
||||
}
|
||||
else
|
||||
{
|
||||
$iVersionId = null;
|
||||
$iVendorId = null;
|
||||
}
|
||||
|
||||
$this->oVendor = new vendor($iVendorId);
|
||||
|
||||
$this->oVersionQueue = new version_queue($iVersionId);
|
||||
}
|
||||
|
||||
function create()
|
||||
{
|
||||
$bSuccess = TRUE;
|
||||
|
||||
/* Create a new vendor if an existing one was not selected, and
|
||||
assign the application to it */
|
||||
if(!$this->oApp->iVendorId)
|
||||
{
|
||||
$this->oVendor->create();
|
||||
$this->oApp->iVendorId = $this->oVendor->iVendorId;
|
||||
}
|
||||
|
||||
if(!$this->oApp->create())
|
||||
$bSuccess = FALSE;
|
||||
|
||||
/* Assign the version to the new application */
|
||||
$this->oVersionQueue->oVersion->iAppId = $this->oApp->iAppId;
|
||||
|
||||
if(!$this->oVersionQueue->create())
|
||||
$bSuccess = FALSE;
|
||||
|
||||
return $bSuccess;
|
||||
}
|
||||
|
||||
function update()
|
||||
{
|
||||
$bSucess = TRUE;
|
||||
|
||||
/* If the vendor was already un-queued then the edit vendor form would not
|
||||
have been displayed, and so the vendor name will not be set. Thus only
|
||||
update the vendor if the name is set */
|
||||
if($this->oVendor->sName)
|
||||
$this->oVendor->update();
|
||||
|
||||
if(!$this->oApp->update())
|
||||
$bSuccess = FALSE;
|
||||
|
||||
if(!$this->oVersionQueue->update())
|
||||
$bSuccess = FALSE;
|
||||
|
||||
return $bSuccess;
|
||||
}
|
||||
|
||||
function unQueue()
|
||||
{
|
||||
/* The vendor is not necessarily queued, as it could have existed on
|
||||
beforehand */
|
||||
if($this->oVendor->sQueued != "false")
|
||||
$this->oVendor->unQueue();
|
||||
|
||||
$this->oApp->unQueue();
|
||||
$this->oVersionQueue->unQueue();
|
||||
}
|
||||
|
||||
function reQueue()
|
||||
{
|
||||
$this->oApp->reQueue();
|
||||
$this->oVersionQueue->reQueue();
|
||||
}
|
||||
|
||||
function reject()
|
||||
{
|
||||
$this->oVersionQueue->reject();
|
||||
$this->oApp->reject();
|
||||
}
|
||||
|
||||
function delete()
|
||||
{
|
||||
$bSuccess = TRUE;
|
||||
|
||||
if(!$this->oApp->delete())
|
||||
$bSuccess = FALSE;
|
||||
|
||||
if(!$this->oVersionQueue->delete())
|
||||
$bSuccess = FALSE;
|
||||
|
||||
return $bSuccess;
|
||||
}
|
||||
|
||||
function outputEditor()
|
||||
{
|
||||
/* We ask the user for the application name first so as to avoid duplicate
|
||||
submissons; a list of potential duplicates is displayed on the next page */
|
||||
if(!$this->oApp->sName)
|
||||
{
|
||||
echo "<input type=\"text\" name=\"sAppName\" size=\"60\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"sSub\" value=\"view\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"sAppType\" value=\"application\" />\n";
|
||||
} else
|
||||
{
|
||||
/* Show potential duplicates */
|
||||
echo html_frame_start("Potential duplicate applications in the ".
|
||||
"database","90%","",0);
|
||||
$this->displayDuplicates();
|
||||
echo html_frame_end(" ");
|
||||
|
||||
$this->oApp->outputEditor();
|
||||
|
||||
/* We need to accept vendors submitted using the old
|
||||
keyword hack. This should be removed soon */
|
||||
if(!$this->oVendor->sName && $this->oApp->iAppId)
|
||||
{
|
||||
$this->oVendor->sName = get_vendor_from_keywords(
|
||||
$this->oApp->sKeywords);
|
||||
}
|
||||
|
||||
/* Display the new vendor form for new applications or if we
|
||||
are processing an application and the vendor is queued */
|
||||
if(!$this->oApp->iAppId || $this->oVendor->sQueued != "false")
|
||||
{
|
||||
echo html_frame_start("New Vendor", "90%");
|
||||
$this->oVendor->outputEditor();
|
||||
echo html_frame_end();
|
||||
}
|
||||
|
||||
$this->oVersionQueue->oVersion->outputEditor();
|
||||
|
||||
global $aClean;
|
||||
|
||||
echo $this->oVersionQueue->oDownloadUrl->outputEditorSingle(
|
||||
$this->oVersionQueue->Oversion->iVersionId, $aClean);
|
||||
|
||||
$this->oVersionQueue->oTestDataQueue->outputEditor();
|
||||
}
|
||||
}
|
||||
|
||||
function getOutputEditorValues($aClean)
|
||||
{
|
||||
$this->oApp->getOutputEditorValues($aClean);
|
||||
$this->oVersionQueue->getOutputEditorValues($aClean);
|
||||
$this->oVendor->getOutputEditorValues($aClean);
|
||||
}
|
||||
|
||||
function checkOutputEditorInput($aClean)
|
||||
{
|
||||
/* We want outputEditor() to be called again so we can display the main
|
||||
app form. No erros are displayed since we only return TRUE */
|
||||
if($this->oApp->sName && !$aClean['bMainAppForm'])
|
||||
return TRUE;
|
||||
|
||||
$sErrors = $this->oApp->checkOutputEditorInput($aClean);
|
||||
$sErrors .= $this->oVersionQueue->checkOutputEditorInput($aClean);
|
||||
return $sErrors;
|
||||
}
|
||||
|
||||
function canEdit()
|
||||
{
|
||||
return $this->oApp->canEdit();
|
||||
}
|
||||
|
||||
function mustBeQueued()
|
||||
{
|
||||
return $this->oApp->mustBeQueued();
|
||||
}
|
||||
|
||||
function displayDuplicates()
|
||||
{
|
||||
echo "<b>Like matches</b>\n";
|
||||
$this->displayDuplicateTable(searchForApplication($this->oApp->sName));
|
||||
echo "<br /><b>Fuzzy matches</b>\n";
|
||||
$this->displayDuplicateTable(searchForApplicationFuzzy($this->oApp->sName, 60));
|
||||
}
|
||||
|
||||
function displayDuplicateTable($hResult)
|
||||
{
|
||||
/* Exit if the MySQL handle is invalid */
|
||||
if($hResult === FALSE)
|
||||
return FALSE;
|
||||
|
||||
/* There's no point in displaying an empty table */
|
||||
if($hResult === null ||mysql_num_rows($hResult) == 0)
|
||||
{
|
||||
echo "No matches.<br />\n";
|
||||
return;
|
||||
}
|
||||
|
||||
$aHeader = array(
|
||||
"Application name",
|
||||
"Description",
|
||||
"No. versions"
|
||||
);
|
||||
|
||||
/* We can only move data if the current application already exists, and
|
||||
we have admin privileges */
|
||||
if($this->oApp->iAppId && $_SESSION['current']->hasPriv("admin"))
|
||||
{
|
||||
$bCanMove = TRUE;
|
||||
$aHeader[] = array("Move data", 'width="80"');
|
||||
} else
|
||||
{
|
||||
$bCanMove = FALSE;
|
||||
}
|
||||
|
||||
echo "<table>";
|
||||
echo html_tr($aHeader, "color4");
|
||||
|
||||
for($i = 0; $oRow = mysql_fetch_object($hResult); $i++)
|
||||
{
|
||||
$oApp = new application($oRow->appId);
|
||||
$aCells = array(
|
||||
$oApp->objectMakeLink(),
|
||||
util_trim_description($oApp->sDescription),
|
||||
sizeof($oApp->aVersionsIds)
|
||||
);
|
||||
|
||||
if($bCanMove)
|
||||
{
|
||||
$aCells[] = "<a href=\"objectManager.php?sClass=application_queue&".
|
||||
"bIsQueue=true&sAction=moveChildren&iId=".
|
||||
$this->oApp->iAppId."&iNewId=".$oApp->iAppId.
|
||||
"\">Move data</a>";
|
||||
}
|
||||
echo html_tr($aCells, ($i % 2) ? "color0" : "color1");
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
|
||||
function display()
|
||||
{
|
||||
$this->oApp->display();
|
||||
}
|
||||
|
||||
function objectMakeUrl()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function objectMakeLink()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function objectGetEntries($bQueued, $bRejected)
|
||||
{
|
||||
return $this->oApp->objectGetEntries($bQueued, $bRejected);
|
||||
}
|
||||
|
||||
function objectGetHeader()
|
||||
{
|
||||
return $this->oApp->objectGetHeader();
|
||||
}
|
||||
|
||||
function objectGetInstanceFromRow($oRow)
|
||||
{
|
||||
return application::objectGetInstanceFromRow($oRow);
|
||||
}
|
||||
|
||||
function objectOutputTableRow($oObject, $sClass, $sEditLinkLabel)
|
||||
{
|
||||
return $this->oApp->objectOutputTableRow($oObject, $sClass, $sEditLinkLabel);
|
||||
}
|
||||
|
||||
function objectMoveChildren($iNewId)
|
||||
{
|
||||
return $this->oApp->objectMoveChildren($iNewId);
|
||||
}
|
||||
|
||||
function objectDisplayAddItemHelp()
|
||||
{
|
||||
$this->oApp->objectDisplayAddItemHelp();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -25,7 +25,8 @@ function global_sidebar_menu()
|
||||
$g->add("Downloadable Apps", BASE."browse_downloadable.php");
|
||||
$g->add("Browse Apps by Rating", BASE."browse_by_rating.php");
|
||||
$g->add("Top 25", BASE."votestats.php");
|
||||
$g->add("Submit Application", BASE."appsubmit.php?sSub=view&sAppType=application");
|
||||
$g->add("Submit Application", BASE."objectManager.php?sClass=application_queue&".
|
||||
"sTitle=Submit+Application&sAction=add");
|
||||
$g->add("Help & Documentation", BASE."help/");
|
||||
$g->add("AppDB Stats", BASE."appdbStats.php");
|
||||
$g->add("View Distributions (".distribution::objectGetEntriesCount(false, false).")", BASE."objectManager.php?sClass=distribution&bIsQueue=false&sTitle=View%20Distributions");
|
||||
|
||||
@@ -10,7 +10,7 @@ function global_admin_menu() {
|
||||
$g = new htmlmenu("Global Admin");
|
||||
|
||||
$g->add("View App Queue (".application::objectGetEntriesCount(true, false).")",
|
||||
BASE."objectManager.php?sClass=application&bIsQueue=true&sTitle=".
|
||||
BASE."objectManager.php?sClass=application_queue&bIsQueue=true&sTitle=".
|
||||
"Application%20Queue");
|
||||
$g->add("View Version Queue (".version::objectGetEntriesCount(true, false).")",
|
||||
BASE."objectManager.php?sClass=version_queue&bIsQueue=true&sTitle=".
|
||||
@@ -44,8 +44,8 @@ function global_admin_menu() {
|
||||
|
||||
$g->add("View Rejected Applications (".application::objectGetEntriesCount(true,
|
||||
true).")",
|
||||
BASE."objectManager.php?sClass=application&bIsQueue=true&bIsRejected=true&".
|
||||
"sTitle=Rejected%20Applications");
|
||||
BASE."objectManager.php?sClass=application_queue&bIsQueue=true&bIsRejected=".
|
||||
"true&sTitle=Rejected%20Applications");
|
||||
$g->add("View Rejected Versions (".version::objectGetEntriesCount(true, true).")",
|
||||
BASE."objectManager.php?sClass=version_queue&bIsQueue=true&".
|
||||
"bIsRejected=true&sTitle=Rejected%20Versions");
|
||||
|
||||
@@ -44,7 +44,7 @@ function global_sidebar_login() {
|
||||
if($iAppsRejected && !$_SESSION['current']->hasPriv("admin"))
|
||||
{
|
||||
$g->add("Review Rejected Apps ($iAppsRejected)", BASE."objectManager.php?".
|
||||
"sClass=application&bIsQueue=true&bIsRejected=true&sTitle=".
|
||||
"sClass=application_queue&bIsQueue=true&bIsRejected=true&sTitle=".
|
||||
"Rejected+Applications", "center");
|
||||
}
|
||||
|
||||
|
||||
@@ -465,8 +465,9 @@ class Version {
|
||||
$sMsg = "The version you submitted (".$oApp->sName." ".$this->sName.") has been rejected by ".$_SESSION['current']->sRealname.".";
|
||||
$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."appsubmit.php?sSub=view&sAppType=version&iVersionId=".$this->iVersionId."\n";
|
||||
$sMsg .= "Reason given:\n";
|
||||
$sMsg .= APPDB_ROOT."objectManager.php?sClass=version_queue".
|
||||
"&bIsQueue=true&bIsRejected=true&iId=".$this->iVersionId."&".
|
||||
"sTitle=Edit+Version\n";
|
||||
break;
|
||||
case "delete":
|
||||
$sSubject = "Submitted version deleted";
|
||||
@@ -538,7 +539,9 @@ class Version {
|
||||
break;
|
||||
case "reject":
|
||||
$sSubject = "Version '".$this->sName."' of '".$oApp->sName."' has been rejected by ".$_SESSION['current']->sRealname;
|
||||
$sMsg .= APPDB_ROOT."appsubmit.php?sAppType=application&sSub=view&iVersionId=".$this->iVersionId."\n";
|
||||
$sMsg .= APPDB_ROOT."objectManager.php?sClass=version_queue".
|
||||
"&bIsQueue=true&bIsRejected=true&iId=".$this->iVersionId."&".
|
||||
"sTitle=Edit+Version\n";
|
||||
|
||||
// if sReplyText is set we should report the reason the version was rejected
|
||||
if($aClean['sReplyText'])
|
||||
|
||||
Reference in New Issue
Block a user