summaryrefslogtreecommitdiffstats
path: root/lib/api
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-02-21 12:50:20 +0100
committerAleksander Machniak <alec@alec.pl>2012-02-21 12:50:20 +0100
commit2f73148c6c3188020968903f1ec85aefa1fe38a1 (patch)
tree3af471181077c3f2c949c906a48f4ed74276af90 /lib/api
parente9467f8d51a35f5a313480874f4f7549f89ad279 (diff)
downloadwebadmin-2f73148c6c3188020968903f1ec85aefa1fe38a1.tar.gz
Small improvements in generate_* methods
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/kolab_api_service_form_value.php19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index 3b9270a..c914815 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -31,7 +31,9 @@ class kolab_api_service_form_value extends kolab_api_service
}
}
- return array("cn" => $postdata['givenname'] . " " . $postdata['sn']);
+ $cn = trim($postdata['givenname'] . " " . $postdata['sn']);
+
+ return array("cn" => $cn);
}
}
@@ -47,7 +49,12 @@ class kolab_api_service_form_value extends kolab_api_service
}
}
- return array("displayname" => $postdata['sn'] . ", " . $postdata['givenname']);
+ $displayname = $postdata['givenname'];
+ if ($postdata['sn']) {
+ $displayname = $postdata['sn'] . ", " . $displayname;
+ }
+
+ return array("displayname" => $displayname);
}
}
@@ -68,9 +75,11 @@ class kolab_api_service_form_value extends kolab_api_service
$sn = iconv('UTF-8', 'ASCII//TRANSLIT', $postdata['sn']);
$givenname = strtolower($givenname);
- $sn = str_replace(' ', '', $sn);
$sn = strtolower($sn);
+ $givenname = preg_replace('/[^a-z-_]/i', '', $givenname);
+ $sn = preg_replace('/[^a-z-_]/i', '', $sn);
+
$mail = $givenname . "." . $sn . "@" . $_SESSION['user']->get_domain();
$orig_mail = $mail;
@@ -109,14 +118,12 @@ class kolab_api_service_form_value extends kolab_api_service
$uid = iconv('UTF-8', 'ASCII//TRANSLIT', $postdata['sn']);
$uid = strtolower($uid);
- $uid = str_replace(' ', '', $uid);
+ $uid = preg_replace('/[^a-z-_]/i', '', $uid);
$orig_uid = $uid;
$auth = Auth::get_instance($_SESSION['user']->get_domain());
- $user = $auth->user_find_by_attribute(array('uid' => $uid));
-
$x = 2;
while ($auth->user_find_by_attribute(array('uid' => $uid))) {
$uid = $orig_uid . $x;