3 * @copyright Copyright (C) 2020, Friendica
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 use Friendica\Core\Worker;
24 use Friendica\Database\DBA;
26 use Friendica\Model\Register;
27 use Friendica\Model\User;
28 use Friendica\Module\Security\Login;
30 function user_allow($hash)
32 $register = Register::getByHash($hash);
33 if (!DBA::isResult($register)) {
37 $user = User::getById($register['uid']);
38 if (!DBA::isResult($user)) {
42 Register::deleteByHash($hash);
44 DBA::update('user', ['blocked' => false, 'verified' => true], ['uid' => $register['uid']]);
46 $profile = DBA::selectFirst('profile', ['net-publish'], ['uid' => $register['uid']]);
48 if (DBA::isResult($profile) && $profile['net-publish'] && DI::config()->get('system', 'directory')) {
49 $url = DI::baseUrl() . '/profile/' . $user['nickname'];
50 Worker::add(PRIORITY_LOW, "Directory", $url);
53 $l10n = DI::l10n()->withLang($register['language']);
55 $res = User::sendRegisterOpenEmail(
58 DI::config()->get('config', 'sitename'),
60 ($register['password'] ?? '') ?: 'Sent in a previous email'
64 info(DI::l10n()->t('Account approved.') . EOL);
69 // This does not have to go through user_remove() and save the nickname
70 // permanently against re-registration, as the person was not yet
71 // allowed to have friends on this system
72 function user_deny($hash)
74 $register = Register::getByHash($hash);
75 if (!DBA::isResult($register)) {
79 $user = User::getById($register['uid']);
80 if (!DBA::isResult($user)) {
84 DBA::delete('user', ['uid' => $register['uid']]);
86 Register::deleteByHash($register['hash']);
88 notice(DI::l10n()->t('Registration revoked for %s', $user['username']) . EOL);
92 function regmod_content(App $a)
95 info(DI::l10n()->t('Please login.') . EOL);
96 return Login::form(DI::args()->getQueryString(), intval(DI::config()->get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED ? 0 : 1);
99 if (!is_site_admin() || !empty($_SESSION['submanage'])) {
100 notice(DI::l10n()->t('Permission denied.') . EOL);
111 if ($cmd === 'deny') {
113 DI::baseUrl()->redirect('admin/users/');
116 if ($cmd === 'allow') {
118 DI::baseUrl()->redirect('admin/users/');