X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FRegister.php;h=6b21a0c7e784d7d688165abc547ec0ff2047802d;hb=0f91d1cbde9e36b10d66fe756229ec8a9635f7eb;hp=c168c517ef6a584a9d1ef183530decc62aae9161;hpb=5b682eb5fbbe08a2cd62c79437d2076793da3511;p=friendica.git diff --git a/src/Module/Register.php b/src/Module/Register.php index c168c517ef..6b21a0c7e7 100644 --- a/src/Module/Register.php +++ b/src/Module/Register.php @@ -1,6 +1,6 @@ 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()->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); } }