4 use Friendica\Core\Config;
5 use Friendica\Core\System;
6 use Friendica\Core\Worker;
7 use Friendica\Database\DBM;
8 use Friendica\Model\User;
10 require_once 'include/enotify.php';
12 function user_allow($hash)
16 $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
21 if (!DBM::is_result($register)) {
25 $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
26 intval($register[0]['uid'])
29 if (!DBM::is_result($user)) {
33 $r = q("DELETE FROM `register` WHERE `hash` = '%s'",
34 dbesc($register[0]['hash'])
38 $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d",
39 intval($register[0]['uid'])
42 $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1",
43 intval($user[0]['uid'])
45 if (DBM::is_result($r) && $r[0]['net-publish']) {
46 $url = System::baseUrl() . '/profile/' . $user[0]['nickname'];
47 if ($url && strlen(Config::get('system', 'directory'))) {
48 Worker::add(PRIORITY_LOW, "Directory", $url);
52 push_lang($register[0]['language']);
54 User::sendRegisterOpenEmail(
56 $a->config['sitename'],
59 $register[0]['password']);
64 info(t('Account approved.') . EOL);
69 // This does not have to go through user_remove() and save the nickname
70 // permanently against re-registration, as the person was not yet
71 // allowed to have friends on this system
72 function user_deny($hash)
74 $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
78 if (!DBM::is_result($register)) {
82 $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
83 intval($register[0]['uid'])
86 dba::delete('user', array('uid' => $register[0]['uid']));
87 dba::delete('register', array('hash' => $register[0]['hash']));
89 notice(sprintf(t('Registration revoked for %s'), $user[0]['username']) . EOL);
93 function regmod_content(App $a)
97 $_SESSION['return_url'] = $a->cmd;
100 info(t('Please login.') . EOL);
101 $o .= '<br /><br />' . login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
105 if ((!is_site_admin()) || (x($_SESSION, 'submanage') && intval($_SESSION['submanage']))) {
106 notice(t('Permission denied.') . EOL);
117 if ($cmd === 'deny') {
119 goaway(System::baseUrl() . "/admin/users/");
123 if ($cmd === 'allow') {
125 goaway(System::baseUrl() . "/admin/users/");