From bd1892578d9f8812ea47e2ffc23bc405681616c7 Mon Sep 17 00:00:00 2001 From: rMalie Date: Mon, 23 Apr 2012 09:38:24 +0000 Subject: [PATCH] // Fix bug on auths for sub employees #PSFV-849 --- admin-dev/init.php | 33 +++---- .../employees/helpers/form/form.tpl | 7 +- .../template/helpers/form/assoshop.tpl | 1 - classes/Employee.php | 90 +++++++++---------- classes/ObjectModel.php | 18 ++++ classes/controller/AdminController.php | 33 +++---- classes/shop/Shop.php | 2 +- 7 files changed, 104 insertions(+), 80 deletions(-) diff --git a/admin-dev/init.php b/admin-dev/init.php index 7c85cd355..86b9bb917 100644 --- a/admin-dev/init.php +++ b/admin-dev/init.php @@ -103,30 +103,33 @@ try $shop_id = ''; Shop::setContext(Shop::CONTEXT_ALL); - if ($context->cookie->shopContext) + if ($this->context->cookie->shopContext) { - $split = explode('-', $context->cookie->shopContext); + $split = explode('-', $this->context->cookie->shopContext); if (count($split) == 2) { if ($split[0] == 'g') - Shop::setContext(Shop::CONTEXT_GROUP, $split[1]); + { + if ($this->context->employee->hasAuthOnShopGroup($split[1])) + Shop::setContext(Shop::CONTEXT_GROUP, $split[1]); + else + { + $shop_id = $this->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::setContext(Shop::CONTEXT_SHOP, $split[1]); - $shop_id = $split[1]; + $shop_id = $this->context->employee->getDefaultShopID(); + Shop::setContext(Shop::CONTEXT_SHOP, $shop_id); } } } - else if ($context->employee->id_profile == _PS_ADMIN_PROFILE_) - $shop_id = ''; - else if (Shop::getTotalShops(false) != Employee::getTotalEmployeeShopById((int)$context->employee->id)) - { - $shops = Employee::getEmployeeShopById((int)$context->employee->id); - if (count($shops)) - $shop_id = (int)$shops[0]; - } - else - Employee::getEmployeeShopAccess((int)$context->employee->id); // Replace existing shop if necessary if (!$shop_id) diff --git a/admin-dev/themes/default/template/controllers/employees/helpers/form/form.tpl b/admin-dev/themes/default/template/controllers/employees/helpers/form/form.tpl index 4835e9f21..02a8693d3 100644 --- a/admin-dev/themes/default/template/controllers/employees/helpers/form/form.tpl +++ b/admin-dev/themes/default/template/controllers/employees/helpers/form/form.tpl @@ -93,12 +93,13 @@ function ifSuperAdmin(el) { var val = $(el).val(); - if(val == {$smarty.const._PS_ADMIN_PROFILE_}) + + if (!val || val == {$smarty.const._PS_ADMIN_PROFILE_}) { - $('.assoShop input[type=checkbox]').attr('disabled', 'disabled'); + $('.assoShop input[type=checkbox]').attr('disabled', true); $('.assoShop input[type=checkbox]').attr('checked', 'checked'); } else - $('.assoShop input[type=checkbox]').attr('disabled', ''); + $('.assoShop input[type=checkbox]').attr('disabled', false); } {/block} diff --git a/admin-dev/themes/default/template/helpers/form/assoshop.tpl b/admin-dev/themes/default/template/helpers/form/assoshop.tpl index 9c33ce5ba..8331ea99f 100644 --- a/admin-dev/themes/default/template/helpers/form/assoshop.tpl +++ b/admin-dev/themes/default/template/helpers/form/assoshop.tpl @@ -26,7 +26,6 @@