]> git.mxchange.org Git - friendica.git/commitdiff
Replace System::baseUrl() by App->getBaseURL() in mod/register
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 14 Oct 2018 12:58:27 +0000 (08:58 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 14 Oct 2018 15:19:59 +0000 (11:19 -0400)
- Remove redundant System::baseUrl() in goaway() calls
- Add more generic Friendica\Model use statement
- Allow empty path in goaway()

boot.php
mod/register.php

index 435de0923c2307bf5b3c5ca7fe0af81173962437..2433143ddbd5224a88b2370d98dedbc619398b0b 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -647,7 +647,7 @@ function killme()
 /**
  * @brief Redirect to another URL and terminate this process.
  */
-function goaway($path)
+function goaway($path = '')
 {
        if (strstr(normalise_link($path), 'http://')) {
                $url = $path;
index 454062d89b6c90c874f7511a1acd8d0ca003fc93..2b3522234e84adfb749cbc8865e526b42aea6745 100644 (file)
@@ -12,7 +12,7 @@ use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
-use Friendica\Model\User;
+use Friendica\Model;
 use Friendica\Module\Tos;
 use Friendica\Util\DateTimeFormat;
 
@@ -67,7 +67,7 @@ function register_post(App $a)
        $arr['language'] = L10n::getBrowserLanguage();
 
        try {
-               $result = User::create($arr);
+               $result = Model\User::create($arr);
        } catch (Exception $e) {
                notice($e->getMessage());
                return;
@@ -76,7 +76,7 @@ function register_post(App $a)
        $user = $result['user'];
 
        if ($netpublish && intval(Config::get('config', 'register_policy')) !== REGISTER_APPROVE) {
-               $url = System::baseUrl() . '/profile/' . $user['nickname'];
+               $url = $a->getBaseUrl() . '/profile/' . $user['nickname'];
                Worker::add(PRIORITY_LOW, "Directory", $url);
        }
 
@@ -92,12 +92,18 @@ function register_post(App $a)
 
                // Only send a password mail when the password wasn't manually provided
                if (!x($_POST, 'password1') || !x($_POST, 'confirm')) {
-                       $res = User::sendRegisterOpenEmail(
-                                       $user['email'], Config::get('config', 'sitename'), System::baseUrl(), $user['username'], $result['password'], $user);
+                       $res = Model\User::sendRegisterOpenEmail(
+                               $user['email'],
+                               Config::get('config', 'sitename'),
+                               $a->getBaseUrl(),
+                               $user['username'],
+                               $result['password'],
+                               $user
+                       );
 
                        if ($res) {
                                info(L10n::t('Registration successful. Please check your email for further instructions.') . EOL);
-                               goaway(System::baseUrl());
+                               goaway();
                        } else {
                                notice(
                                        L10n::t('Failed to send email message. Here your accout details:<br> login: %s<br> password: %s<br><br>You can change your password after login.',
@@ -108,12 +114,12 @@ function register_post(App $a)
                        }
                } else {
                        info(L10n::t('Registration successful.') . EOL);
-                       goaway(System::baseUrl());
+                       goaway();
                }
        } elseif (intval(Config::get('config', 'register_policy')) === REGISTER_APPROVE) {
                if (!strlen(Config::get('config', 'admin_email'))) {
                        notice(L10n::t('Your registration can not be processed.') . EOL);
-                       goaway(System::baseUrl());
+                       goaway();
                }
 
                $hash = random_string();
@@ -146,9 +152,9 @@ function register_post(App $a)
                                'source_name'  => $user['username'],
                                'source_mail'  => $user['email'],
                                'source_nick'  => $user['nickname'],
-                               'source_link'  => System::baseUrl() . "/admin/users/",
-                               'link'         => System::baseUrl() . "/admin/users/",
-                               'source_photo' => System::baseUrl() . "/photo/avatar/" . $user['uid'] . ".jpg",
+                               'source_link'  => $a->getBaseUrl() . "/admin/users/",
+                               'link'         => $a->getBaseUrl() . "/admin/users/",
+                               'source_photo' => $a->getBaseUrl() . "/photo/avatar/" . $user['uid'] . ".jpg",
                                'to_email'     => $admin['email'],
                                'uid'          => $admin['uid'],
                                'language'     => $admin['language'] ? $admin['language'] : 'en',
@@ -156,11 +162,17 @@ function register_post(App $a)
                        ]);
                }
                // send notification to the user, that the registration is pending
-               User::sendRegisterPendingEmail(
-                       $user['email'], Config::get('config', 'sitename'), $user['username']);
+               Model\User::sendRegisterPendingEmail(
+                       $user['email'],
+                       Config::get('config', 'sitename'),
+                       $user['username'],
+                       $a->getBaseURL(),
+                       $user['nickname'],
+                       $result['password']
+               );
 
                info(L10n::t('Your registration is pending approval by the site owner.') . EOL);
-               goaway(System::baseUrl());
+               goaway();
        }
 
        return;