<?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;
use Friendica\Content\Pager;
-use Friendica\Core\Config;
-use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Register;
use Friendica\Model\User;
-use Friendica\Module\BaseAdminModule;
+use Friendica\Module\BaseAdmin;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
-class Users extends BaseAdminModule
+class Users extends BaseAdmin
{
public static function post(array $parameters = [])
{
$nu_name = $_POST['new_user_name'] ?? '';
$nu_nickname = $_POST['new_user_nickname'] ?? '';
$nu_email = $_POST['new_user_email'] ?? '';
- $nu_language = Config::get('system', 'language');
+ $nu_language = DI::config()->get('system', 'language');
parent::checkFormSecurityTokenRedirectOnError('/admin/users', 'admin_users');
Thank you and welcome to %4$s.'));
- $preamble = sprintf($preamble, $user['username'], Config::get('config', 'sitename'));
- $body = sprintf($body, DI::baseUrl()->get(), $user['nickname'], $result['password'], Config::get('config', 'sitename'));
-
- notification([
- 'type' => SYSTEM_EMAIL,
- 'language' => $user['language'],
- 'to_name' => $user['username'],
- 'to_email' => $user['email'],
- 'uid' => $user['uid'],
- 'subject' => DI::l10n()->t('Registration details for %s', Config::get('config', 'sitename')),
- 'preamble' => $preamble,
- 'body' => $body]);
+ $preamble = sprintf($preamble, $user['username'], DI::config()->get('config', 'sitename'));
+ $body = sprintf($body, DI::baseUrl()->get(), $user['nickname'], $result['password'], DI::config()->get('config', 'sitename'));
+
+ $email = DI::emailer()
+ ->newSystemMail()
+ ->withMessage(DI::l10n()->t('Registration details for %s', DI::config()->get('config', 'sitename')), $preamble, $body)
+ ->forUser($user)
+ ->withRecipient($user['email'])
+ ->build();
+ return DI::emailer()->send($email);
}
if (!empty($_POST['page_users_block'])) {
// @TODO Move this to Model\User:block($users);
DBA::update('user', ['blocked' => 1], ['uid' => $users]);
- notice(L10n::tt('%s user blocked', '%s users blocked', count($users)));
+ notice(DI::l10n()->tt('%s user blocked', '%s users blocked', count($users)));
}
if (!empty($_POST['page_users_unblock'])) {
// @TODO Move this to Model\User:unblock($users);
DBA::update('user', ['blocked' => 0], ['uid' => $users]);
- notice(L10n::tt('%s user unblocked', '%s users unblocked', count($users)));
+ notice(DI::l10n()->tt('%s user unblocked', '%s users unblocked', count($users)));
}
if (!empty($_POST['page_users_delete'])) {
}
}
- notice(L10n::tt('%s user deleted', '%s users deleted', count($users)));
+ notice(DI::l10n()->tt('%s user deleted', '%s users deleted', count($users)));
}
if (!empty($_POST['page_users_approve'])) {
);
$users = DBA::toArray($usersStmt);
- $adminlist = explode(',', str_replace(' ', '', Config::get('config', 'admin_email')));
+ $adminlist = explode(',', str_replace(' ', '', DI::config()->get('config', 'admin_email')));
$_setup_users = function ($e) use ($adminlist) {
$page_types = [
User::PAGE_FLAGS_NORMAL => DI::l10n()->t('Normal Account Page'),