]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/User.php
Fix several warnings and errors
[friendica.git] / src / Model / User.php
index ef49f45edab1012f9873678c473f2137542d960f..83375115ecef6a61a3847454dc4840cbcae93614 100644 (file)
@@ -18,7 +18,6 @@ use Friendica\Core\Protocol;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
-use Friendica\Model\Photo;
 use Friendica\Model\TwoFactor\AppSpecificPassword;
 use Friendica\Object\Image;
 use Friendica\Util\Crypto;
@@ -105,6 +104,27 @@ class User
                return DBA::selectFirst('user', $fields, ['uid' => $uid]);
        }
 
+       /**
+        * Returns a user record based on it's GUID
+        *
+        * @param string $guid   The guid of the user
+        * @param array  $fields The fields to retrieve
+        * @param bool   $active True, if only active records are searched
+        *
+        * @return array|boolean User record if it exists, false otherwise
+        * @throws Exception
+        */
+       public static function getByGuid(string $guid, array $fields = [], bool $active = true)
+       {
+               if ($active) {
+                       $cond = ['guid' => $guid, 'account_expired' => false, 'account_removed' => false];
+               } else {
+                       $cond = ['guid' => $guid];
+               }
+
+               return DBA::selectFirst('user', $fields, $cond);
+       }
+
        /**
         * @param  string        $nickname
         * @param array          $fields
@@ -170,7 +190,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`
@@ -602,6 +623,7 @@ class User
                        }
                }
 
+               /// @todo Check if this part is really needed. We should have fetched all this data in advance
                if (empty($username) || empty($email) || empty($nickname)) {
                        if ($openid_url) {
                                if (!Network::isUrlValid($openid_url)) {