mirror of
https://github.com/friendica/friendica
synced 2025-04-19 14:30:10 +00:00
Centralize config.admin_email management in Model\User
This commit is contained in:
parent
cbe8d463b1
commit
fe547b7851
11 changed files with 134 additions and 134 deletions
|
@ -23,6 +23,7 @@ namespace Friendica\Module\Api\GNUSocial\GNUSocial;
|
|||
|
||||
use Friendica\App;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Module\Register;
|
||||
|
||||
|
@ -42,7 +43,7 @@ class Config extends BaseApi
|
|||
'logo' => DI::baseUrl() . '/images/friendica-64.png',
|
||||
'fancy' => true,
|
||||
'language' => DI::config()->get('system', 'language'),
|
||||
'email' => DI::config()->get('config', 'admin_email'),
|
||||
'email' => implode(',', User::getAdminEmailList()),
|
||||
'broughtby' => '',
|
||||
'broughtbyurl' => '',
|
||||
'timezone' => DI::config()->get('system', 'default_timezone'),
|
||||
|
|
|
@ -113,7 +113,7 @@ abstract class BaseUsers extends BaseModeration
|
|||
|
||||
protected function setupUserCallback(): \Closure
|
||||
{
|
||||
$adminlist = explode(',', str_replace(' ', '', DI::config()->get('config', 'admin_email')));
|
||||
$adminlist = User::getAdminEmailList();
|
||||
return function ($user) use ($adminlist) {
|
||||
$page_types = [
|
||||
User::PAGE_FLAGS_NORMAL => $this->t('Normal Account Page'),
|
||||
|
|
|
@ -352,7 +352,7 @@ class Register extends BaseModule
|
|||
DI::baseUrl()->redirect();
|
||||
}
|
||||
} elseif (intval(DI::config()->get('config', 'register_policy')) === self::APPROVE) {
|
||||
if (!strlen(DI::config()->get('config', 'admin_email'))) {
|
||||
if (!User::getAdminEmailList()) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Your registration can not be processed.'));
|
||||
DI::baseUrl()->redirect();
|
||||
}
|
||||
|
@ -387,34 +387,23 @@ class Register extends BaseModule
|
|||
DI::sysmsg()->addInfo(DI::l10n()->t('Your registration is pending approval by the site owner.'));
|
||||
DI::baseUrl()->redirect();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
private function sendNotification(array $user, string $event)
|
||||
{
|
||||
// send email to admins
|
||||
$admins_stmt = DBA::select(
|
||||
'user',
|
||||
['uid', 'language', 'email'],
|
||||
['email' => explode(',', str_replace(' ', '', DI::config()->get('config', 'admin_email')))]
|
||||
);
|
||||
|
||||
// send notification to admins
|
||||
while ($admin = DBA::fetch($admins_stmt)) {
|
||||
foreach (User::getAdminListForEmailing(['uid', 'language', 'email']) as $admin) {
|
||||
DI::notify()->createFromArray([
|
||||
'type' => Model\Notification\Type::SYSTEM,
|
||||
'event' => $event,
|
||||
'uid' => $admin['uid'],
|
||||
'link' => DI::baseUrl()->get(true) . '/moderation/users/',
|
||||
'source_name' => $user['username'],
|
||||
'source_mail' => $user['email'],
|
||||
'source_nick' => $user['nickname'],
|
||||
'source_link' => DI::baseUrl()->get(true) . '/moderation/users/',
|
||||
'source_photo' => User::getAvatarUrl($user, Proxy::SIZE_THUMB),
|
||||
'type' => Model\Notification\Type::SYSTEM,
|
||||
'event' => $event,
|
||||
'uid' => $admin['uid'],
|
||||
'link' => DI::baseUrl()->get(true) . '/moderation/users/',
|
||||
'source_name' => $user['username'],
|
||||
'source_mail' => $user['email'],
|
||||
'source_nick' => $user['nickname'],
|
||||
'source_link' => DI::baseUrl()->get(true) . '/moderation/users/',
|
||||
'source_photo' => User::getAvatarUrl($user, Proxy::SIZE_THUMB),
|
||||
'show_in_notification_page' => false
|
||||
]);
|
||||
}
|
||||
DBA::close($admins_stmt);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue