mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-08 16:14:26 +02:00
New area "moderation"
- Moved several admin pages to the moderation area - ACL still is checking for administrator credentials
This commit is contained in:
parent
4fb7e9b023
commit
18f54f4425
61 changed files with 1707 additions and 1417 deletions
116
src/Module/Moderation/Users/Pending.php
Normal file
116
src/Module/Moderation/Users/Pending.php
Normal file
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2022, the Friendica project
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Module\Moderation\Users;
|
||||
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Model\Register;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\Moderation\BaseUsers;
|
||||
|
||||
class Pending extends BaseUsers
|
||||
{
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
$this->checkModerationAccess();
|
||||
|
||||
self::checkFormSecurityTokenRedirectOnError('/admin/users/pending', 'admin_users_pending');
|
||||
|
||||
$pending = $request['pending'] ?? [];
|
||||
|
||||
if (!empty($request['page_users_approve'])) {
|
||||
foreach ($pending as $hash) {
|
||||
User::allow($hash);
|
||||
}
|
||||
$this->systemMessages->addInfo($this->tt('%s user approved', '%s users approved', count($pending)));
|
||||
}
|
||||
|
||||
if (!empty($request['page_users_deny'])) {
|
||||
foreach ($pending as $hash) {
|
||||
User::deny($hash);
|
||||
}
|
||||
$this->systemMessages->addInfo($this->tt('%s registration revoked', '%s registrations revoked', count($pending)));
|
||||
}
|
||||
|
||||
$this->baseUrl->redirect('admin/users/pending');
|
||||
}
|
||||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
parent::content();
|
||||
|
||||
$action = $this->parameters['action'] ?? '';
|
||||
$uid = $this->parameters['uid'] ?? 0;
|
||||
|
||||
if ($uid) {
|
||||
$user = User::getById($uid, ['username', 'blocked']);
|
||||
if (!$user) {
|
||||
$this->systemMessages->addNotice($this->t('User not found'));
|
||||
$this->baseUrl->redirect('admin/users');
|
||||
}
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'allow':
|
||||
self::checkFormSecurityTokenRedirectOnError('/admin/users/pending', 'admin_users_pending', 't');
|
||||
User::allow(Register::getPendingForUser($uid)['hash'] ?? '');
|
||||
$this->systemMessages->addNotice($this->t('Account approved.'));
|
||||
$this->baseUrl->redirect('admin/users/pending');
|
||||
break;
|
||||
case 'deny':
|
||||
self::checkFormSecurityTokenRedirectOnError('/admin/users/pending', 'admin_users_pending', 't');
|
||||
User::deny(Register::getPendingForUser($uid)['hash'] ?? '');
|
||||
$this->systemMessages->addNotice($this->t('Registration revoked'));
|
||||
$this->baseUrl->redirect('admin/users/pending');
|
||||
break;
|
||||
}
|
||||
|
||||
$pager = new Pager($this->l10n, $this->args->getQueryString(), 100);
|
||||
|
||||
$pending = Register::getPending($pager->getStart(), $pager->getItemsPerPage());
|
||||
|
||||
$count = Register::getPendingCount();
|
||||
|
||||
$t = Renderer::getMarkupTemplate('admin/users/pending.tpl');
|
||||
return self::getTabsHTML('pending') . Renderer::replaceMacros($t, [
|
||||
// strings //
|
||||
'$title' => $this->t('Administration'),
|
||||
'$page' => $this->t('User registrations awaiting review'),
|
||||
'$select_all' => $this->t('select all'),
|
||||
'$th_pending' => [$this->t('Request date'), $this->t('Name'), $this->t('Email')],
|
||||
'$no_pending' => $this->t('No registrations.'),
|
||||
'$pendingnotetext' => $this->t('Note from the user'),
|
||||
'$approve' => $this->t('Approve'),
|
||||
'$deny' => $this->t('Deny'),
|
||||
|
||||
'$form_security_token' => self::getFormSecurityToken('admin_users_pending'),
|
||||
|
||||
// values //
|
||||
'$baseurl' => $this->baseUrl->get(true),
|
||||
'$query_string' => $this->args->getQueryString(),
|
||||
|
||||
'$pending' => $pending,
|
||||
'$count' => $count,
|
||||
'$pager' => $pager->renderFull($count),
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue