summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-09-13 13:48:45 +0200
committerAleksander Machniak <alec@alec.pl>2013-09-13 13:48:45 +0200
commit91afe32e589c11f498aee999ce15c4e517b9c1b0 (patch)
treebcd77ca923658b088fff6808af9b367368a444a3 /lib
parenta90c4a38cbc2af8310c171c40af0540c0f022987 (diff)
downloadwebadmin-91afe32e589c11f498aee999ce15c4e517b9c1b0.tar.gz
Support kolab_wap.vlv configuration option
Diffstat (limited to 'lib')
-rw-r--r--lib/Auth/LDAP.php9
-rw-r--r--lib/Conf.php32
-rw-r--r--lib/ext/Net/LDAP3.php3
3 files changed, 36 insertions, 8 deletions
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index e4245c5..5a9a8a8 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -46,17 +46,12 @@ class LDAP extends Net_LDAP3 {
$this->config_set("debug", true);
$this->config_set("log_hook", array($this, "_log"));
- //$this->config_set("vlv", false);
$this->config_set("config_root_dn", "cn=config");
-
$this->config_set("service_bind_dn", $this->conf->get("service_bind_dn"));
$this->config_set("service_bind_pw", $this->conf->get("service_bind_pw"));
- $login_filter = $this->conf->get("kolab_wap", "login_filter");
-
- if (!empty($login_filter)) {
- $this->config_set("login_filter", $login_filter);
- }
+ $this->config_set("login_filter", $this->conf->get("kolab_wap", "login_filter"));
+ $this->config_set("vlv", $this->conf->get("kolab_wap", "vlv", Conf::AUTO));
// See if we are to connect to any domain explicitly defined.
if (empty($domain)) {
diff --git a/lib/Conf.php b/lib/Conf.php
index 6131850..82c3eea 100644
--- a/lib/Conf.php
+++ b/lib/Conf.php
@@ -34,6 +34,7 @@ class Conf {
const BOOL = 1;
const INT = 2;
const FLOAT = 3;
+ const AUTO = 4;
/**
* This implements the 'singleton' design pattern
@@ -70,10 +71,15 @@ class Conf {
switch ($type) {
case self::INT:
return intval($value);
+
case self::FLOAT:
return floatval($value);
+
case self::BOOL:
return (bool) preg_match('/^(true|1|on|enabled|yes)$/i', $value);
+
+ case self::AUTO:
+ return $this->auto($value);
}
return (string) $value;
@@ -225,4 +231,30 @@ class Conf {
}
}
}
+
+ /**
+ * Auto-detection and conversion of config value
+ */
+ private function auto($value)
+ {
+ if (preg_match('/^(true|on|enabled|yes|false|off|disabled|no)$/i', $value)) {
+ return (bool) preg_match('/^(true|on|enabled|yes)$/i', $value);
+ }
+
+ if (is_numeric($value)) {
+ if (strpos($value, '.')) {
+ return floatval($value);
+ }
+ else {
+ return intval($value);
+ }
+ }
+
+ // array in JSON format
+ if ($value[0] == '{' || $value[0] == '[') {
+ return json_decode($value, true);
+ }
+
+ return (string) $value;
+ }
}
diff --git a/lib/ext/Net/LDAP3.php b/lib/ext/Net/LDAP3.php
index 4977aa4..6e0ccc6 100644
--- a/lib/ext/Net/LDAP3.php
+++ b/lib/ext/Net/LDAP3.php
@@ -1899,7 +1899,8 @@ class Net_LDAP3
if (isset($this->config['vlv'])) {
if ($this->config['vlv'] === false) {
return array();
- } else {
+ }
+ else if (is_array($this->config['vlv'])) {
return $this->config['vlv'];
}
}