fix PHP 8.0 error creating a new mail-accounts

"new" > 0 === true :(
This commit is contained in:
Ralf Becker 2021-10-25 14:44:22 +02:00
parent e080afc94f
commit 6a3df9355c

View File

@ -869,7 +869,14 @@ class admin_mail
// clear current account-data, as account has changed and we going to read selected one
$content = array_intersect_key($content, array_flip(array('called_for', 'accounts', 'acc_id', 'tabs')));
if ($content['acc_id'] > 0)
if ($content['acc_id'] === 'new')
{
$content['account_id'] = $content['called_for'];
$content['old_acc_id'] = $content['acc_id']; // to not call add/wizard, if we return from to
unset($content['tabs']);
return $this->add($content);
}
elseif ($content['acc_id'] > 0)
{
try {
$account = Mail\Account::read($content['acc_id'], $this->is_admin && $content['called_for'] ?
@ -899,13 +906,6 @@ class admin_mail
Framework::window_close($e->getMessage().' ('.get_class($e).': '.$e->getCode().')');
}
}
elseif ($content['acc_id'] === 'new')
{
$content['account_id'] = $content['called_for'];
$content['old_acc_id'] = $content['acc_id']; // to not call add/wizard, if we return from to
unset($content['tabs']);
return $this->add($content);
}
}
// some defaults for new accounts
if (!isset($content['account_id']) || empty($content['acc_id']) || $content['acc_id'] === 'new')
@ -1005,7 +1005,7 @@ class admin_mail
{
$account->imapServer()->retrieveRules();
}
$new_account = !($content['acc_id'] > 0);
$new_account = !((int)$content['acc_id'] > 0);
// check for deliveryMode="forwardOnly", if a forwarding-address is given
if ($content['acc_smtp_type'] != 'EGroupware\\Api\\Mail\\Smtp' &&
$content['deliveryMode'] == Mail\Smtp::FORWARD_ONLY &&
@ -1340,7 +1340,7 @@ class admin_mail
$readonlys['button[multiple]'] = true;
}
// when called by admin for existing accounts, display further administrative actions
if ($content['called_for'] && $content['acc_id'] > 0)
if ($content['called_for'] && (int)$content['acc_id'] > 0)
{
$admin_actions = array();
foreach(Api\Hooks::process(array(
@ -1471,8 +1471,8 @@ class admin_mail
$url = 'https://autoconfig.thunderbird.net/v1.1/'.$domain;
try {
$xml = @simplexml_load_file($url);
if (!$xml->emailProvider) throw new Api\Exception\NotFound();
$xml = simplexml_load_string(file_get_contents($url) ?: '');
if (!$xml || !$xml->emailProvider) throw new Api\Exception\NotFound();
$provider = array(
'displayName' => (string)$xml->emailProvider->displayName,
);
@ -1604,11 +1604,11 @@ class admin_mail
if (strpos($_data['domain'], '.') !== false)
{
$userData['mailLocalAddress'] = preg_replace('/@'.preg_quote($ea_account->acc_domain).'$/', '@'.$_data['domain'], $userData['mailLocalAddress']);
$userData['mailLocalAddress'] = preg_replace('/@'.preg_quote($ea_account->acc_domain, '/').'$/', '@'.$_data['domain'], $userData['mailLocalAddress']);
foreach($userData['mailAlternateAddress'] as &$alias)
{
$alias = preg_replace('/@'.preg_quote($ea_account->acc_domain).'$/', '@'.$_data['domain'], $alias);
$alias = preg_replace('/@'.preg_quote($ea_account->acc_domain, '/').'$/', '@'.$_data['domain'], $alias);
}
}
// fullfill the saveUserData requirements
@ -1618,7 +1618,7 @@ class admin_mail
}
else
{
$msg .= lang('No profile defined for user %1', '#'.$_data['id'].' '.$account['account_fullname']."\n");
$msg = lang('No profile defined for user %1', '#'.$_data['id'].' '.$account['account_fullname']."\n");
}
}