From 644b3a162827b1ba38b50c55cfed8a4604910bf1 Mon Sep 17 00:00:00 2001 From: Alexander Klimov <Alexander.Klimov@netways.de> Date: Fri, 25 Jul 2014 14:49:05 +0200 Subject: [PATCH] Make it possible to remove an authentication backend refs #6434 --- application/controllers/ConfigController.php | 22 ++++++++++--------- .../config/authentication/remove.phtml | 14 +++++------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index e56a8cdbe..2205bc4b2 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -366,23 +366,25 @@ class ConfigController extends BaseConfigController $configArray = IcingaConfig::app('authentication', true)->toArray(); $authBackend = $this->getParam('auth_backend'); - if (!isset($configArray[$authBackend])) { - Notification::error('Can\'t perform removal: Unknown Authentication Backend Provided'); - $this->render('authentication/remove'); - return; + if (false === array_key_exists($authBackend, $configArray)) { + $this->addErrorMessage( + $this->translate('Can\'t perform removal: Unknown authentication backend provided') + ); + $this->redirectNow('config/configurationerror'); } $form = new ConfirmRemovalForm(); - $form->setRequest($this->getRequest()); - $form->setRemoveTarget('auth_backend', $authBackend); + $request = $this->getRequest(); - if ($form->isSubmittedAndValid()) { + if ($request->isPost() && $form->isValid($request->getPost())) { unset($configArray[$authBackend]); if ($this->writeAuthenticationFile($configArray)) { - Notification::success('Authentication Backend "' . $authBackend . '" Removed'); - $this->redirectNow("config/authentication"); + Notification::success(sprintf( + $this->translate('Authentication Backend "%s" Removed'), + $authBackend + )); + $this->redirectNow('config/authentication'); } - return; } $this->view->form = $form; diff --git a/application/views/scripts/config/authentication/remove.phtml b/application/views/scripts/config/authentication/remove.phtml index ed478d24b..23b85f6d7 100644 --- a/application/views/scripts/config/authentication/remove.phtml +++ b/application/views/scripts/config/authentication/remove.phtml @@ -1,10 +1,8 @@ <h4> - <i class="icinga-icon-remove"></i> - Remove Backend "<?= $this->escape($this->name); ?>" + <?php printf( + $this->translate('Remove Backend "%s"'), + $this->escape($name) + ); ?> </h4> - -<?php if (isset($this->messageBox)): ?> - <?= $this->messageBox->render() ?> -<?php endif ?> - -<?= $this->form ?> \ No newline at end of file +<?= $messageBox ?> +<?= $form ?>