mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-25 16:18:57 +01:00
rest to implement support for different mailbox names types / mail_login_types
This commit is contained in:
parent
be5bffcc01
commit
de0c3bdcd4
@ -423,6 +423,8 @@ class emailadmin_smtp_ldap extends defaultsmtp
|
|||||||
/**
|
/**
|
||||||
* Build mailbox address for given account and mail_addr_type
|
* Build mailbox address for given account and mail_addr_type
|
||||||
*
|
*
|
||||||
|
* If $account is an array (with values for keys account_(id|lid|email), it does NOT call accounts class
|
||||||
|
*
|
||||||
* @param int|array $account account_id or whole account array with values for keys
|
* @param int|array $account account_id or whole account array with values for keys
|
||||||
* @param string $domain=null domain, default use $this->defaultDomain
|
* @param string $domain=null domain, default use $this->defaultDomain
|
||||||
* @param string $mail_login_type=null standard(uid), vmailmgr(uid@domain), email or uidNumber,
|
* @param string $mail_login_type=null standard(uid), vmailmgr(uid@domain), email or uidNumber,
|
||||||
@ -437,20 +439,26 @@ class emailadmin_smtp_ldap extends defaultsmtp
|
|||||||
switch($mail_login_type)
|
switch($mail_login_type)
|
||||||
{
|
{
|
||||||
case 'email':
|
case 'email':
|
||||||
return is_array($account) ? $account['account_email'] : $GLOBALS['egw']->accounts->id2name($account,'account_email');
|
$mbox = is_array($account) ? $account['account_email'] : $GLOBALS['egw']->accounts->id2name($account,'account_email');
|
||||||
|
break;
|
||||||
|
|
||||||
case 'uidNumber':
|
case 'uidNumber':
|
||||||
if (is_array($account)) $account = $account['account_id'];
|
if (is_array($account)) $account = $account['account_id'];
|
||||||
return 'u'.$account.'@'.$domain;
|
$mbox = 'u'.$account.'@'.$domain;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'standard':
|
case 'standard':
|
||||||
if (is_array($account)) $account = $account['account_id'];
|
$mbox = is_array($account) ? $account['account_lid'] : $GLOBALS['egw']->accounts->id2name($account);
|
||||||
return $GLOBALS['egw']->accounts->id2name($account);
|
break;
|
||||||
|
|
||||||
case 'vmailmgr':
|
case 'vmailmgr':
|
||||||
default:
|
default:
|
||||||
if (is_array($account)) $account = $account['account_id'];
|
$mbox = is_array($account) ? $account['account_lid'] : $GLOBALS['egw']->accounts->id2name($account);
|
||||||
return $GLOBALS['egw']->accounts->id2name($account).'@'.$domain;
|
$mbox .= '@'.$domain;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
$mbox = strtolower($mbox);
|
||||||
|
|
||||||
|
return $mbox;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,6 +238,10 @@ class emailadmin_ui extends emailadmin_bo
|
|||||||
'admin' => lang('Username/Password defined by admin'),
|
'admin' => lang('Username/Password defined by admin'),
|
||||||
'uidNumber' => lang('UserId@domain eg. u1234@domain'),
|
'uidNumber' => lang('UserId@domain eg. u1234@domain'),
|
||||||
);
|
);
|
||||||
|
if (strpos($serverclass,'_') === false)
|
||||||
|
{
|
||||||
|
include_once(EGW_INCLUDE_ROOT.'/emailadmin/inc/class.'.$serverclass.'.inc.php');
|
||||||
|
}
|
||||||
if (!empty($serverclass) && stripos(constant($serverclass.'::CAPABILITIES'),'logintypeemail') !== false)
|
if (!empty($serverclass) && stripos(constant($serverclass.'::CAPABILITIES'),'logintypeemail') !== false)
|
||||||
{
|
{
|
||||||
$returnval['email'] = lang('use Users eMail-Address (as seen in Useraccount)');
|
$returnval['email'] = lang('use Users eMail-Address (as seen in Useraccount)');
|
||||||
|
@ -141,6 +141,7 @@ class setup_cmd_config extends setup_cmd
|
|||||||
'username (standard)' => 'standard',
|
'username (standard)' => 'standard',
|
||||||
'username@domain (virtual mail manager)' => 'vmailmgr',
|
'username@domain (virtual mail manager)' => 'vmailmgr',
|
||||||
'Username/Password defined by admin' => 'admin',
|
'Username/Password defined by admin' => 'admin',
|
||||||
|
'userId@domain eg. u123@domain' => 'uidNumber',
|
||||||
'email (Standard Maildomain should be set)' => 'email',
|
'email (Standard Maildomain should be set)' => 'email',
|
||||||
),'default'=>'standard'),
|
),'default'=>'standard'),
|
||||||
),
|
),
|
||||||
|
@ -512,7 +512,7 @@ class setup_cmd_ldap extends setup_cmd
|
|||||||
*
|
*
|
||||||
* @param string $this->object_class='qmailUser'
|
* @param string $this->object_class='qmailUser'
|
||||||
* @param string $this->mbox_attr='mailmessagestore' lowercase!!!
|
* @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
|
* @return string with success message N entries modified
|
||||||
* @throws egw_exception if dn not found, not listable or delete fails
|
* @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';
|
$object_class = $this->object_class ? $this->object_class : 'qmailUser';
|
||||||
$mbox_attr = $this->mbox_attr ? $this->mbox_attr : 'mailmessagestore';
|
$mbox_attr = $this->mbox_attr ? $this->mbox_attr : 'mailmessagestore';
|
||||||
$mail_login_format = $this->mail_login_format ? $this->mail_login_format : 'email';
|
$mail_login_type = $this->mail_login_type ? $this->mail_login_type : '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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!($sr = ldap_search($this->test_ldap->ds,$this->ldap_base,
|
if (!($sr = ldap_search($this->test_ldap->ds,$this->ldap_base,
|
||||||
'objectClass='.$object_class,array('mail','uidNumber','uid',$mbox_attr))) ||
|
'objectClass='.$object_class,array('mail','uidNumber','uid',$mbox_attr))) ||
|
||||||
@ -555,13 +545,12 @@ class setup_cmd_ldap extends setup_cmd
|
|||||||
{
|
{
|
||||||
if ($n === 'count') continue;
|
if ($n === 'count') continue;
|
||||||
|
|
||||||
$replace = array(
|
$mbox = emailadmin_smtp_ldap::mailbox_addr(array(
|
||||||
'mail' => $entry['mail'][0],
|
'account_id' => $entry['uidnumber'][0],
|
||||||
'uidnumber' => $entry['uidnumber'][0],
|
'account_lid' => $entry['uid'][0],
|
||||||
'uid' => $entry['uid'][0],
|
'account_email' => $entry['mail'][0],
|
||||||
'domain' => $this->domain,
|
),$mail_login_type,$this->domain);
|
||||||
);
|
|
||||||
$mbox = strtolower(str_replace(array_keys($replace),$replace,$mbox_format));
|
|
||||||
if ($mbox === $entry[$mbox_attr][0]) continue; // nothing to change
|
if ($mbox === $entry[$mbox_attr][0]) continue; // nothing to change
|
||||||
|
|
||||||
if (!$this->test && !ldap_modify($this->test_ldap->ds,$entry['dn'],array(
|
if (!$this->test && !ldap_modify($this->test_ldap->ds,$entry['dn'],array(
|
||||||
|
@ -230,3 +230,29 @@ function sql_passwdhashes($config)
|
|||||||
}
|
}
|
||||||
return $out;
|
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;
|
||||||
|
}
|
||||||
|
@ -176,11 +176,7 @@
|
|||||||
<tr class="row_on"">
|
<tr class="row_on"">
|
||||||
<td>{lang_Mail_server_login_type}:</td>
|
<td>{lang_Mail_server_login_type}:</td>
|
||||||
<td>
|
<td>
|
||||||
<select name="newsettings[mail_login_type]">
|
<select name="newsettings[mail_login_type]">{hook_mail_login_type}</select>
|
||||||
<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>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="row_off"">
|
<tr class="row_off"">
|
||||||
|
Loading…
Reference in New Issue
Block a user