X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FRegister.php;h=a62525a986a5cbef067ed135c490eca6a7c8f9b7;hb=96d2cddb54f3ea3ead6e43e5ca1f814ed6327987;hp=c168c517ef6a584a9d1ef183530decc62aae9161;hpb=a20c6e321660429d764815350235bb8445738d10;p=friendica.git
diff --git a/src/Module/Register.php b/src/Module/Register.php
index c168c517ef..a62525a986 100644
--- a/src/Module/Register.php
+++ b/src/Module/Register.php
@@ -1,6 +1,6 @@
DI::l10n()->t('Your invitation code: '),
'$invite_id' => $invite_id,
'$regtitle' => DI::l10n()->t('Registration'),
- '$registertext' => BBCode::convert(DI::config()->get('config', 'register_text', '')),
+ '$registertext' => BBCode::convertForUriId(User::getSystemUriId(), DI::config()->get('config', 'register_text', '')),
'$fillwith' => $fillwith,
'$fillext' => $fillext,
'$oidlabel' => $oidlabel,
@@ -161,7 +161,7 @@ class Register extends BaseModule
'$ask_password' => $ask_password,
'$password1' => ['password1', DI::l10n()->t('New Password:'), '', DI::l10n()->t('Leave empty for an auto generated password.')],
'$password2' => ['confirm', DI::l10n()->t('Confirm:'), '', ''],
- '$nickdesc' => DI::l10n()->t('Choose a profile nickname. This must begin with a text character. Your profile address on this site will then be "nickname@%s".', DI::baseUrl()->getHostname()),
+ '$nickdesc' => DI::l10n()->t('Choose a profile nickname. This must begin with a text character. Your profile address on this site will then be "nickname@%s".', DI::baseUrl()->getHost()),
'$nicklabel' => DI::l10n()->t('Choose a nickname: '),
'$photo' => $photo,
'$publish' => $profile_publish,
@@ -169,7 +169,7 @@ class Register extends BaseModule
'$username' => $username,
'$email' => $email,
'$nickname' => $nickname,
- '$sitename' => DI::baseUrl()->getHostname(),
+ '$sitename' => DI::baseUrl()->getHost(),
'$importh' => DI::l10n()->t('Import'),
'$importt' => DI::l10n()->t('Import your profile to this friendica instance'),
'$showtoslink' => DI::config()->get('system', 'tosdisplay'),
@@ -298,7 +298,7 @@ class Register extends BaseModule
$user = $result['user'];
- $base_url = DI::baseUrl()->get();
+ $base_url = (string)DI::baseUrl();
if ($netpublish && intval(DI::config()->get('config', 'register_policy')) !== self::APPROVE) {
$url = $base_url . '/profile/' . $user['nickname'];
@@ -352,7 +352,8 @@ 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()) {
+ $this->logger->critical('Registration policy is set to APPROVE but no admin email address has been set in config.admin_email');
DI::sysmsg()->addNotice(DI::l10n()->t('Your registration can not be processed.'));
DI::baseUrl()->redirect();
}
@@ -362,10 +363,17 @@ class Register extends BaseModule
DI::sysmsg()->addNotice(DI::l10n()->t('You have to leave a request note for the admin.')
. DI::l10n()->t('Your registration can not be processed.'));
- DI::baseUrl()->redirect('register/');
+ $this->baseUrl->redirect('register');
}
- Model\Register::createForApproval($user['uid'], DI::config()->get('system', 'language'), $_POST['permonlybox']);
+ try {
+ Model\Register::createForApproval($user['uid'], DI::config()->get('system', 'language'), $_POST['permonlybox']);
+ } catch (\Throwable $e) {
+ $this->logger->error('Unable to create a `register` record.', ['user' => $user]);
+ DI::sysmsg()->addNotice(DI::l10n()->t('An internal error occured.')
+ . DI::l10n()->t('Your registration can not be processed.'));
+ $this->baseUrl->redirect('register');
+ }
// invite system
if ($using_invites && $invite_id) {
@@ -387,34 +395,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) . '/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),
+ 'type' => Model\Notification\Type::SYSTEM,
+ 'event' => $event,
+ 'uid' => $admin['uid'],
+ 'link' => DI::baseUrl() . '/moderation/users/',
+ 'source_name' => $user['username'],
+ 'source_mail' => $user['email'],
+ 'source_nick' => $user['nickname'],
+ 'source_link' => DI::baseUrl() . '/moderation/users/',
+ 'source_photo' => User::getAvatarUrl($user, Proxy::SIZE_THUMB),
'show_in_notification_page' => false
]);
}
- DBA::close($admins_stmt);
}
}