<?php
+/**
+ * @copyright Copyright (C) 2010-2021, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
namespace Friendica\Module;
use Friendica\BaseModule;
use Friendica\Content\Text\BBCode;
-use Friendica\Core\Config;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
-use Friendica\Core\L10n\L10n as L10nClass;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model;
+use Friendica\Model\User;
+use Friendica\Util\Proxy;
use Friendica\Util\Strings;
/**
// logged in users can register others (people/pages/groups)
// even with closed registrations, unless specifically prohibited by site policy.
// 'block_extended_register' blocks all registrations, period.
- $block = Config::get('system', 'block_extended_register');
+ $block = DI::config()->get('system', 'block_extended_register');
if (local_user() && $block) {
notice(DI::l10n()->t('Permission denied.'));
}
}
- if (!local_user() && (intval(Config::get('config', 'register_policy')) === self::CLOSED)) {
+ if (!local_user() && (intval(DI::config()->get('config', 'register_policy')) === self::CLOSED)) {
notice(DI::l10n()->t('Permission denied.'));
return '';
}
- $max_dailies = intval(Config::get('system', 'max_daily_registrations'));
+ $max_dailies = intval(DI::config()->get('system', 'max_daily_registrations'));
if ($max_dailies) {
$count = DBA::count('user', ['`register_date` > UTC_TIMESTAMP - INTERVAL 1 day']);
if ($count >= $max_dailies) {
$photo = $_REQUEST['photo'] ?? '';
$invite_id = $_REQUEST['invite_id'] ?? '';
- if (local_user() || Config::get('system', 'no_openid')) {
+ if (local_user() || DI::config()->get('system', 'no_openid')) {
$fillwith = '';
$fillext = '';
$oidlabel = '';
$oidlabel = DI::l10n()->t('Your OpenID (optional): ');
}
- if (Config::get('system', 'publish_all')) {
+ if (DI::config()->get('system', 'publish_all')) {
$profile_publish = '<input type="hidden" name="profile_publish_reg" value="1" />';
} else {
- $publish_tpl = Renderer::getMarkupTemplate('profile_publish.tpl');
+ $publish_tpl = Renderer::getMarkupTemplate('profile/publish.tpl');
$profile_publish = Renderer::replaceMacros($publish_tpl, [
'$instance' => 'reg',
'$pubdesc' => DI::l10n()->t('Include your profile in member directory?'),
$tos = new Tos();
$o = Renderer::replaceMacros($tpl, [
- '$invitations' => Config::get('system', 'invitation_only'),
- '$permonly' => intval(Config::get('config', 'register_policy')) === self::APPROVE,
- '$permonlybox' => ['permonlybox', DI::l10n()->t('Note for the admin'), '', DI::l10n()->t('Leave a message for the admin, why you want to join this node'), 'required'],
+ '$invitations' => DI::config()->get('system', 'invitation_only'),
+ '$permonly' => intval(DI::config()->get('config', 'register_policy')) === self::APPROVE,
+ '$permonlybox' => ['permonlybox', DI::l10n()->t('Note for the admin'), '', DI::l10n()->t('Leave a message for the admin, why you want to join this node'), DI::l10n()->t('Required')],
'$invite_desc' => DI::l10n()->t('Membership on this site is by invitation only.'),
'$invite_label' => DI::l10n()->t('Your invitation code: '),
'$invite_id' => $invite_id,
'$regtitle' => DI::l10n()->t('Registration'),
- '$registertext' => BBCode::convert(Config::get('config', 'register_text', '')),
+ '$registertext' => BBCode::convert(DI::config()->get('config', 'register_text', '')),
'$fillwith' => $fillwith,
'$fillext' => $fillext,
'$oidlabel' => $oidlabel,
'$sitename' => DI::baseUrl()->getHostname(),
'$importh' => DI::l10n()->t('Import'),
'$importt' => DI::l10n()->t('Import your profile to this friendica instance'),
- '$showtoslink' => Config::get('system', 'tosdisplay'),
+ '$showtoslink' => DI::config()->get('system', 'tosdisplay'),
'$tostext' => DI::l10n()->t('Terms of Service'),
- '$showprivstatement' => Config::get('system', 'tosprivstatement'),
+ '$showprivstatement' => DI::config()->get('system', 'tosprivstatement'),
'$privstatement'=> $tos->privacy_complete,
'$form_security_token' => BaseModule::getFormSecurityToken('register'),
- '$explicit_content' => Config::get('system', 'explicit_content', false),
+ '$explicit_content' => DI::config()->get('system', 'explicit_content', false),
'$explicit_content_note' => DI::l10n()->t('Note: This node explicitly contains adult content'),
'$additional' => !empty(local_user()),
'$parent_password' => ['parent_password', DI::l10n()->t('Parent Password:'), '', DI::l10n()->t('Please enter the password of the parent account to legitimize your request.')]
{
BaseModule::checkFormSecurityTokenRedirectOnError('/register', 'register');
- $a = DI::app();
-
$arr = ['post' => $_POST];
Hook::callAll('register_post', $arr);
DI::baseUrl()->redirect('register?' . http_build_query($regdata));
}
- $max_dailies = intval(Config::get('system', 'max_daily_registrations'));
+ $max_dailies = intval(DI::config()->get('system', 'max_daily_registrations'));
if ($max_dailies) {
$count = DBA::count('user', ['`register_date` > UTC_TIMESTAMP - INTERVAL 1 day']);
if ($count >= $max_dailies) {
}
}
- switch (Config::get('config', 'register_policy')) {
+ switch (DI::config()->get('config', 'register_policy')) {
case self::OPEN:
$blocked = 0;
$verified = 1;
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']) {
$arr['blocked'] = $blocked;
$arr['verified'] = $verified;
- $arr['language'] = L10nClass::detectLanguage($_SERVER, $_GET, DI::config()->get('system', 'language'));
+ $arr['language'] = L10n::detectLanguage($_SERVER, $_GET, DI::config()->get('system', 'language'));
try {
$result = Model\User::create($arr);
$base_url = DI::baseUrl()->get();
- if ($netpublish && intval(Config::get('config', 'register_policy')) !== self::APPROVE) {
+ if ($netpublish && intval(DI::config()->get('config', 'register_policy')) !== self::APPROVE) {
$url = $base_url . '/profile/' . $user['nickname'];
Worker::add(PRIORITY_LOW, 'Directory', $url);
}
DI::baseUrl()->redirect('delegation');
}
- $using_invites = Config::get('system', 'invitation_only');
- $num_invites = Config::get('system', 'number_invites');
+ $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'])) : '');
- if (intval(Config::get('config', 'register_policy')) === self::OPEN) {
+ if (intval(DI::config()->get('config', 'register_policy')) === self::OPEN) {
if ($using_invites && $invite_id) {
Model\Register::deleteByHash($invite_id);
DI::pConfig()->set($user['uid'], 'system', 'invites_remaining', $num_invites);
// Only send a password mail when the password wasn't manually provided
if (empty($_POST['password1']) || empty($_POST['confirm'])) {
$res = Model\User::sendRegisterOpenEmail(
- L10n::withLang($arr['language']),
+ DI::l10n()->withLang($arr['language']),
$user,
- Config::get('config', 'sitename'),
+ DI::config()->get('config', 'sitename'),
$base_url,
$result['password']
);
info(DI::l10n()->t('Registration successful.'));
DI::baseUrl()->redirect();
}
- } elseif (intval(Config::get('config', 'register_policy')) === self::APPROVE) {
- if (!strlen(Config::get('config', 'admin_email'))) {
+ } elseif (intval(DI::config()->get('config', 'register_policy')) === self::APPROVE) {
+ if (!strlen(DI::config()->get('config', 'admin_email'))) {
notice(DI::l10n()->t('Your registration can not be processed.'));
DI::baseUrl()->redirect();
}
DI::baseUrl()->redirect('register/');
}
- Model\Register::createForApproval($user['uid'], Config::get('system', 'language'), $_POST['permonlybox']);
+ Model\Register::createForApproval($user['uid'], DI::config()->get('system', 'language'), $_POST['permonlybox']);
// invite system
if ($using_invites && $invite_id) {
$admins_stmt = DBA::select(
'user',
['uid', 'language', 'email'],
- ['email' => explode(',', str_replace(' ', '', Config::get('config', 'admin_email')))]
+ ['email' => explode(',', str_replace(' ', '', DI::config()->get('config', 'admin_email')))]
);
// send notification to admins
while ($admin = DBA::fetch($admins_stmt)) {
\notification([
- 'type' => NOTIFY_SYSTEM,
+ 'type' => Model\Notification\Type::SYSTEM,
'event' => 'SYSTEM_REGISTER_REQUEST',
+ 'uid' => $admin['uid'],
+ 'link' => $base_url . '/admin/users/',
'source_name' => $user['username'],
'source_mail' => $user['email'],
'source_nick' => $user['nickname'],
'source_link' => $base_url . '/admin/users/',
- 'link' => $base_url . '/admin/users/',
- 'source_photo' => $base_url . '/photo/avatar/' . $user['uid'] . '.jpg',
- 'to_email' => $admin['email'],
- 'uid' => $admin['uid'],
- 'language' => ($admin['language'] ?? '') ?: 'en',
+ 'source_photo' => User::getAvatarUrlForId($user['uid'], Proxy::SIZE_THUMB),
'show_in_notification_page' => false
]);
}
// send notification to the user, that the registration is pending
Model\User::sendRegisterPendingEmail(
$user,
- Config::get('config', 'sitename'),
+ DI::config()->get('config', 'sitename'),
$base_url,
$result['password']
);