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);
}
}
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]);
+ }
}
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);
}
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');
}