Exemplo n.º 1
0
 /**
  * Display a confirmation form to remove the backend identified by the 'backend' parameter
  */
 public function removeuserbackendAction()
 {
     $this->assertPermission('config/application/userbackend');
     $backendName = $this->params->getRequired('backend');
     $backendForm = new UserBackendConfigForm();
     $backendForm->setIniConfig(Config::app('authentication'));
     $form = new ConfirmRemovalForm();
     $form->setRedirectUrl('config/userbackend');
     $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 backend "%s" successfully removed'), $backendName));
             return true;
         }
         return false;
     });
     $form->handleRequest();
     $this->renderForm($form, $this->translate('Remove User Backend'));
 }
Exemplo n.º 2
0
 /**
  * Run the configured backend's inspection checks and show the result, if necessary
  *
  * This will only run any validation if the user pushed the 'backend_validation' button.
  *
  * @param   array   $formData
  *
  * @return  bool
  */
 public function isValidPartial(array $formData)
 {
     if (isset($formData['backend_validation']) && parent::isValid($formData)) {
         $self = clone $this;
         if (($resourceElement = $self->getSubForm('backend_form')->getElement('resource')) !== null) {
             $resourceElement->setIgnore(false);
         }
         $inspection = UserBackendConfigForm::inspectUserBackend($self);
         if ($inspection !== null) {
             $join = function ($e) use(&$join) {
                 return is_string($e) ? $e : join("\n", array_map($join, $e));
             };
             $this->addElement('note', 'inspection_output', array('order' => 0, 'value' => '<strong>' . $this->translate('Validation Log') . "</strong>\n\n" . join("\n", array_map($join, $inspection->toArray())), 'decorators' => array('ViewHelper', array('HtmlTag', array('tag' => 'pre', 'class' => 'log-output')))));
             if ($inspection->hasError()) {
                 $this->warning(sprintf($this->translate('Failed to successfully validate the configuration: %s'), $inspection->getError()));
                 return false;
             }
         }
         $this->info($this->translate('The configuration has been successfully validated.'));
     } elseif (!isset($formData['backend_validation'])) {
         // This is usually done by isValid(Partial), but as we're not calling any of these...
         $this->populate($formData);
     }
     return true;
 }
Exemplo n.º 3
0
 /**
  * Return the config form for user backends
  *
  * @return  ConfigForm
  */
 protected function getConfigForm()
 {
     $form = new UserBackendConfigForm();
     $form->setIniConfig($this->config);
     return $form;
 }
Exemplo n.º 4
0
 /**
  * Action for removing a user backend
  */
 public function removeuserbackendAction()
 {
     $this->assertPermission('config/application/userbackend');
     $form = new ConfirmRemovalForm(array('onSuccess' => function ($form) {
         $configForm = new UserBackendConfigForm();
         $configForm->setIniConfig(Config::app('authentication'));
         $authBackend = $form->getRequest()->getQuery('backend');
         try {
             $configForm->remove($authBackend);
         } catch (InvalidArgumentException $e) {
             Notification::error($e->getMessage());
             return false;
         }
         if ($configForm->save()) {
             Notification::success(sprintf(t('User backend "%s" has been successfully removed'), $authBackend));
         } else {
             return false;
         }
     }));
     $form->setTitle($this->translate('Remove User Backend'));
     $form->setRedirectUrl('config/userbackend');
     $form->setAction(Url::fromRequest());
     $form->handleRequest();
     $this->view->form = $form;
     $this->render('userbackend/remove');
 }