lib/api

Aleksander Machniak machniak at kolabsys.com
Fri Jan 2 16:55:50 CET 2015


 lib/api/kolab_api_service_form_value.php |   18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

New commits:
commit 87af7747c2c2f2548abf5a796b5478a6220b5694
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Fri Jan 2 10:55:12 2015 -0500

    Clean redundant spaces when generating some values i.e. displayName (#3471)

diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index 127834a..970f680 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -407,7 +407,7 @@ class kolab_api_service_form_value extends kolab_api_service
             }
 
             // TODO: Generate using policy from configuration
-            $cn = trim($postdata['givenname'] . " " . $postdata['sn']);
+            $cn = trim(trim($postdata['givenname']) . " " . trim($postdata['sn']));
 
             return $cn;
         }
@@ -424,7 +424,7 @@ class kolab_api_service_form_value extends kolab_api_service
             }
 
             $auth = Auth::get_instance($_SESSION['user']->get_domain());
-            $cn   = $postdata['cn'];
+            $cn   = trim($postdata['cn']);
 
             $x = 2;
             while (($resource_found = $auth->resource_find_by_attribute(array('cn' => $cn)))) {
@@ -438,7 +438,7 @@ class kolab_api_service_form_value extends kolab_api_service
                     }
                 }
 
-                $cn = $postdata['cn'] . ' #' . $x;
+                $cn = trim($postdata['cn']) . ' #' . $x;
                 $x++;
             }
 
@@ -457,9 +457,11 @@ class kolab_api_service_form_value extends kolab_api_service
             }
 
             // TODO: Generate using policy from configuration
-            $displayname = $postdata['givenname'];
-            if ($postdata['sn']) {
-                $displayname = $postdata['sn'] . ", " . $displayname;
+            $displayname = trim($postdata['givenname']);
+            $sn          = trim($postdata['sn']);
+
+            if ($sn) {
+                $displayname = $sn . ", " . $displayname;
             }
 
             // TODO: Figure out what may be sent as an additional comment;
@@ -606,7 +608,7 @@ class kolab_api_service_form_value extends kolab_api_service
             //console("normalized resource data", $resourcedata);
 
             // TODO: Normalize $postdata
-            $mail_local  = 'resource-' . $postdata['type_key'] . '-' . strtolower($resourcedata['cn']);
+            $mail_local  = 'resource-' . $postdata['type_key'] . '-' . strtolower(trim($resourcedata['cn']));
             $mail_domain = $_SESSION['user']->get_domain();
             $mail        = $mail_local . '@' . $mail_domain;
             $auth        = Auth::get_instance($_SESSION['user']->get_domain());
@@ -805,7 +807,7 @@ class kolab_api_service_form_value extends kolab_api_service
 
 
             if (empty($postdata['uid'])) {
-                $postdata['uid'] = $postdata['sn'];
+                $postdata['uid'] = trim($postdata['sn']);
             }
 
             $userdata = kolab_recipient_policy::normalize_userdata($postdata);




More information about the commits mailing list