Don't use arguments for vendor::create() and vendor::update()

This commit is contained in:
Alexander Nicolaysen Sørnes
2007-01-28 23:28:14 +00:00
committed by WineHQ
parent 03c8c62699
commit d8aa5380a2
5 changed files with 52 additions and 29 deletions

View File

@@ -180,10 +180,12 @@ if ($aClean['sSub'])
$oApp = new Application($aClean['iAppId']); $oApp = new Application($aClean['iAppId']);
$oApp->GetOutputEditorValues($aClean); // load the values from $aClean $oApp->GetOutputEditorValues($aClean); // load the values from $aClean
// add new vendor // add new vendor
if($aClean['sAppVendorName'] and !$aClean['iAppVendorId']) if($aClean['sVendorName'] and !$aClean['iAppVendorId'])
{ {
$oVendor = new Vendor(); $oVendor = new Vendor();
$oVendor->create($aClean['sAppVendorName'],$aClean['sAppWebpage']); $oVendor->getOutputEditorValues($aClean);
$oVendor->sWebpage = $aClean['sAppWebpage'];
$oVendor->create();
$oApp->iVendorId = $oVendor->iVendorId; $oApp->iVendorId = $oVendor->iVendorId;
} }
$oApp->update(true); $oApp->update(true);

View File

@@ -9,7 +9,8 @@ if(!$_SESSION['current']->hasPriv("admin"))
$oVendor = new Vendor($aClean['iVendorId']); $oVendor = new Vendor($aClean['iVendorId']);
if($aClean['sSubmit']) if($aClean['sSubmit'])
{ {
$oVendor->update($aClean['sName'],$aClean['sWebpage']); $oVendor->getOutputEditorValues($aClean);
$oVendor->update();
util_redirect_and_exit(apidb_fullurl("vendorview.php")); util_redirect_and_exit(apidb_fullurl("vendorview.php"));
} }
else else

View File

