From 54b39b1eaa82a70bd1d70e5cce65cf4094c7ce4c Mon Sep 17 00:00:00 2001 From: rMalie Date: Mon, 23 Apr 2012 12:25:06 +0000 Subject: [PATCH] // Fix BO connection bug with employees auth git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14808 b9a71923-0436-4b27-9f14-aed3839534dd --- admin-dev/init.php | 54 +++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/admin-dev/init.php b/admin-dev/init.php index 86b9bb917..8773ff529 100644 --- a/admin-dev/init.php +++ b/admin-dev/init.php @@ -101,41 +101,45 @@ try $context->currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); - $shop_id = ''; - Shop::setContext(Shop::CONTEXT_ALL); - if ($this->context->cookie->shopContext) + + if ($context->employee->isLoggedBack()) { - $split = explode('-', $this->context->cookie->shopContext); - if (count($split) == 2) + $shop_id = ''; + Shop::setContext(Shop::CONTEXT_ALL); + if ($context->cookie->shopContext) { - if ($split[0] == 'g') + $split = explode('-', $context->cookie->shopContext); + if (count($split) == 2) { - if ($this->context->employee->hasAuthOnShopGroup($split[1])) - Shop::setContext(Shop::CONTEXT_GROUP, $split[1]); + if ($split[0] == 'g') + { + if ($context->employee->hasAuthOnShopGroup($split[1])) + Shop::setContext(Shop::CONTEXT_GROUP, $split[1]); + else + { + $shop_id = $context->employee->getDefaultShopID(); + Shop::setContext(Shop::CONTEXT_SHOP, $shop_id); + } + } + else if ($context->employee->hasAuthOnShop($split[1])) + { + $shop_id = $split[1]; + Shop::setContext(Shop::CONTEXT_SHOP, $shop_id); + } else { - $shop_id = $this->context->employee->getDefaultShopID(); + $shop_id = $context->employee->getDefaultShopID(); Shop::setContext(Shop::CONTEXT_SHOP, $shop_id); } } - else if ($this->context->employee->hasAuthOnShop($split[1])) - { - $shop_id = $split[1]; - Shop::setContext(Shop::CONTEXT_SHOP, $shop_id); - } - else - { - $shop_id = $this->context->employee->getDefaultShopID(); - Shop::setContext(Shop::CONTEXT_SHOP, $shop_id); - } } - } - // Replace existing shop if necessary - if (!$shop_id) - $context->shop = new Shop(Configuration::get('PS_SHOP_DEFAULT')); - else if ($context->shop->id != $shop_id) - $context->shop = new Shop($shop_id); + // Replace existing shop if necessary + if (!$shop_id) + $context->shop = new Shop(Configuration::get('PS_SHOP_DEFAULT')); + else if ($context->shop->id != $shop_id) + $context->shop = new Shop($shop_id); + } } catch(PrestaShopException $e) {