Pinned posts now work for visitors in the intended way

This commit is contained in:
Michael 2019-11-08 06:52:44 +00:00
parent 2200996d44
commit fc94cad5f2
4 changed files with 34 additions and 10 deletions

View file

@ -801,10 +801,12 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
/**
* Fetch all comments from a query. Additionally set the newest resharer as thread owner.
*
* @param $thread_items Database statement with thread posts
* @param array $thread_items Database statement with thread posts
* @param boolean $pinned Is the item pinned?
*
* @return array items with parents and comments
*/
function conversation_fetch_comments($thread_items) {
function conversation_fetch_comments($thread_items, $pinned) {
$comments = [];
$parentlines = [];
$lineno = 0;
@ -822,6 +824,10 @@ function conversation_fetch_comments($thread_items) {
$parentlines[] = $lineno;
}
if ($row['gravity'] == GRAVITY_PARENT) {
$row['pinned'] = $pinned;
}
$comments[] = $row;
$lineno++;
}
@ -872,7 +878,7 @@ function conversation_add_children(array $parents, $block_authors, $order, $uid)
$thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity']), $condition, $params);
$comments = conversation_fetch_comments($thread_items);
$comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false);
if (count($comments) != 0) {
$items = array_merge($items, $comments);