summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-10-02 13:14:32 (GMT)
committerAleksander Machniak <alec@alec.pl>2013-10-02 13:14:32 (GMT)
commit32d3a28486b96239c0e87cc3d8c9ccb75e86013b (patch)
tree0a2bb1e067bb0a98eb93251309b41f4b2a5196c3
parent6891db5325215d212fc086cef33e26bec9a40cce (diff)
downloadkolab-wap-32d3a28486b96239c0e87cc3d8c9ccb75e86013b.tar.gz
Fix various validation inconsistences and empty value checks
Conflicts: lib/api/kolab_api_service_form_value.php
-rw-r--r--lib/api/kolab_api_service_form_value.php17
-rw-r--r--lib/ext/Net/LDAP3.php7
-rw-r--r--lib/kolab_api_service.php2
3 files changed, 11 insertions, 15 deletions
diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index e79c526..7fe315c 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -1096,8 +1096,8 @@ class kolab_api_service_form_value extends kolab_api_service
private function validate_alias($value)
{
- $auth = Auth::get_instance();
$conf = Conf::get_instance();
+
if (!is_array($value)) {
$value = (array)($value);
}
@@ -1116,15 +1116,11 @@ class kolab_api_service_form_value extends kolab_api_service
}
}
+ return 'OK';
}
private function validate_associateddomain($value)
{
- return $value;
-
- $auth = Auth::get_instance();
- $conf = Conf::get_instance();
-
if (!is_array($value)) {
$value = (array)($value);
}
@@ -1132,7 +1128,6 @@ class kolab_api_service_form_value extends kolab_api_service
//console("form_value.validate_associateddomain(\$value)", $value);
return $value;
-
}
private function validate_astaccountrealmedpassword($value, $postdata)
@@ -1154,8 +1149,8 @@ class kolab_api_service_form_value extends kolab_api_service
private function validate_mail($value)
{
- $auth = Auth::get_instance();
$conf = Conf::get_instance();
+
if (!is_array($value)) {
$value = (array)($value);
}
@@ -1173,6 +1168,8 @@ class kolab_api_service_form_value extends kolab_api_service
}
}
}
+
+ return 'OK';
}
private function validate_mailquota($value)
@@ -1191,8 +1188,8 @@ class kolab_api_service_form_value extends kolab_api_service
private function validate_mailalternateaddress($value)
{
- $auth = Auth::get_instance();
$conf = Conf::get_instance();
+
if (!is_array($value)) {
$value = (array)($value);
}
@@ -1210,6 +1207,8 @@ class kolab_api_service_form_value extends kolab_api_service
}
}
}
+
+ return 'OK';
}
private function _highest_of_two($one, $two)
diff --git a/lib/ext/Net/LDAP3.php b/lib/ext/Net/LDAP3.php
index 6e0ccc6..c81cf6f 100644
--- a/lib/ext/Net/LDAP3.php
+++ b/lib/ext/Net/LDAP3.php
@@ -1234,7 +1234,6 @@ class Net_LDAP3
// Compare each attribute value of the old attrs with the corresponding value
// in the new attrs, if any.
foreach ($old_attrs as $attr => $old_attr_value) {
-
if (is_array($old_attr_value)) {
if (count($old_attr_value) == 1) {
$old_attrs[$attr] = $old_attr_value[0];
@@ -1243,7 +1242,6 @@ class Net_LDAP3
}
if (array_key_exists($attr, $new_attrs)) {
-
if (is_array($new_attrs[$attr])) {
if (count($new_attrs[$attr]) == 1) {
$new_attrs[$attr] = $new_attrs[$attr][0];
@@ -1321,7 +1319,7 @@ class Net_LDAP3
}
} else {
- if (empty($new_attrs[$attr])) {
+ if (!isset($new_attrs[$attr]) || $new_attrs[$attr] === '' || (is_array($new_attrs[$attr]) && empty($new_attrs[$attr]))) {
switch ($attr) {
case "userpassword":
break;
@@ -1354,7 +1352,6 @@ class Net_LDAP3
}
if (array_key_exists($attr, $old_attrs)) {
-
if (is_array($old_attrs[$attr])) {
if (count($old_attrs[$attr]) == 1) {
$old_attrs[$attr] = $old_attrs[$attr][0];
@@ -1371,7 +1368,7 @@ class Net_LDAP3
$_sort2 = false;
}
- if (empty($value)) {
+ if ($value === null || $value === '' || (is_array($value) && empty($value))) {
if (!array_key_exists($attr, $mod_array['del'])) {
switch ($attr) {
case 'userpassword':
diff --git a/lib/kolab_api_service.php b/lib/kolab_api_service.php
index a154f7d..1cc46c9 100644
--- a/lib/kolab_api_service.php
+++ b/lib/kolab_api_service.php
@@ -286,7 +286,7 @@ abstract class kolab_api_service
$special_attr_validate = Array();
foreach ($validate_result as $attr_name => $value) {
- if (!empty($value) && $value !== "OK" && $value !== 0) {
+ if ($value !== false && $value !== '' && $value !== null && $value !== "OK") {
$special_attr_validate[$attr_name] = $value;
}
}