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\n"; echo "\n\n"; - - echo html_frame_start("New Version Form",400,"",0); - echo "\n"; - - //app parent - echo '',"\n"; - - //version - echo '',"\n"; - echo '',"\n"; - - echo '',"\n"; - echo '',"\n"; - - echo '',"\n"; - echo '',"\n"; - - - echo '',"\n"; - echo '
Application',"\n"; - $x->make_option_list("appId",$oVersion->iAppId,"appFamily","appId","appName"); - echo '
Version name
Description

email Text
' ,"\n"; - echo ''; - echo ' ',"\n"; - echo '',"\n"; - echo '
',"\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\n"; echo "\n\n"; - //view application details - echo html_frame_start("New Application Form",400,"",0); - echo "\n"; - - //category - echo '',"\n"; - - //name - echo '',"\n"; - echo '',"\n"; - /* * vendor/alt vendor fields * if user selected a predefined vendorId: @@ -260,44 +217,41 @@ if ($_REQUEST['sub']) //vendor field if($iVendorId) $sVendor = ""; - echo '',"\n"; - echo '',"\n"; - echo '',"\n"; - - echo '',"\n"; - - //url - echo '',"\n"; - echo '',"\n"; - - // application desc - echo '',"\n"; - echo '',"\n"; - - // version name - echo '',"\n"; - echo '',"\n"; - - // version description - echo '',"\n"; - echo '',"\n"; - - - echo '',"\n"; - echo '',"\n"; - - echo '',"\n"; - echo '
Category',"\n"; - $x->make_option_list("catId",$oApp->iCatId,"appCategory","catId","catName"); - echo '
App Name
App Vendor
 ',"\n"; - $x->make_option_list("vendorId", $iVendorId ,"vendor","vendorId","vendorName"); - echo '
App URL
Application Description

Version name
Version Description

email Text
' ,"\n"; - echo ''; - echo ' ',"\n"; - echo '',"\n"; - echo '',"\n"; - echo '
',"\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"; + echo '',"\n"; + echo '',"\n"; + + echo '',"\n"; + echo '
email Text
' ,"\n"; + if ($oApp) //application + { + echo ''; + echo ' ',"\n"; + } else // app version + { + echo ''; + echo ' ',"\n"; + } + + echo '',"\n"; + echo '',"\n"; + echo '
',"\n"; + echo '',"\n"; + echo html_frame_end(); echo html_back_link(1,'adminAppQueue.php'); } else if ($_REQUEST['sub'] == 'add') @@ -305,10 +259,10 @@ if ($_REQUEST['sub']) if (is_numeric($_REQUEST['appId']) && !is_numeric($_REQUEST['versionId'])) // application { // add new vendor - if($sVendor) + if($_REQUEST['appVendorName']) { $oVendor = new Vendor(); - $oVendor->create($sVendor); + $oVendor->create($_REQUEST['appVendorName'],$_REQUEST['appWebpage']); } $oApp = new Application($_REQUEST['appId']); diff --git a/admin/editAppFamily.php b/admin/editAppFamily.php index 342dbed..df60572 100644 --- a/admin/editAppFamily.php +++ b/admin/editAppFamily.php @@ -30,56 +30,41 @@ if(isset($_REQUEST['submit'])) else // Show the form for editing the Application Family { - HtmlAreaLoaderScript(array("editor")); - $family = new TableVE("edit"); - $result = query_appdb("SELECT * from appFamily WHERE appId = '{$_REQUEST['appId']}'"); + + $oApp = new Application($_REQUEST['appId']); - if(!mysql_num_rows($result)) + if(!$oApp) { errorpage('Application does not exist'); } - $ob = mysql_fetch_object($result); - - if($_SESSION['current']->showDebuggingInfos()) { echo "

appName: $ob->appName

"; } + if($_SESSION['current']->showDebuggingInfos()) { echo "

appName: $oApp->sName

