mirror of
https://github.com/friendica/friendica
synced 2025-04-22 07:50: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
|
@ -98,6 +98,7 @@ class Site extends BaseAdmin
|
|||
$enable_multi_reg = !empty($_POST['enable_multi_reg']);
|
||||
$enable_openid = !empty($_POST['enable_openid']);
|
||||
$enable_regfullname = !empty($_POST['enable_regfullname']);
|
||||
$register_notification = !empty($_POST['register_notification']);
|
||||
$community_page_style = (!empty($_POST['community_page_style']) ? intval(trim($_POST['community_page_style'])) : 0);
|
||||
$max_author_posts_community_page = (!empty($_POST['max_author_posts_community_page']) ? intval(trim($_POST['max_author_posts_community_page'])) : 0);
|
||||
|
||||
|
@ -266,6 +267,7 @@ class Site extends BaseAdmin
|
|||
DI::config()->set('system', 'block_extended_register', !$enable_multi_reg);
|
||||
DI::config()->set('system', 'no_openid' , !$enable_openid);
|
||||
DI::config()->set('system', 'no_regfullname' , !$enable_regfullname);
|
||||
DI::config()->set('system', 'register_notification' , $register_notification);
|
||||
DI::config()->set('system', 'community_page_style' , $community_page_style);
|
||||
DI::config()->set('system', 'max_author_posts_community_page', $max_author_posts_community_page);
|
||||
DI::config()->set('system', 'verifyssl' , $verifyssl);
|
||||
|
@ -492,6 +494,7 @@ class Site extends BaseAdmin
|
|||
'$enable_multi_reg' => ['enable_multi_reg', DI::l10n()->t('Enable multiple registrations'), !DI::config()->get('system', 'block_extended_register'), DI::l10n()->t('Enable users to register additional accounts for use as pages.')],
|
||||
'$enable_openid' => ['enable_openid', DI::l10n()->t('Enable OpenID'), !DI::config()->get('system', 'no_openid'), DI::l10n()->t('Enable OpenID support for registration and logins.')],
|
||||
'$enable_regfullname' => ['enable_regfullname', DI::l10n()->t('Enable Fullname check'), !DI::config()->get('system', 'no_regfullname'), DI::l10n()->t('Enable check to only allow users to register with a space between the first name and the last name in their full name.')],
|
||||
'$register_notification' => ['register_notification', DI::l10n()->t('Notify admin on new registration'), DI::config()->get('system', 'register_notification'), DI::l10n()->t('If enabled and the system is set to an open registration, a notification for each new registration is sent to the admin.')],
|
||||
'$community_page_style' => ['community_page_style', DI::l10n()->t('Community pages for visitors'), DI::config()->get('system', 'community_page_style'), DI::l10n()->t('Which community pages should be available for visitors. Local users always see both pages.'), $community_page_style_choices],
|
||||
'$max_author_posts_community_page' => ['max_author_posts_community_page', DI::l10n()->t('Posts per user on community page'), DI::config()->get('system', 'max_author_posts_community_page'), DI::l10n()->t('The maximum number of posts per user on the community page. (Not valid for "Global Community")')],
|
||||
'$mail_able' => function_exists('imap_open'),
|
||||
|
|
|
@ -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