diff --git a/plugins/Tags/templates/Tags/index.php b/plugins/Tags/templates/Tags/index.php index 5f2fded..345809b 100644 --- a/plugins/Tags/templates/Tags/index.php +++ b/plugins/Tags/templates/Tags/index.php @@ -10,7 +10,8 @@ echo $this->element('genericElements/IndexTable/index_table', [ 'data' => [ 'type' => 'simple', 'text' => __('Add tag'), - 'popover_url' => '/tags/add' + 'popover_url' => '/tags/add', + 'requirement' => !empty($loggedUser['role']['perm_admin']), ] ] ], @@ -65,12 +66,14 @@ echo $this->element('genericElements/IndexTable/index_table', [ [ 'open_modal' => '/tags/edit/[onclick_params_data_path]', 'modal_params_data_path' => 'id', - 'icon' => 'edit' + 'icon' => 'edit', + 'requirement' => !empty($loggedUser['role']['perm_admin']), ], [ 'open_modal' => '/tags/delete/[onclick_params_data_path]', 'modal_params_data_path' => 'id', - 'icon' => 'trash' + 'icon' => 'trash', + 'requirement' => !empty($loggedUser['role']['perm_admin']), ], ] ] diff --git a/src/Controller/Component/Navigation/Tags.php b/src/Controller/Component/Navigation/Tags.php index 74c5735..0af9849 100644 --- a/src/Controller/Component/Navigation/Tags.php +++ b/src/Controller/Component/Navigation/Tags.php @@ -5,4 +5,21 @@ require_once(APP . 'Controller' . DS . 'Component' . DS . 'Navigation' . DS . 'b class TagsNavigation extends BaseNavigation { + public function addLinks() + { + $controller = 'Tags'; + if (empty($this->viewVars['loggedUser']['role']['perm_admin'])) { + $this->bcf->removeLink($controller, 'view', $controller, 'edit'); + $this->bcf->removeLink($controller, 'edit', $controller, 'edit'); + } + } + + public function addActions() + { + $controller = 'Tags'; + if (empty($this->viewVars['loggedUser']['role']['perm_admin'])) { + $this->bcf->removeAction($controller, 'view', $controller, 'delete'); + $this->bcf->removeAction($controller, 'edit', $controller, 'delete'); + } + } }