Fix that one can't advance the wizard when skipping the ldap discovery

fixes #8506
This commit is contained in:
Johannes Meyer 2015-03-02 18:19:41 +01:00
parent 65eafc0e8f
commit e9bae08a6e
2 changed files with 12 additions and 10 deletions

View File

@ -24,7 +24,6 @@ class LdapDiscoveryForm extends Form
'text',
'domain',
array(
'required' => true,
'label' => $this->translate('Search Domain'),
'description' => $this->translate('Search this domain for records of available servers.'),
)

View File

@ -3,7 +3,9 @@
namespace Icinga\Module\Setup\Forms;
use Zend_Validate_NotEmpty;
use Icinga\Web\Form;
use Icinga\Web\Form\ErrorLabeller;
use Icinga\Forms\LdapDiscoveryForm;
use Icinga\Protocol\Ldap\Discovery;
use Icinga\Module\Setup\Forms\LdapDiscoveryConfirmPage;
@ -55,15 +57,11 @@ class LdapDiscoveryPage extends Form
$discoveryForm = new LdapDiscoveryForm();
$this->addElements($discoveryForm->createElements($formData)->getElements());
$this->getElement('domain')->setRequired(
isset($formData['skip_validation']) === false || ! $formData['skip_validation']
);
$this->addElement(
'checkbox',
'skip_validation',
array(
'required' => true,
'label' => $this->translate('Skip'),
'description' => $this->translate('Do not discover LDAP servers and enter all settings manually.')
)
@ -82,19 +80,24 @@ class LdapDiscoveryPage extends Form
if (false === parent::isValid($data)) {
return false;
}
if ($data['skip_validation']) {
if (isset($data['skip_validation']) && $data['skip_validation']) {
return true;
}
if (isset($data['domain'])) {
if (isset($data['domain']) && $data['domain']) {
$this->discovery = Discovery::discoverDomain($data['domain']);
if ($this->discovery->isSuccess()) {
return true;
}
}
$this->addError(
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;
}