From 2164fcf4b4944f74a940f57e7ad39e4dbc156c6f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 26 May 2015 10:12:25 +0200 Subject: [PATCH] GroupController: Extend AuthBackendController refs #8826 --- application/controllers/GroupController.php | 94 +-------------------- 1 file changed, 2 insertions(+), 92 deletions(-) diff --git a/application/controllers/GroupController.php b/application/controllers/GroupController.php index ddb4d1e84..eb5d5df8f 100644 --- a/application/controllers/GroupController.php +++ b/application/controllers/GroupController.php @@ -2,21 +2,17 @@ /* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ use \Exception; -use \Zend_Controller_Action_Exception; -use Icinga\Application\Config; use Icinga\Application\Logger; -use Icinga\Authentication\UserGroup\UserGroupBackend; -use Icinga\Authentication\UserGroup\UserGroupBackendInterface; use Icinga\Data\Reducible; use Icinga\Data\Filter\Filter; use Icinga\Forms\Config\UserGroupForm; -use Icinga\Web\Controller; +use Icinga\Web\Controller\AuthBackendController; use Icinga\Web\Form; use Icinga\Web\Notification; use Icinga\Web\Url; use Icinga\Web\Widget; -class GroupController extends Controller +class GroupController extends AuthBackendController { /** * Redirect to this controller's list action @@ -275,92 +271,6 @@ class GroupController extends Controller $form->handleRequest(); } - /** - * Return all user group backends implementing the given interface - * - * @param string $interface The class path of the interface, or null if no interface check should be made - * - * @return array - */ - protected function loadUserGroupBackends($interface = null) - { - $backends = array(); - foreach (Config::app('groups') as $backendName => $backendConfig) { - $candidate = UserGroupBackend::create($backendName, $backendConfig); - if (! $interface || $candidate instanceof $interface) { - $backends[] = $candidate; - } - } - - return $backends; - } - - /** - * Return the given user group backend or the first match in order - * - * @param string $name The name of the backend, or null in case the first match should be returned - * @param string $interface The interface the backend should implement, no interface check if null - * - * @return UserGroupBackendInterface - * - * @throws Zend_Controller_Action_Exception In case the given backend name is invalid - */ - protected function getUserGroupBackend($name = null, $interface = 'Icinga\Data\Selectable') - { - if ($name !== null) { - $config = Config::app('groups'); - if (! $config->hasSection($name)) { - $this->httpNotFound(sprintf($this->translate('User group backend "%s" not found'), $name)); - } else { - $backend = UserGroupBackend::create($name, $config->getSection($name)); - if ($interface && !$backend instanceof $interface) { - $interfaceParts = explode('\\', strtolower($interface)); - throw new Zend_Controller_Action_Exception( - sprintf( - $this->translate('User group backend "%s" is not %s'), - $name, - array_pop($interfaceParts) - ), - 400 - ); - } - } - } else { - $backends = $this->loadUserGroupBackends($interface); - $backend = array_shift($backends); - } - - return $backend; - } - - /** - * Create the tabs to list users and groups - */ - protected function createListTabs() - { - $tabs = $this->getTabs(); - $tabs->add( - 'user/list', - array( - 'title' => $this->translate('List users of authentication backends'), - 'label' => $this->translate('Users'), - 'icon' => 'user', - 'url' => 'user/list' - ) - ); - $tabs->add( - 'group/list', - array( - 'title' => $this->translate('List groups of user group backends'), - 'label' => $this->translate('Groups'), - 'icon' => 'users', - 'url' => 'group/list' - ) - ); - - return $tabs; - } - /** * Create the tabs to display when showing a group *