3 * @copyright Copyright (C) 2020, Friendica
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\Admin\Users;
24 use Friendica\Core\Renderer;
26 use Friendica\Model\User;
27 use Friendica\Module\Admin\BaseUsers;
29 class Create extends BaseUsers
31 public static function post(array $parameters = [])
33 self::checkAdminAccess();
35 self::checkFormSecurityTokenRedirectOnError('/admin/users/create', 'admin_users_create');
37 $nu_name = $_POST['new_user_name'] ?? '';
38 $nu_nickname = $_POST['new_user_nickname'] ?? '';
39 $nu_email = $_POST['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 DI::baseUrl()->redirect('admin/users');
46 } catch (\Exception $ex) {
47 notice($ex->getMessage());
51 DI::baseUrl()->redirect('admin/users/create');
54 public static function content(array $parameters = [])
56 parent::content($parameters);
58 $t = Renderer::getMarkupTemplate('admin/users/create.tpl');
59 return self::getTabsHTML('all') . Renderer::replaceMacros($t, [
61 '$title' => DI::l10n()->t('Administration'),
62 '$page' => DI::l10n()->t('New User'),
63 '$submit' => DI::l10n()->t('Add User'),
65 '$form_security_token' => self::getFormSecurityToken('admin_users_create'),
68 '$baseurl' => DI::baseUrl()->get(true),
69 '$query_string' => DI::args()->getQueryString(),
71 '$newusername' => ['new_user_name', DI::l10n()->t('Name'), '', DI::l10n()->t('Name of the new user.')],
72 '$newusernickname' => ['new_user_nickname', DI::l10n()->t('Nickname'), '', DI::l10n()->t('Nickname of the new user.')],
73 '$newuseremail' => ['new_user_email', DI::l10n()->t('Email'), '', DI::l10n()->t('Email address of the new user.'), '', '', 'email'],