rest to implement support for different mailbox names types / mail_login_types

This commit is contained in:
Ralf Becker 2010-08-31 10:13:28 +00:00
parent 2ebd10efba
commit bfc3b262b3
4 changed files with 36 additions and 24 deletions

View File

@ -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'),
),

View File

@ -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(

View File

@ -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 .= '<option value="' . $value . '"' . $selected . '>' . $label . '</option>' . "\n";
}
return $out;
}

View File

@ -176,11 +176,7 @@
<tr class="row_on"">
<td>{lang_Mail_server_login_type}:</td>
<td>
<select name="newsettings[mail_login_type]">
<option value="standard" {selected_mail_login_type_standard}>{lang_standard (login-name_identical_to_eGroupWare_user-name)}</option>
<option value="vmailmgr" {selected_mail_login_type_vmailmgr}>{lang_Virtual_mail_manager_(login-name_includes_domain)}</option>
<option value="email" {selected_mail_login_type_email}>{lang_email_(Standard_Maildomain_should_be_set)}</option>
</select>
<select name="newsettings[mail_login_type]">{hook_mail_login_type}</select>
</td>
</tr>
<tr class="row_off"">