@@ -12,7 +12,7 @@
* - iAppId, application identifier * - iAppId, application identifier
* - iVersionId, version identifier * - iVersionId, version identifier
* - iTestingId, * - iTestingId,
* - sAppVendorName, * - sVendorName,
* - iVendorId, * - iVendorId,
* - sAppWebpage, * - sAppWebpage,
* - sAppKeywords, * - sAppKeywords,
@@ -172,18 +172,21 @@ if ($aClean['sSub'])
if(empty($errors)) if(empty($errors))
{ {
if($aClean['sAppVendorName']) if($aClean['sVendorName'])
{ {
$aClean['iVendorId']=""; $aClean['iVendorId']="";
//FIXME: fix this when we fix vendor submission //FIXME: fix this when we fix vendor submission
if($_SESSION['current']->hasPriv("admin")) if($_SESSION['current']->hasPriv("admin"))
{ {
$oVendor = new Vendor(); $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 //FIXME: remove this when we fix vendor submission
$oApp->sKeywords = $aClean['sAppKeywords']." *** ".$aClean['sAppVendorName']; $oApp->sKeywords = $aClean['sAppKeywords']." *** ".$aClean['sVendorName'];
if($oApp->iAppId) if($oApp->iAppId)
{ {
$oApp->update(); $oApp->update();
@@ -315,7 +318,7 @@ if ($aClean['sSub'])
if(!$iVendorId) if(!$iVendorId)
{ {
$sVendor = get_vendor_from_keywords($oApp->sKeywords); $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); $hResult = query_appdb($sQuery);
if($hResult) if($hResult)
{ {
@@ -328,7 +331,7 @@ if ($aClean['sSub'])
if(!$iVendorId) if(!$iVendorId)
{ {
$hResult = query_parameters("select * from vendor where vendorname like '%?%'", $hResult = query_parameters("select * from vendor where vendorname like '%?%'",
$aClean['sAppVendorName']); $aClean['sVendorName']);
if($hResult) if($hResult)
{ {
$oRow = mysql_fetch_object($hResult); $oRow = mysql_fetch_object($hResult);
@@ -337,7 +340,7 @@ if ($aClean['sSub'])
} }
//vendor field //vendor field
if($iVendorId) if($iVendorId)
$aClean['sAppVendorName'] = ""; $aClean['sVendorName'] = "";
} else //app version } else //app version
{ {
if($oVersion->iVersionId) if($oVersion->iVersionId)
@@ -371,7 +374,7 @@ if ($aClean['sSub'])
$oTest->sTestedDate = date('Y-m-d H:i:s'); $oTest->sTestedDate = date('Y-m-d H:i:s');
if($aClean['sAppType'] == 'application') if($aClean['sAppType'] == 'application')
$oApp->outputEditor($aClean['sAppVendorName']); $oApp->outputEditor($aClean['sVendorName']);
$oVersion->outputEditor(false, false); $oVersion->outputEditor(false, false);

View File

@@ -520,7 +520,7 @@ class Application {
// vendor name // vendor name
echo '<tr valign=top><td class="color0"><b>Vendor</b></td>',"\n"; echo '<tr valign=top><td class="color0"><b>Vendor</b></td>',"\n";
echo '<td><input size="20" type=text name="sAppVendorName" value="'.$sVendorName.'"></td></tr>',"\n"; echo '<td><input size="20" type=text name="sVendorName" value="'.$sVendorName.'"></td></tr>',"\n";
// alt vendor // alt vendor
$x = new TableVE("view"); $x = new TableVE("view");
@@ -583,7 +583,7 @@ class Application {
$errors .= "<li>Please enter an application name.</li>\n"; $errors .= "<li>Please enter an application name.</li>\n";
// No vendor entered, and nothing in the list is selected // No vendor entered, and nothing in the list is selected
if (empty($aValues['sAppVendorName']) && !$aValues['iAppVendorId']) if (empty($aValues['sVendorName']) && !$aValues['iAppVendorId'])
$errors .= "<li>Please enter a vendor.</li>\n"; $errors .= "<li>Please enter a vendor.</li>\n";
if (empty($aValues['shAppDescription'])) if (empty($aValues['shAppDescription']))

View File

@@ -54,10 +54,11 @@ class Vendor {
/** /**
* Creates a new vendor. * Creates a new vendor.
*/ */
function create($sName=null, $sWebpage=null) function create()
{ {
$hResult = query_parameters("INSERT INTO vendor (vendorName, vendorURL) ". $hResult = query_parameters("INSERT INTO vendor (vendorName, vendorURL) ".
"VALUES ('?', '?')", $sName, $sWebpage); "VALUES ('?', '?')",
$this->sName, $this->sWebpage);
if($hResult) if($hResult)
{ {
$this->iVendorId = mysql_insert_id(); $this->iVendorId = mysql_insert_id();
@@ -76,23 +77,23 @@ class Vendor {
* Update vendor. * Update vendor.
* Returns true on success and false on failure. * Returns true on success and false on failure.
*/ */
function update($sName=null, $sWebpage=null) function update()
{ {
if(!$this->iVendorId) 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 = '?'", if (!query_parameters("UPDATE vendor SET vendorName = '?' WHERE vendorId = '?'",
$sName, $this->iVendorId)) $this->sName, $this->iVendorId))
return false; return false;
$this->sName = $sName; $this->sName = $sName;
} }
if($sWebpage) if($this->sWebpage)
{ {
if (!query_parameters("UPDATE vendor SET vendorURL = '?' WHERE vendorId = '?'", if (!query_parameters("UPDATE vendor SET vendorURL = '?' WHERE vendorId = '?'",
$sWebpage, $this->iVendorId)) $this->sWebpage, $this->iVendorId))
return false; return false;
$this->sWebpage = $sWebpage; $this->sWebpage = $sWebpage;
} }
@@ -113,29 +114,45 @@ class Vendor {
$sQuery = "DELETE FROM vendor $sQuery = "DELETE FROM vendor
WHERE vendorId = '?' WHERE vendorId = '?'
LIMIT 1"; LIMIT 1";
query_parameters($sQuery, $this->iVendorId); if(query_parameters($sQuery, $this->iVendorId))
{
addmsg("The vendor has been deleted.", "green"); addmsg("The vendor has been deleted.", "green");
return TRUE;
}
return FALSE;
} }
} }
function outputEditor() function outputEditor()
{ {
echo html_frame_start("Vendor Form", "90%", "", 0);
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n"; echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
// Name // Name
echo '<tr valign=top><td class="color1" width="20%"><b>Vendor Name</b></td>',"\n"; echo '<tr valign=top><td class="color1" width="20%"><b>Vendor Name</b></td>',"\n";
echo '<td class="color0"><input type=text name="sName" value="'.$this->sName.'" size="50"></td></tr>',"\n"; echo '<td class="color0"><input type=text name="sVendorName" value="'.$this->sName.'" size="50"></td></tr>',"\n";
// Url // Url
echo '<tr valign=top><td class="color1"><b>Vendor Url</b></td>',"\n"; echo '<tr valign=top><td class="color1"><b>Vendor Url</b></td>',"\n";
echo '<td class="color0"><input type=text name="sWebpage" value="'.$this->sWebpage.'" size="50"></td></tr>',"\n"; echo '<td class="color0"><input type=text name="sVendorWebpage" value="'.$this->sWebpage.'" size="50"></td></tr>',"\n";
echo '<input type="hidden" name="iVendorId" value="'.$this->iVendorId.'">',"\n"; echo '<input type="hidden" name="iVendorId" value="'.$this->iVendorId.'">',"\n";
echo "</table>\n"; echo "</table>\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 */ /* Get the total number of Vendors in the database */