[icinga-checkins] icinga.org: icingaweb2/feature/security-gui-5647: Security: Add action for removing roles

git at icinga.org git at icinga.org
Wed Nov 19 14:42:34 CET 2014


Module: icingaweb2
Branch: feature/security-gui-5647
Commit: f7076816eb14bfa46a69a9462b9abf732e3ae9c3
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=f7076816eb14bfa46a69a9462b9abf732e3ae9c3

Author: Eric Lippmann <eric.lippmann at netways.de>
Date:   Wed Nov 19 14:40:49 2014 +0100

Security: Add action for removing roles

refs #5647

---

 application/controllers/SecurityController.php |   21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/application/controllers/SecurityController.php b/application/controllers/SecurityController.php
index 362442d..57f2285 100644
--- a/application/controllers/SecurityController.php
+++ b/application/controllers/SecurityController.php
@@ -89,19 +89,19 @@ class SecurityController extends ActionController
         $this->view->form = $role;
     }
 
-    public function removePermissionAction()
+    public function removeRoleAction()
     {
-        $name = $this->_request->getParam('permission');
+        $name = $this->_request->getParam('role');
         if (empty($name)) {
             throw new Zend_Controller_Action_Exception(
-                sprintf($this->translate('Required parameter \'%s\' missing'), 'permission'),
+                sprintf($this->translate('Required parameter \'%s\' missing'), 'role'),
                 400
             );
         }
-        $permission = new PermissionForm();
+        $role = new RoleForm();
         try {
-            $permission
-                ->setIniConfig(Config::app('permissions', true))
+            $role
+                ->setIniConfig(Config::app('roles', true))
                 ->load($name);
         } catch (InvalidArgumentException $e) {
             throw new Zend_Controller_Action_Exception(
@@ -110,21 +110,22 @@ class SecurityController extends ActionController
             );
         }
         $confirmation = new ConfirmRemovalForm(array(
-            'onSuccess' => function (Request $request, ConfirmRemovalForm $confirmation) use ($name, $permission) {
+            'onSuccess' => function (ConfirmRemovalForm $confirmation) use ($name, $role) {
                 try {
-                    $permission->remove($name);
+                    $role->remove($name);
                 } catch (InvalidArgumentException $e) {
                     Notification::error($e->getMessage());
                     return false;
                 }
-                if ($permission->save()) {
-                    Notification::success(sprintf(t('Permission \'%s\' has been successfully removed'), $name));
+                if ($role->save()) {
+                    Notification::success(t('Role removed'));
                     return true;
                 }
                 return false;
             }
         ));
         $confirmation
+            ->setSubmitLabel($this->translate('Remove Role'))
             ->setRedirectUrl('security')
             ->handleRequest();
         $this->view->name = $name;



More information about the icinga-checkins mailing list