本文整理汇总了PHP中Icinga\Web\Form::isValid方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::isValid方法的具体用法?PHP Form::isValid怎么用?PHP Form::isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Icinga\Web\Form
的用法示例。
在下文中一共展示了Form::isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isValid
/**
* 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();
}
示例2: isValid
/**
* 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;
}
示例3: isValidPartial
/**
* 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;
}
示例4: isValid
/**
* 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;
}
示例5: isValidPartial
/**
* 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;
}
示例6: isValid
/**
* {@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;
}
示例7: isValid
/**
* 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;
}
示例8: isValid
/**
* 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;
}
示例9: isValidPartial
/**
* 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;
}
示例10: isValid
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;
}
示例11: isValid
/**
* 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;
}
示例12: isValid
/**
* 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;
}
示例13: isValid
/**
* 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;
}
示例14: isValidPartial
/**
* 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;
}
示例15: isValid
/**
* 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;
}