mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 08:39:07 +01:00
improving/fixing for case of multiple default accounts depending on memberships
This commit is contained in:
parent
6d62f6b1d0
commit
f250efdd73
@ -1783,14 +1783,14 @@ class admin_mail
|
||||
{
|
||||
if ($_data['quota'] !== '' || $_data['accountStatus'] !== '' || strpos($_data['domain'], '.'))
|
||||
{
|
||||
$ea_account = Mail\Account::get_default(false, false, false, false, $_data['id']);
|
||||
if (!Mail\Account::is_multiple($ea_account))
|
||||
$ea_account = Mail\Account::get_default(false, false, false, true, $_data['id'], true);
|
||||
if (!$ea_account || !Mail\Account::is_multiple($ea_account))
|
||||
{
|
||||
$msg = lang('No default account found!');
|
||||
$msg = $account['account_fullname'].' (#'.$_data['id'].'): '.lang('No default account found!');
|
||||
return $response->data($msg);
|
||||
}
|
||||
|
||||
if (($userData = $ea_account->getUserData()))
|
||||
if ($ea_account && ($userData = $ea_account->getUserData()))
|
||||
{
|
||||
$userData = array(
|
||||
'acc_smtp_type' => $ea_account->acc_smtp_type,
|
||||
@ -1811,12 +1811,12 @@ class admin_mail
|
||||
// fulfill the saveUserData requirements
|
||||
$userData += $ea_account->params;
|
||||
$ea_account->saveUserData($_data['id'], $userData);
|
||||
$msg = $account['account_fullname'].' ('.'#'.$_data['id'].'): '.
|
||||
$msg = $account['account_fullname'].' (#'.$_data['id'].'): '.
|
||||
($userData['accountStatus'] === 'active' ? lang('activated') : lang('deactivated'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg = lang('No profile defined for user %1', '#'.$_data['id'].' '.$account['account_fullname']."\n");
|
||||
$msg = lang('No profile defined for user %1', $account['account_fullname'].' (#'.$_data['id'].")\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -489,7 +489,7 @@ class Account implements \ArrayAccess
|
||||
// it is quicker to try connection, assuming we want to do that anyway, instead of reading user-data
|
||||
if ($try_connect)
|
||||
{
|
||||
// as querying user-data is a lot slower then just trying to connect, and we need probably need to connect anyway, we try that
|
||||
// as querying user-data is a lot slower than just trying to connect, and we need probably need to connect anyway, we try that
|
||||
$imap = $this->imapserver();
|
||||
try {
|
||||
$imap->login();
|
||||
@ -1595,15 +1595,21 @@ class Account implements \ArrayAccess
|
||||
* @param boolean $return_id =false true: return acc_id, false return account object
|
||||
* @param boolean $log_no_default =true true: error_log if no default found, false be silent
|
||||
* @param boolean $user_context =true false: we have no user context, need a smtp-only account or one without password
|
||||
* @param boolean|int $current_user true: search only for current user, false search for all, or integer account_id to search for
|
||||
* @param boolean|int $current_user true: search only for current user, false search for all,
|
||||
* or integer account_id to search for (we can NOT connect to an IMAP account in that case!)
|
||||
* @param ?boolean $multiple =null true: only return accounts for multiple, false: only return single accounts, null (default): return both
|
||||
* @return Account|int|null
|
||||
*/
|
||||
static function get_default($smtp=false, $return_id=false, $log_no_default=true, $user_context=true, $current_user=true)
|
||||
static function get_default($smtp=false, $return_id=false, $log_no_default=true, $user_context=true, $current_user=true, ?bool $multiple=null)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach(self::search($current_user, 'params') as $acc_id => $params)
|
||||
{
|
||||
if (isset($multiple) && $multiple !== self::is_multiple($params))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ($smtp)
|
||||
{
|
||||
if (!$params['acc_smtp_host'] || !$params['acc_smtp_port']) continue;
|
||||
@ -1630,7 +1636,7 @@ class Account implements \ArrayAccess
|
||||
if (!$params['acc_imap_host'] || !$params['acc_imap_port']) continue;
|
||||
$account = new Account($params, is_bool($current_user) ? null : $current_user);
|
||||
// continue if we have either no imap username or password
|
||||
if (!$account->is_imap()) continue;
|
||||
if (is_bool($current_user) && !$account->is_imap()) continue;
|
||||
}
|
||||
return $return_id ? $acc_id : (isset($account) && $account->acc_id == $acc_id ?
|
||||
$account : new Account($params, is_bool($current_user) ? null : $current_user));
|
||||
|
Loading…
Reference in New Issue
Block a user