]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/User.php
Merge pull request #13331 from annando/paging-search
[friendica.git] / src / Model / User.php
index d6a72fbfe9256b11e9ed027a2f6f16e7b4277eb4..89d75849fe9430057a65a34953c718e7b68d516f 100644 (file)
@@ -132,6 +132,17 @@ class User
                return null;
        }
 
+       /**
+        * Get the Uri-Id of the system account
+        *
+        * @return integer
+        */
+       public static function getSystemUriId(): int
+       {
+               $system = self::getSystemAccount();
+               return $system['uri-id'] ?? 0;
+       }
+
        /**
         * Fetch the system account
         *
@@ -483,7 +494,7 @@ class User
        }
 
        /**
-        * Returns the default circle for a given user and network
+        * Returns the default circle for a given user
         *
         * @param int $uid User id
         *
@@ -502,6 +513,24 @@ class User
                return $default_circle;
        }
 
+       /**
+        * Returns the default circle for groups for a given user
+        *
+        * @param int $uid User id
+        *
+        * @return int circle id
+        * @throws Exception
+        */
+       public static function getDefaultGroupCircle(int $uid): int
+       {
+               $default_circle = DI::pConfig()->get($uid, 'system', 'default-group-gid');
+               if (empty($default_circle)) {
+                       $default_circle = self::getDefaultCircle($uid);
+               }
+
+               return $default_circle;
+       }
+
        /**
         * Authenticate a user with a clear text password
         *
@@ -1208,6 +1237,11 @@ class User
 
                DBA::update('user', $fields, ['uid' => $uid]);
 
+               $def_gid_groups = Circle::create($uid, DI::l10n()->t('Groups'));
+               if ($def_gid_groups) {
+                       DI::pConfig()->set($uid, 'system', 'default-group-gid', $def_gid_groups);
+               }
+
                // if we have no OpenID photo try to look up an avatar
                if (!strlen($photo)) {
                        $photo = Network::lookupAvatarByEmail($email);