From 49300a870760541ae2544dedaa5677eb0d40a055 Mon Sep 17 00:00:00 2001
From: Chris Morgan
Date: Mon, 10 Oct 2005 02:37:55 +0000
Subject: [PATCH] Factor application/version editing code out of files and move
it into the application and version classes. Add support to
HtmlAreaLoaderScript() to be called multiple times on a single page without
generating javascript that overwrites the previous html area settings.
---
admin/adminAppQueue.php | 122 +++++++--------------
admin/editAppFamily.php | 53 ++++-----
admin/editAppVersion.php | 46 ++------
admin/resubmitRejectedApps.php | 92 ++++------------
appsubmit.php | 189 ++++++++++-----------------------
include/application.php | 162 ++++++++++++++++++++++------
include/util.php | 84 ++++++++++-----
include/version.php | 163 +++++++++++++++++++++-------
8 files changed, 457 insertions(+), 454 deletions(-)
diff --git a/admin/adminAppQueue.php b/admin/adminAppQueue.php
index 541afcd..f67c3ab 100644
--- a/admin/adminAppQueue.php
+++ b/admin/adminAppQueue.php
@@ -136,11 +136,9 @@ if ($_REQUEST['sub'])
if (!$oApp) //app version
{
- HtmlAreaLoaderScript(array("editor"));
-
echo html_frame_start("Potential duplicate versions in the database","90%","",0);
- $oApp = new Application($oVersion->iAppId);
- display_versions($oApp->iAppId, $oApp->aVersionsIds);
+ $oAppForVersion = new Application($oVersion->iAppId);
+ display_versions($oAppForVersion->iAppId, $oAppForVersion->aVersionsIds);
echo html_frame_end(" ");
//help
@@ -152,37 +150,9 @@ if ($_REQUEST['sub'])
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";
} else // application
{
- HtmlAreaLoaderScript(array("editor", "editor2"));
-
- echo html_frame_start("Potential duplicate applications in the database","90%","",0);
+ echo html_frame_start("Potential duplicate applications in the database", "90%", "", 0);
perform_search_and_output_results($oApp->sName);
echo html_frame_end(" ");
@@ -206,19 +176,6 @@ if ($_REQUEST['sub'])
echo "submitter to let them know the item was deleted.
',"\n";
}
- echo html_frame_end(" ");
+ /* output the appropriate editors depending on whether we are processing an application */
+ /* and a version or just a version */
+ if($oApp)
+ {
+ $oApp->OutputEditor($sVendor);
+ $oVersion->OutputEditor(false);
+ } else
+ {
+ $oVersion->OutputEditor(true);
+ }
+
+ echo html_frame_start("Reply text", "90%", "", 0);
+ echo "
',"\n";
-
-
// vendor/alt vendor fields
// if user selected a predefined vendorId:
$iVendorId = $oApp->iVendorId;
@@ -153,7 +110,6 @@ if ($_REQUEST['sub'])
// 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);
@@ -164,7 +120,6 @@ if ($_REQUEST['sub'])
$oRow = mysql_fetch_object($hResult);
$iVendorId = $oRow->vendorId;
}
-
}
// try for a partial match
@@ -182,44 +137,39 @@ if ($_REQUEST['sub'])
//vendor field
if($iVendorId)
$sVendor = "";
- echo '
This is a template; enter version-specific description here
-
- Wine compatibility
- What works:
- - settings
- - help
- What doesn't work:
- - erasing
- What was not tested:
- - burning
-
-
Tested versions
-
-
App. version
Wine version
Installs?
Runs?
Rating
-
-
-
3.23
20050111
yes
yes
Gold
-
-
3.23
20041201
yes
yes
Silver
-
-
3.21
20040615
yes
yes
Bronze
-
";
-
if(!$_SESSION['current']->isLoggedIn())
{
// you must be logged in to submit app
@@ -44,50 +16,43 @@ if(!$_SESSION['current']->isLoggedIn())
exit;
}
-// Check the input of a submitted form. And output with a list
-// of errors. (
\n";
-
- if (empty($fields['versionName']))
- $errors .= "
Please enter an application version.
\n";
-
- // No vendor entered, and nothing in the list is selected
- if (empty($fields['vendorName']) && !$fields['vendorId'] && !$fields['appId'])
- $errors .= "
',"\n";
- else
- echo $_REQUEST['versionDescription'].'',"\n";
+ $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);
+ } else
+ {
+ $oVersion->OutputEditor(true);
+ }
echo '',"\n";
@@ -243,7 +163,6 @@ if (isset($_REQUEST['apptype']))
echo ' ',"\n";
}
echo '
',"\n";
- echo html_frame_end();
echo "";
}
apidb_footer();
diff --git a/include/application.php b/include/application.php
index 2b2f8c0..ac27023 100644
--- a/include/application.php
+++ b/include/application.php
@@ -113,7 +113,7 @@ class Application {
/**
* Creates a new application.
*/
- function create($sName=null, $sDescription=null, $sKeywords=null, $sWebpage=null, $iVendorId=null, $iCatId=null)
+ function create()
{
// Security, if we are not an administrator the application must be queued.
if(!($_SESSION['current']->hasPriv("admin")))
@@ -121,12 +121,12 @@ class Application {
else
$this->sQueued = 'false';
- $aInsert = compile_insert_string(array( 'appName' => $sName,
- 'description'=> $sDescription,
- 'keywords' => $sKeywords,
- 'webPage' => $sWebpage,
- 'vendorId' => $iVendorId,
- 'catId' => $iCatId,
+ $aInsert = compile_insert_string(array( 'appName' => $this->sName,
+ 'description'=> $this->sDescription,
+ 'keywords' => $this->sKeywords,
+ 'webPage' => $this->sWebpage,
+ 'vendorId' => $this->iVendorId,
+ 'catId' => $this->iCatId,
'submitterId'=> $_SESSION['current']->iUserId,
'queued' => $this->sQueued));
$sFields = "({$aInsert['FIELDS']})";
@@ -148,66 +148,63 @@ class Application {
* Update application.
* Returns true on success and false on failure.
*/
- function update($sName=null, $sDescription=null, $sKeywords=null, $sWebpage=null, $iVendorId=null, $iCatId=null)
+ function update()
{
$sWhatChanged = "";
- if ($sName && $sName!=$this->sName)
+ /* create an instance of ourselves so we can see what has changed */
+ $oApp = new Application($this->iAppId);
+
+ if ($this->sName && ($this->sName!=$oApp->sName))
{
- $sUpdate = compile_update_string(array('appName' => $sName));
+ $sUpdate = compile_update_string(array('appName' => $this->sName));
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
return false;
- $sWhatChanged .= "Name was changed from ".$this->sName." to ".$sName.".\n\n";
- $this->sName = $sName;
+ $sWhatChanged .= "Name was changed from ".$oApp->sName." to ".$this->sName.".\n\n";
}
- if ($sDescription && $sDescription!=$this->sDescription)
+ if ($this->sDescription && ($this->sDescription!=$oApp->sDescription))
{
- $sUpdate = compile_update_string(array('description' => $sDescription));
+ $sUpdate = compile_update_string(array('description' => $this->sDescription));
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
return false;
- $sWhatChanged .= "Description was changed from\n ".$this->sDescription."\n to \n".$sDescription.".\n\n";
- $this->sDescription = $sDescription;
+ $sWhatChanged .= "Description was changed from\n ".$oApp->sDescription."\n to \n".$this->sDescription.".\n\n";
}
- if ($sKeywords && $sKeywords!=$this->sKeywords)
+ if ($this->sKeywords && ($this->sKeywords!=$oApp->sKeywords))
{
- $sUpdate = compile_update_string(array('keywords' => $sKeywords));
+ $sUpdate = compile_update_string(array('keywords' => $this->sKeywords));
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
return false;
- $sWhatChanged .= "Keywords were changed from\n ".$this->sKeywords."\n to \n".$sKeywords.".\n\n";
- $this->sKeywords = $sKeywords;
+ $sWhatChanged .= "Keywords were changed from\n ".$oApp->sKeywords."\n to \n".$this->sKeywords.".\n\n";
}
- if ($sWebpage && $sWebpage!=$this->sWebpage)
+ if ($this->sWebpage && ($this->sWebpage!=$oApp->sWebpage))
{
- $sUpdate = compile_update_string(array('webPage' => $sWebpage));
+ $sUpdate = compile_update_string(array('webPage' => $this->sWebpage));
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
return false;
- $sWhatChanged .= "Web page was changed from ".$this->sWebpage." to ".$sWebpage.".\n\n";
- $this->sWebpage = $sWebpage;
+ $sWhatChanged .= "Web page was changed from ".$oApp->sWebpage." to ".$this->sWebpage.".\n\n";
}
- if ($iVendorId && $iVendorId!=$this->iVendorId)
+ if ($this->iVendorId && ($this->iVendorId!=$oApp->iVendorId))
{
- $sUpdate = compile_update_string(array('vendorId' => $iVendorId));
+ $sUpdate = compile_update_string(array('vendorId' => $this->iVendorId));
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
return false;
- $oVendorBefore = new Vendor($this->iVendorId);
- $oVendorAfter = new Vendor($iVendorId);
+ $oVendorBefore = new Vendor($oApp->iVendorId);
+ $oVendorAfter = new Vendor($this->iVendorId);
$sWhatChanged .= "Vendor was changed from ".$oVendorBefore->sName." to ".$oVendorBefore->sName.".\n\n";
- $this->iVendorId = $iVendorId;
}
- if ($iCatId && $iCatId!=$this->iCatId)
+ if ($this->iCatId && ($this->iCatId!=$oApp->iCatId))
{
- $sUpdate = compile_update_string(array('catId' => $iCatId));
+ $sUpdate = compile_update_string(array('catId' => $this->iCatId));
if (!query_appdb("UPDATE appFamily SET ".$sUpdate." WHERE appId = ".$this->iAppId))
return false;
- $oCatBefore = new Category($this->iCatId);
- $oCatAfter = new Category($iCatId);
+ $oCatBefore = new Category($oApp->iCatId);
+ $oCatAfter = new Category($this->iCatId);
$sWhatChanged .= "Vendor was changed from ".$oCatBefore->sName." to ".$oCatAfter->sName.".\n\n";
- $this->iCatId = $iCatId;
}
if($sWhatChanged)
$this->SendNotificationMail("edit",$sWhatChanged);
@@ -415,6 +412,98 @@ class Application {
if($sEmail)
mail_appdb($sEmail, $sSubject ,$sMsg);
}
+
+
+ /* output a html table and this applications values to the fields for editing */
+ function OutputEditor($sVendorName)
+ {
+ HtmlAreaLoaderScript(array("app_editor"));
+
+ echo html_frame_start("Application Form", "90%", "", 0);
+ echo "
\n";
+
+ // No vendor entered, and nothing in the list is selected
+ if (empty($_REQUEST['appVendorName']) && !$_REQUEST['appVendorId'] && !$_REQUEST['appId'])
+ $errors .= "