"; } apidb_header("Edit Application Family"); echo "
\n"; - echo html_frame_start("Data for Application ID $ob->appId", "90%","",0); - echo html_table_begin("width='100%' border=0 align=left cellpadding=6 cellspacing=0 class='box-body'"); - echo ''; - echo 'Name',"\n"; - echo 'Vendor'; - $family->make_option_list("vendorId", $ob->vendorId, "vendor", "vendorId", "vendorName"); - echo '',"\n"; - echo 'Keywords',"\n"; - echo 'Description', "\n"; - if(trim(strip_tags($ob->description))=="") $ob->description="

Enter description here

"; - echo '

', "\n"; - echo '',"\n"; - echo '

'; - echo 'Web Page',"\n"; - echo 'Category'; - $family->make_option_list("catId", $ob->catId, "appCategory", "catId", "catName"); - echo '',"\n"; - echo '',"\n"; + echo ''; - echo html_table_end(); - echo html_frame_end(); + $oApp->OutputEditor(""); + + echo '', "\n"; + echo '',"\n"; + echo '
', "\n"; echo "
"; - // url edit form + echo "

"; + + // url edit form echo '

',"\n"; - echo ''; + echo ''; echo html_frame_start("Edit URL","90%","",0); echo '',"\n"; - + $i = 0; - $result = query_appdb("SELECT * FROM appData WHERE appId = $ob->appId AND type = 'url' AND versionId = 0"); + $result = query_appdb("SELECT * FROM appData WHERE appId = $oApp->iAppId AND type = 'url' AND versionId = 0"); if($result && mysql_num_rows($result) > 0) { echo '',"\n"; echo '',"\n"; - + echo '',"\n"; - + echo '
Delete',"\n"; @@ -110,14 +95,14 @@ else echo '
New
',"\n"; echo html_frame_end(); echo "
"; - echo html_back_link(1,BASE."appview.php?appId=$ob->appId"); + echo html_back_link(1,BASE."appview.php?appId=$ob->appId"); } apidb_footer(); diff --git a/admin/editAppVersion.php b/admin/editAppVersion.php index c2ea5b3..d2a8ba7 100644 --- a/admin/editAppVersion.php +++ b/admin/editAppVersion.php @@ -26,49 +26,23 @@ if(isset($_REQUEST['submit'])) } else /* or display the webform for making changes */ { - HtmlAreaLoaderScript(array("editor")); /* load the appropriate htmlarea controls */ - $oVersion = new Version($_REQUEST['versionId']); + /* if the sDescription is empty, put the default in */ + if(trim(strip_tags($oVersion->sDescription))=="") + $oVersion->sDescription = GetDefaultVersionDescription(); + apidb_header("Edit Application Version"); echo "
\n"; - echo html_frame_start("Data for Application ID: ".$oVersion->iAppId." Version ID: ".$oVersion->iVersionId, "90%","",0); - echo html_table_begin("width='100%' border=0 align=left cellpadding=6 cellspacing=0 class='box-body'"); + + $oVersion->OutputEditor(false); /* false = not allowing the user to modify the parent application */ + echo ''; echo ''; - echo 'Name'.lookup_app_name($oVersion->iAppId).'',"\n"; - echo 'Version',"\n"; - echo 'Version specific description', "\n"; - // FIXME: put templates in config file or somewhere else. - if(trim(strip_tags($oVersion->sDescription))=="") - { - $oVersion->sDescription = "

This is a template; enter version-specific description here

"; - $oVersion->sDescription .= "

- Wine compatibility
- What works:
- - settings
- - help
-
What doesn't work:
- - erasing
-
What was not tested:
- - burning
-

"; - $oVersion->sDescription .= "

Tested versions
- - - - - - - - - -
App. versionWine versionInstalls?Runs?Rating
3.2320050111yesyesGold
3.2320041201yesyesSilver
3.2120040615yesyesBronze


"; - } - echo '

', "\n"; - echo '',"\n"; - echo '

