X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FRegister.php;h=9c09baef82d937f76dc993a027dd35ef1cfe4062;hb=e7384288766f342da98b7d0ada082db516501ac6;hp=35be8ce2908c558d437bacaebafc22634ca36d7b;hpb=53e38b03130ea798bba44db44ccb7f331dc4b91d;p=friendica.git diff --git a/src/Module/Register.php b/src/Module/Register.php index 35be8ce290..9c09baef82 100644 --- a/src/Module/Register.php +++ b/src/Module/Register.php @@ -1,6 +1,6 @@ @@ -42,6 +47,16 @@ class Register extends BaseModule const APPROVE = 1; const OPEN = 2; + /** @var Tos */ + protected $tos; + + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManageConfigValues $config, array $server, array $parameters = []) + { + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + + $this->tos = new Tos($l10n, $baseUrl, $args, $logger, $profiler, $response, $config, $server, $parameters); + } + /** * Module GET method to display any content * @@ -51,7 +66,7 @@ class Register extends BaseModule * * @return string */ - public static function content(array $parameters = []) + protected function content(array $request = []): string { // logged in users can register others (people/pages/groups) // even with closed registrations, unless specifically prohibited by site policy. @@ -80,7 +95,7 @@ class Register extends BaseModule if ($max_dailies) { $count = DBA::count('user', ['`register_date` > UTC_TIMESTAMP - INTERVAL 1 day']); if ($count >= $max_dailies) { - Logger::log('max daily registrations exceeded.'); + Logger::notice('max daily registrations exceeded.'); notice(DI::l10n()->t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.')); return ''; } @@ -127,8 +142,6 @@ class Register extends BaseModule $tpl = $arr['template']; - $tos = new Tos(); - $o = Renderer::replaceMacros($tpl, [ '$invitations' => DI::config()->get('system', 'invitation_only'), '$permonly' => intval(DI::config()->get('config', 'register_policy')) === self::APPROVE, @@ -162,7 +175,7 @@ class Register extends BaseModule '$showtoslink' => DI::config()->get('system', 'tosdisplay'), '$tostext' => DI::l10n()->t('Terms of Service'), '$showprivstatement' => DI::config()->get('system', 'tosprivstatement'), - '$privstatement'=> $tos->privacy_complete, + '$privstatement'=> $this->tos->privacy_complete, '$form_security_token' => BaseModule::getFormSecurityToken('register'), '$explicit_content' => DI::config()->get('system', 'explicit_content', false), '$explicit_content_note' => DI::l10n()->t('Note: This node explicitly contains adult content'), @@ -180,7 +193,7 @@ class Register extends BaseModule * Extend this method if the module is supposed to process POST requests. * Doesn't display any content */ - public static function post(array $parameters = []) + protected function post(array $request = []) { BaseModule::checkFormSecurityTokenRedirectOnError('/register', 'register'); @@ -248,10 +261,6 @@ class Register extends BaseModule DI::baseUrl()->redirect('register/'); } - - // Overwriting the "tar pit" field with the real one - $arr['email'] = $arr['field1']; - if ($additional_account) { $user = DBA::selectFirst('user', ['email'], ['uid' => local_user()]); if (!DBA::isResult($user)) { @@ -264,6 +273,9 @@ class Register extends BaseModule $arr['password1'] = $arr['confirm'] = $arr['parent_password']; $arr['repeat'] = $arr['email'] = $user['email']; + } else { + // Overwriting the "tar pit" field with the real one + $arr['email'] = $arr['field1']; } if ($arr['email'] != $arr['repeat']) { @@ -301,7 +313,7 @@ class Register extends BaseModule $using_invites = DI::config()->get('system', 'invitation_only'); $num_invites = DI::config()->get('system', 'number_invites'); - $invite_id = (!empty($_POST['invite_id']) ? Strings::escapeTags(trim($_POST['invite_id'])) : ''); + $invite_id = (!empty($_POST['invite_id']) ? trim($_POST['invite_id']) : ''); if (intval(DI::config()->get('config', 'register_policy')) === self::OPEN) { if ($using_invites && $invite_id) { @@ -364,16 +376,16 @@ class Register extends BaseModule // send notification to admins while ($admin = DBA::fetch($admins_stmt)) { - \notification([ + DI::notify()->createFromArray([ 'type' => Model\Notification\Type::SYSTEM, 'event' => 'SYSTEM_REGISTER_REQUEST', 'uid' => $admin['uid'], - 'link' => $base_url . '/admin/users/', + 'link' => DI::baseUrl()->get(true) . '/admin/users/', 'source_name' => $user['username'], 'source_mail' => $user['email'], 'source_nick' => $user['nickname'], - 'source_link' => $base_url . '/admin/users/', - 'source_photo' => $base_url . '/photo/avatar/' . $user['uid'] . '.jpg', + 'source_link' => DI::baseUrl()->get(true) . '/admin/users/', + 'source_photo' => User::getAvatarUrl($user, Proxy::SIZE_THUMB), 'show_in_notification_page' => false ]); }