X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fregmod.php;h=ed030723d3114eb8fc5016daed6085cb4e17a169;hb=7072e213444a8a23da83b16cfeba37c807a54674;hp=11d8eee412eadd013fb2b0197b825803db8baa2c;hpb=170dd2a7050e98547b9e636c70a0720b3716ec63;p=friendica.git
diff --git a/mod/regmod.php b/mod/regmod.php
index 11d8eee412..ed030723d3 100644
--- a/mod/regmod.php
+++ b/mod/regmod.php
@@ -4,70 +4,48 @@
*/
use Friendica\App;
-use Friendica\Core\Config;
-use Friendica\Core\L10n;
-use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
+use Friendica\DI;
+use Friendica\Model\Register;
use Friendica\Model\User;
-use Friendica\Module\Login;
-
-require_once 'include/enotify.php';
+use Friendica\Module\Security\Login;
function user_allow($hash)
{
- $a = get_app();
-
- $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
- DBA::escape($hash)
- );
-
-
+ $register = Register::getByHash($hash);
if (!DBA::isResult($register)) {
return false;
}
- $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
- intval($register[0]['uid'])
- );
-
+ $user = User::getById($register['uid']);
if (!DBA::isResult($user)) {
- killme();
+ exit();
}
- $r = q("DELETE FROM `register` WHERE `hash` = '%s'",
- DBA::escape($register[0]['hash'])
- );
+ Register::deleteByHash($hash);
+ DBA::update('user', ['blocked' => false, 'verified' => true], ['uid' => $register['uid']]);
- $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d",
- intval($register[0]['uid'])
- );
+ $profile = DBA::selectFirst('profile', ['net-publish'], ['uid' => $register['uid']]);
- $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1",
- intval($user[0]['uid'])
- );
- if (DBA::isResult($r) && $r[0]['net-publish']) {
- $url = System::baseUrl() . '/profile/' . $user[0]['nickname'];
- if ($url && strlen(Config::get('system', 'directory'))) {
- Worker::add(PRIORITY_LOW, "Directory", $url);
- }
+ if (DBA::isResult($profile) && $profile['net-publish'] && DI::config()->get('system', 'directory')) {
+ $url = DI::baseUrl() . '/profile/' . $user['nickname'];
+ Worker::add(PRIORITY_LOW, "Directory", $url);
}
- L10n::pushLang($register[0]['language']);
+ $l10n = DI::l10n()->withLang($register['language']);
$res = User::sendRegisterOpenEmail(
- $user[0]['email'],
- Config::get('config', 'sitename'),
- System::baseUrl(),
- $user[0]['username'],
- $register[0]['password'],
- $user[0]);
-
- L10n::popLang();
+ $l10n,
+ $user,
+ DI::config()->get('config', 'sitename'),
+ DI::baseUrl()->get(),
+ ($register['password'] ?? '') ?: 'Sent in a previous email'
+ );
if ($res) {
- info(L10n::t('Account approved.') . EOL);
+ info(DI::l10n()->t('Account approved.') . EOL);
return true;
}
}
@@ -77,40 +55,38 @@ function user_allow($hash)
// allowed to have friends on this system
function user_deny($hash)
{
- $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
- DBA::escape($hash)
- );
-
+ $register = Register::getByHash($hash);
if (!DBA::isResult($register)) {
return false;
}
- $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
- intval($register[0]['uid'])
- );
+ $user = User::getById($register['uid']);
+ if (!DBA::isResult($user)) {
+ exit();
+ }
+
+ DBA::delete('user', ['uid' => $register['uid']]);
- DBA::delete('user', ['uid' => $register[0]['uid']]);
- DBA::delete('register', ['hash' => $register[0]['hash']]);
+ Register::deleteByHash($register['hash']);
- notice(L10n::t('Registration revoked for %s', $user[0]['username']) . EOL);
+ notice(DI::l10n()->t('Registration revoked for %s', $user['username']) . EOL);
return true;
}
function regmod_content(App $a)
{
if (!local_user()) {
- info(L10n::t('Please login.') . EOL);
- $o = '
' . Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 0 : 1);
- return $o;
+ info(DI::l10n()->t('Please login.') . EOL);
+ return Login::form(DI::args()->getQueryString(), intval(DI::config()->get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED ? 0 : 1);
}
- if ((!is_site_admin()) || (x($_SESSION, 'submanage') && intval($_SESSION['submanage']))) {
- notice(L10n::t('Permission denied.') . EOL);
+ if (!is_site_admin() || !empty($_SESSION['submanage'])) {
+ notice(DI::l10n()->t('Permission denied.') . EOL);
return '';
}
if ($a->argc != 3) {
- killme();
+ exit();
}
$cmd = $a->argv[1];
@@ -118,13 +94,11 @@ function regmod_content(App $a)
if ($cmd === 'deny') {
user_deny($hash);
- goaway(System::baseUrl() . "/admin/users/");
- killme();
+ DI::baseUrl()->redirect('admin/users/');
}
if ($cmd === 'allow') {
user_allow($hash);
- goaway(System::baseUrl() . "/admin/users/");
- killme();
+ DI::baseUrl()->redirect('admin/users/');
}
}