// Force install of modules in global context

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8178 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2011-08-24 15:04:50 +00:00
parent 829ad87f8a
commit 89fcb38dc7
3 changed files with 47 additions and 5 deletions
+9 -1
View File
@@ -85,4 +85,12 @@ if (Shop::isMultiShopActivated() && Tools::getValue('setShopContext') !== false)
$context->currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$context->country = $defaultCountry;
$context->shop = new Shop(Shop::getContextID());
$shopID = '';
if ($context->cookie->shopContext)
{
$split = explode('-', $context->cookie->shopContext);
if (count($split) == 2 && $split[0] == 's')
$shopID = (int)$split[1];
}
$context->shop = new Shop($shopID);
+14
View File
@@ -288,6 +288,14 @@ class AdminModules extends AdminTab
$this->_errors[] = Tools::displayError('This module is already uninstalled:').' '.$module->name;
else
{
// If we install a module, force temporary global context for multishop
if (Shop::isMultiShopActivated() && Context::shop() != Shop::CONTEXT_ALL)
{
Context::getContext()->tmpOldShop = clone(Context::getContext()->shop);
Context::getContext()->shop = new Shop();
Configuration::updateValue('RSS_FEED_TITLE', 'lol');
}
if (((method_exists($module, $method) && ($echo = $module->{$method}())) || ($echo = ' ')) AND $key == 'configure' AND Module::isInstalled($module->name))
{
$backlink = self::$currentIndex.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name;
@@ -335,6 +343,12 @@ class AdminModules extends AdminTab
$return = ($method == 'install' ? 12 : 13);
elseif ($echo === false)
$module_errors[] = $name;
if (Shop::isMultiShopActivated() && Context::shop() != Shop::CONTEXT_ALL && isset(Context::getContext()->tmpOldShop))
{
Context::getContext()->shop = clone(Context::getContext()->tmpOldShop);
unset(Context::getContext()->tmpOldShop);
}
}
if ($key != 'configure' AND isset($_GET['bpay']))
Tools::redirectAdmin('index.php?tab=AdminPayment&token='.Tools::getAdminToken('AdminPayment'.(int)(Tab::getIdFromClassName('AdminPayment')).(int)$this->context->employee->id));
+24 -4
View File
@@ -535,7 +535,28 @@ class ShopCore extends ObjectModel
*/
public static function getContext($type = null)
{
static $executed = false, $shopID = 0, $shopGroupID = 0;
$context = Context::getContext();
if (!isset($context->shop))
return ($type == 'shop' || $type == 'group') ? '' : array('', '');
$shopID = $context->shop->id;
$shopGroupID = $context->shop->id_group_shop;
if (defined('PS_ADMIN_DIR'))
{
if (!isset($context->cookie) || !$context->cookie->shopContext)
return ($type == 'shop' || $type == 'group') ? '' : array('', '');
// Parse shopContext cookie value (E.g. s-2, g-4)
$split = explode('-', $context->cookie->shopContext);
if (count($split) == 2 && $split[0] == 'g')
$shopGroupID = (int)$split[1];
}
if ($type == 'shop')
return $shopID;
else if ($type == 'group')
return $shopGroupID;
return array($shopID, $shopGroupID);
if (!$executed)
{
@@ -547,7 +568,7 @@ class ShopCore extends ObjectModel
return ($type == 'shop' || $type == 'group') ? '' : array('', '');
// Parse shopContext cookie value (E.g. s-2, g-4)
$split = explode('-', Context::getContext()->cookie->shopContext);
$split = explode('-', $context->cookie->shopContext);
if (count($split) == 2)
{
if ($split[0] == 's')
@@ -561,8 +582,7 @@ class ShopCore extends ObjectModel
}
else
{
if (!isset($context->shop))
return ($type == 'shop' || $type == 'group') ? '' : array('', '');
$shopID = (int)$context->shop->getID();
$shopGroupID = (int)$context->shop->id_group_shop;
}