From ae30a62055efffa007160d2845dc5cb3644cc322 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 2 Jun 2015 10:23:40 +0200 Subject: [PATCH] ConfigController: Add tab for the user group backend configuration refs #8826 --- application/controllers/ConfigController.php | 20 +++++--- .../UsergroupbackendController.php | 47 +++++++++++++++---- library/Icinga/Web/Menu.php | 5 -- 3 files changed, 53 insertions(+), 19 deletions(-) diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index 6b7dbc705..ce020733b 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -46,6 +46,14 @@ class ConfigController extends Controller )); $allowedActions[] = 'general'; } + if ($auth->hasPermission('config/application/resources')) { + $tabs->add('resource', array( + 'title' => $this->translate('Configure which resources are being utilized by Icinga Web 2'), + 'label' => $this->translate('Resources'), + 'url' => 'config/resource' + )); + $allowedActions[] = 'resource'; + } if ($auth->hasPermission('config/application/userbackend')) { $tabs->add('userbackend', array( 'title' => $this->translate('Configure how users authenticate with and log into Icinga Web 2'), @@ -54,13 +62,13 @@ class ConfigController extends Controller )); $allowedActions[] = 'userbackend'; } - if ($auth->hasPermission('config/application/resources')) { - $tabs->add('resource', array( - 'title' => $this->translate('Configure which resources are being utilized by Icinga Web 2'), - 'label' => $this->translate('Resources'), - 'url' => 'config/resource' + if ($auth->hasPermission('config/application/usergroupbackend')) { + $tabs->add('usergroupbackend', array( + 'title' => $this->translate('Configure how users are associated with groups by Icinga Web 2'), + 'label' => $this->translate('User Groups'), + 'url' => 'usergroupbackend/list' )); - $allowedActions[] = 'resource'; + $allowedActions[] = 'usergroupbackend'; } $this->firstAllowedAction = array_shift($allowedActions); } diff --git a/application/controllers/UsergroupbackendController.php b/application/controllers/UsergroupbackendController.php index e03880637..cdb6826be 100644 --- a/application/controllers/UsergroupbackendController.php +++ b/application/controllers/UsergroupbackendController.php @@ -37,14 +37,7 @@ class UsergroupbackendController extends Controller public function listAction() { $this->view->backendNames = Config::app('groups')->keys(); - $this->getTabs()->add( - 'usergroupbackend/list', - array( - 'title' => $this->translate('List all user group backends'), - 'label' => $this->translate('User group backends'), - 'url' => 'usergroupbackend/list' - ) - )->activate('usergroupbackend/list'); + $this->createListTabs()->activate('usergroupbackend'); } /** @@ -149,4 +142,42 @@ class UsergroupbackendController extends Controller $this->view->form = $form; $this->render('form'); } + + /** + * Create the tabs for the application configuration + */ + protected function createListTabs() + { + $tabs = $this->getTabs(); + if ($this->hasPermission('config/application/general')) { + $tabs->add('general', array( + 'title' => $this->translate('Adjust the general configuration of Icinga Web 2'), + 'label' => $this->translate('General'), + 'url' => 'config/general' + )); + } + if ($this->hasPermission('config/application/resources')) { + $tabs->add('resource', array( + 'title' => $this->translate('Configure which resources are being utilized by Icinga Web 2'), + 'label' => $this->translate('Resources'), + 'url' => 'config/resource' + )); + } + if ($this->hasPermission('config/application/userbackend')) { + $tabs->add('userbackend', array( + 'title' => $this->translate('Configure how users authenticate with and log into Icinga Web 2'), + 'label' => $this->translate('Authentication'), + 'url' => 'config/userbackend' + )); + } + if ($this->hasPermission('config/application/usergroupbackend')) { + $tabs->add('usergroupbackend', array( + 'title' => $this->translate('Configure how users are associated with groups by Icinga Web 2'), + 'label' => $this->translate('User Groups'), + 'url' => 'usergroupbackend/list' + )); + } + + return $tabs; + } } diff --git a/library/Icinga/Web/Menu.php b/library/Icinga/Web/Menu.php index ef27204c8..63d92fc9f 100644 --- a/library/Icinga/Web/Menu.php +++ b/library/Icinga/Web/Menu.php @@ -259,11 +259,6 @@ class Menu implements RecursiveIterator 'permission' => 'config/authentication/*', 'priority' => 820 )); - $section->add(t('UserGroupBackends'), array( - 'url' => 'usergroupbackend/list', - 'permission' => 'config/application/usergroupbackend', - 'priority' => 830 - )); $section->add(t('Modules'), array( 'url' => 'config/modules', 'permission' => 'config/modules',