Children for the network page are now fetched correctly in the conversation

This commit is contained in:
Michael 2018-02-26 06:38:27 +00:00
parent 9308b7f2df
commit d2728cad2e
1 changed files with 8 additions and 7 deletions

View File

@ -496,7 +496,7 @@ function item_condition() {
* that are based on unique features of the calling module.
*
*/
function conversation(App $a, $items, $mode, $update, $preview = false, $ordering = '') {
function conversation(App $a, $items, $mode, $update, $preview = false, $order = 'commented') {
require_once 'mod/proxy.php';
$ssl_state = ((local_user()) ? true : false);
@ -520,7 +520,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $orderin
$previewing = (($preview) ? ' preview ' : '');
if ($mode === 'network') {
$items = community_add_items($items, $ordering);
$items = conversation_add_children($items, false, $order);
$profile_owner = local_user();
if (!$update) {
/*
@ -581,7 +581,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $orderin
. " var profile_page = 1; </script>";
}
} elseif ($mode === 'community') {
$items = community_add_items($items, $ordering);
$items = conversation_add_children($items, true, $order);
$profile_owner = 0;
if (!$update) {
$live_update_div = '<div id="live-community"></div>' . "\r\n"
@ -900,15 +900,16 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $orderin
*
* @return array items with parents and comments
*/
function community_add_items($parents, $ordering = "`commented`") {
function conversation_add_children($parents, $block_authors, $order) {
$max_comments = Config::get("system", "max_comments", 100);
$items = [];
$block_sql = $block_authors ? "AND NOT `author`.`hidden` AND NOT `author`.`blocked`" : "";
foreach ($parents AS $parent) {
$thread_items = dba::p(item_query()." AND `item`.`uid` = ?
AND `item`.`parent-uri` = ?
AND NOT `author`.`hidden` AND NOT `author`.`blocked`
AND `item`.`parent-uri` = ? $block_sql
ORDER BY `item`.`commented` DESC LIMIT ".intval($max_comments + 1),
local_user(),
$parent['uri']
@ -950,7 +951,7 @@ function community_add_items($parents, $ordering = "`commented`") {
}
}
$items = conv_sort($items, $ordering);
$items = conv_sort($items, $order);
return $items;
}