From 5afedb28d4387eef580f7a6602016cc676d8d9e1 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 23 Dec 2017 07:33:51 +0000 Subject: [PATCH] You can now comment on the community page --- include/conversation.php | 12 +++++++----- mod/community.php | 29 +++++++++++++++++++++++++++-- src/Object/Thread.php | 4 ++++ 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index ee68d8f5c9..0fc6a418d7 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -574,10 +574,10 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { } } elseif ($mode === 'community') { $profile_owner = 0; - if (!$update) { - $live_update_div = '
' . "\r\n" - . "\r\n"; - } +// if (!$update) { +// $live_update_div = '
' . "\r\n" +// . "\r\n"; +// } } elseif ($mode === 'search') { $live_update_div = '' . "\r\n"; } @@ -617,8 +617,10 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { } else { $writable = false; } + $writable = true; - if ($mode === 'network-new' || $mode === 'search' || $mode === 'community') { + if ($mode === 'network-new' || $mode === 'search') { +// || $mode === 'community') { /* * "New Item View" on network page or search page results diff --git a/mod/community.php b/mod/community.php index df21263278..10852b49e2 100644 --- a/mod/community.php +++ b/mod/community.php @@ -114,9 +114,34 @@ function community_getpublicitems($start, $itemspage) { $r = dba::p("SELECT ".item_fieldlists()." FROM `thread` INNER JOIN `item` ON `item`.`id` = `thread`.`iid` ".item_joins(). "WHERE `thread`.`uid` = 0 AND `verb` = ? - ORDER BY `thread`.`created` DESC LIMIT ".intval($start).", ".intval($itemspage), + ORDER BY `thread`.`commented` DESC LIMIT ".intval($start).", ".intval($itemspage), ACTIVITY_POST ); - return dba::inArray($r); + while ($rr = dba::fetch($r)) { + if (!in_array($rr['item_id'], $parents_arr)) { + $parents_arr[] = $rr['item_id']; + } + } + + dba::close(); + + $max_comments = Config::get("system", "max_comments", 100); + + $items = array(); + + foreach ($parents_arr AS $parents) { + $thread_items = dba::p(item_query()." AND `item`.`uid` = 0 + AND `item`.`parent` = ? + ORDER BY `item`.`commented` DESC LIMIT ".intval($max_comments + 1), + $parents + ); + + if (DBM::is_result($thread_items)) { + $items = array_merge($items, dba::inArray($thread_items)); + } + } + $items = conv_sort($items, "`commented`"); + + return $items; } diff --git a/src/Object/Thread.php b/src/Object/Thread.php index 2872fe4a02..a03bae6e9d 100644 --- a/src/Object/Thread.php +++ b/src/Object/Thread.php @@ -66,6 +66,10 @@ class Thread extends BaseObject $this->profile_owner = $a->profile['uid']; $this->writable = can_write_wall($a, $this->profile_owner) || $writable; break; + case 'community': + $this->profile_owner = local_user(); + $this->writable = $writable; + break; default: logger('[ERROR] Conversation::setMode : Unhandled mode ('. $mode .').', LOGGER_DEBUG); return false; -- 2.39.5