]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Group.php
spelling: birthdays
[friendica.git] / src / Model / Group.php
index 268680a165b79cd7e90e5ae96c190764c7a9af11..eb4008184f943d1242ba30663352e1896f75acf3 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -102,7 +102,7 @@ class Group
                                $group = DBA::selectFirst('group', ['deleted'], ['id' => $gid]);
                                if (DBA::isResult($group) && $group['deleted']) {
                                        DBA::update('group', ['deleted' => 0], ['id' => $gid]);
-                                       notice(DI::l10n()->t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.'));
+                                       DI::sysmsg()->addNotice(DI::l10n()->t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.'));
                                }
                                return true;
                        }
@@ -138,25 +138,29 @@ class Group
         */
        public static function getIdsByContactId(int $cid): array
        {
-               $return = [];
+               $contact = Contact::getById($cid, ['rel']);
+               if (!$contact) {
+                       return [];
+               }
+
+               $groupIds = [];
 
                $stmt = DBA::select('group_member', ['gid'], ['contact-id' => $cid]);
                while ($group = DBA::fetch($stmt)) {
-                       $return[] = $group['gid'];
+                       $groupIds[] = $group['gid'];
                }
                DBA::close($stmt);
 
                // Meta-groups
-               $contact = Contact::getById($cid, ['rel']);
                if ($contact['rel'] == Contact::FOLLOWER || $contact['rel'] == Contact::FRIEND) {
-                       $return[] = self::FOLLOWERS;
+                       $groupIds[] = self::FOLLOWERS;
                }
 
                if ($contact['rel'] == Contact::FRIEND) {
-                       $return[] = self::MUTUALS;
+                       $groupIds[] = self::MUTUALS;
                }
 
-               return $return;
+               return $groupIds;
        }
 
        /**
@@ -183,8 +187,8 @@ class Group
                                        ) AS `count`
                                FROM `group`
                                WHERE `group`.`uid` = ?;",
-                       local_user(),
-                       local_user()
+                       DI::userSession()->getLocalUserId(),
+                       DI::userSession()->getLocalUserId()
                );
 
                return DBA::toArray($stmt);
@@ -522,7 +526,7 @@ class Group
         */
        public static function sidebarWidget(string $every = 'contact', string $each = 'group', string $editmode = 'standard', $group_id = '', int $cid = 0)
        {
-               if (!local_user()) {
+               if (!DI::userSession()->getLocalUserId()) {
                        return '';
                }
 
@@ -540,7 +544,7 @@ class Group
                        $member_of = self::getIdsByContactId($cid);
                }
 
-               $stmt = DBA::select('group', [], ['deleted' => false, 'uid' => local_user(), 'cid' => null], ['order' => ['name']]);
+               $stmt = DBA::select('group', [], ['deleted' => false, 'uid' => DI::userSession()->getLocalUserId(), 'cid' => null], ['order' => ['name']]);
                while ($group = DBA::fetch($stmt)) {
                        $selected = (($group_id == $group['id']) ? ' group-selected' : '');