mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-16 20:05:14 +02:00
Move "User::deny()" to own method and update usages
This commit is contained in:
parent
6aee153bbd
commit
b4f6e8fda1
4 changed files with 49 additions and 35 deletions
|
@ -20,44 +20,19 @@
|
|||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Register;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\Security\Login;
|
||||
|
||||
// This does not have to go through user_remove() and save the nickname
|
||||
// permanently against re-registration, as the person was not yet
|
||||
// allowed to have friends on this system
|
||||
function user_deny($hash)
|
||||
{
|
||||
$register = Register::getByHash($hash);
|
||||
if (!DBA::isResult($register)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$user = User::getById($register['uid']);
|
||||
if (!DBA::isResult($user)) {
|
||||
exit();
|
||||
}
|
||||
|
||||
DBA::delete('user', ['uid' => $register['uid']]);
|
||||
|
||||
Register::deleteByHash($register['hash']);
|
||||
|
||||
notice(DI::l10n()->t('Registration revoked for %s', $user['username']) . EOL);
|
||||
return true;
|
||||
}
|
||||
|
||||
function regmod_content(App $a)
|
||||
{
|
||||
if (!local_user()) {
|
||||
info(DI::l10n()->t('Please login.') . EOL);
|
||||
info(DI::l10n()->t('Please login.'));
|
||||
return Login::form(DI::args()->getQueryString(), intval(DI::config()->get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED ? 0 : 1);
|
||||
}
|
||||
|
||||
if (!is_site_admin() || !empty($_SESSION['submanage'])) {
|
||||
notice(DI::l10n()->t('Permission denied.') . EOL);
|
||||
notice(DI::l10n()->t('Permission denied.'));
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -69,13 +44,15 @@ function regmod_content(App $a)
|
|||
$hash = $a->argv[2];
|
||||
|
||||
if ($cmd === 'deny') {
|
||||
user_deny($hash);
|
||||
if (User::deny($hash)) {
|
||||
notice(DI::l10n()->t('Registration revoked'));
|
||||
}
|
||||
DI::baseUrl()->redirect('admin/users/');
|
||||
}
|
||||
|
||||
if ($cmd === 'allow') {
|
||||
if (User::allow($hash)) {
|
||||
info(DI::l10n()->t('Account approved.') . EOL);
|
||||
info(DI::l10n()->t('Account approved.'));
|
||||
}
|
||||
DI::baseUrl()->redirect('admin/users/');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue