diff --git a/admin/adminAppQueue.php b/admin/adminAppQueue.php index f303191..bede150 100644 --- a/admin/adminAppQueue.php +++ b/admin/adminAppQueue.php @@ -180,10 +180,12 @@ if ($aClean['sSub']) $oApp = new Application($aClean['iAppId']); $oApp->GetOutputEditorValues($aClean); // load the values from $aClean // add new vendor - if($aClean['sAppVendorName'] and !$aClean['iAppVendorId']) + if($aClean['sVendorName'] and !$aClean['iAppVendorId']) { $oVendor = new Vendor(); - $oVendor->create($aClean['sAppVendorName'],$aClean['sAppWebpage']); + $oVendor->getOutputEditorValues($aClean); + $oVendor->sWebpage = $aClean['sAppWebpage']; + $oVendor->create(); $oApp->iVendorId = $oVendor->iVendorId; } $oApp->update(true); diff --git a/admin/editVendor.php b/admin/editVendor.php index f501bb4..7c76c62 100644 --- a/admin/editVendor.php +++ b/admin/editVendor.php @@ -9,7 +9,8 @@ if(!$_SESSION['current']->hasPriv("admin")) $oVendor = new Vendor($aClean['iVendorId']); if($aClean['sSubmit']) { - $oVendor->update($aClean['sName'],$aClean['sWebpage']); + $oVendor->getOutputEditorValues($aClean); + $oVendor->update(); util_redirect_and_exit(apidb_fullurl("vendorview.php")); } else diff --git a/appsubmit.php b/appsubmit.php index 826130c..031a1af 100644 --- a/appsubmit.php +++ b/appsubmit.php @@ -12,7 +12,7 @@ * - iAppId, application identifier * - iVersionId, version identifier * - iTestingId, - * - sAppVendorName, + * - sVendorName, * - iVendorId, * - sAppWebpage, * - sAppKeywords, @@ -172,18 +172,21 @@ if ($aClean['sSub']) if(empty($errors)) { - if($aClean['sAppVendorName']) + if($aClean['sVendorName']) { $aClean['iVendorId']=""; //FIXME: fix this when we fix vendor submission if($_SESSION['current']->hasPriv("admin")) { $oVendor = new Vendor(); - $oVendor->create($aClean['sAppVendorName'],$aClean['sAppWebpage']); + $oVendor->getOutputEditorValues($aClean); + $oVendor->sWebpage = $aClean['sAppWebpage']; + $oVendor->create(); + $oApp->iVendorId = $oVendor->iVendorId; } } //FIXME: remove this when we fix vendor submission - $oApp->sKeywords = $aClean['sAppKeywords']." *** ".$aClean['sAppVendorName']; + $oApp->sKeywords = $aClean['sAppKeywords']." *** ".$aClean['sVendorName']; if($oApp->iAppId) { $oApp->update(); @@ -315,7 +318,7 @@ if ($aClean['sSub']) if(!$iVendorId) { $sVendor = get_vendor_from_keywords($oApp->sKeywords); - $sQuery = "SELECT vendorId FROM vendor WHERE vendorname = '".$aClean['sAppVendorName']."';"; + $sQuery = "SELECT vendorId FROM vendor WHERE vendorname = '".$aClean['sVendorName']."';"; $hResult = query_appdb($sQuery); if($hResult) { @@ -328,7 +331,7 @@ if ($aClean['sSub']) if(!$iVendorId) { $hResult = query_parameters("select * from vendor where vendorname like '%?%'", - $aClean['sAppVendorName']); + $aClean['sVendorName']); if($hResult) { $oRow = mysql_fetch_object($hResult); @@ -337,7 +340,7 @@ if ($aClean['sSub']) } //vendor field if($iVendorId) - $aClean['sAppVendorName'] = ""; + $aClean['sVendorName'] = ""; } else //app version { if($oVersion->iVersionId) @@ -371,7 +374,7 @@ if ($aClean['sSub']) $oTest->sTestedDate = date('Y-m-d H:i:s'); if($aClean['sAppType'] == 'application') - $oApp->outputEditor($aClean['sAppVendorName']); + $oApp->outputEditor($aClean['sVendorName']); $oVersion->outputEditor(false, false); diff --git a/include/application.php b/include/application.php index 2520e99..ca77184 100644 --- a/include/application.php +++ b/include/application.php @@ -520,7 +520,7 @@ class Application { // vendor name echo 'Vendor',"\n"; - echo '',"\n"; + echo '',"\n"; // alt vendor $x = new TableVE("view"); @@ -583,7 +583,7 @@ class Application { $errors .= "
  • Please enter an application name.
  • \n"; // No vendor entered, and nothing in the list is selected - if (empty($aValues['sAppVendorName']) && !$aValues['iAppVendorId']) + if (empty($aValues['sVendorName']) && !$aValues['iAppVendorId']) $errors .= "
  • Please enter a vendor.
  • \n"; if (empty($aValues['shAppDescription'])) diff --git a/include/vendor.php b/include/vendor.php index 0a6064d..42a2fd1 100644 --- a/include/vendor.php +++ b/include/vendor.php @@ -54,10 +54,11 @@ class Vendor { /** * Creates a new vendor. */ - function create($sName=null, $sWebpage=null) + function create() { $hResult = query_parameters("INSERT INTO vendor (vendorName, vendorURL) ". - "VALUES ('?', '?')", $sName, $sWebpage); + "VALUES ('?', '?')", + $this->sName, $this->sWebpage); if($hResult) { $this->iVendorId = mysql_insert_id(); @@ -76,23 +77,23 @@ class Vendor { * Update vendor. * Returns true on success and false on failure. */ - function update($sName=null, $sWebpage=null) + function update() { if(!$this->iVendorId) - return $this->create($sName, $sWebpage); + return $this->create(); - if($sName) + if($this->sName) { if (!query_parameters("UPDATE vendor SET vendorName = '?' WHERE vendorId = '?'", - $sName, $this->iVendorId)) + $this->sName, $this->iVendorId)) return false; $this->sName = $sName; - } + } - if($sWebpage) + if($this->sWebpage) { if (!query_parameters("UPDATE vendor SET vendorURL = '?' WHERE vendorId = '?'", - $sWebpage, $this->iVendorId)) + $this->sWebpage, $this->iVendorId)) return false; $this->sWebpage = $sWebpage; } @@ -100,7 +101,7 @@ class Vendor { } - /** + /** * Deletes the vendor from the database. */ function delete($bSilent=false) @@ -113,29 +114,45 @@ class Vendor { $sQuery = "DELETE FROM vendor WHERE vendorId = '?' LIMIT 1"; - query_parameters($sQuery, $this->iVendorId); - addmsg("The vendor has been deleted.", "green"); + if(query_parameters($sQuery, $this->iVendorId)) + { + addmsg("The vendor has been deleted.", "green"); + return TRUE; + } + + return FALSE; } } function outputEditor() { - echo html_frame_start("Vendor Form", "90%", "", 0); echo "\n"; // Name echo '',"\n"; - echo '',"\n"; + echo '',"\n"; // Url echo '',"\n"; - echo '',"\n"; + echo '',"\n"; echo '',"\n"; echo "
    Vendor Name
    Vendor Url
    \n"; - echo html_frame_end(); } + function canEdit() + { + if($_SESSION['current']->hasPriv("admin")) + return TRUE; + else + return FALSE; + } + + function getOutputEditorValues($aClean) + { + $this->sName = $aClean['sVendorName']; + $this->sWebpage = $aClean['sVendorWebpage']; + } } /* Get the total number of Vendors in the database */