6 use Friendica\Core\Config;
7 use Friendica\Core\L10n;
8 use Friendica\Core\System;
9 use Friendica\Core\Worker;
10 use Friendica\Database\DBM;
11 use Friendica\Model\User;
12 use Friendica\Module\Login;
14 require_once 'include/enotify.php';
16 function user_allow($hash)
20 $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
25 if (!DBM::is_result($register)) {
29 $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
30 intval($register[0]['uid'])
33 if (!DBM::is_result($user)) {
37 $r = q("DELETE FROM `register` WHERE `hash` = '%s'",
38 dbesc($register[0]['hash'])
42 $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d",
43 intval($register[0]['uid'])
46 $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1",
47 intval($user[0]['uid'])
49 if (DBM::is_result($r) && $r[0]['net-publish']) {
50 $url = System::baseUrl() . '/profile/' . $user[0]['nickname'];
51 if ($url && strlen(Config::get('system', 'directory'))) {
52 Worker::add(PRIORITY_LOW, "Directory", $url);
56 L10n::pushLang($register[0]['language']);
58 $res = User::sendRegisterOpenEmail(
60 $a->config['sitename'],
63 $register[0]['password']);
68 info(L10n::t('Account approved.') . EOL);
73 // This does not have to go through user_remove() and save the nickname
74 // permanently against re-registration, as the person was not yet
75 // allowed to have friends on this system
76 function user_deny($hash)
78 $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
82 if (!DBM::is_result($register)) {
86 $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
87 intval($register[0]['uid'])
90 dba::delete('user', ['uid' => $register[0]['uid']]);
91 dba::delete('register', ['hash' => $register[0]['hash']]);
93 notice(L10n::t('Registration revoked for %s', $user[0]['username']) . EOL);
97 function regmod_content(App $a)
102 info(L10n::t('Please login.') . EOL);
103 $o = '<br /><br />' . Login::form($a->query_string, $a->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/");