mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-21 23:43:17 +01:00
fix mass activation of mail-accounts to cope with (multiple) default accounts, different from the one of the current admin-user
This commit is contained in:
parent
8d4134f683
commit
6d62f6b1d0
@ -1766,7 +1766,7 @@ class admin_mail
|
||||
* @param array $_data account an array of data called via long task running dialog
|
||||
* $_data:array (
|
||||
* id => account_id,
|
||||
* qouta => quotaLimit,
|
||||
* quota => quotaLimit,
|
||||
* domain => mailLocalAddress,
|
||||
* status => mail activation status('active'|'')
|
||||
* )
|
||||
@ -1781,24 +1781,22 @@ class admin_mail
|
||||
$response = Api\Json\Response::get();
|
||||
if (($account = $GLOBALS['egw']->accounts->read($_data['id'])))
|
||||
{
|
||||
if ($_data['quota'] !== '' || $_data['accountStatus'] !== ''
|
||||
|| strpos($_data['domain'], '.'))
|
||||
if ($_data['quota'] !== '' || $_data['accountStatus'] !== '' || strpos($_data['domain'], '.'))
|
||||
{
|
||||
$emailadmin = Mail\Account::get_default();
|
||||
if (!Mail\Account::is_multiple($emailadmin))
|
||||
$ea_account = Mail\Account::get_default(false, false, false, false, $_data['id']);
|
||||
if (!Mail\Account::is_multiple($ea_account))
|
||||
{
|
||||
$msg = lang('No default account found!');
|
||||
return $response->data($msg);
|
||||
}
|
||||
|
||||
$ea_account = Mail\Account::read($emailadmin->acc_id, $_data['id']);
|
||||
if (($userData = $ea_account->getUserData ()))
|
||||
if (($userData = $ea_account->getUserData()))
|
||||
{
|
||||
$userData = array(
|
||||
'acc_smtp_type' => $ea_account->acc_smtp_type,
|
||||
'accountStatus' => $_data['status'],
|
||||
'quotaLimit' => $_data['qouta']? $_data['qouta']: $userData['qoutaLimit'],
|
||||
'mailLocalAddress' => $userData['mailLocalAddress']
|
||||
'quotaLimit' => $_data['quota'] ?: $userData['quotaLimit'],
|
||||
'mailLocalAddress' => $userData['mailLocalAddress'],
|
||||
);
|
||||
|
||||
if (strpos($_data['domain'], '.') !== false)
|
||||
@ -1810,15 +1808,15 @@ class admin_mail
|
||||
$alias = preg_replace('/@'.preg_quote($ea_account->acc_domain, '/').'$/', '@'.$_data['domain'], $alias);
|
||||
}
|
||||
}
|
||||
// fullfill the saveUserData requirements
|
||||
// fulfill the saveUserData requirements
|
||||
$userData += $ea_account->params;
|
||||
$ea_account->saveUserData($_data['id'], $userData);
|
||||
$msg = '#'.$_data['id'].' '.$account['account_fullname']. ' '.($userData['accountStatus'] == 'active'? lang('activated'):lang('deactivated'));
|
||||
$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");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1251,7 +1251,7 @@ class AdminApp extends EgwApp
|
||||
|
||||
for (var i=0;i< Object.keys(_selected).length;i++)
|
||||
{
|
||||
accounts[i] = [{id:_selected[i]['id'].split('::')[1],qouta:"", domain:"", status:_action.id == 'active'?_action.id:''}, this.et2._inst.etemplate_exec_id];
|
||||
accounts[i] = [{id:_selected[i]['id'].split('::')[1],quota:"", domain:"", status:_action.id == 'active'?_action.id:''}, this.et2._inst.etemplate_exec_id];
|
||||
}
|
||||
var callbackDialog = function (btn){
|
||||
if(btn === Et2Dialog.YES_BUTTON)
|
||||
|
@ -1595,13 +1595,14 @@ 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
|
||||
* @return Account|int|null
|
||||
*/
|
||||
static function get_default($smtp=false, $return_id=false, $log_no_default=true, $user_context=true)
|
||||
static function get_default($smtp=false, $return_id=false, $log_no_default=true, $user_context=true, $current_user=true)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach(self::search(true, 'params') as $acc_id => $params)
|
||||
foreach(self::search($current_user, 'params') as $acc_id => $params)
|
||||
{
|
||||
if ($smtp)
|
||||
{
|
||||
@ -1627,12 +1628,12 @@ class Account implements \ArrayAccess
|
||||
else
|
||||
{
|
||||
if (!$params['acc_imap_host'] || !$params['acc_imap_port']) continue;
|
||||
$account = new Account($params);
|
||||
$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;
|
||||
}
|
||||
return $return_id ? $acc_id : (isset($account) && $account->acc_id == $acc_id ?
|
||||
$account : new Account($params));
|
||||
$account : new Account($params, is_bool($current_user) ? null : $current_user));
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
|
Loading…
Reference in New Issue
Block a user