7 use Friendica\Core\Config;
8 use Friendica\Core\L10n;
9 use Friendica\Core\System;
10 use Friendica\Core\Worker;
11 use Friendica\Database\DBA;
12 use Friendica\Model\Register;
13 use Friendica\Model\User;
14 use Friendica\Module\Login;
16 function user_allow($hash)
20 $register = Register::getByHash($hash);
21 if (!DBA::isResult($register)) {
25 $user = User::getById($register['uid']);
26 if (!DBA::isResult($user)) {
30 Register::deleteByHash($hash);
32 DBA::update('user', ['blocked' => false, 'verified' => true], ['uid' => $register['uid']]);
34 $profile = DBA::selectFirst('profile', ['net-publish'], ['uid' => $register['uid'], 'is-default' => true]);
36 if (DBA::isResult($profile) && $profile['net-publish'] && Config::get('system', 'directory')) {
37 $url = System::baseUrl() . '/profile/' . $user['nickname'];
38 Worker::add(PRIORITY_LOW, "Directory", $url);
41 L10n::pushLang($register['language']);
43 $res = User::sendRegisterOpenEmail(
45 Config::get('config', 'sitename'),
47 defaults($register, 'password', 'Sent in a previous email')
53 info(L10n::t('Account approved.') . EOL);
58 // This does not have to go through user_remove() and save the nickname
59 // permanently against re-registration, as the person was not yet
60 // allowed to have friends on this system
61 function user_deny($hash)
63 $register = Register::getByHash($hash);
64 if (!DBA::isResult($register)) {
68 $user = User::getById($register['uid']);
69 if (!DBA::isResult($user)) {
73 DBA::delete('user', ['uid' => $register['uid']]);
75 Register::deleteByHash($register['hash']);
77 notice(L10n::t('Registration revoked for %s', $user['username']) . EOL);
81 function regmod_content(App $a)
84 info(L10n::t('Please login.') . EOL);
85 return Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED ? 0 : 1);
88 if (!is_site_admin() || !empty($_SESSION['submanage'])) {
89 notice(L10n::t('Permission denied.') . EOL);
100 if ($cmd === 'deny') {
102 $a->internalRedirect('admin/users/');
105 if ($cmd === 'allow') {
107 $a->internalRedirect('admin/users/');