[-] BO : fixed charts and grids in multishop #PSCFV-8978
This commit is contained in:
+45
-2
@@ -37,7 +37,6 @@ $height = Tools::getValue('height');
|
||||
$id_employee = Tools::getValue('id_employee');
|
||||
$id_lang = Tools::getValue('id_lang');
|
||||
|
||||
|
||||
if (!isset($cookie->id_employee) || !$cookie->id_employee || $cookie->id_employee != $id_employee)
|
||||
die(Tools::displayError());
|
||||
|
||||
@@ -47,6 +46,51 @@ if (!Validate::isModuleName($module))
|
||||
if (!Tools::file_exists_cache($module_path = dirname(__FILE__).'/../modules/'.$module.'/'.$module.'.php'))
|
||||
die(Tools::displayError());
|
||||
|
||||
$shop_id = '';
|
||||
Shop::setContext(Shop::CONTEXT_ALL);
|
||||
if (Context::getContext()->cookie->shopContext)
|
||||
{
|
||||
$split = explode('-', Context::getContext()->cookie->shopContext);
|
||||
if (count($split) == 2)
|
||||
{
|
||||
if ($split[0] == 'g')
|
||||
{
|
||||
if (Context::getContext()->employee->hasAuthOnShopGroup($split[1]))
|
||||
Shop::setContext(Shop::CONTEXT_GROUP, $split[1]);
|
||||
else
|
||||
{
|
||||
$shop_id = Context::getContext()->employee->getDefaultShopID();
|
||||
Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
|
||||
}
|
||||
}
|
||||
else if (Shop::getShop($split[1]) && Context::getContext()->employee->hasAuthOnShop($split[1]))
|
||||
{
|
||||
$shop_id = $split[1];
|
||||
Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$shop_id = Context::getContext()->employee->getDefaultShopID();
|
||||
Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check multishop context and set right context if need
|
||||
if (Shop::getContext())
|
||||
{
|
||||
if (Shop::getContext() == Shop::CONTEXT_SHOP && !Shop::CONTEXT_SHOP)
|
||||
Shop::setContext(Shop::CONTEXT_GROUP, Shop::getContextShopGroupID());
|
||||
if (Shop::getContext() == Shop::CONTEXT_GROUP && !Shop::CONTEXT_GROUP)
|
||||
Shop::setContext(Shop::CONTEXT_ALL);
|
||||
}
|
||||
|
||||
// Replace existing shop if necessary
|
||||
if (!$shop_id)
|
||||
Context::getContext()->shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
|
||||
elseif (Context::getContext()->shop->id != $shop_id)
|
||||
Context::getContext()->shop = new Shop($shop_id);
|
||||
|
||||
require_once($module_path);
|
||||
|
||||
$graph = new $module();
|
||||
@@ -57,4 +101,3 @@ if ($option)
|
||||
|
||||
$graph->create($render, $type, $width, $height, $layers);
|
||||
$graph->draw();
|
||||
|
||||
|
||||
@@ -50,6 +50,53 @@ if (!Validate::isModuleName($module))
|
||||
if (!Tools::file_exists_cache($module_path = dirname(__FILE__).'/../modules/'.$module.'/'.$module.'.php'))
|
||||
die(Tools::displayError());
|
||||
|
||||
|
||||
$shop_id = '';
|
||||
Shop::setContext(Shop::CONTEXT_ALL);
|
||||
if (Context::getContext()->cookie->shopContext)
|
||||
{
|
||||
$split = explode('-', Context::getContext()->cookie->shopContext);
|
||||
if (count($split) == 2)
|
||||
{
|
||||
if ($split[0] == 'g')
|
||||
{
|
||||
if (Context::getContext()->employee->hasAuthOnShopGroup($split[1]))
|
||||
Shop::setContext(Shop::CONTEXT_GROUP, $split[1]);
|
||||
else
|
||||
{
|
||||
$shop_id = Context::getContext()->employee->getDefaultShopID();
|
||||
Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
|
||||
}
|
||||
}
|
||||
else if (Shop::getShop($split[1]) && Context::getContext()->employee->hasAuthOnShop($split[1]))
|
||||
{
|
||||
$shop_id = $split[1];
|
||||
Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$shop_id = Context::getContext()->employee->getDefaultShopID();
|
||||
Shop::setContext(Shop::CONTEXT_SHOP, $shop_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check multishop context and set right context if need
|
||||
if (Shop::getContext())
|
||||
{
|
||||
if (Shop::getContext() == Shop::CONTEXT_SHOP && !Shop::CONTEXT_SHOP)
|
||||
Shop::setContext(Shop::CONTEXT_GROUP, Shop::getContextShopGroupID());
|
||||
if (Shop::getContext() == Shop::CONTEXT_GROUP && !Shop::CONTEXT_GROUP)
|
||||
Shop::setContext(Shop::CONTEXT_ALL);
|
||||
}
|
||||
|
||||
// Replace existing shop if necessary
|
||||
if (!$shop_id)
|
||||
Context::getContext()->shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
|
||||
elseif (Context::getContext()->shop->id != $shop_id)
|
||||
Context::getContext()->shop = new Shop($shop_id);
|
||||
|
||||
|
||||
require_once($module_path);
|
||||
|
||||
$grid = new $module();
|
||||
|
||||
Reference in New Issue
Block a user