diff --git a/admin-dev/themes/default/template/header.tpl b/admin-dev/themes/default/template/header.tpl index aa1d5265b..5899a52fb 100644 --- a/admin-dev/themes/default/template/header.tpl +++ b/admin-dev/themes/default/template/header.tpl @@ -93,7 +93,7 @@ } - + {if $display_header}
{l s='Loading...'}
diff --git a/classes/Profile.php b/classes/Profile.php index cd8ad2533..4d314ca91 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -110,17 +110,25 @@ class ProfileCore extends ObjectModel return (isset($accesses[$id_tab]) ? $accesses[$id_tab] : false); } - public static function getProfileAccesses($id_profile) + public static function getProfileAccesses($id_profile, $type = 'id_tab') { + if (!in_array($type, array('id_tab', 'class_name'))) + return false; + if (!isset(self::$_cache_accesses[$id_profile])) + self::$_cache_accesses[$id_profile] = array(); + + if (!isset(self::$_cache_accesses[$id_profile][$type])) { + self::$_cache_accesses[$id_profile][$type] = array(); // Super admin profile has full auth if ($id_profile == _PS_ADMIN_PROFILE_) { foreach (Tab::getTabs(Context::getContext()->language->id) as $tab) - self::$_cache_accesses[$id_profile][$tab['id_tab']] = array( + self::$_cache_accesses[$id_profile][$type][$tab[$type]] = array( 'id_profile' => _PS_ADMIN_PROFILE_, 'id_tab' => $tab['id_tab'], + 'class_name' => $tab['class_name'], 'view' => '1', 'add' => '1', 'edit' => '1', @@ -131,19 +139,16 @@ class ProfileCore extends ObjectModel { $result = Db::getInstance()->executeS(' SELECT * - FROM `'._DB_PREFIX_.'access` + FROM `'._DB_PREFIX_.'access` a + LEFT JOIN `'._DB_PREFIX_.'tab` t ON t.id_tab = a.id_tab WHERE `id_profile` = '.(int)$id_profile); - self::$_cache_accesses[$id_profile] = array(); foreach ($result as $row) - { - if (!isset(self::$_cache_accesses[$id_profile][$row['id_tab']])) - self::$_cache_accesses[$id_profile][$row['id_tab']] = array(); - self::$_cache_accesses[$id_profile][$row['id_tab']] = $row; - } + self::$_cache_accesses[$id_profile][$type][$row[$type]] = $row; } } - return self::$_cache_accesses[$id_profile]; + + return self::$_cache_accesses[$id_profile][$type]; } } diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 07c35ffcf..df48d52d7 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -1270,9 +1270,39 @@ class AdminControllerCore extends Controller if (empty($sub_tabs)) unset($tabs[$index]); } + + if (Validate::isLoadedObject($this->context->employee)) + { + $accesses = Profile::getProfileAccesses($this->context->employee->id_profile, 'class_name'); - /* Hooks are volontary out the initialize array (need those variables already assigned) */ - $bo_color = empty($this->context->employee->bo_color) ? '#FFFFFF' : $this->context->employee->bo_color; + /* Hooks are volontary out the initialize array (need those variables already assigned) */ + $bo_color = empty($this->context->employee->bo_color) ? '#FFFFFF' : $this->context->employee->bo_color; + $this->context->smarty->assign(array( + 'autorefresh_notifications' => Configuration::get('PS_ADMIN_REFRESH_NOTIFICATION'), + 'help_box' => Configuration::get('PS_HELPBOX'), + 'round_mode' => Configuration::get('PS_PRICE_ROUND_MODE'), + 'brightness' => Tools::getBrightness($bo_color) < 128 ? 'white' : '#383838', + 'bo_width' => (int)$this->context->employee->bo_width, + 'bo_color' => isset($this->context->employee->bo_color) ? Tools::htmlentitiesUTF8($this->context->employee->bo_color) : null, + 'show_new_orders' => Configuration::get('PS_SHOW_NEW_ORDERS') && $accesses['AdminOrders']['view'], + 'show_new_customers' => Configuration::get('PS_SHOW_NEW_CUSTOMERS') && $accesses['AdminCustomers']['view'], + 'show_new_messages' => Configuration::get('PS_SHOW_NEW_MESSAGES') && $accesses['AdminCustomerThreads']['view'], + 'first_name' => Tools::substr($this->context->employee->firstname, 0, 1), + 'last_name' => htmlentities($this->context->employee->lastname, ENT_COMPAT, 'UTF-8'), + 'employee' => $this->context->employee, + 'search_type' => Tools::getValue('bo_search_type'), + 'bo_query' => Tools::safeOutput(Tools::stripslashes(Tools::getValue('bo_query'))), + 'quick_access' => $quick_access, + 'multi_shop' => Shop::isFeatureActive(), + 'shop_list' => Helper::renderShopList(), + 'shop' => $this->context->shop, + 'shop_group' => new ShopGroup((int)Shop::getContextShopGroupID()), + 'current_parent_id' => (int)Tab::getCurrentParentId(), + 'tabs' => $tabs, + 'is_multishop' => $is_multishop, + 'multishop_context' => $this->multishop_context, + )); + } $this->context->smarty->assign(array( 'img_dir' => _PS_IMG_, 'iso' => $this->context->language->iso_code, @@ -1280,35 +1310,14 @@ class AdminControllerCore extends Controller 'iso_user' => $this->context->language->iso_code, 'country_iso_code' => $this->context->country->iso_code, 'version' => _PS_VERSION_, - 'autorefresh_notifications' => Configuration::get('PS_ADMIN_REFRESH_NOTIFICATION'), - 'help_box' => Configuration::get('PS_HELPBOX'), - 'round_mode' => Configuration::get('PS_PRICE_ROUND_MODE'), - 'brightness' => Tools::getBrightness($bo_color) < 128 ? 'white' : '#383838', 'lang_iso' => $this->context->language->iso_code, 'link' => $this->context->link, - 'bo_width' => (int)$this->context->employee->bo_width, - 'bo_color' => isset($this->context->employee->bo_color) ? Tools::htmlentitiesUTF8($this->context->employee->bo_color) : null, 'shop_name' => Configuration::get('PS_SHOP_NAME'), - 'show_new_orders' => Configuration::get('PS_SHOW_NEW_ORDERS'), - 'show_new_customers' => Configuration::get('PS_SHOW_NEW_CUSTOMERS'), - 'show_new_messages' => Configuration::get('PS_SHOW_NEW_MESSAGES'), - 'first_name' => Tools::substr($this->context->employee->firstname, 0, 1), - 'last_name' => htmlentities($this->context->employee->lastname, ENT_COMPAT, 'UTF-8'), 'base_url' => $this->context->shop->getBaseURL(), - 'employee' => $this->context->employee, - 'search_type' => Tools::getValue('bo_search_type'), - 'bo_query' => Tools::safeOutput(Tools::stripslashes(Tools::getValue('bo_query'))), - 'quick_access' => $quick_access, - 'multi_shop' => Shop::isFeatureActive(), - 'shop_list' => Helper::renderShopList(), - 'shop' => $this->context->shop, - 'shop_group' => new ShopGroup((int)Shop::getContextShopGroupID()), 'tab' => $tab, 'current_parent_id' => (int)Tab::getCurrentParentId(), 'tabs' => $tabs, 'install_dir_exists' => file_exists(_PS_ADMIN_DIR_.'/../install'), - 'is_multishop' => $is_multishop, - 'multishop_context' => $this->multishop_context, 'pic_dir' => _THEME_PROD_PIC_DIR_, 'controller_name' => htmlentities(Tools::getValue('controller')), 'currentIndex' => self::$currentIndex