// Fix assignations in conditions with logical operators + normalize

This commit is contained in:
rMalie
2012-02-01 16:42:20 +00:00
parent 4c97888a66
commit 7501cb424c
7 changed files with 13 additions and 13 deletions
@@ -1340,7 +1340,7 @@ class AdminProductsControllerCore extends AdminController
if (!$new_path = $image->getPathForCreation()) if (!$new_path = $image->getPathForCreation())
$this->errors[] = Tools::displayError('An error occurred during new folder creation'); $this->errors[] = Tools::displayError('An error occurred during new folder creation');
if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') || !move_uploaded_file($_FILES['image_product']['tmp_name'], $tmpName)) if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) || !move_uploaded_file($_FILES['image_product']['tmp_name'], $tmpName))
$this->errors[] = Tools::displayError('An error occurred during the image upload'); $this->errors[] = Tools::displayError('An error occurred during the image upload');
else if (!ImageManager::resize($tmpName, $new_path.'.'.$image->image_format)) else if (!ImageManager::resize($tmpName, $new_path.'.'.$image->image_format))
$this->errors[] = Tools::displayError('An error occurred while copying image.'); $this->errors[] = Tools::displayError('An error occurred while copying image.');
+1 -1
View File
@@ -79,7 +79,7 @@ class AdminTagsControllerCore extends AdminController
public function postProcess() public function postProcess()
{ {
if ($this->tabAccess['edit'] === '1' && Tools::getValue('submitAdd'.$this->table)) if ($this->tabAccess['edit'] === '1' && Tools::getValue('submitAdd'.$this->table))
if ($id = (int)Tools::getValue($this->identifier) && $obj = new $this->className($id) && Validate::isLoadedObject($obj)) if (($id = (int)Tools::getValue($this->identifier)) && ($obj = new $this->className($id)) && Validate::isLoadedObject($obj))
$obj->setProducts($_POST['products']); $obj->setProducts($_POST['products']);
return parent::postProcess(); return parent::postProcess();
} }
+1 -1
View File
@@ -502,7 +502,7 @@ class AuthControllerCore extends FrontController
{ {
// if registration type is in one step, we save the address // if registration type is in one step, we save the address
if (Configuration::get('PS_REGISTRATION_PROCESS_TYPE')) if (Configuration::get('PS_REGISTRATION_PROCESS_TYPE'))
if (!$country = new Country($address->id_country, Configuration::get('PS_LANG_DEFAULT')) || !Validate::isLoadedObject($country)) if (!($country = new Country($address->id_country, Configuration::get('PS_LANG_DEFAULT'))) || !Validate::isLoadedObject($country))
die(Tools::displayError()); die(Tools::displayError());
$contains_state = isset($country) && is_object($country) ? (int)$country->contains_state: 0; $contains_state = isset($country) && is_object($country) ? (int)$country->contains_state: 0;
$id_state = isset($address) && is_object($address) ? (int)$address->id_state: 0; $id_state = isset($address) && is_object($address) ? (int)$address->id_state: 0;
+1 -1
View File
@@ -87,7 +87,7 @@ class BlockSpecials extends Module
if (Configuration::get('PS_CATALOG_MODE')) if (Configuration::get('PS_CATALOG_MODE'))
return ; return ;
if (!$special = Product::getRandomSpecial((int)$params['cookie']->id_lang) AND !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')) if (!($special = Product::getRandomSpecial((int)$params['cookie']->id_lang)) && !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY'))
return; return;
$this->smarty->assign(array( $this->smarty->assign(array(
+5 -5
View File
@@ -49,9 +49,9 @@ class BlockTags extends Module
function install() function install()
{ {
if (parent::install() == false if (parent::install() == false
OR $this->registerHook('leftColumn') == false || $this->registerHook('leftColumn') == false
OR $this->registerHook('header') == false || $this->registerHook('header') == false
OR Configuration::updateValue('BLOCKTAGS_NBR', 10) == false) || Configuration::updateValue('BLOCKTAGS_NBR', 10) == false)
return false; return false;
return true; return true;
} }
@@ -61,13 +61,13 @@ class BlockTags extends Module
$output = '<h2>'.$this->displayName.'</h2>'; $output = '<h2>'.$this->displayName.'</h2>';
if (Tools::isSubmit('submitBlockTags')) if (Tools::isSubmit('submitBlockTags'))
{ {
if (!$tagsNbr = Tools::getValue('tagsNbr') OR empty($tagsNbr)) if (!($tagsNbr = Tools::getValue('tagsNbr')) || empty($tagsNbr))
$output .= '<div class="alert error">'.$this->l('Please fill in the "tags displayed" field.').'</div>'; $output .= '<div class="alert error">'.$this->l('Please fill in the "tags displayed" field.').'</div>';
elseif ((int)($tagsNbr) == 0) elseif ((int)($tagsNbr) == 0)
$output .= '<div class="alert error">'.$this->l('Invalid number.').'</div>'; $output .= '<div class="alert error">'.$this->l('Invalid number.').'</div>';
else else
{ {
Configuration::updateValue('BLOCKTAGS_NBR', (int)($tagsNbr)); Configuration::updateValue('BLOCKTAGS_NBR', (int)$tagsNbr);
$output .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="'.$this->l('Confirmation').'" />'.$this->l('Settings updated').'</div>'; $output .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="'.$this->l('Confirmation').'" />'.$this->l('Settings updated').'</div>';
} }
} }
+2 -2
View File
@@ -62,13 +62,13 @@ class BlockViewed extends Module
$output = '<h2>'.$this->displayName.'</h2>'; $output = '<h2>'.$this->displayName.'</h2>';
if (Tools::isSubmit('submitBlockViewed')) if (Tools::isSubmit('submitBlockViewed'))
{ {
if (!$productNbr = Tools::getValue('productNbr') OR empty($productNbr)) if (!($productNbr = Tools::getValue('productNbr')) || empty($productNbr))
$output .= '<div class="alert error">'.$this->l('You must fill in the \'Products displayed\' field.').'</div>'; $output .= '<div class="alert error">'.$this->l('You must fill in the \'Products displayed\' field.').'</div>';
elseif ((int)($productNbr) == 0) elseif ((int)($productNbr) == 0)
$output .= '<div class="alert error">'.$this->l('Invalid number.').'</div>'; $output .= '<div class="alert error">'.$this->l('Invalid number.').'</div>';
else else
{ {
Configuration::updateValue('PRODUCTS_VIEWED_NBR', (int)($productNbr)); Configuration::updateValue('PRODUCTS_VIEWED_NBR', (int)$productNbr);
$output .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="'.$this->l('Confirmation').'" />'.$this->l('Settings updated').'</div>'; $output .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="'.$this->l('Confirmation').'" />'.$this->l('Settings updated').'</div>';
} }
} }
+2 -2
View File
@@ -153,14 +153,14 @@ class Editorial extends Module
$editorial->update(); $editorial->update();
/* upload the image */ /* upload the image */
if (isset($_FILES['body_homepage_logo']) AND isset($_FILES['body_homepage_logo']['tmp_name']) AND !empty($_FILES['body_homepage_logo']['tmp_name'])) if (isset($_FILES['body_homepage_logo']) && isset($_FILES['body_homepage_logo']['tmp_name']) && !empty($_FILES['body_homepage_logo']['tmp_name']))
{ {
Configuration::set('PS_IMAGE_GENERATION_METHOD', 1); Configuration::set('PS_IMAGE_GENERATION_METHOD', 1);
if(file_exists(dirname(__FILE__).'/homepage_logo.jpg')) if(file_exists(dirname(__FILE__).'/homepage_logo.jpg'))
unlink(dirname(__FILE__).'/homepage_logo.jpg'); unlink(dirname(__FILE__).'/homepage_logo.jpg');
if ($error = ImageManager::validateUpload($_FILES['body_homepage_logo'])) if ($error = ImageManager::validateUpload($_FILES['body_homepage_logo']))
$errors .= $error; $errors .= $error;
elseif (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') OR !move_uploaded_file($_FILES['body_homepage_logo']['tmp_name'], $tmpName)) elseif (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) || !move_uploaded_file($_FILES['body_homepage_logo']['tmp_name'], $tmpName))
return false; return false;
elseif (!ImageManager::resize($tmpName, dirname(__FILE__).'/homepage_logo.jpg')) elseif (!ImageManager::resize($tmpName, dirname(__FILE__).'/homepage_logo.jpg'))
$errors .= $this->displayError($this->l('An error occurred during the image upload.')); $errors .= $this->displayError($this->l('An error occurred during the image upload.'));