3 * @copyright Copyright (C) 2010-2023, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Module\Moderation\Users;
24 use Friendica\Content\Pager;
25 use Friendica\Core\Renderer;
26 use Friendica\Model\Register;
27 use Friendica\Model\User;
28 use Friendica\Module\Moderation\BaseUsers;
30 class Pending extends BaseUsers
32 protected function post(array $request = [])
34 $this->checkModerationAccess();
36 self::checkFormSecurityTokenRedirectOnError('moderation/users/pending', 'admin_users_pending');
38 $pending = $request['pending'] ?? [];
40 if (!empty($request['page_users_approve'])) {
41 foreach ($pending as $hash) {
44 $this->systemMessages->addInfo($this->tt('%s user approved', '%s users approved', count($pending)));
47 if (!empty($request['page_users_deny'])) {
48 foreach ($pending as $hash) {
51 $this->systemMessages->addInfo($this->tt('%s registration revoked', '%s registrations revoked', count($pending)));
54 $this->baseUrl->redirect('moderation/users/pending');
57 protected function content(array $request = []): string
61 $action = $this->parameters['action'] ?? '';
62 $uid = $this->parameters['uid'] ?? 0;
65 $user = User::getById($uid, ['username', 'blocked']);
67 $this->systemMessages->addNotice($this->t('User not found'));
68 $this->baseUrl->redirect('moderation/users');
74 self::checkFormSecurityTokenRedirectOnError('moderation/users/pending', 'admin_users_pending', 't');
75 User::allow(Register::getPendingForUser($uid)['hash'] ?? '');
76 $this->systemMessages->addNotice($this->t('Account approved.'));
77 $this->baseUrl->redirect('moderation/users/pending');
80 self::checkFormSecurityTokenRedirectOnError('moderation/users/pending', 'admin_users_pending', 't');
81 User::deny(Register::getPendingForUser($uid)['hash'] ?? '');
82 $this->systemMessages->addNotice($this->t('Registration revoked'));
83 $this->baseUrl->redirect('moderation/users/pending');
87 $pager = new Pager($this->l10n, $this->args->getQueryString(), 100);
89 $pending = Register::getPending($pager->getStart(), $pager->getItemsPerPage());
91 $count = Register::getPendingCount();
93 $t = Renderer::getMarkupTemplate('moderation/users/pending.tpl');
94 return self::getTabsHTML('pending') . Renderer::replaceMacros($t, [
96 '$title' => $this->t('Administration'),
97 '$page' => $this->t('User registrations awaiting review'),
98 '$select_all' => $this->t('select all'),
99 '$th_pending' => [$this->t('Request date'), $this->t('Name'), $this->t('Email')],
100 '$no_pending' => $this->t('No registrations.'),
101 '$pendingnotetext' => $this->t('Note from the user'),
102 '$approve' => $this->t('Approve'),
103 '$deny' => $this->t('Deny'),
105 '$form_security_token' => self::getFormSecurityToken('admin_users_pending'),
108 '$query_string' => $this->args->getQueryString(),
110 '$pending' => $pending,
112 '$pager' => $pager->renderFull($count),