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']);
69 info(L10n::t('Account approved.') . EOL);
74 // This does not have to go through user_remove() and save the nickname
75 // permanently against re-registration, as the person was not yet
76 // allowed to have friends on this system
77 function user_deny($hash)
79 $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
83 if (!DBA::isResult($register)) {
87 $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
88 intval($register[0]['uid'])
91 DBA::delete('user', ['uid' => $register[0]['uid']]);
92 DBA::delete('register', ['hash' => $register[0]['hash']]);
94 notice(L10n::t('Registration revoked for %s', $user[0]['username']) . EOL);
98 function regmod_content(App $a)
101 info(L10n::t('Please login.') . EOL);
102 $o = '<br /><br />' . Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 0 : 1);
106 if ((!is_site_admin()) || (x($_SESSION, 'submanage') && intval($_SESSION['submanage']))) {
107 notice(L10n::t('Permission denied.') . EOL);
118 if ($cmd === 'deny') {
120 goaway(System::baseUrl() . "/admin/users/");
124 if ($cmd === 'allow') {
126 goaway(System::baseUrl() . "/admin/users/");