mirror of
https://github.com/friendica/friendica
synced 2025-04-24 03:10:11 +00:00
Issue 12097: Notify for each new user registration
This commit is contained in:
parent
12a352f441
commit
0f9e2b6da4
6 changed files with 317 additions and 248 deletions
|
@ -333,6 +333,10 @@ class Register extends BaseModule
|
|||
|
||||
if ($res) {
|
||||
DI::sysmsg()->addInfo(DI::l10n()->t('Registration successful. Please check your email for further instructions.'));
|
||||
$this->sendNotification($user, 'SYSTEM_REGISTER_NEW');
|
||||
if (DI::config()->get('system', 'register_notification')) {
|
||||
$this->sendNotification($user, 'SYSTEM_REGISTER_NEW');
|
||||
}
|
||||
DI::baseUrl()->redirect();
|
||||
} else {
|
||||
DI::sysmsg()->addNotice(
|
||||
|
@ -343,6 +347,9 @@ class Register extends BaseModule
|
|||
}
|
||||
} else {
|
||||
DI::sysmsg()->addInfo(DI::l10n()->t('Registration successful.'));
|
||||
if (DI::config()->get('system', 'register_notification')) {
|
||||
$this->sendNotification($user, 'SYSTEM_REGISTER_NEW');
|
||||
}
|
||||
DI::baseUrl()->redirect();
|
||||
}
|
||||
} elseif (intval(DI::config()->get('config', 'register_policy')) === self::APPROVE) {
|
||||
|
@ -367,29 +374,8 @@ class Register extends BaseModule
|
|||
DI::pConfig()->set($user['uid'], 'system', 'invites_remaining', $num_invites);
|
||||
}
|
||||
|
||||
// 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)) {
|
||||
DI::notify()->createFromArray([
|
||||
'type' => Model\Notification\Type::SYSTEM,
|
||||
'event' => 'SYSTEM_REGISTER_REQUEST',
|
||||
'uid' => $admin['uid'],
|
||||
'link' => DI::baseUrl()->get(true) . '/admin/users/',
|
||||
'source_name' => $user['username'],
|
||||
'source_mail' => $user['email'],
|
||||
'source_nick' => $user['nickname'],
|
||||
'source_link' => DI::baseUrl()->get(true) . '/admin/users/',
|
||||
'source_photo' => User::getAvatarUrl($user, Proxy::SIZE_THUMB),
|
||||
'show_in_notification_page' => false
|
||||
]);
|
||||
}
|
||||
DBA::close($admins_stmt);
|
||||
// send notification to the admin
|
||||
$this->sendNotification($user, 'SYSTEM_REGISTER_REQUEST');
|
||||
|
||||
// send notification to the user, that the registration is pending
|
||||
Model\User::sendRegisterPendingEmail(
|
||||
|
@ -405,4 +391,31 @@ class Register extends BaseModule
|
|||
|
||||
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)) {
|
||||
DI::notify()->createFromArray([
|
||||
'type' => Model\Notification\Type::SYSTEM,
|
||||
'event' => $event,
|
||||
'uid' => $admin['uid'],
|
||||
'link' => DI::baseUrl()->get(true) . '/admin/users/',
|
||||
'source_name' => $user['username'],
|
||||
'source_mail' => $user['email'],
|
||||
'source_nick' => $user['nickname'],
|
||||
'source_link' => DI::baseUrl()->get(true) . '/admin/users/',
|
||||
'source_photo' => User::getAvatarUrl($user, Proxy::SIZE_THUMB),
|
||||
'show_in_notification_page' => false
|
||||
]);
|
||||
}
|
||||
DBA::close($admins_stmt);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue