]> git.mxchange.org Git - friendica.git/commitdiff
Use centralized function to fetch query results
authorMichael <heluecht@pirati.ca>
Fri, 8 Apr 2022 06:04:50 +0000 (06:04 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 8 Apr 2022 06:04:50 +0000 (06:04 +0000)
src/Model/Contact.php
src/Model/Post/Collection.php
src/Module/Profile/Status.php
src/Protocol/ActivityPub/Processor.php

index 439f9b34ba05c44b27cacdc641b098281b6a70f9..df1a25cd7d81ef0a966b74a6821059b87f5dbaef 100644 (file)
@@ -1461,7 +1461,7 @@ class Contact
                        if ($pager->getStart() == 0) {
                                $cdata = Contact::getPublicAndUserContactID($cid, local_user());
                                if (!empty($cdata['public'])) {
-                                       $pinned = DBA::selectToArray('collection-view', ['uri-id'], ['cid' => $cdata['public'], 'type' => Post\Collection::FEATURED]);
+                                       $pinned = Post\Collection::selectToArrayForContact($cdata['public'], Post\Collection::FEATURED, ['uri-id']);
                                        $items = array_merge($items, $pinned);
                                }
                        }
index f7a1a996bbcaca58a50faefb06c17c3f44fb61b4..476e9d3b336802f68cf5d31a2bc32b6397de8965 100644 (file)
@@ -58,4 +58,17 @@ class Collection
 
                DBA::delete('post-collection', ['uri-id' => $uri_id, 'type' => $type]);
        }
+
+       /**
+        * Fetch collections for a given contact
+        *
+        * @param integer $cid
+        * @param [type] $type
+        * @param array $fields
+        * @return array
+        */
+       public static function selectToArrayForContact(int $cid, int $type = self::FEATURED, array $fields = []) 
+       {
+               return DBA::selectToArray('collection-view', $fields, ['cid' => $cid, 'type' => $type]);
+       }
 }
index 23b78d959a01c0b7f60a6b384467e3f4d5121a7f..f3015692f328439e41633f464b016ff2ab623093 100644 (file)
@@ -209,7 +209,7 @@ class Status extends BaseProfile
 
                if ($pager->getStart() == 0 && !empty($profile['uid'])) {
                        $pcid = Contact::getPublicIdByUserId($profile['uid']);
-                       $pinned = DBA::selectToArray('collection-view', [], ['cid' => $pcid, 'type' => Post\Collection::FEATURED]);
+                       $pinned = Post\Collection::selectToArrayForContact($pcid, Post\Collection::FEATURED);
                        $items = array_merge($items, $pinned);
                }
 
index d6bce87f4f58e8d9f4451016b7858a25fa853b1f..e5653a554fd565aa79cf286e9fd2604e28d0ed1a 100644 (file)
@@ -999,7 +999,7 @@ class Processor
                        return;
                }
 
-               $posts = DBA::selectToArray('collection-view', ['uri-id'], ['cid' => $pcid, 'type' => Post\Collection::FEATURED]);
+               $posts = Post\Collection::selectToArrayForContact($pcid, Post\Collection::FEATURED);
                if (!empty($posts)) {
                        $old_featured = array_column($posts, 'uri-id');
                }