From 9ca620e4e7e31d65533a5121ab9f18c9c36117fb Mon Sep 17 00:00:00 2001 From: rGaillard Date: Fri, 5 Oct 2012 13:51:04 +0000 Subject: [PATCH] // Shop Context without multishop is now no longer ALL but SHOP #PSCFV-4730 git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@17791 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/Configuration.php | 45 +++++++++++++++++++-------------------- classes/shop/Shop.php | 15 +++++++------ 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/classes/Configuration.php b/classes/Configuration.php index a3b79824a..ec8c2767b 100644 --- a/classes/Configuration.php +++ b/classes/Configuration.php @@ -94,9 +94,9 @@ class ConfigurationCore extends ObjectModel public static function getIdByName($key, $id_shop_group = null, $id_shop = null) { if ($id_shop === null) - $id_shop = Shop::getContextShopID(); + $id_shop = Shop::getContextShopID(true); if ($id_shop_group === null) - $id_shop_group = Shop::getContextShopGroupID(); + $id_shop_group = Shop::getContextShopGroupID(true); $sql = 'SELECT id_configuration FROM '._DB_PREFIX_.'configuration @@ -153,12 +153,11 @@ class ConfigurationCore extends ObjectModel if (!self::$_CONF) return Db::getInstance()->getValue('SELECT `value` FROM `'._DB_PREFIX_.'configuration` WHERE `name` = "'.pSQL($key).'"'); } - $id_lang = (int)$id_lang; if ($id_shop === null) - $id_shop = Shop::getContextShopID(); + $id_shop = Shop::getContextShopID(true); if ($id_shop_group === null) - $id_shop_group = Shop::getContextShopGroupID(); + $id_shop_group = Shop::getContextShopGroupID(true); if (!isset(self::$_CONF[$id_lang])) $id_lang = 0; @@ -208,9 +207,9 @@ class ConfigurationCore extends ObjectModel $id_lang = (int)$id_lang; if ($id_shop === null) - $id_shop = Shop::getContextShopID(); + $id_shop = Shop::getContextShopID(true); if ($id_shop_group === null) - $id_shop_group = Shop::getContextShopGroupID(); + $id_shop_group = Shop::getContextShopGroupID(true); $results = array(); foreach ($keys as $key) @@ -251,9 +250,9 @@ class ConfigurationCore extends ObjectModel die(Tools::displayError()); if ($id_shop === null) - $id_shop = Shop::getContextShopID(); + $id_shop = Shop::getContextShopID(true); if ($id_shop_group === null) - $id_shop_group = Shop::getContextShopGroupID(); + $id_shop_group = Shop::getContextShopGroupID(true); if (!is_array($values)) $values = array($values); @@ -298,9 +297,9 @@ class ConfigurationCore extends ObjectModel die(Tools::displayError()); if ($id_shop === null) - $id_shop = Shop::getContextShopID(); + $id_shop = Shop::getContextShopID(true); if ($id_shop_group === null) - $id_shop_group = Shop::getContextShopGroupID(); + $id_shop_group = Shop::getContextShopGroupID(true); if (!is_array($values)) $values = array($values); @@ -411,9 +410,9 @@ class ConfigurationCore extends ObjectModel return; $id_shop = null; - $id_shop_group = Shop::getContextShopGroupID(); + $id_shop_group = Shop::getContextShopGroupID(true); if (Shop::getContext() == Shop::CONTEXT_SHOP) - $id_shop = Shop::getContextShopID(); + $id_shop = Shop::getContextShopID(true); $id = Configuration::getIdByName($key, $id_shop_group, $id_shop); Db::getInstance()->execute(' @@ -437,22 +436,22 @@ class ConfigurationCore extends ObjectModel { if (Shop::getContext() == Shop::CONTEXT_ALL) $id_shop = $id_shop_group = null; - else if (Shop::getContext() == Shop::CONTEXT_GROUP) + elseif (Shop::getContext() == Shop::CONTEXT_GROUP) { - $id_shop_group = Shop::getContextShopGroupID(); + $id_shop_group = Shop::getContextShopGroupID(true); $id_shop = null; } else { - $id_shop_group = Shop::getContextShopGroupID(); - $id_shop = Shop::getContextShopID(); + $id_shop_group = Shop::getContextShopGroupID(true); + $id_shop = Shop::getContextShopID(true); } if ($context == Shop::CONTEXT_SHOP && Configuration::hasKey($key, $id_lang, null, $id_shop)) return true; - else if ($context == Shop::CONTEXT_GROUP && Configuration::hasKey($key, $id_lang, $id_shop_group)) + elseif ($context == Shop::CONTEXT_GROUP && Configuration::hasKey($key, $id_lang, $id_shop_group)) return true; - else if ($context == Shop::CONTEXT_ALL && Configuration::hasKey($key, $id_lang)) + elseif ($context == Shop::CONTEXT_ALL && Configuration::hasKey($key, $id_lang)) return true; return false; } @@ -497,9 +496,9 @@ class ConfigurationCore extends ObjectModel protected static function sqlRestriction($id_shop_group, $id_shop) { if ($id_shop) - return ' AND id_shop = '.$id_shop; + return ' AND id_shop = '.(int)$id_shop; else if ($id_shop_group) - return ' AND id_shop_group = '.$id_shop_group.' AND id_shop IS NULL'; + return ' AND id_shop_group = '.(int)$id_shop_group.' AND id_shop IS NULL'; else return ' AND id_shop_group IS NULL AND id_shop IS NULL'; } @@ -516,11 +515,11 @@ class ConfigurationCore extends ObjectModel public function getWebserviceObjectList($sql_join, $sql_filter, $sql_sort, $sql_limit) { $query = ' - SELECT DISTINCT main.`'.$this->def['primary'].'` FROM `'._DB_PREFIX_.$this->def['table'].'` main + SELECT DISTINCT main.`'.bqSQL($this->def['primary']).'` FROM `'._DB_PREFIX_.bqSQL($this->def['table']).'` main '.$sql_join.' WHERE id_configuration NOT IN ( SELECT id_configuration - FROM '._DB_PREFIX_.$this->def['table'].'_lang + FROM '._DB_PREFIX_.bqSQL($this->def['table']).'_lang ) '.$sql_filter.' '.($sql_sort != '' ? $sql_sort : '').' '.($sql_limit != '' ? $sql_limit : '').' diff --git a/classes/shop/Shop.php b/classes/shop/Shop.php index 56c8dc6f4..b4d26d132 100644 --- a/classes/shop/Shop.php +++ b/classes/shop/Shop.php @@ -802,10 +802,6 @@ class ShopCore extends ObjectModel */ public static function setContext($type, $id = null) { - // Always use global context for mono-shop mode - if (!Shop::isFeatureActive()) - $type = self::CONTEXT_ALL; - switch ($type) { case self::CONTEXT_ALL : @@ -845,8 +841,10 @@ class ShopCore extends ObjectModel * * @return int */ - public static function getContextShopID() + public static function getContextShopID($null_value_without_multishop = false) { + if ($null_value_without_multishop && !Shop::isFeatureActive()) + return null; return self::$context_id_shop; } @@ -855,8 +853,11 @@ class ShopCore extends ObjectModel * * @return int */ - public static function getContextShopGroupID() + public static function getContextShopGroupID($null_value_without_multishop = false) { + if ($null_value_without_multishop && !Shop::isFeatureActive()) + return null; + return self::$context_id_shop_group; } @@ -950,7 +951,7 @@ class ShopCore extends ObjectModel static $feature_active = null; if ($feature_active === null) - $feature_active = Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && (Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'shop') > 1); + $feature_active = Configuration::getGlobalValue('PS_MULTISHOP_FEATURE_ACTIVE') && (Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'shop') > 1); return $feature_active; }