summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-03-14 18:24:10 +0000
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-03-14 19:15:27 +0000
commit5ddad1bc17829d1871685f90985c46bd5cccb882 (patch)
tree685f3104bd3dfa166a30e7fd0b4ea099d638bb5d
parent20e01ce079da94fa194cef212c5803668da7b270 (diff)
downloadwebadmin-5ddad1bc17829d1871685f90985c46bd5cccb882.tar.gz
Add form_value.generate_homedirectory()
-rw-r--r--lib/api/kolab_api_service_form_value.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index 2ada7a2..e2baea5 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -107,6 +107,36 @@ class kolab_api_service_form_value extends kolab_api_service
}
}
+ private function generate_homedirectory($postdata, $attribs = array())
+ {
+ if (isset($attribs['auto_form_fields']) && isset($attribs['auto_form_fields']['homedirectory'])) {
+ // Use Data Please
+ foreach ($attribs['auto_form_fields']['homedirectory']['data'] as $key) {
+ if (!isset($postdata[$key])) {
+ throw new Exception("Key not set: " . $key, 12356);
+ }
+ }
+
+ $uid = iconv('UTF-8', 'ASCII//TRANSLIT', $postdata['sn']);
+ $uid = strtolower($uid);
+ $uid = preg_replace('/[^a-z-_]/i', '', $uid);
+
+ $orig_uid = $uid;
+
+ $auth = Auth::get_instance($_SESSION['user']->get_domain());
+
+ $x = 2;
+ while ($auth->user_find_by_attribute(array('uid' => $uid))) {
+ $uid = $orig_uid . $x;
+ $x++;
+ }
+
+ // TODO: Home directory base path from configuration?
+
+ return array('homedirectory' => '/home/'.$uid);
+ }
+ }
+
private function generate_mail($postdata, $attribs = array())
{
if (isset($attribs['auto_form_fields']) && isset($attribs['auto_form_fields']['mail'])) {