From bfc3b262b35dcdc05082120e51192e985fa84b81 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 31 Aug 2010 10:13:28 +0000 Subject: [PATCH] rest to implement support for different mailbox names types / mail_login_types --- setup/inc/class.setup_cmd_config.inc.php | 1 + setup/inc/class.setup_cmd_ldap.inc.php | 27 +++++++----------------- setup/inc/hook_config.inc.php | 26 +++++++++++++++++++++++ setup/templates/default/config.tpl | 6 +----- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/setup/inc/class.setup_cmd_config.inc.php b/setup/inc/class.setup_cmd_config.inc.php index ca7eff2629..d1c41f6304 100644 --- a/setup/inc/class.setup_cmd_config.inc.php +++ b/setup/inc/class.setup_cmd_config.inc.php @@ -141,6 +141,7 @@ class setup_cmd_config extends setup_cmd 'username (standard)' => 'standard', 'username@domain (virtual mail manager)' => 'vmailmgr', 'Username/Password defined by admin' => 'admin', + 'userId@domain eg. u123@domain' => 'uidNumber', 'email (Standard Maildomain should be set)' => 'email', ),'default'=>'standard'), ), diff --git a/setup/inc/class.setup_cmd_ldap.inc.php b/setup/inc/class.setup_cmd_ldap.inc.php index 93a6230feb..a18b9340db 100644 --- a/setup/inc/class.setup_cmd_ldap.inc.php +++ b/setup/inc/class.setup_cmd_ldap.inc.php @@ -512,7 +512,7 @@ class setup_cmd_ldap extends setup_cmd * * @param string $this->object_class='qmailUser' * @param string $this->mbox_attr='mailmessagestore' lowercase!!! - * @param string $this->mail_login_format='email' 'email', 'vmailmgr', 'standard' or 'uidNumber' + * @param string $this->mail_login_type='email' 'email', 'vmailmgr', 'standard' or 'uidNumber' * @return string with success message N entries modified * @throws egw_exception if dn not found, not listable or delete fails */ @@ -532,17 +532,7 @@ class setup_cmd_ldap extends setup_cmd } $object_class = $this->object_class ? $this->object_class : 'qmailUser'; $mbox_attr = $this->mbox_attr ? $this->mbox_attr : 'mailmessagestore'; - $mail_login_format = $this->mail_login_format ? $this->mail_login_format : 'email'; - - // translate EGroupware mail_login_format into ldap attribute names - switch($mail_login_format) - { - case 'email': $mbox_format = 'mail'; break; - case 'vmailmgr': $mbox_format = 'uid@domain'; break; - case 'standard': $mbox_format = 'uid'; break; - case 'uidNumber': $mbox_format = 'uuidnumber@domain'; break; // uu to get u123 - default: throw new egw_exception('Unknown mail_login_format "%1"!',$mail_login_format); - } + $mail_login_type = $this->mail_login_type ? $this->mail_login_type : 'email'; if (!($sr = ldap_search($this->test_ldap->ds,$this->ldap_base, 'objectClass='.$object_class,array('mail','uidNumber','uid',$mbox_attr))) || @@ -555,13 +545,12 @@ class setup_cmd_ldap extends setup_cmd { if ($n === 'count') continue; - $replace = array( - 'mail' => $entry['mail'][0], - 'uidnumber' => $entry['uidnumber'][0], - 'uid' => $entry['uid'][0], - 'domain' => $this->domain, - ); - $mbox = strtolower(str_replace(array_keys($replace),$replace,$mbox_format)); + $mbox = emailadmin_smtp_ldap::mailbox_addr(array( + 'account_id' => $entry['uidnumber'][0], + 'account_lid' => $entry['uid'][0], + 'account_email' => $entry['mail'][0], + ),$mail_login_type,$this->domain); + if ($mbox === $entry[$mbox_attr][0]) continue; // nothing to change if (!$this->test && !ldap_modify($this->test_ldap->ds,$entry['dn'],array( diff --git a/setup/inc/hook_config.inc.php b/setup/inc/hook_config.inc.php index 59f892e105..4c2321b2b0 100644 --- a/setup/inc/hook_config.inc.php +++ b/setup/inc/hook_config.inc.php @@ -230,3 +230,29 @@ function sql_passwdhashes($config) } return $out; } + +/** + * Make mail-login-types from emailadmin available to config template + * + * @param array $config + * @return string + */ +function mail_login_type($config) +{ + $types = emailadmin_ui::getIMAPLoginTypes('cyrusimap'); + unset($types['admin']); + + foreach($types as $value => $label) + { + if($config['mail_login_type'] == $value) + { + $selected = ' selected="selected"'; + } + else + { + $selected = ''; + } + $out .= '' . "\n"; + } + return $out; +} diff --git a/setup/templates/default/config.tpl b/setup/templates/default/config.tpl index f5af32b85f..79a3d0835e 100644 --- a/setup/templates/default/config.tpl +++ b/setup/templates/default/config.tpl @@ -176,11 +176,7 @@ {lang_Mail_server_login_type}: - +