<?php
/**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
namespace Friendica\Module;
+use Friendica\App;
use Friendica\BaseModule;
use Friendica\Content\Text\BBCode;
+use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model;
-use Friendica\Util\Strings;
+use Friendica\Model\User;
+use Friendica\Util\Profiler;
+use Friendica\Util\Proxy;
+use Psr\Log\LoggerInterface;
/**
* @author Hypolite Petovan <hypolite@mrpetovan.com>
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
*
*
* @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.
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 '';
}
$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,
'$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'),
* 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');
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)) {
$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']) {
$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) {
// send notification to admins
while ($admin = DBA::fetch($admins_stmt)) {
- \notification([
- 'type' => Model\Notify\Type::SYSTEM,
+ DI::notify()->createFromArray([
+ 'type' => Model\Notification\Type::SYSTEM,
'event' => 'SYSTEM_REGISTER_REQUEST',
'uid' => $admin['uid'],
'link' => $base_url . '/admin/users/',
'source_mail' => $user['email'],
'source_nick' => $user['nickname'],
'source_link' => $base_url . '/admin/users/',
- 'source_photo' => $base_url . '/photo/avatar/' . $user['uid'] . '.jpg',
+ 'source_photo' => User::getAvatarUrl($user, Proxy::SIZE_THUMB),
'show_in_notification_page' => false
]);
}