mirror of
https://github.com/friendica/friendica
synced 2025-04-27 13:10:10 +00:00
Split admin/users into 6 separate modules
- They now feature working pagination
This commit is contained in:
parent
213716d44c
commit
388c0b69d6
31 changed files with 2312 additions and 1002 deletions
121
src/Module/Admin/Users/Pending.php
Normal file
121
src/Module/Admin/Users/Pending.php
Normal file
|
@ -0,0 +1,121 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2020, Friendica
|
||||
*
|
||||
* @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\Admin\Users;
|
||||
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Register;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\Admin\BaseUsers;
|
||||
use Friendica\Module\BaseAdmin;
|
||||
use Friendica\Util\Temporal;
|
||||
|
||||
class Pending extends BaseUsers
|
||||
{
|
||||
public static function post(array $parameters = [])
|
||||
{
|
||||
self::checkAdminAccess();
|
||||
|
||||
self::checkFormSecurityTokenRedirectOnError('/admin/users/pending', 'admin_users_pending');
|
||||
|
||||
$pending = $_POST['pending'] ?? [];
|
||||
|
||||
if (!empty($_POST['page_users_approve'])) {
|
||||
foreach ($pending as $hash) {
|
||||
User::allow($hash);
|
||||
}
|
||||
info(DI::l10n()->tt('%s user approved', '%s users approved', count($pending)));
|
||||
}
|
||||
|
||||
if (!empty($_POST['page_users_deny'])) {
|
||||
foreach ($pending as $hash) {
|
||||
User::deny($hash);
|
||||
}
|
||||
info(DI::l10n()->tt('%s registration revoked', '%s registrations revoked', count($pending)));
|
||||
}
|
||||
|
||||
DI::baseUrl()->redirect('admin/users/pending');
|
||||
}
|
||||
|
||||
public static function content(array $parameters = [])
|
||||
{
|
||||
parent::content($parameters);
|
||||
|
||||
$action = $parameters['action'] ?? '';
|
||||
$uid = $parameters['uid'] ?? 0;
|
||||
|
||||
if ($uid) {
|
||||
$user = User::getById($uid, ['username', 'blocked']);
|
||||
if (!DBA::isResult($user)) {
|
||||
notice(DI::l10n()->t('User not found'));
|
||||
DI::baseUrl()->redirect('admin/users');
|
||||
return ''; // NOTREACHED
|
||||
}
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'allow':
|
||||
self::checkFormSecurityTokenRedirectOnError('/admin/users/pending', 'admin_users_pending', 't');
|
||||
User::allow(Register::getPendingForUser($uid)['hash'] ?? '');
|
||||
notice(DI::l10n()->t('Account approved.'));
|
||||
DI::baseUrl()->redirect('admin/users/pending');
|
||||
break;
|
||||
case 'deny':
|
||||
self::checkFormSecurityTokenRedirectOnError('/admin/users/pending', 'admin_users_pending', 't');
|
||||
User::deny(Register::getPendingForUser($uid)['hash'] ?? '');
|
||||
notice(DI::l10n()->t('Registration revoked'));
|
||||
DI::baseUrl()->redirect('admin/users/pending');
|
||||
break;
|
||||
}
|
||||
|
||||
$pager = new Pager(DI::l10n(), DI::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' => DI::l10n()->t('Administration'),
|
||||
'$page' => DI::l10n()->t('User registrations awaiting review'),
|
||||
'$select_all' => DI::l10n()->t('select all'),
|
||||
'$th_pending' => [DI::l10n()->t('Request date'), DI::l10n()->t('Name'), DI::l10n()->t('Email')],
|
||||
'$no_pending' => DI::l10n()->t('No registrations.'),
|
||||
'$pendingnotetext' => DI::l10n()->t('Note from the user'),
|
||||
'$approve' => DI::l10n()->t('Approve'),
|
||||
'$deny' => DI::l10n()->t('Deny'),
|
||||
|
||||
'$form_security_token' => self::getFormSecurityToken('admin_users_pending'),
|
||||
|
||||
// values //
|
||||
'$baseurl' => DI::baseUrl()->get(true),
|
||||
'$query_string' => DI::args()->getQueryString(),
|
||||
|
||||
'$pending' => $pending,
|
||||
'$count' => $count,
|
||||
'$pager' => $pager->renderFull($count),
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue