// 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
This commit is contained in:
+22
-23
@@ -94,9 +94,9 @@ class ConfigurationCore extends ObjectModel
|
|||||||
public static function getIdByName($key, $id_shop_group = null, $id_shop = null)
|
public static function getIdByName($key, $id_shop_group = null, $id_shop = null)
|
||||||
{
|
{
|
||||||
if ($id_shop === null)
|
if ($id_shop === null)
|
||||||
$id_shop = Shop::getContextShopID();
|
$id_shop = Shop::getContextShopID(true);
|
||||||
if ($id_shop_group === null)
|
if ($id_shop_group === null)
|
||||||
$id_shop_group = Shop::getContextShopGroupID();
|
$id_shop_group = Shop::getContextShopGroupID(true);
|
||||||
|
|
||||||
$sql = 'SELECT id_configuration
|
$sql = 'SELECT id_configuration
|
||||||
FROM '._DB_PREFIX_.'configuration
|
FROM '._DB_PREFIX_.'configuration
|
||||||
@@ -153,12 +153,11 @@ class ConfigurationCore extends ObjectModel
|
|||||||
if (!self::$_CONF)
|
if (!self::$_CONF)
|
||||||
return Db::getInstance()->getValue('SELECT `value` FROM `'._DB_PREFIX_.'configuration` WHERE `name` = "'.pSQL($key).'"');
|
return Db::getInstance()->getValue('SELECT `value` FROM `'._DB_PREFIX_.'configuration` WHERE `name` = "'.pSQL($key).'"');
|
||||||
}
|
}
|
||||||
|
|
||||||
$id_lang = (int)$id_lang;
|
$id_lang = (int)$id_lang;
|
||||||
if ($id_shop === null)
|
if ($id_shop === null)
|
||||||
$id_shop = Shop::getContextShopID();
|
$id_shop = Shop::getContextShopID(true);
|
||||||
if ($id_shop_group === null)
|
if ($id_shop_group === null)
|
||||||
$id_shop_group = Shop::getContextShopGroupID();
|
$id_shop_group = Shop::getContextShopGroupID(true);
|
||||||
|
|
||||||
if (!isset(self::$_CONF[$id_lang]))
|
if (!isset(self::$_CONF[$id_lang]))
|
||||||
$id_lang = 0;
|
$id_lang = 0;
|
||||||
@@ -208,9 +207,9 @@ class ConfigurationCore extends ObjectModel
|
|||||||
|
|
||||||
$id_lang = (int)$id_lang;
|
$id_lang = (int)$id_lang;
|
||||||
if ($id_shop === null)
|
if ($id_shop === null)
|
||||||
$id_shop = Shop::getContextShopID();
|
$id_shop = Shop::getContextShopID(true);
|
||||||
if ($id_shop_group === null)
|
if ($id_shop_group === null)
|
||||||
$id_shop_group = Shop::getContextShopGroupID();
|
$id_shop_group = Shop::getContextShopGroupID(true);
|
||||||
|
|
||||||
$results = array();
|
$results = array();
|
||||||
foreach ($keys as $key)
|
foreach ($keys as $key)
|
||||||
@@ -251,9 +250,9 @@ class ConfigurationCore extends ObjectModel
|
|||||||
die(Tools::displayError());
|
die(Tools::displayError());
|
||||||
|
|
||||||
if ($id_shop === null)
|
if ($id_shop === null)
|
||||||
$id_shop = Shop::getContextShopID();
|
$id_shop = Shop::getContextShopID(true);
|
||||||
if ($id_shop_group === null)
|
if ($id_shop_group === null)
|
||||||
$id_shop_group = Shop::getContextShopGroupID();
|
$id_shop_group = Shop::getContextShopGroupID(true);
|
||||||
|
|
||||||
if (!is_array($values))
|
if (!is_array($values))
|
||||||
$values = array($values);
|
$values = array($values);
|
||||||
@@ -298,9 +297,9 @@ class ConfigurationCore extends ObjectModel
|
|||||||
die(Tools::displayError());
|
die(Tools::displayError());
|
||||||
|
|
||||||
if ($id_shop === null)
|
if ($id_shop === null)
|
||||||
$id_shop = Shop::getContextShopID();
|
$id_shop = Shop::getContextShopID(true);
|
||||||
if ($id_shop_group === null)
|
if ($id_shop_group === null)
|
||||||
$id_shop_group = Shop::getContextShopGroupID();
|
$id_shop_group = Shop::getContextShopGroupID(true);
|
||||||
|
|
||||||
if (!is_array($values))
|
if (!is_array($values))
|
||||||
$values = array($values);
|
$values = array($values);
|
||||||
@@ -411,9 +410,9 @@ class ConfigurationCore extends ObjectModel
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
$id_shop = null;
|
$id_shop = null;
|
||||||
$id_shop_group = Shop::getContextShopGroupID();
|
$id_shop_group = Shop::getContextShopGroupID(true);
|
||||||
if (Shop::getContext() == Shop::CONTEXT_SHOP)
|
if (Shop::getContext() == Shop::CONTEXT_SHOP)
|
||||||
$id_shop = Shop::getContextShopID();
|
$id_shop = Shop::getContextShopID(true);
|
||||||
|
|
||||||
$id = Configuration::getIdByName($key, $id_shop_group, $id_shop);
|
$id = Configuration::getIdByName($key, $id_shop_group, $id_shop);
|
||||||
Db::getInstance()->execute('
|
Db::getInstance()->execute('
|
||||||
@@ -437,22 +436,22 @@ class ConfigurationCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
if (Shop::getContext() == Shop::CONTEXT_ALL)
|
if (Shop::getContext() == Shop::CONTEXT_ALL)
|
||||||
$id_shop = $id_shop_group = null;
|
$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;
|
$id_shop = null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$id_shop_group = Shop::getContextShopGroupID();
|
$id_shop_group = Shop::getContextShopGroupID(true);
|
||||||
$id_shop = Shop::getContextShopID();
|
$id_shop = Shop::getContextShopID(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($context == Shop::CONTEXT_SHOP && Configuration::hasKey($key, $id_lang, null, $id_shop))
|
if ($context == Shop::CONTEXT_SHOP && Configuration::hasKey($key, $id_lang, null, $id_shop))
|
||||||
return true;
|
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;
|
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 true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -497,9 +496,9 @@ class ConfigurationCore extends ObjectModel
|
|||||||
protected static function sqlRestriction($id_shop_group, $id_shop)
|
protected static function sqlRestriction($id_shop_group, $id_shop)
|
||||||
{
|
{
|
||||||
if ($id_shop)
|
if ($id_shop)
|
||||||
return ' AND id_shop = '.$id_shop;
|
return ' AND id_shop = '.(int)$id_shop;
|
||||||
else if ($id_shop_group)
|
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
|
else
|
||||||
return ' AND id_shop_group IS NULL AND id_shop IS NULL';
|
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)
|
public function getWebserviceObjectList($sql_join, $sql_filter, $sql_sort, $sql_limit)
|
||||||
{
|
{
|
||||||
$query = '
|
$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.'
|
'.$sql_join.'
|
||||||
WHERE id_configuration NOT IN
|
WHERE id_configuration NOT IN
|
||||||
( SELECT id_configuration
|
( SELECT id_configuration
|
||||||
FROM '._DB_PREFIX_.$this->def['table'].'_lang
|
FROM '._DB_PREFIX_.bqSQL($this->def['table']).'_lang
|
||||||
) '.$sql_filter.'
|
) '.$sql_filter.'
|
||||||
'.($sql_sort != '' ? $sql_sort : '').'
|
'.($sql_sort != '' ? $sql_sort : '').'
|
||||||
'.($sql_limit != '' ? $sql_limit : '').'
|
'.($sql_limit != '' ? $sql_limit : '').'
|
||||||
|
|||||||
@@ -802,10 +802,6 @@ class ShopCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public static function setContext($type, $id = null)
|
public static function setContext($type, $id = null)
|
||||||
{
|
{
|
||||||
// Always use global context for mono-shop mode
|
|
||||||
if (!Shop::isFeatureActive())
|
|
||||||
$type = self::CONTEXT_ALL;
|
|
||||||
|
|
||||||
switch ($type)
|
switch ($type)
|
||||||
{
|
{
|
||||||
case self::CONTEXT_ALL :
|
case self::CONTEXT_ALL :
|
||||||
@@ -845,8 +841,10 @@ class ShopCore extends ObjectModel
|
|||||||
*
|
*
|
||||||
* @return int
|
* @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;
|
return self::$context_id_shop;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -855,8 +853,11 @@ class ShopCore extends ObjectModel
|
|||||||
*
|
*
|
||||||
* @return int
|
* @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;
|
return self::$context_id_shop_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -950,7 +951,7 @@ class ShopCore extends ObjectModel
|
|||||||
static $feature_active = null;
|
static $feature_active = null;
|
||||||
|
|
||||||
if ($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;
|
return $feature_active;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user