'; + + echo html_frame_start("Info", "90%", "", 0); + echo "\n"; echo '',"\n"; diff --git a/admin/resubmitRejectedApps.php b/admin/resubmitRejectedApps.php index ccf05ac..ad23d24 100644 --- a/admin/resubmitRejectedApps.php +++ b/admin/resubmitRejectedApps.php @@ -74,8 +74,6 @@ 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); @@ -89,35 +87,8 @@ 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\n"; echo "
Rating',"\n"; make_maintainer_rating_list("maintainer_rating", $oVersion->sTestedRating); echo '
\n\n"; - - echo html_frame_start("Rejected Version Form",400,"",0); - echo "\n"; - - //app parent - echo '',"\n"; - - //version - echo '',"\n"; - echo '',"\n"; - - echo '',"\n"; - echo '',"\n"; - - echo '',"\n"; - echo '',"\n"; - - - echo '',"\n"; - echo '
Application',"\n"; - $x->make_option_list("appId",$oVersion->iAppId,"appFamily","appId","appName"); - echo '
Version name
Description

email Text
' ,"\n"; - echo ''; - echo ' ',"\n"; - echo '
',"\n"; } else // application { - HtmlAreaLoaderScript(array("editor")); - echo html_frame_start("Potential duplicate applications in the database","90%","",0); perform_search_and_output_results($oApp->sName); echo html_frame_end(" "); @@ -131,20 +102,6 @@ if ($_REQUEST['sub']) echo "submitter to let them know the item was deleted.

\n\n"; echo "\n\n"; - //view application details - echo html_frame_start("New Application Form",400,"",0); - echo "\n"; - - //category - echo '',"\n"; - - //name - echo '',"\n"; - 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 '',"\n"; - echo '',"\n"; - echo '',"\n"; - - echo '',"\n"; + } - //url - echo '',"\n"; - echo '',"\n"; - - // application desc - echo '',"\n"; - echo '',"\n"; + if($oApp) + { + $oApp->OutputEditor($sVendor); + $oVersion->OutputEditor(false); + } else + { + $oVersion->OutputEditor(true); + } - // version name - echo '',"\n"; - echo '',"\n"; - - // version description - echo '',"\n"; - echo '',"\n"; - - - echo '',"\n"; - echo '',"\n"; + echo '',"\n"; + echo '',"\n"; + if($oApp) // application + { echo '',"\n"; echo '
Category',"\n"; - $x->make_option_list("catId",$oApp->iCatId,"appCategory","catId","catName"); - echo '
App Name
App Vendor
 ',"\n"; - $x->make_option_list("vendorId", $iVendorId ,"vendor","vendorId","vendorName"); - echo '
App URL
Application Description

Version name
Version Description

email Text
email Text
' ,"\n"; echo ''; echo ' ',"\n"; echo '',"\n"; echo '
',"\n"; + } else // version + { + echo '' ,"\n"; + echo ''; + echo ' ',"\n"; + echo '',"\n"; + echo '',"\n"; } echo html_frame_end(" "); - echo html_back_link(1,$_SERVER['PHP_SELF']); + echo html_back_link(1, $_SERVER['PHP_SELF']); } else if ($_REQUEST['sub'] == 'ReQueue') { diff --git a/appsubmit.php b/appsubmit.php index 4bb8f6d..794bd69 100644 --- a/appsubmit.php +++ b/appsubmit.php @@ -8,34 +8,6 @@ require(BASE."include/tableve.php"); require(BASE."include/mail.php"); require(BASE."include/application.php"); - /* - * Templates - * FIXME: put templates in config file or somewhere else. - */ - $sAppDescription = "

Enter a description of the application here

"; - $sVersionDescription = "

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. versionWine versionInstalls?Runs?Rating
3.2320050111yesyesGold
3.2320041201yesyesSilver
3.2120040615yesyesBronze


"; - 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. () -function checkInput($fields) -{ - $errors = ""; - - if (strlen($fields['appName']) > 200 ) - $errors .= "
  • Your application name is too long.
  • \n"; - - if (empty($fields['appName']) && !$fields['appId']) - $errors .= "
  • Please enter an application name.
  • \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 .= "
  • Please enter a vendor.
  • \n"; - - if (empty($fields['appDescription']) && !$fields['appId']) - $errors .= "
  • Please enter a description of your application.
  • \n"; - - if (empty($errors)) - return ""; - else - return $errors; -} - /* * User submitted an application */ if (isset($_REQUEST['appName'])) { - // Check input and exit if we found errors + $errors = ""; + + // Check input and exit if we found errors + $oApplication = new Application(); + $errors .= $oApplication->CheckOutputEditorInput(); + + $oVersion = new Version(); + $errors .= $oVersion->CheckOutputEditorInput(); - $errors = checkInput($_REQUEST); if(empty($errors)) { - if($vendorName) $_REQUEST['vendorId']=""; + 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(); - $oApplication = new Application(); - $oApplication->create($_REQUEST['appName'], $_REQUEST['appDescription'], $_REQUEST['keywords']." *** ".$_REQUEST['vendorName'], $_REQUEST['webpage'], $_REQUEST['vendorId'], $_REQUEST['catId']); - $oVersion = new Version(); - $oVersion->create($_REQUEST['versionName'], $_REQUEST['versionDescription'], null, null, $oApplication->iAppId); redirect(apidb_fullurl("index.php")); } @@ -99,12 +64,14 @@ if (isset($_REQUEST['appName'])) elseif (isset($_REQUEST['versionName']) && is_numeric($_REQUEST['appId'])) { // Check input and exit if we found errors - $errors = checkInput($_REQUEST); + + $oVersion = new Version(); + $errors = $oVersion->CheckOutputEditorInput(); + if(empty($errors)) { - - $oVersion = new Version(); - $oVersion->create($_REQUEST['versionName'], $_REQUEST['versionDescription'], null, null, $_REQUEST['appId']); + $oVersion->GetOutputEditorValues(); + $oVersion->create(); redirect(apidb_fullurl("index.php")); } } @@ -155,78 +122,31 @@ if (isset($_REQUEST['apptype'])) echo '

    ',"\n"; } - // new application and version - if ($_REQUEST['apptype'] == 1) + if($_REQUEST['apptype'] == 1 && (trim(strip_tags($_REQUEST['appDescription']))=="")) { - HtmlAreaLoaderScript(array("editor", "editor2")); - - echo html_frame_start("New Application Form",400,"",0); - echo "\n"; - echo '',"\n"; - echo '',"\n"; - - // app Category - $w = new TableVE("view"); - echo '',"\n"; - - echo '',"\n"; - echo '',"\n"; - - // alt vendor - $x = new TableVE("view"); - echo '',"\n"; - - echo '',"\n"; - echo '',"\n"; - - echo '',"\n"; - echo '',"\n"; - - echo '',"\n"; - if(trim(strip_tags($_REQUEST['appDescription']))=="") - { - $_REQUEST['appDescription'] = $sAppDescription; - } - echo '',"\n"; - - } - // new version - else - { - HtmlAreaLoaderScript(array("editor2")); - - echo html_frame_start("New Version Form",400,"",0); - - echo "
    Application name
    Category',"\n"; - $w->make_option_list("catId",$_REQUEST['catId'],"appCategory","catId","catName"); - echo '
    Vendor
     ',"\n"; - $x->make_option_list("vendorId",$_REQUEST['vendorId'],"vendor","vendorId","vendorName"); - echo '
    URL
    Keywords
    Application Description

    \n"; - - // app parent - $x = new TableVE("view"); - echo '',"\n"; + $_REQUEST['appDescription'] = GetDefaultApplicationDescription(); } - echo '',"\n"; - echo '',"\n"; + if(trim(strip_tags($_REQUEST['versionDescription']))=="") { - $_REQUEST['versionDescription'] = $sVersionDescription; - } - echo '',"\n"; - echo '',"\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 '
    Application',"\n"; - $x->make_option_list("appId",$_REQUEST['appId'],"appFamily","appId","appName"); - echo '
    Version name
    Version description

    ',"\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"; + echo '',"\n"; + echo '',"\n"; + + // app Category + $w = new TableVE("view"); + echo '',"\n"; + + // vendor name + echo '',"\n"; + echo '',"\n"; + + // alt vendor + $x = new TableVE("view"); + echo '',"\n"; + + // url + echo '',"\n"; + echo '',"\n"; + + echo '',"\n"; + echo '',"\n"; + + echo '',"\n"; + echo '',"\n"; + else + echo $this->sDescription.'

    ',"\n"; + + echo "
    Application name
    Category',"\n"; + $w->make_option_list("appCatId", $this->iCatId,"appCategory","catId","catName"); + echo '
    Vendor
     ',"\n"; + $x->make_option_list("appVendorId", $this->iVendorId,"vendor","vendorId","vendorName"); + echo '
    URL
    Keywords
    Application Description

    \n"; + + echo html_frame_end(); + } + + function CheckOutputEditorInput() + { + $errors = ""; + + if (empty($_REQUEST['appCatId']) && !$_REQUEST['appId']) + $errors .= "
  • Please enter a category for your application.
  • \n"; + + if (strlen($_REQUEST['appName']) > 200 ) + $errors .= "
  • Your application name is too long.
  • \n"; + + if (empty($_REQUEST['appName']) && !$_REQUEST['appId']) + $errors .= "
  • Please enter an application name.
  • \n"; + + // No vendor entered, and nothing in the list is selected + if (empty($_REQUEST['appVendorName']) && !$_REQUEST['appVendorId'] && !$_REQUEST['appId']) + $errors .= "
  • Please enter a vendor.
  • \n"; + + if (empty($_REQUEST['appDescription']) && !$_REQUEST['appId']) + $errors .= "
  • Please enter a description of your application.
  • \n"; + + return $errors; + } + + /* retrieves values from $_REQUEST that were output by OutputEditor() */ + function GetOutputEditorValues() + { + if(get_magic_quotes_gpc()) + { + $this->sName = stripslashes($_REQUEST['appName']); + $this->sDescription = stripslashes($_REQUEST['appDescription']); + $this->iCatId = stripslashes($_REQUEST['appCatId']); + $this->iVendorId = stripslashes($_REQUEST['appVendorId']); + $this->sWebpage = stripslashes($_REQUEST['appWebpage']); + $this->sKeywords = stripslashes($_REQUEST['appKeywords']); + } else + { + $this->sName = $_REQUEST['appName']; + $this->sDescription = $_REQUEST['appDescription']; + $this->iCatId = $_REQUEST['appCatId']; + $this->iVendorId = $_REQUEST['appVendorId']; + $this->sWebpage = $_REQUEST['appWebpage']; + $this->sKeywords = $_REQUEST['appKeywords']; + } + } } @@ -459,4 +548,9 @@ function trim_description($sDescription) $aDesc = explode("

    ",$aDesc[0],2); return trim(strip_tags($aDesc[0])); } + +function GetDefaultApplicationDescription() +{ + return "

    Enter a description of the application here

    "; +} ?> diff --git a/include/util.php b/include/util.php index 27ab715..ae52f36 100644 --- a/include/util.php +++ b/include/util.php @@ -583,23 +583,23 @@ function display_versions($iAppId, $aVersionsIds) /* or false if processing changes for an application family */ function process_app_version_changes($isVersion) { + /* load up the version or application depending on which values are set */ if($isVersion) - { $oVersion = new Version($_REQUEST['versionId']); + else $oApp = new Application($_REQUEST['appId']); - } // commit changes of form to database if(($_REQUEST['submit'] == "Update Database") && $isVersion) /* is a version */ { - $oVersion->update($_REQUEST['versionName'], $_REQUEST['description'], $_REQUEST['maintainer_release'], $_REQUEST['maintainer_rating']); + $oVersion->GetOutputEditorValues(); + $oVersion->update(); } else if(($_REQUEST['submit'] == "Update Database") && !$isVersion) /* is an application */ { - $oApp = new Application($_REQUEST['appId']); - $oApp->update($_REQUEST['appName'], $_REQUEST['description'], $_REQUEST['keywords'], $_REQUEST['webPage'], $_REQUEST['vendorId'], $_REQUEST['catId']); + $oApp->GetOutputEditorValues(); + $oApp->update(); } else if($_REQUEST['submit'] == "Update URL") { - $sWhatChanged = ""; $bAppChanged = false; @@ -810,6 +810,8 @@ function GetSimplifiedPath($relative) function HtmlAreaLoaderScript($aTextareas) { + static $outputIndex = 0; + echo ' '; + + $outputIndex++; /* increment the output index */ } ?> diff --git a/include/version.php b/include/version.php index d6ad011..8e63076 100644 --- a/include/version.php +++ b/include/version.php @@ -137,7 +137,7 @@ class Version { /** * Creates a new version. */ - function create($sName=null, $sDescription=null, $sTestedRelease=null, $sTestedRating=null, $iAppId=null) + function create() { // Security, if we are not an administrator or an appmaintainer the version must be queued. if(!($_SESSION['current']->hasPriv("admin") || $_SESSION['current']->isSupermaintainer($iAppId))) @@ -145,11 +145,11 @@ class Version { else $this->sQueued = 'false'; - $aInsert = compile_insert_string(array( 'versionName' => $sName, - 'description' => $sDescription, - 'maintainer_release'=> $sTestedRelease, - 'maintainer_rating' => $sTestedRating, - 'appId' => $iAppId, + $aInsert = compile_insert_string(array( 'versionName' => $this->sName, + 'description' => $this->sDescription, + 'maintainer_release'=> $this->sTestedRelease, + 'maintainer_rating' => $this->sTestedRating, + 'appId' => $this->iAppId, 'submitterId' => $_SESSION['current']->iUserId, 'queued' => $this->sQueued )); $sFields = "({$aInsert['FIELDS']})"; @@ -163,7 +163,9 @@ class Version { return true; } else + { return false; + } } @@ -172,71 +174,66 @@ class Version { * FIXME: Use compile_update_string instead of addslashes. * Returns true on success and false on failure. */ - function update($sName=null, $sDescription=null, $sTestedRelease=null, $sTestedRating=null, $iAppId=null) + function update() { $sWhatChanged = ""; - if ($sName && $sName!=$this->sName) + $oVersion = new Version($this->iVersionId); + + if ($this->sName && ($this->sName!=$oVersion->sName)) { - $sUpdate = compile_update_string(array('versionName' => $sName)); + $sUpdate = compile_update_string(array('versionName' => $this->sName)); if (!query_appdb("UPDATE appVersion SET ".$sUpdate." WHERE versionId = ".$this->iVersionId)) return false; - $sWhatChanged .= "Name was changed from:\n\t'".$this->sName."'\nto:\n\t'".$sName."'\n\n"; - $this->sName = $sName; + $sWhatChanged .= "Name was changed from:\n\t'".$oVersion->sName."'\nto:\n\t'".$this->sName."'\n\n"; } - if ($sDescription && $sDescription!=$this->sDescription) + if ($this->sDescription && ($this->sDescription!=$oVersion->sDescription)) { - $sUpdate = compile_update_string(array('description' => $sDescription)); + $sUpdate = compile_update_string(array('description' => $this->sDescription)); if (!query_appdb("UPDATE appVersion SET ".$sUpdate." WHERE versionId = ".$this->iVersionId)) return false; - if($this->sDescription != "") - $sWhatChanged .= "Description was changed from\n ".$this->sDescription."\n to \n".$sDescription.".\n\n"; + if($oVersion->sDescription != "") + $sWhatChanged .= "Description was changed from\n ".$oVersion->sDescription."\n to \n".$this->sDescription.".\n\n"; else - $sWhatChanged .= "Description was changed to \n".$sDescription.".\n\n"; - - $this->sDescription = $sDescription; + $sWhatChanged .= "Description was changed to \n".$this->sDescription.".\n\n"; } - if ($sTestedRelease && $sTestedRelease!=$this->sTestedRelease) + if ($this->sTestedRelease && ($this->sTestedRelease!=$oVersion->sTestedRelease)) { $sUpdate = compile_update_string(array('maintainer_release' => $sTestedRelease)); if (!query_appdb("UPDATE appVersion SET ".$sUpdate." WHERE versionId = ".$this->iVersionId)) return false; - if($this->sTestedRelease != "") - $sWhatChanged .= "Last tested release was changed from ".$this->sTestedRelease." to ".$sTestedRelease.".\n\n"; + if($oVersion->sTestedRelease != "") + $sWhatChanged .= "Last tested release was changed from ".$oVersion->sTestedRelease." to ".$this->sTestedRelease.".\n\n"; else - $sWhatChanged .= "Last tested release was changed to ".$sTestedRelease.".\n\n"; - - $this->sTestedRelease = $sTestedRelease; + $sWhatChanged .= "Last tested release was changed to ".$this->sTestedRelease.".\n\n"; } - if ($sTestedRating && $sTestedRating!=$this->sTestedRating) + if ($this->sTestedRating && ($this->sTestedRating!=$oVersion->sTestedRating)) { - $sUpdate = compile_update_string(array('maintainer_rating' => $sTestedRating)); - if (!query_appdb("UPDATE appVersion SET maintainer_rating = '".$sTestedRating."' WHERE versionId = ".$this->iVersionId)) + $sUpdate = compile_update_string(array('maintainer_rating' => $this->sTestedRating)); + if (!query_appdb("UPDATE appVersion SET ".$sUpdate."' WHERE versionId = ".$this->iVersionId)) return false; if($this->sTestedRating != "") - $sWhatChanged .= "Rating was changed from ".$this->sTestedRating." to ".$sTestedRating.".\n\n"; + $sWhatChanged .= "Rating was changed from ".$oVersion->sTestedRating." to ".$this->sTestedRating.".\n\n"; else - $sWhatChanged .= "Rating was changed to ".$sTestedRating.".\n\n"; - - $this->sTestedRating = $sTestedRating; + $sWhatChanged .= "Rating was changed to ".$this->sTestedRating.".\n\n"; } - if ($iAppId && $iAppId!=$this->iAppId) + if ($this->iAppId && ($this->iAppId!=$oVersion->iAppId)) { - $sUpdate = compile_update_string(array('appId' => $iAppId)); + $sUpdate = compile_update_string(array('appId' => $this->iAppId)); if (!query_appdb("UPDATE appVersion SET ".$sUpdate." WHERE versionId = ".$this->iVersionId)) return false; - $oAppBefore = new Application($this->iAppId); - $oAppAfter = new Application($iAppId); + $oAppBefore = new Application($oVersion->iAppId); + $oAppAfter = new Application($this->iAppId); $sWhatChanged .= "Version was moved from application ".$oAppBefore->sName." to application ".$oAppAfter->sName.".\n\n"; - $this->iAppId = $iAppId; } + if($sWhatChanged) $this->SendNotificationMail("edit",$sWhatChanged); return true; @@ -489,5 +486,99 @@ class Version { if($sEmail) mail_appdb($sEmail, $sSubject ,$sMsg); } + + /* output html and the current versions information for editing */ + /* if $editParentApplication is true that means we need to display fields */ + /* to let the user change the parent application of this version */ + /* otherwise, if $editParentAppliation is false, we leave them out */ + function OutputEditor($editParentApplication) + { + HtmlAreaLoaderScript(array("version_editor")); + echo html_frame_start("Version Form", "90%", "", 0); + echo "\n"; + + if($editParentApplication) + { + // app parent + $x = new TableVE("view"); + echo '', "\n"; + echo '',"\n"; + } + + // version name + echo '',"\n"; + echo '',"\n"; + + // version description + echo '',"\n"; + echo '',"\n"; + else + echo $this->sDescription.'

    ',"\n"; + + echo '
    Application',"\n"; + $x->make_option_list("appId",$this->iAppId,"appFamily","appId","appName"); + echo '
    Version name
    Version description

    ',"\n"; + + echo html_frame_end(); + } + + function CheckOutputEditorInput() + { + $errors = ""; + + if (empty($_REQUEST['versionName'])) + $errors .= "
  • Please enter an application version.
  • \n"; + + if (empty($_REQUEST['versionDescription'])) + $errors .= "
  • Please enter a version description.
  • \n"; + + return $errors; + } + + /* retrieves values from $_REQUEST that were output by OutputEditor() */ + function GetOutputEditorValues() + { + if(get_magic_quotes_gpc()) + { + $this->sName = stripslashes($_REQUEST['versionName']); + $this->sDescription = stripslashes($_REQUEST['versionDescription']); + } else + { + $this->sName = $_REQUEST['versionName']; + $this->sDescription = $_REQUEST['versionDescription']; + } + } +} + +function GetDefaultVersionDescription() +{ + return "

    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. versionWine versionInstalls?Runs?Rating
    3.2320050111yesyesGold
    3.2320041201yesyesSilver
    3.2120040615yesyesBronze


    "; } ?>