]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/User.php
Remove unused `use` statements & remove PConfig class
[friendica.git] / src / Model / User.php
index b4da6d25685c8d608923e55d59f3f832615e3fac..f19ebc03c5ce971201adaaf85f38dcbb39dd0da1 100644 (file)
@@ -13,15 +13,16 @@ use Friendica\Core\Config;
 use Friendica\Core\Hook;
 use Friendica\Core\L10n;
 use Friendica\Core\Logger;
-use Friendica\Core\PConfig;
 use Friendica\Core\Protocol;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
+use Friendica\DI;
 use Friendica\Model\TwoFactor\AppSpecificPassword;
 use Friendica\Object\Image;
 use Friendica\Util\Crypto;
 use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Images;
 use Friendica\Util\Network;
 use Friendica\Util\Strings;
 use Friendica\Worker\Delivery;
@@ -190,7 +191,8 @@ class User
                        `user`.`page-flags`,
                        `user`.`account-type`,
                        `user`.`prvnets`,
-                       `user`.`account_removed`
+                       `user`.`account_removed`,
+                       `user`.`hidewall`
                        FROM `contact`
                        INNER JOIN `user`
                                ON `user`.`uid` = `contact`.`uid`
@@ -214,12 +216,12 @@ class User
                // Check if the returned data is valid, otherwise fix it. See issue #6122
 
                // Check for correct url and normalised nurl
-               $url = System::baseUrl() . '/profile/' . $r['nickname'];
+               $url = DI::baseUrl() . '/profile/' . $r['nickname'];
                $repair = ($r['url'] != $url) || ($r['nurl'] != Strings::normaliseLink($r['url']));
 
                if (!$repair) {
                        // Check if "addr" is present and correct
-                       $addr = $r['nickname'] . '@' . substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3);
+                       $addr = $r['nickname'] . '@' . substr(DI::baseUrl(), strpos(DI::baseUrl(), '://') + 3);
                        $repair = ($addr != $r['addr']);
                }
 
@@ -272,7 +274,7 @@ class User
                $default_group = 0;
 
                if ($network == Protocol::OSTATUS) {
-                       $default_group = PConfig::get($uid, "ostatus", "default_group");
+                       $default_group = DI::pConfig()->get($uid, "ostatus", "default_group");
                }
 
                if ($default_group != 0) {
@@ -323,7 +325,7 @@ class User
        {
                $user = self::getAuthenticationInfo($user_info);
 
-               if ($third_party && PConfig::get($user['uid'], '2fa', 'verified')) {
+               if ($third_party && DI::pConfig()->get($user['uid'], '2fa', 'verified')) {
                        // Third-party apps can't verify two-factor authentication, we use app-specific passwords instead
                        if (AppSpecificPassword::authenticateUser($user['uid'], $password)) {
                                return $user['uid'];
@@ -585,7 +587,6 @@ class User
         */
        public static function create(array $data)
        {
-               $a = \get_app();
                $return = ['user' => null, 'password' => ''];
 
                $using_invites = Config::get('system', 'invitation_only');
@@ -631,9 +632,9 @@ class User
                                $_SESSION['register'] = 1;
                                $_SESSION['openid'] = $openid_url;
 
-                               $openid = new LightOpenID($a->getHostName());
+                               $openid = new LightOpenID(DI::baseUrl()->getHostname());
                                $openid->identity = $openid_url;
-                               $openid->returnUrl = System::baseUrl() . '/openid';
+                               $openid->returnUrl = DI::baseUrl() . '/openid';
                                $openid->required = ['namePerson/friendly', 'contact/email', 'namePerson'];
                                $openid->optional = ['namePerson/first', 'media/image/aspect11', 'media/image/default'];
                                try {
@@ -780,8 +781,8 @@ class User
                $insert_result = DBA::insert('profile', [
                        'uid' => $uid,
                        'name' => $username,
-                       'photo' => System::baseUrl() . "/photo/profile/{$uid}.jpg",
-                       'thumb' => System::baseUrl() . "/photo/avatar/{$uid}.jpg",
+                       'photo' => DI::baseUrl() . "/photo/profile/{$uid}.jpg",
+                       'thumb' => DI::baseUrl() . "/photo/avatar/{$uid}.jpg",
                        'publish' => $publish,
                        'is-default' => 1,
                        'net-publish' => $netpublish,
@@ -828,15 +829,15 @@ class User
                        $filename = basename($photo);
                        $img_str = Network::fetchUrl($photo, true);
                        // guess mimetype from headers or filename
-                       $type = Image::guessType($photo, true);
+                       $type = Images::guessType($photo, true);
 
                        $Image = new Image($img_str, $type);
                        if ($Image->isValid()) {
                                $Image->scaleToSquare(300);
 
-                               $hash = Photo::newResource();
+                               $resource_id = Photo::newResource();
 
-                               $r = Photo::store($Image, $uid, 0, $hash, $filename, L10n::t('Profile Photos'), 4);
+                               $r = Photo::store($Image, $uid, 0, $resource_id, $filename, L10n::t('Profile Photos'), 4);
 
                                if ($r === false) {
                                        $photo_failure = true;
@@ -844,7 +845,7 @@ class User
 
                                $Image->scaleDown(80);
 
-                               $r = Photo::store($Image, $uid, 0, $hash, $filename, L10n::t('Profile Photos'), 5);
+                               $r = Photo::store($Image, $uid, 0, $resource_id, $filename, L10n::t('Profile Photos'), 5);
 
                                if ($r === false) {
                                        $photo_failure = true;
@@ -852,14 +853,14 @@ class User
 
                                $Image->scaleDown(48);
 
-                               $r = Photo::store($Image, $uid, 0, $hash, $filename, L10n::t('Profile Photos'), 6);
+                               $r = Photo::store($Image, $uid, 0, $resource_id, $filename, L10n::t('Profile Photos'), 6);
 
                                if ($r === false) {
                                        $photo_failure = true;
                                }
 
                                if (!$photo_failure) {
-                                       Photo::update(['profile' => 1], ['resource-id' => $hash]);
+                                       Photo::update(['profile' => 1], ['resource-id' => $resource_id]);
                                }
                        }
                }
@@ -914,6 +915,7 @@ class User
         *
         * It's here as a function because the mail is sent from different parts
         *
+        * @param L10n\L10n   $l10n     The used language
         * @param array  $user     User record array
         * @param string $sitename
         * @param string $siteurl
@@ -921,9 +923,9 @@ class User
         * @return NULL|boolean from notification() and email() inherited
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public static function sendRegisterOpenEmail($user, $sitename, $siteurl, $password)
+       public static function sendRegisterOpenEmail(L10n\L10n $l10n, $user, $sitename, $siteurl, $password)
        {
-               $preamble = Strings::deindent(L10n::t(
+               $preamble = Strings::deindent($l10n->t(
                        '
                                Dear %1$s,
                                Thank you for registering at %2$s. Your account has been created.
@@ -931,7 +933,7 @@ class User
                        $user['username'],
                        $sitename
                ));
-               $body = Strings::deindent(L10n::t(
+               $body = Strings::deindent($l10n->t(
                        '
                        The login details are as follows: