Example #1
0
 /**
  * Display a confirmation form to remove the instance identified by the 'instance' parameter
  */
 public function removeinstanceAction()
 {
     $config = $this->Config('instances');
     $form = new ConfirmRemovalForm(array('onSuccess' => function ($form) use($config) {
         $instanceName = $form->getRequest()->getQuery('instance');
         $configForm = new InstanceConfigForm();
         $configForm->setIniConfig($config);
         try {
             $configForm->remove($instanceName);
         } catch (InvalidArgumentException $e) {
             Notification::error($e->getMessage());
             return;
         }
         if ($configForm->save()) {
             Notification::success(sprintf($this->translate('Instance "%s" successfully removed.'), $instanceName));
         } else {
             return false;
         }
     }));
     $form->setTitle($this->translate('Remove Existing Instance'));
     $form->addDescription($this->translate('If you have still any environments or views referring to this instance, ' . 'you won\'t be able to send commands anymore after deletion.'));
     $form->addElement('note', 'question', array('value' => $this->translate('Are you sure you want to remove this instance?'), 'decorators' => array('ViewHelper', array('HtmlTag', array('tag' => 'p')))));
     $form->setRedirectUrl('monitoring/config');
     $form->handleRequest();
     $this->view->form = $form;
 }
 /**
  * Display a confirmation form to remove a resource
  */
 public function removeresourceAction()
 {
     $this->assertPermission('config/application/resources');
     $this->getTabs()->add('resources/remove', array('label' => $this->translate('Remove Resource'), 'url' => Url::fromRequest()))->activate('resources/remove');
     $form = new ConfirmRemovalForm(array('onSuccess' => function ($form) {
         $configForm = new ResourceConfigForm();
         $configForm->setIniConfig(Config::app('resources'));
         $resource = $form->getRequest()->getQuery('resource');
         try {
             $configForm->remove($resource);
         } catch (InvalidArgumentException $e) {
             Notification::error($e->getMessage());
             return false;
         }
         if ($configForm->save()) {
             Notification::success(sprintf(t('Resource "%s" has been successfully removed'), $resource));
         } else {
             return false;
         }
     }));
     $form->setRedirectUrl('config/resource');
     $form->handleRequest();
     // Check if selected resource is currently used for authentication
     $resource = $this->getRequest()->getQuery('resource');
     $authConfig = Config::app('authentication');
     foreach ($authConfig as $backendName => $config) {
         if ($config->get('resource') === $resource) {
             $form->addDescription(sprintf($this->translate('The resource "%s" is currently utilized for authentication by user backend "%s". ' . 'Removing the resource can result in noone being able to log in any longer.'), $resource, $backendName));
         }
     }
     $this->view->form = $form;
     $this->render('resource/remove');
 }
Example #3
0
 /**
  * Remove a role
  */
 public function removeAction()
 {
     $this->assertPermission('config/authentication/roles/remove');
     $name = $this->params->getRequired('role');
     $role = new RoleForm();
     try {
         $role->setIniConfig(Config::app('roles', true))->load($name);
     } catch (NotFoundError $e) {
         $this->httpNotFound($e->getMessage());
     }
     $confirmation = new ConfirmRemovalForm(array('onSuccess' => function (ConfirmRemovalForm $confirmation) use($name, $role) {
         try {
             $role->remove($name);
         } catch (NotFoundError $e) {
             Notification::error($e->getMessage());
             return false;
         }
         if ($role->save()) {
             Notification::success(t('Role removed'));
             return true;
         }
         return false;
     }));
     $confirmation->setSubmitLabel($this->translate('Remove Role'))->setRedirectUrl('role/list')->handleRequest();
     $this->renderForm($confirmation, $this->translate('Remove Role'));
 }
 public function removePaneAction()
 {
     $form = new ConfirmRemovalForm();
     $this->createTabs();
     $dashboard = $this->dashboard;
     if (!$this->_request->getParam('pane')) {
         throw new Zend_Controller_Action_Exception('Missing parameter "pane"', 400);
     }
     $pane = $this->_request->getParam('pane');
     $action = $this;
     $form->setOnSuccess(function (Form $form) use($dashboard, $pane, $action) {
         $pane = $dashboard->getPane($pane);
         $dashboard->removePane($pane->getTitle());
         $dashboardConfig = $dashboard->getConfig();
         try {
             $dashboardConfig->saveIni();
             Notification::success(t('Dashboard has been removed') . ': ' . $pane->getTitle());
         } catch (Exception $e) {
             $action->view->error = $e;
             $action->view->config = $dashboardConfig;
             $action->render('error');
             return false;
         }
         return true;
     });
     $form->setTitle($this->translate('Remove Dashboard'));
     $form->setRedirectUrl('dashboard/settings');
     $form->handleRequest();
     $this->view->pane = $pane;
     $this->view->form = $form;
 }
 /**
  * Remove a navigation item
  */
 public function removeAction()
 {
     $itemName = $this->params->getRequired('name');
     $itemType = $this->params->getRequired('type');
     $user = $this->Auth()->getUser();
     $navigationConfigForm = new NavigationConfigForm();
     $navigationConfigForm->setUser($user);
     $navigationConfigForm->setShareConfig(Config::navigation($itemType));
     $navigationConfigForm->setUserConfig(Config::navigation($itemType, $user->getUsername()));
     $form = new ConfirmRemovalForm();
     $form->setRedirectUrl('navigation');
     $form->setOnSuccess(function (ConfirmRemovalForm $form) use($itemName, $navigationConfigForm) {
         try {
             $itemConfig = $navigationConfigForm->delete($itemName);
         } catch (NotFoundError $e) {
             Notification::success(sprintf(t('Navigation Item "%s" not found. No action required'), $itemName));
             return true;
         } catch (Exception $e) {
             $form->error($e->getMessage());
             return false;
         }
         if ($navigationConfigForm->save()) {
             if ($itemConfig->type === 'menu-item') {
                 $form->getResponse()->setRerenderLayout();
             }
             Notification::success(sprintf(t('Navigation Item "%s" successfully removed'), $itemName));
             return true;
         }
         return false;
     });
     $form->handleRequest();
     $this->renderForm($form, $this->translate('Remove Navigation Item'));
 }
