Revert "LdapResourceForm: Validate the host field and do not require a port"

This reverts commit a34d6026b3.

refs #7990
This commit is contained in:
Johannes Meyer 2015-03-11 08:00:20 +01:00
parent e4e6c1cb28
commit 2cf09ebc48
3 changed files with 14 additions and 38 deletions

View File

@ -32,7 +32,7 @@ class LdapResourceForm extends Form
array(
'required' => true,
'label' => $this->translate('Resource Name'),
'description' => $this->translate('The unique name of this resource.')
'description' => $this->translate('The unique name of this resource')
)
);
$this->addElement(
@ -42,40 +42,18 @@ class LdapResourceForm extends Form
'required' => true,
'label' => $this->translate('Host'),
'description' => $this->translate(
'The hostname, address or URL of the LDAP server.'
'The hostname or address of the LDAP server to use for authentication'
),
'value' => 'localhost',
'validators' => array(
array(
'Callback',
false,
array(
'callback' => function ($v) {
return strpos($v, '?') === false;
},
'messages' => array(
'callbackValue' => $this->translate(
'The URL pointing to the LDAP server must not contain any filter attributes.'
)
)
)
)
),
'requirement' => $this->translate(
'The LDAP server\'s URL must have the following format: [ldap[s]://]host[:port]'
)
'value' => 'localhost'
)
);
$this->addElement(
'number',
'port',
array(
'allowEmpty' => true,
'required' => true,
'label' => $this->translate('Port'),
'description' => $this->translate(
'The port of the LDAP server. Leave empty if you\'ll set this as part of the URL above.'
. ' If not set the default port (389) is being used.'
),
'description' => $this->translate('The port of the LDAP server to use for authentication'),
'value' => 389
)
);
@ -96,7 +74,7 @@ class LdapResourceForm extends Form
array(
'required' => true,
'label' => $this->translate('Bind DN'),
'description' => $this->translate('The user dn to use for querying the ldap server.')
'description' => $this->translate('The user dn to use for querying the ldap server')
)
);
$this->addElement(
@ -106,7 +84,7 @@ class LdapResourceForm extends Form
'required' => true,
'renderPassword' => true,
'label' => $this->translate('Bind Password'),
'description' => $this->translate('The password to use for querying the ldap server.')
'description' => $this->translate('The password to use for querying the ldap server')
)
);

View File

@ -3,6 +3,7 @@
namespace Icinga\Protocol\Ldap;
use Exception;
use Icinga\Exception\ProgrammingError;
use Icinga\Protocol\Ldap\Exception as LdapException;
use Icinga\Application\Platform;
@ -75,7 +76,7 @@ class Connection
$this->bind_dn = $config->bind_dn;
$this->bind_pw = $config->bind_pw;
$this->root_dn = $config->root_dn;
$this->port = $config->get('port') ?: $this->port;
$this->port = $config->get('port', $this->port);
}
public function getHostname()

View File

@ -132,15 +132,12 @@ class Number extends FormElement
*/
public function isValid($value, $context = null)
{
if (! parent::isValid($value, $context)) {
$this->setValue($value);
$value = $this->getValue();
if (! is_numeric($value)) {
$this->addError(sprintf($this->translate('\'%s\' is not a valid number'), $value));
return false;
}
if ((! empty($value) || !$this->getAllowEmpty()) && !is_numeric($value)) {
$this->addError(sprintf(t('\'%s\' is not a valid number'), $value));
return false;
}
return true;
return parent::isValid($value, $context);
}
}