]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Admin/Users.php
Merge pull request #8272 from MrPetovan/bug/8254-regex-url-img
[friendica.git] / src / Module / Admin / Users.php
index 710708087374cdfff71c6d347fa6115b40fb79be..fbaab1ded297b3277af484bcc29a1e0cfa7c61af 100644 (file)
@@ -1,19 +1,37 @@
 <?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\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 = [])
        {
@@ -24,7 +42,7 @@ class Users extends BaseAdminModule
                $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');
 
@@ -74,18 +92,16 @@ class Users extends BaseAdminModule
 
                        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'])) {
@@ -214,7 +230,7 @@ class Users extends BaseAdminModule
                );
                $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'),