diff --git a/controllers/admin/AdminHomeController.php b/controllers/admin/AdminHomeController.php index df52aea06..a5d4f1494 100644 --- a/controllers/admin/AdminHomeController.php +++ b/controllers/admin/AdminHomeController.php @@ -181,53 +181,64 @@ class AdminHomeControllerCore extends AdminController protected function getQuickLinks() { - $quick_links['first'] = array( - 'href' => $this->context->link->getAdminLink('AdminStats').'&module=statsbestproducts', - 'title' => $this->l('Products sold recently'), - 'description' => $this->l('Create a new category and organize your catalog.'), - ); - - $quick_links['second'] = array( - 'href' => $this->context->link->getAdminLink('AdminOrders').'&addorder', - 'title' => $this->l('New order'), - 'description' => $this->l('Fill your catalog with new products.'), - ); - - $quick_links['third'] = array( - 'href' => $this->context->link->getAdminLink('AdminSpecificPriceRule').'&addspecific_price_rule', - 'title' => $this->l('New Price Rule for catalog'), - 'description' => $this->l('Monitor your activity with a thorough analysis of your shop.'), - ); - - $quick_links['fourth'] = array( - 'href' => $this->context->link->getAdminLink('AdminProducts').'&addproduct', - 'title' => $this->l('New Product'), - 'description' => $this->l('Add a new employee account and discharge a part of your duties as shop owner.'), - ); + $quick_links = array(); - $quick_links['fifth'] = array( - 'href' => $this->context->link->getAdminLink('AdminModules').'&addcategory', - 'title' => $this->l('New module'), - 'description' => $this->l('Create a new category and organize your catalog.'), - ); + $profile_access = Profile::getProfileAccesses($this->context->employee->id_profile); + if ($profile_access[(int)Tab::getIdFromClassName('AdminStats')]['view']) + $quick_links['first'] = array( + 'href' => $this->context->link->getAdminLink('AdminStats').'&module=statsbestproducts', + 'title' => $this->l('Products sold recently'), + 'description' => $this->l('Create a new category and organize your catalog.'), + ); + + if ($profile_access[(int)Tab::getIdFromClassName('AdminOrders')]['add']) + $quick_links['second'] = array( + 'href' => $this->context->link->getAdminLink('AdminOrders').'&addorder', + 'title' => $this->l('New order'), + 'description' => $this->l('Fill your catalog with new products.'), + ); + + if ($profile_access[(int)Tab::getIdFromClassName('AdminSpecificPriceRule')]['add']) + $quick_links['third'] = array( + 'href' => $this->context->link->getAdminLink('AdminSpecificPriceRule').'&addspecific_price_rule', + 'title' => $this->l('New Price Rule for catalog'), + 'description' => $this->l('Monitor your activity with a thorough analysis of your shop.'), + ); + + if ($profile_access[(int)Tab::getIdFromClassName('AdminProducts')]['add']) + $quick_links['fourth'] = array( + 'href' => $this->context->link->getAdminLink('AdminProducts').'&addproduct', + 'title' => $this->l('New Product'), + 'description' => $this->l('Add a new employee account and discharge a part of your duties as shop owner.'), + ); - $quick_links['sixth'] = array( - 'href' => $this->context->link->getAdminLink('AdminCartRules').'&addcart_rule', - 'title' => $this->l('New Price Rule for cart'), - 'description' => $this->l('Fill your catalog with new products.'), - ); + if ($profile_access[(int)Tab::getIdFromClassName('AdminModules')]['view']) + $quick_links['fifth'] = array( + 'href' => $this->context->link->getAdminLink('AdminModules'), + 'title' => $this->l('New module'), + 'description' => $this->l('Configure your modules.'), + ); + + if ($profile_access[(int)Tab::getIdFromClassName('AdminCartRules')]['add']) + $quick_links['sixth'] = array( + 'href' => $this->context->link->getAdminLink('AdminCartRules').'&addcart_rule', + 'title' => $this->l('New Price Rule for cart'), + 'description' => $this->l('Add new cart rule.'), + ); + + if ($profile_access[(int)Tab::getIdFromClassName('AdminCmsContent')]['add']) + $quick_links['seventh'] = array( + 'href' => $this->context->link->getAdminLink('AdminCmsContent').'&addcms', + 'title' => $this->l('New Page CMS'), + 'description' => $this->l('Add a new CMS page.'), + ); - $quick_links['seventh'] = array( - 'href' => $this->context->link->getAdminLink('AdminCmsContent').'&addcms', - 'title' => $this->l('New Page CMS'), - 'description' => $this->l('Monitor your activity with a thorough analysis of your shop.'), - ); - - $quick_links['eighth'] = array( - 'href' => $this->context->link->getAdminLink('AdminCarts').'&id_cart', - 'title' => $this->l('Abandoned Carts'), - 'description' => $this->l('Add a new employee account and discharge a part of your duties as shop owner.'), - ); + if ($profile_access[(int)Tab::getIdFromClassName('AdminCarts')]['view']) + $quick_links['eighth'] = array( + 'href' => $this->context->link->getAdminLink('AdminCarts').'&id_cart', + 'title' => $this->l('Abandoned Carts'), + 'description' => $this->l('View your customer carts.'), + ); return $quick_links; } diff --git a/controllers/admin/AdminWarehousesController.php b/controllers/admin/AdminWarehousesController.php index 67643ef6e..48da5b24a 100644 --- a/controllers/admin/AdminWarehousesController.php +++ b/controllers/admin/AdminWarehousesController.php @@ -81,10 +81,6 @@ class AdminWarehousesControllerCore extends AdminController */ public function renderList() { - // Checks access - if (!($this->tabAccess['add'] === '1')) - unset($this->toolbar_btn['new']); - // removes links on rows $this->list_no_link = true; @@ -474,17 +470,25 @@ class AdminWarehousesControllerCore extends AdminController } } } - - /** - * Checks access of the employee - */ - public function processCheckAccess() + + public function initContent() { - if (Tools::isSubmit('submitAdd'.$this->table) && !($this->tabAccess['add'] === '1')) + if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) { - $this->errors[] = Tools::displayError('You do not have the required permissions to add warehouses.'); - return parent::postProcess(); + $this->warnings[md5('PS_ADVANCED_STOCK_MANAGEMENT')] = $this->l('You need to activate advanced stock management prior to use this feature.'); + return false; } + parent::initContent(); + } + + public function initProcess() + { + if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) + { + $this->warnings[md5('PS_ADVANCED_STOCK_MANAGEMENT')] = $this->l('You need to activate advanced stock management prior to use this feature.'); + return false; + } + parent::initProcess(); } /** @@ -595,15 +599,5 @@ class AdminWarehousesControllerCore extends AdminController return; $obj->resetStockAvailable(); } - /** - * @see AdminController::initProcess() - */ - public function initProcess() - { - // checks access - $this->processCheckAccess(); - - return parent::initprocess(); - } }