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\Database\DBM;
13 use Friendica\Model\User;
14 use Friendica\Module\Login;
16 require_once 'include/enotify.php';
18 function user_allow($hash)
22 $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
27 if (!DBM::is_result($register)) {
31 $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
32 intval($register[0]['uid'])
35 if (!DBM::is_result($user)) {
39 $r = q("DELETE FROM `register` WHERE `hash` = '%s'",
40 dbesc($register[0]['hash'])
44 $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d",
45 intval($register[0]['uid'])
48 $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1",
49 intval($user[0]['uid'])
51 if (DBM::is_result($r) && $r[0]['net-publish']) {
52 $url = System::baseUrl() . '/profile/' . $user[0]['nickname'];
53 if ($url && strlen(Config::get('system', 'directory'))) {
54 Worker::add(PRIORITY_LOW, "Directory", $url);
58 L10n::pushLang($register[0]['language']);
60 $res = User::sendRegisterOpenEmail(
62 Config::get('config', 'sitename'),
65 $register[0]['password']);
70 info(L10n::t('Account approved.') . EOL);
75 // This does not have to go through user_remove() and save the nickname
76 // permanently against re-registration, as the person was not yet
77 // allowed to have friends on this system
78 function user_deny($hash)
80 $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
84 if (!DBM::is_result($register)) {
88 $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
89 intval($register[0]['uid'])
92 dba::delete('user', ['uid' => $register[0]['uid']]);
93 dba::delete('register', ['hash' => $register[0]['hash']]);
95 notice(L10n::t('Registration revoked for %s', $user[0]['username']) . EOL);
99 function regmod_content(App $a)
102 info(L10n::t('Please login.') . EOL);
103 $o = '<br /><br />' . Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 0 : 1);
107 if ((!is_site_admin()) || (x($_SESSION, 'submanage') && intval($_SESSION['submanage']))) {
108 notice(L10n::t('Permission denied.') . EOL);
119 if ($cmd === 'deny') {
121 goaway(System::baseUrl() . "/admin/users/");
125 if ($cmd === 'allow') {
127 goaway(System::baseUrl() . "/admin/users/");