3 * @copyright Copyright (C) 2010-2022, 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\Core\Renderer;
26 use Friendica\Model\User;
27 use Friendica\Module\Moderation\BaseUsers;
29 class Create extends BaseUsers
31 protected function post(array $request = [])
33 $this->checkModerationAccess();
35 self::checkFormSecurityTokenRedirectOnError('moderation/users/create', 'admin_users_create');
37 $nu_name = $request['new_user_name'] ?? '';
38 $nu_nickname = $request['new_user_nickname'] ?? '';
39 $nu_email = $request['new_user_email'] ?? '';
40 $nu_language = DI::config()->get('system', 'language');
42 if ($nu_name !== '' && $nu_email !== '' && $nu_nickname !== '') {
44 User::createMinimal($nu_name, $nu_email, $nu_nickname, $nu_language);
45 $this->baseUrl->redirect('moderation/users');
46 } catch (\Exception $ex) {
47 $this->systemMessages->addNotice($ex->getMessage());
51 $this->baseUrl->redirect('moderation/users/create');
54 protected function content(array $request = []): string
58 $t = Renderer::getMarkupTemplate('moderation/users/create.tpl');
59 return self::getTabsHTML('all') . Renderer::replaceMacros($t, [
61 '$title' => $this->t('Administration'),
62 '$page' => $this->t('New User'),
63 '$submit' => $this->t('Add User'),
65 '$form_security_token' => self::getFormSecurityToken('admin_users_create'),
68 '$baseurl' => $this->baseUrl->get(true),
69 '$query_string' => $this->args->getQueryString(),
71 '$newusername' => ['new_user_name', $this->t('Name'), '', $this->t('Name of the new user.')],
72 '$newusernickname' => ['new_user_nickname', $this->t('Nickname'), '', $this->t('Nickname of the new user.')],
73 '$newuseremail' => ['new_user_email', $this->t('Email'), '', $this->t('Email address of the new user.'), '', '', 'email'],