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\User;
13 use Friendica\Module\Login;
15 require_once 'include/enotify.php';
17 function user_allow($hash)
21 $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
26 if (!DBA::isResult($register)) {
30 $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
31 intval($register[0]['uid'])
34 if (!DBA::isResult($user)) {
38 $r = q("DELETE FROM `register` WHERE `hash` = '%s'",
39 DBA::escape($register[0]['hash'])
43 $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d",
44 intval($register[0]['uid'])
47 $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1",
48 intval($user[0]['uid'])
50 if (DBA::isResult($r) && $r[0]['net-publish']) {
51 $url = System::baseUrl() . '/profile/' . $user[0]['nickname'];
52 if ($url && strlen(Config::get('system', 'directory'))) {
53 Worker::add(PRIORITY_LOW, "Directory", $url);
57 L10n::pushLang($register[0]['language']);
59 $res = User::sendRegisterOpenEmail(
61 Config::get('config', 'sitename'),
64 $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 (!DBA::isResult($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/");