/** * Validate the given form data and check whether the wizard's requirements are fulfilled * * @param array $data The data to validate * * @return bool */ public function isValid($data) { if (false === parent::isValid($data)) { return false; } return $this->wizard->getRequirements()->fulfilled(); }
/** * Validate the given form data and check whether a BIND-request is successful * * @param array $data The data to validate * * @return bool */ public function isValid($data) { if (false === parent::isValid($data)) { return false; } return true; }
/** * 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)) { if (!$this->validateConfiguration(true)) { 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; }
/** * Validate the given form data and check whether a BIND-request is successful * * @param array $data The data to validate * * @return bool */ public function isValid($data) { if (false === parent::isValid($data)) { return false; } if (false === isset($data['skip_validation']) || $data['skip_validation'] == 0) { if (false === LdapResourceForm::isValidResource($this)) { $this->addSkipValidationCheckbox(); return false; } } return true; }
/** * Check whether it's possible to connect to the database server * * This will only run the check 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)) { try { $db = new DbTool($this->getValues()); $db->checkConnectivity(); } catch (PDOException $e) { $this->warning(sprintf($this->translate('Failed to successfully validate the configuration: %s'), $e->getMessage())); return false; } $this->info($this->translate('The configuration has been successfully validated.')); } return true; }
/** * {@inheritdoc} */ public function isValid($formData) { $valid = parent::isValid($formData); if (!$valid) { return false; } $oldPasswordEl = $this->getElement('old_password'); if (!$this->backend->authenticate($this->Auth()->getUser(), $oldPasswordEl->getValue())) { $oldPasswordEl->addError($this->translate('Old password is invalid')); $this->markAsError(); return false; } return true; }
/** * 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; }
/** * Validate the given form data and check whether it's possible to connect to the database server * * @param array $data The data to validate * * @return bool */ public function isValid($data) { if (false === parent::isValid($data)) { return false; } if (false === isset($data['skip_validation']) || $data['skip_validation'] == 0) { try { $db = new DbTool($this->getValues()); $db->checkConnectivity(); } catch (PDOException $e) { $this->addError($e->getMessage()); $this->addSkipValidationCheckbox(); return false; } } return true; }
/** * 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)) { $inspection = ResourceConfigForm::inspectResource($this); 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.')); } return true; }
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; }
/** * Validate the given form data and check whether a BIND-request is successful * * @param array $data The data to validate * * @return bool */ public function isValid($data) { if (false === parent::isValid($data)) { return false; } if (isset($data['skip_validation']) && $data['skip_validation']) { return true; } if (isset($data['domain']) && $data['domain']) { try { $this->discovery = Discovery::discoverDomain($data['domain']); if ($this->discovery->isSuccess()) { return true; } } catch (Exception $e) { } $this->error(sprintf($this->translate('Could not find any LDAP servers on the domain "%s".'), $data['domain'])); } else { $labeller = new ErrorLabeller(array('element' => $this->getElement('domain'))); $this->getElement('domain')->addError($labeller->translate(Zend_Validate_NotEmpty::IS_EMPTY)); } return false; }
/** * Validate the given request data and ensure that any new user does not already exist * * @param array $data The request data to validate * * @return bool */ public function isValid($data) { if (false === parent::isValid($data)) { return false; } if ($data['user_type'] === 'new_user' && !$this->hasUser($data['new_user'])) { $this->getElement('new_user')->addError($this->translate('Username already exists.')); return false; } return true; }
/** * Validate the given form data and check whether the defined user has sufficient access rights * * @param array $data The data to validate * * @return bool */ public function isValid($data) { if (false === parent::isValid($data)) { return false; } if (isset($data['skip_validation']) && $data['skip_validation']) { return true; } $config = $this->config; $config['username'] = $this->getValue('username'); $config['password'] = $this->getValue('password'); $db = new DbTool($config); try { $db->connectToDb(); // Are we able to login on the database? } catch (PDOException $_) { try { $db->connectToHost(); // Are we able to login on the server? } catch (PDOException $e) { // We are NOT able to login on the server.. $this->error($e->getMessage()); $this->addSkipValidationCheckbox(); return false; } } // In case we are connected the credentials filled into this // form need to be granted to create databases, users... if (false === $db->checkPrivileges($this->databaseSetupPrivileges)) { $this->error($this->translate('The provided credentials cannot be used to create the database and/or the user.')); $this->addSkipValidationCheckbox(); return false; } // ...and to grant all required usage privileges to others if (false === $db->isGrantable($this->databaseUsagePrivileges)) { $this->error(sprintf($this->translate('The provided credentials cannot be used to grant all required privileges to the login "%s".'), $this->config['username'])); $this->addSkipValidationCheckbox(); return false; } return true; }
/** * 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; }
/** * Validate the given form data and check whether it's possible to authenticate using the configured backend * * @param array $data The data to validate * * @return bool */ public function isValid($data) { if (false === parent::isValid($data)) { return false; } if (false === isset($data['skip_validation']) || $data['skip_validation'] == 0) { $self = clone $this; $self->addElement('text', 'resource', array('value' => $this->getResourceConfig())); if ($this->config['type'] === 'ldap' && false === LdapBackendForm::isValidUserBackend($self)) { $this->addSkipValidationCheckbox(); return false; } } return true; }
/** * Validate the given request data and ensure that any new user does not already exist * * @param array $data The request data to validate * * @return bool */ public function isValid($data) { if (false === parent::isValid($data)) { return false; } if ($data['user_type'] === 'new_user' && array_search($data['new_user'], $this->fetchUsers()) !== false) { $this->getElement('new_user')->addError($this->translate('Username already exists.')); return false; } return true; }