예제 #1
0
 /**
  * Display a confirmation form to remove the backend identified by the 'backend' parameter
  */
 public function removebackendAction()
 {
     $config = $this->Config('backends');
     $form = new ConfirmRemovalForm(array('onSuccess' => function ($form) use($config) {
         $backendName = $form->getRequest()->getQuery('backend');
         $configForm = new BackendConfigForm();
         $configForm->setIniConfig($config);
         try {
             $configForm->remove($backendName);
         } catch (InvalidArgumentException $e) {
             Notification::error($e->getMessage());
             return;
         }
         if ($configForm->save()) {
             Notification::success(sprintf($this->translate('Backend "%s" successfully removed.'), $backendName));
         } else {
             return false;
         }
     }));
     $form->setTitle($this->translate('Remove Existing Backend'));
     $form->setRedirectUrl('monitoring/config');
     $form->handleRequest();
     $this->view->form = $form;
 }
예제 #2
0
 /**
  * Return whether the given values are valid
  *
  * @param   array   $formData   The data to validate
  *
  * @return  bool
  */
 public function isValid($formData)
 {
     if (!parent::isValid($formData)) {
         return false;
     }
     if (!isset($formData['skip_validation']) || !$formData['skip_validation']) {
         $configObject = new ConfigObject($this->getValues());
         if (!DbResourceForm::isValidResource($this, $configObject)) {
             $this->addSkipValidationCheckbox($this->translate('Check this to not to validate connectivity with the given database server.'));
             return false;
         } elseif (!BackendConfigForm::isValidIdoSchema($this, $configObject) || !BackendConfigForm::isValidIdoInstance($this, $configObject)) {
             $this->addSkipValidationCheckbox($this->translate('Check this to not to validate the IDO schema in the given database.'));
             return false;
         }
     }
     return true;
 }
예제 #3
0
 public function isValid($data)
 {
     if (false === parent::isValid($data)) {
         return false;
     }
     if (false === isset($data['skip_validation']) || $data['skip_validation'] == 0) {
         $configObject = new ConfigObject($this->getValues());
         if (false === DbResourceForm::isValidResource($this, $configObject)) {
             $this->addSkipValidationCheckbox($this->translate('Check this to not to validate connectivity with the given database server'));
             return false;
         } elseif (false === BackendConfigForm::isValidIdoSchema($this, $configObject)) {
             $this->addSkipValidationCheckbox($this->translate('Check this to not to validate the ido schema'));
             return false;
         } elseif (false === BackendConfigForm::isValidIdoInstance($this, $configObject)) {
             $this->addSkipValidationCheckbox($this->translate('Check this to not to validate the ido instance'));
             return false;
         }
     }
     return true;
 }
예제 #4
0
 /**
  * Return whether the configuration is valid
  *
  * @param   bool    $showLog    Whether to show the validation log
  *
  * @return  bool
  */
 protected function validateConfiguration($showLog = false)
 {
     $inspection = ResourceConfigForm::inspectResource($this);
     if ($inspection !== null) {
         if ($showLog) {
             $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->error(sprintf($this->translate('Failed to successfully validate the configuration: %s'), $inspection->getError()));
             return false;
         }
     }
     $configObject = new ConfigObject($this->getValues());
     if (!BackendConfigForm::isValidIdoSchema($this, $configObject) || !BackendConfigForm::isValidIdoInstance($this, $configObject)) {
         return false;
     }
     if ($this->getValue('db') === 'pgsql') {
         $db = new DbTool($this->getValues());
         $version = $db->connectToDb()->getServerVersion();
         if (version_compare($version, '9.1', '<')) {
             $this->error($this->translate(sprintf('The server\'s version %s is too old. The minimum required version is %s.', $version, '9.1')));
             return false;
         }
     }
     return true;
 }
예제 #5
0
 /**
  * Display a confirmation form to remove the backend identified by the 'backend' parameter
  */
 public function removebackendAction()
 {
     $backendName = $this->params->getRequired('backend-name');
     $backendForm = new BackendConfigForm();
     $backendForm->setIniConfig($this->Config('backends'));
     $form = new ConfirmRemovalForm();
     $form->setRedirectUrl('monitoring/config');
     $form->setTitle(sprintf($this->translate('Remove Monitoring Backend %s'), $backendName));
     $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('Monitoring backend "%s" successfully removed'), $backendName));
             return true;
         }
         return false;
     });
     $form->handleRequest();
     $this->view->form = $form;
     $this->render('form');
 }