]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/User.php
Apply suggestions from code review
[friendica.git] / src / Model / User.php
index ed63d67650d7212bbadd08404c6398ab339e5f5c..854961154b5dfe56772dc11c70c7d4314a1eaae0 100644 (file)
@@ -88,7 +88,7 @@ class User
         * ACCOUNT_TYPE_NEWS - the account is a news reflector
         *      Associated page type: PAGE_FLAGS_SOAPBOX
         *
-        * ACCOUNT_TYPE_COMMUNITY - the account is community forum
+        * ACCOUNT_TYPE_COMMUNITY - the account is community group
         *      Associated page types: PAGE_COMMUNITY, PAGE_FLAGS_PRVGROUP
         *
         * ACCOUNT_TYPE_RELAY - the account is a relay
@@ -483,7 +483,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 +502,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 +1226,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);