From 7501cb424cf724a78cd024db62bae665ae162476 Mon Sep 17 00:00:00 2001 From: rMalie Date: Wed, 1 Feb 2012 16:42:20 +0000 Subject: [PATCH] // Fix assignations in conditions with logical operators + normalize --- controllers/admin/AdminProductsController.php | 2 +- controllers/admin/AdminTagsController.php | 2 +- controllers/front/AuthController.php | 2 +- modules/blockspecials/blockspecials.php | 2 +- modules/blocktags/blocktags.php | 10 +++++----- modules/blockviewed/blockviewed.php | 4 ++-- modules/editorial/editorial.php | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 525a001bd..28586d7db 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -1340,7 +1340,7 @@ class AdminProductsControllerCore extends AdminController if (!$new_path = $image->getPathForCreation()) $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'); else if (!ImageManager::resize($tmpName, $new_path.'.'.$image->image_format)) $this->errors[] = Tools::displayError('An error occurred while copying image.'); diff --git a/controllers/admin/AdminTagsController.php b/controllers/admin/AdminTagsController.php index 7453ee433..d153473ed 100644 --- a/controllers/admin/AdminTagsController.php +++ b/controllers/admin/AdminTagsController.php @@ -79,7 +79,7 @@ class AdminTagsControllerCore extends AdminController public function postProcess() { 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']); return parent::postProcess(); } diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index 8070cefb8..6ed5a7fbd 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -502,7 +502,7 @@ class AuthControllerCore extends FrontController { // if registration type is in one step, we save the address 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()); $contains_state = isset($country) && is_object($country) ? (int)$country->contains_state: 0; $id_state = isset($address) && is_object($address) ? (int)$address->id_state: 0; diff --git a/modules/blockspecials/blockspecials.php b/modules/blockspecials/blockspecials.php index 2b3e5d81a..cce358d43 100644 --- a/modules/blockspecials/blockspecials.php +++ b/modules/blockspecials/blockspecials.php @@ -87,7 +87,7 @@ class BlockSpecials extends Module if (Configuration::get('PS_CATALOG_MODE')) 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; $this->smarty->assign(array( diff --git a/modules/blocktags/blocktags.php b/modules/blocktags/blocktags.php index 0756dd055..d35bb1fac 100644 --- a/modules/blocktags/blocktags.php +++ b/modules/blocktags/blocktags.php @@ -49,9 +49,9 @@ class BlockTags extends Module function install() { if (parent::install() == false - OR $this->registerHook('leftColumn') == false - OR $this->registerHook('header') == false - OR Configuration::updateValue('BLOCKTAGS_NBR', 10) == false) + || $this->registerHook('leftColumn') == false + || $this->registerHook('header') == false + || Configuration::updateValue('BLOCKTAGS_NBR', 10) == false) return false; return true; } @@ -61,13 +61,13 @@ class BlockTags extends Module $output = '

'.$this->displayName.'

'; if (Tools::isSubmit('submitBlockTags')) { - if (!$tagsNbr = Tools::getValue('tagsNbr') OR empty($tagsNbr)) + if (!($tagsNbr = Tools::getValue('tagsNbr')) || empty($tagsNbr)) $output .= '
'.$this->l('Please fill in the "tags displayed" field.').'
'; elseif ((int)($tagsNbr) == 0) $output .= '
'.$this->l('Invalid number.').'
'; else { - Configuration::updateValue('BLOCKTAGS_NBR', (int)($tagsNbr)); + Configuration::updateValue('BLOCKTAGS_NBR', (int)$tagsNbr); $output .= '
'.$this->l('Confirmation').''.$this->l('Settings updated').'
'; } } diff --git a/modules/blockviewed/blockviewed.php b/modules/blockviewed/blockviewed.php index b56746e6f..3b9d7d2d8 100644 --- a/modules/blockviewed/blockviewed.php +++ b/modules/blockviewed/blockviewed.php @@ -62,13 +62,13 @@ class BlockViewed extends Module $output = '

'.$this->displayName.'

'; if (Tools::isSubmit('submitBlockViewed')) { - if (!$productNbr = Tools::getValue('productNbr') OR empty($productNbr)) + if (!($productNbr = Tools::getValue('productNbr')) || empty($productNbr)) $output .= '
'.$this->l('You must fill in the \'Products displayed\' field.').'
'; elseif ((int)($productNbr) == 0) $output .= '
'.$this->l('Invalid number.').'
'; else { - Configuration::updateValue('PRODUCTS_VIEWED_NBR', (int)($productNbr)); + Configuration::updateValue('PRODUCTS_VIEWED_NBR', (int)$productNbr); $output .= '
'.$this->l('Confirmation').''.$this->l('Settings updated').'
'; } } diff --git a/modules/editorial/editorial.php b/modules/editorial/editorial.php index 86ea844c5..0ca5352d4 100644 --- a/modules/editorial/editorial.php +++ b/modules/editorial/editorial.php @@ -153,14 +153,14 @@ class Editorial extends Module $editorial->update(); /* 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); if(file_exists(dirname(__FILE__).'/homepage_logo.jpg')) unlink(dirname(__FILE__).'/homepage_logo.jpg'); if ($error = ImageManager::validateUpload($_FILES['body_homepage_logo'])) $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; elseif (!ImageManager::resize($tmpName, dirname(__FILE__).'/homepage_logo.jpg')) $errors .= $this->displayError($this->l('An error occurred during the image upload.'));