// Fix BO connection bug with employees auth

This commit is contained in:
rMalie committed 2012-04-23 12:25:06 +00:00
1 parent beaf5749a7
commit b05aeaac13
1 file changed
+29 -25
+29 -25
View File
@@ -101,41 +101,45 @@ try
$context->currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); $context->currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$shop_id = '';
Shop::setContext(Shop::CONTEXT_ALL); if ($context->employee->isLoggedBack())
if ($this->context->cookie->shopContext)
{ {
$split = explode('-', $this->context->cookie->shopContext); $shop_id = '';
if (count($split) == 2) 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])) if ($split[0] == 'g')
Shop::setContext(Shop::CONTEXT_GROUP, $split[1]); {
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 else
{ {
$shop_id = $this->context->employee->getDefaultShopID(); $shop_id = $context->employee->getDefaultShopID();
Shop::setContext(Shop::CONTEXT_SHOP, $shop_id); 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 // Replace existing shop if necessary
if (!$shop_id) if (!$shop_id)
$context->shop = new Shop(Configuration::get('PS_SHOP_DEFAULT')); $context->shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
else if ($context->shop->id != $shop_id) else if ($context->shop->id != $shop_id)
$context->shop = new Shop($shop_id); $context->shop = new Shop($shop_id);
}
} }
catch(PrestaShopException $e) catch(PrestaShopException $e)
{ {