X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fregmod.php;h=ed030723d3114eb8fc5016daed6085cb4e17a169;hb=7072e213444a8a23da83b16cfeba37c807a54674;hp=433a8f5e4e309e9fd7cc86809c5ce6e4d6b5f819;hpb=540adaf829b4835bf99fa47e58520cf998defb88;p=friendica.git
diff --git a/mod/regmod.php b/mod/regmod.php
index 433a8f5e4e..ed030723d3 100644
--- a/mod/regmod.php
+++ b/mod/regmod.php
@@ -4,65 +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 = Register::getByHash($hash);
-
if (!DBA::isResult($register)) {
return false;
}
- $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
- intval($register['uid'])
- );
-
+ $user = User::getById($register['uid']);
if (!DBA::isResult($user)) {
- killme();
+ exit();
}
Register::deleteByHash($hash);
- $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d",
- intval($register['uid'])
- );
+ DBA::update('user', ['blocked' => false, 'verified' => true], ['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);
- }
+ $profile = DBA::selectFirst('profile', ['net-publish'], ['uid' => $register['uid']]);
+
+ 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['language']);
+ $l10n = DI::l10n()->withLang($register['language']);
$res = User::sendRegisterOpenEmail(
- $user[0]['email'],
- Config::get('config', 'sitename'),
- System::baseUrl(),
- $user[0]['username'],
- 'Sent in a previous email',
- $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;
}
}
@@ -73,38 +56,37 @@ function user_allow($hash)
function user_deny($hash)
{
$register = Register::getByHash($hash);
-
if (!DBA::isResult($register)) {
return false;
}
- $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
- intval($register['uid'])
- );
+ $user = User::getById($register['uid']);
+ if (!DBA::isResult($user)) {
+ exit();
+ }
DBA::delete('user', ['uid' => $register['uid']]);
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];
@@ -112,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/');
}
}