2 commits - lib/api lib/ext lib/kolab_api_service.php lib/kolab_html.php

Aleksander Machniak machniak at kolabsys.com
Wed Oct 2 15:12:44 CEST 2013


 lib/api/kolab_api_service_form_value.php |   17 +++++++++--------
 lib/ext/Net/LDAP3.php                    |    7 ++-----
 lib/kolab_api_service.php                |    2 +-
 lib/kolab_html.php                       |    2 +-
 4 files changed, 13 insertions(+), 15 deletions(-)

New commits:
commit 1d99b6e0995f7eafc8a38cfc3196925d9168f2bb
Author: Aleksander Machniak <alec at alec.pl>
Date:   Wed Oct 2 15:12:05 2013 +0200

    Fix various validation inconsistences and empty value checks

diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index 7f476e9..d96a9b1 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -1089,8 +1089,8 @@ class kolab_api_service_form_value extends kolab_api_service
 
     private function validate_alias($value, $postdata = null, $validation_type = null)
     {
-        $auth = Auth::get_instance();
         $conf = Conf::get_instance();
+
         if (!is_array($value)) {
             $value = (array)($value);
         }
@@ -1112,15 +1112,12 @@ class kolab_api_service_form_value extends kolab_api_service
                 }
             }
         }
+
+        return 'OK';
     }
 
     private function validate_associateddomain($value, $postdata = array(), $validation_type = null)
     {
-        return $value;
-
-        $auth = Auth::get_instance();
-        $conf = Conf::get_instance();
-
         if (!is_array($value)) {
             $value = (array)($value);
         }
@@ -1149,8 +1146,8 @@ class kolab_api_service_form_value extends kolab_api_service
 
     private function validate_mail($value, $postdata = array(), $validation_type = null)
     {
-        $auth = Auth::get_instance();
         $conf = Conf::get_instance();
+
         if (!is_array($value)) {
             $value = (array)($value);
         }
@@ -1172,6 +1169,8 @@ class kolab_api_service_form_value extends kolab_api_service
                 }
             }
         }
+
+        return 'OK';
     }
 
     private function validate_mailquota($value, $postdata = array(), $validation_type = null)
@@ -1190,8 +1189,8 @@ class kolab_api_service_form_value extends kolab_api_service
 
     private function validate_mailalternateaddress($value, $postdata = array(), $validation_type = null)
     {
-        $auth = Auth::get_instance();
         $conf = Conf::get_instance();
+
         if (!is_array($value)) {
             $value = (array)($value);
         }
@@ -1213,6 +1212,8 @@ class kolab_api_service_form_value extends kolab_api_service
                 }
             }
         }
+
+        return 'OK';
     }
 
     private function _list_options_members($postdata, $attribs = array())
diff --git a/lib/ext/Net/LDAP3.php b/lib/ext/Net/LDAP3.php
index ffe645f..e661edb 100644
--- a/lib/ext/Net/LDAP3.php
+++ b/lib/ext/Net/LDAP3.php
@@ -1229,7 +1229,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];
@@ -1238,7 +1237,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];
@@ -1316,7 +1314,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;
@@ -1349,7 +1347,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];
@@ -1366,7 +1363,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 8294dcd..fa5bd8e 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;
             }
         }


commit c4ff3570cb284f0b786146b169c0def686c84ca3
Author: Aleksander Machniak <alec at alec.pl>
Date:   Wed Oct 2 14:51:48 2013 +0200

    Fix mailquota value formatting (Bug #2309)

diff --git a/lib/kolab_html.php b/lib/kolab_html.php
index d54eabc..8b296f8 100644
--- a/lib/kolab_html.php
+++ b/lib/kolab_html.php
@@ -170,7 +170,7 @@ class kolab_html
                 $attribs['value'] /= 1024;
                 $unit = 'mb';
             }
-            if ($attribs['value'] >= 1024) {
+            if ($attribs['value'] % 1024 == 0 && $attribs['value'] >= 1024) {
                 $attribs['value'] /= 1024;
                 $unit = 'gb';
             }




More information about the commits mailing list