Don't use arguments for vendor::create() and vendor::update()
This commit is contained in:
committed by
WineHQ
parent
03c8c62699
commit
d8aa5380a2
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -520,7 +520,7 @@ class Application {
|
||||
|
||||
// vendor name
|
||||
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
|
||||
$x = new TableVE("view");
|
||||
@@ -583,7 +583,7 @@ class Application {
|
||||
$errors .= "<li>Please enter an application name.</li>\n";
|
||||
|
||||
// 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";
|
||||
|
||||
if (empty($aValues['shAppDescription']))
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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 "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
|
||||
|
||||
// Name
|
||||
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
|
||||
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 "</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 */
|
||||
|
||||
Reference in New Issue
Block a user