Example #6
0
 /**
  * Remove a command transport
  */
 public function removetransportAction()
 {
     $transportName = $this->params->getRequired('transport');
     $transportForm = new TransportConfigForm();
     $transportForm->setIniConfig($this->Config('commandtransports'));
     $form = new ConfirmRemovalForm();
     $form->setRedirectUrl('monitoring/config');
     $form->setTitle(sprintf($this->translate('Remove Command Transport %s'), $transportName));
     $form->info($this->translate('If you still have any environments or views referring to this transport, ' . 'you won\'t be able to send commands anymore after deletion.'), false);
     $form->setOnSuccess(function (ConfirmRemovalForm $form) use($transportName, $transportForm) {
         try {
             $transportForm->delete($transportName);
         } catch (Exception $e) {
             $form->error($e->getMessage());
             return false;
         }
         if ($transportForm->save()) {
             Notification::success(sprintf(t('Command transport "%s" successfully removed'), $transportName));
             return true;
         }
         return false;
     });
     $form->handleRequest();
     $this->view->form = $form;
     $this->render('form');
 }
 /**
  * Remove a user group backend
  */
 public function removeAction()
 {
     $backendName = $this->params->getRequired('backend');
     $backendForm = new UserGroupBackendForm();
     $backendForm->setIniConfig(Config::app('groups'));
     $form = new ConfirmRemovalForm();
     $form->setRedirectUrl('usergroupbackend/list');
     $form->setOnSuccess(function (ConfirmRemovalForm $form) use($backendName, $backendForm) {
         try {
             $backendForm->delete($backendName);
         } catch (Exception $e) {
             $form->error($e->getMessage());
             return false;
         }
         if ($backendForm->save()) {
             Notification::success(sprintf(t('User group backend "%s" successfully removed'), $backendName));
             return true;
         }
         return false;
     });
     $form->handleRequest();
     $this->renderForm($form, $this->translate('Remove User Group Backend'));
 }
Example #8
0
 /**
  * Remove a monitoring instance
  */
 public function removeinstanceAction()
 {
     $instanceName = $this->params->getRequired('instance');
     $instanceForm = new InstanceConfigForm();
     $instanceForm->setIniConfig($this->Config('instances'));
     $form = new ConfirmRemovalForm();
     $form->setRedirectUrl('monitoring/config');
     $form->setTitle(sprintf($this->translate('Remove Monitoring Instance %s'), $instanceName));
     $form->addDescription($this->translate('If you have still any environments or views referring to this instance, ' . 'you won\'t be able to send commands anymore after deletion.'));
     $form->setOnSuccess(function (ConfirmRemovalForm $form) use($instanceName, $instanceForm) {
         try {
             $instanceForm->delete($instanceName);
         } catch (Exception $e) {
             $form->error($e->getMessage());
             return false;
         }
         if ($instanceForm->save()) {
             Notification::success(sprintf(t('Monitoring instance "%s" successfully removed'), $instanceName));
             return true;
         }
         return false;
     });
     $form->handleRequest();
     $this->view->form = $form;
     $this->render('form');
 }
Example #9
0
 /**
  * Remove a role
  *
  * @throws Zend_Controller_Action_Exception If the required parameter 'role' is missing or the role does not exist
  */
 public function removeAction()
 {
     $this->assertPermission('config/authentication/roles/remove');
     $name = $this->_request->getParam('role');
     if (empty($name)) {
         throw new Zend_Controller_Action_Exception(sprintf($this->translate('Required parameter \'%s\' missing'), 'role'), 400);
     }
     $role = new RoleForm();
     try {
         $role->setIniConfig(Config::app('roles', true))->load($name);
     } catch (InvalidArgumentException $e) {
         throw new Zend_Controller_Action_Exception($e->getMessage(), 400);
     }
     $confirmation = new ConfirmRemovalForm(array('onSuccess' => function (ConfirmRemovalForm $confirmation) use($name, $role) {
         try {
             $role->remove($name);
         } catch (InvalidArgumentException $e) {
             Notification::error($e->getMessage());
             return false;
         }
         if ($role->save()) {
             Notification::success(t('Role removed'));
             return true;
         }
         return false;
     }));
     $confirmation->setTitle(sprintf($this->translate('Remove Role %s'), $name))->setSubmitLabel($this->translate('Remove Role'))->setRedirectUrl('role/list')->handleRequest();
     $this->view->form = $confirmation;
     $this->render('form');
 }