Centralize config.admin_email management in Model\User

This commit is contained in:
Hypolite Petovan 2022-11-12 12:01:22 -05:00
parent cbe8d463b1
commit fe547b7851
11 changed files with 134 additions and 134 deletions

View file

@ -113,12 +113,9 @@ class Account extends BaseSettings
$err .= DI::l10n()->t('Invalid email.');
}
// ensure new email is not the admin mail
if (DI::config()->get('config', 'admin_email')) {
$adminlist = explode(",", str_replace(" ", "", strtolower(DI::config()->get('config', 'admin_email'))));
if (in_array(strtolower($email), $adminlist)) {
$err .= DI::l10n()->t('Cannot change to that email.');
$email = $user['email'];
}
if (in_array(strtolower($email), User::getAdminEmailList())) {
$err .= DI::l10n()->t('Cannot change to that email.');
$email = $user['email'];
}
}

View file

@ -85,14 +85,8 @@ class RemoveMe extends BaseSettings
}
// send notification to admins so that they can clean up the backups
$admin_mails = explode(',', $this->config->get('config', 'admin_email'));
foreach ($admin_mails as $mail) {
$admin = $this->database->selectFirst('user', ['uid', 'language', 'email', 'username'], ['email' => trim($mail)]);
if (!$admin) {
continue;
}
$l10n = $this->l10n->withLang($admin['language']);
foreach (User::getAdminListForEmailing(['uid', 'language', 'email']) as $admin) {
$l10n = $this->l10n->withLang($admin['language'] ?: 'en');
$email = $this->emailer
->newSystemMail()