X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FUser.php;h=854961154b5dfe56772dc11c70c7d4314a1eaae0;hb=e659a0314086dd700dbe5e754e383ab758725805;hp=cb769ce3fc809532221450cca772f8d18413260f;hpb=4f7740264ec1d5b7633e24f317d75d00ddf8caad;p=friendica.git diff --git a/src/Model/User.php b/src/Model/User.php index cb769ce3fc..854961154b 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -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 * @@ -675,6 +693,10 @@ class User */ public static function updateLastActivity(int $uid) { + if (!$uid) { + return; + } + $user = User::getById($uid, ['last-activity']); if (empty($user)) { return; @@ -1204,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); @@ -1640,7 +1667,7 @@ class User */ public static function identities(int $uid): array { - if (empty($uid)) { + if (!$uid) { return []; } @@ -1651,7 +1678,7 @@ class User return $identities; } - if ($user['parent-uid'] == 0) { + if (!$user['parent-uid']) { // First add our own entry $identities = [[ 'uid' => $user['uid'], @@ -1712,7 +1739,7 @@ class User */ public static function hasIdentities(int $uid): bool { - if (empty($uid)) { + if (!$uid) { return false; } @@ -1721,7 +1748,7 @@ class User return false; } - if ($user['parent-uid'] != 0) { + if ($user['parent-uid']) { return true; } @@ -1848,8 +1875,8 @@ class User { $condition = [ 'email' => self::getAdminEmailList(), - 'parent-uid' => 0, - 'blocked' => 0, + 'parent-uid' => null, + 'blocked' => false, 'verified' => true, 'account_removed' => false, 'account_expired' => false,