From 281b2ac7d4c9e0bc2210d6e97e021c86bae3d076 Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 15 Dec 2008 08:20:05 +0000 Subject: [PATCH] Updated account creation -Now configurable modifyable git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13290 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../mail/kolab/class_mail-methods-kolab.inc | 4 +- .../mail/personal/mail/class_mail-methods.inc | 55 ++++++++++++++----- 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-kolab.inc b/gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-kolab.inc index 03cacb41a..69ffbff15 100644 --- a/gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-kolab.inc +++ b/gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-kolab.inc @@ -30,8 +30,8 @@ class mailMethodKolab extends mailMethodCyrus protected $share_prefix = 'shared\\.'; /* Account ID creation */ - protected $user_id = "__PREFIX____UATTRIB__"; - protected $share_id = "__PREFIX____CN__@__DOMAIN__"; + protected $user_id = "%prefix%%uattrib%"; + protected $share_id = "%prefix%%cn%@%domain%"; protected $userObjectClasses = array("kolabInetOrgPerson"); protected $shareObjectClasses = array("kolabSharedFolder"); diff --git a/gosa-plugins/mail/personal/mail/class_mail-methods.inc b/gosa-plugins/mail/personal/mail/class_mail-methods.inc index 2dac9998c..eacab61c1 100644 --- a/gosa-plugins/mail/personal/mail/class_mail-methods.inc +++ b/gosa-plugins/mail/personal/mail/class_mail-methods.inc @@ -24,17 +24,17 @@ class mailMethod{ !!Depends on the attributes 'user_prefix'/'share_prefix' and the option 'cyrusUseSlashes' Examples - based on defaults : - __PREFIX__ => "user." or "user/" (Depending on cyrusUseSlashes=FALSE/TRUE) - __CN__ => "technik" (The groups cn) - __UID__ => "herbert" (The users uid) - __MAIL__ => "herbert@domain.de"(The mail address) - __DOMAIN__ => "domain.de" (The domain part of the specified mail) - __MAILPART__ => "herbert" (The mail address without domain) - __UATTRIB__ => "herbert"/"herbert@domains.de" + %PREFIX% => "user." or "user/" (Depending on cyrusUseSlashes=FALSE/TRUE) + %CN% => "technik" (The groups cn) + %UID% => "herbert" (The users uid) + %MAIL% => "herbert@domain.de"(The mail address) + %DOMAIN% => "domain.de" (The domain part of the specified mail) + %MAILPART% => "herbert" (The mail address without domain) + %UATTRIB% => "herbert"/"herbert@domains.de" (Configured in gosa.conf mailAttribute="mail"/"uid") */ - protected $user_id = "__PREFIX____UATTRIB__"; - protected $share_id = "__PREFIX____UATTRIB__"; + protected $user_id = "%PREFIX%%UATTRIB%"; + protected $share_id = "%PREFIX%%UATTRIB%"; /* Create accounts in cyrus style with '/' instead of '.' */ protected $cyrusUseSlashes= FALSE; @@ -76,7 +76,7 @@ class mailMethod{ " " => "none"); protected $acl_mapping = array(); - + /*! \brief Constructs the mail class @param Object Config The GOsa configuration object @@ -101,6 +101,7 @@ class mailMethod{ }else{ $this->type = $type; } + } @@ -137,6 +138,21 @@ class mailMethod{ $this->acl_mapping[$acl] = _($name); } + /* Check if we have an individual user/folder creation syntax + */ + $tmp = $this->config->get_cfg_value("mailUserCreation"); + if(!empty($tmp)){ + @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "".$tmp."", + "MAIL: User creation set to"); + $this->user_id = $tmp; + } + $tmp = $this->config->get_cfg_value("mailFolderCreation"); + if(!empty($tmp)){ + @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "".$tmp."", + "MAIL: Shared folder creation set to"); + $this->share_id = $tmp; + } + $this->build_account_id(); $this->initial_account_id = $this->account_id; } @@ -324,11 +340,24 @@ class mailMethod{ /* Create account_id */ - $from = array("/__CN__/","/__UID__/","/__PREFIX__/","/__UATTRIB__/","/__DOMAIN__/","/__MAILPART__/","/__MAIL__/"); + $from = array("/%cn%/i","/%uid%/i","/%prefix%/i","/%uattrib%/i","/%domain%/i","/%mailpart%/i","/%mail%/i"); $to = array($this->parent->cn,$this->parent->uid,$prefix,$this->parent->$uattrib, $domain, $mailpart,$mail); - $acc_id = trim(strtolower(preg_replace($from,$to,$acc_string))); + /* Check for not replaced pattern. + */ + if(preg_match("/%/",$acc_id)){ + $notr = preg_replace("/^[^%]*/","",$acc_id); + if(!empty($notr)){ + @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"Warning", + sprintf("MAIL: WARNING unknown pattern in account creation string '%s' near '%s'", $acc_id, $notr)); + + /* Remove incomprehensible patterns */ + $acc_id = preg_replace("/%[^%]+%/","",$acc_id); + } + } + + if($this->account_id != $acc_id){ $this->account_id = $acc_id; @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"", "MAIL: AccountID generated: ".$acc_id.""); @@ -378,7 +407,7 @@ class mailMethod{ /* Create account_id */ - $from = array("/__CN__/","/__UID__/","/__PREFIX__/","/__UATTRIB__/","/__DOMAIN__/","/__MAILPART__/","/__MAIL__/"); + $from = array("/%CN%/","/%UID%/","/%PREFIX%/","/%UATTRIB%/","/%DOMAIN%/","/%MAILPART%/","/%MAIL%/"); $to = array($this->parent->cn,$this->parent->uid,$prefix,$this->parent->$uattrib, $domain, $mailpart,$mail); $acc_id = trim(strtolower(preg_replace($from,$to,$acc_string))); -- 2.30.2