summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2015-01-02 15:55:12 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2015-01-02 15:55:12 (GMT)
commit87af7747c2c2f2548abf5a796b5478a6220b5694 (patch)
tree474d8a1047b3da1713a6490195b2005d8b244bfe
parent17b5c924a7de8de86ce8755b9eb6d888b14fb888 (diff)
downloadkolab-wap-87af7747c2c2f2548abf5a796b5478a6220b5694.tar.gz
Clean redundant spaces when generating some values i.e. displayName (#3471)
-rw-r--r--lib/api/kolab_api_service_form_value.php18
1 files changed, 10 insertions, 8 deletions
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);