From f255749c6ac9570669808d0b4bdc5961b4a06c82 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 6 Oct 2020 05:18:54 +0000 Subject: [PATCH] Issue 9358: liking and commenting on the community page now gives a feedback --- src/Module/Conversation/Community.php | 37 +++++++++++-------- view/templates/wall_thread.tpl | 2 +- .../frio/templates/threaded_conversation.tpl | 2 +- .../templates/threaded_conversation.tpl | 2 +- view/theme/smoothly/templates/wall_thread.tpl | 2 +- .../vier/templates/threaded_conversation.tpl | 2 +- 6 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/Module/Conversation/Community.php b/src/Module/Conversation/Community.php index 24ee56f6c..c8fd431ba 100644 --- a/src/Module/Conversation/Community.php +++ b/src/Module/Conversation/Community.php @@ -46,6 +46,7 @@ class Community extends BaseModule protected static $itemsPerPage; protected static $since_id; protected static $max_id; + protected static $item_id; public static function content(array $parameters = []) { @@ -258,6 +259,7 @@ class Community extends BaseModule self::$since_id = $_GET['since_id'] ?? null; self::$max_id = $_GET['max_id'] ?? null; self::$max_id = $_GET['last_commented'] ?? self::$max_id; + self::$item_id = $_GET['item'] ?? null; } /** @@ -271,7 +273,7 @@ class Community extends BaseModule */ protected static function getItems() { - $items = self::selectItems(self::$since_id, self::$max_id, self::$itemsPerPage); + $items = self::selectItems(self::$since_id, self::$max_id, self::$item_id, self::$itemsPerPage); $maxpostperauthor = (int) DI::config()->get('system', 'max_author_posts_community_page'); if ($maxpostperauthor != 0 && self::$content == 'local') { @@ -303,7 +305,7 @@ class Community extends BaseModule self::$max_id = $items[count($items) - 1]['commented']; } - $items = self::selectItems(self::$since_id, self::$max_id, self::$itemsPerPage); + $items = self::selectItems(self::$since_id, self::$max_id, self::$item_id, self::$itemsPerPage); } } else { $selected_items = $items; @@ -322,7 +324,7 @@ class Community extends BaseModule * @throws \Exception * @TODO Move to repository/factory */ - private static function selectItems($since_id, $max_id, $itemspage) + private static function selectItems($since_id, $max_id, $item_id, $itemspage) { $r = false; @@ -342,19 +344,24 @@ class Community extends BaseModule return []; } - if (local_user() && !empty($_REQUEST['no_sharer'])) { - $condition[0] .= " AND NOT EXISTS (SELECT `uri-id` FROM `thread` AS t1 WHERE `t1`.`uri-id` = `thread`.`uri-id` AND `t1`.`uid` = ?)"; - $condition[] = local_user(); - } + if (isset($item_id)) { + $condition[0] .= " AND `iid` = ?"; + $condition[] = $item_id; + } else { + if (local_user() && !empty($_REQUEST['no_sharer'])) { + $condition[0] .= " AND NOT EXISTS (SELECT `uri-id` FROM `thread` AS t1 WHERE `t1`.`uri-id` = `thread`.`uri-id` AND `t1`.`uid` = ?)"; + $condition[] = local_user(); + } + + if (isset($max_id)) { + $condition[0] .= " AND `commented` < ?"; + $condition[] = $max_id; + } - if (isset($max_id)) { - $condition[0] .= " AND `commented` < ?"; - $condition[] = $max_id; - } - - if (isset($since_id)) { - $condition[0] .= " AND `commented` > ?"; - $condition[] = $since_id; + if (isset($since_id)) { + $condition[0] .= " AND `commented` > ?"; + $condition[] = $since_id; + } } $r = Item::selectThreadForUser(0, ['uri', 'commented', 'author-link'], $condition, ['order' => ['commented' => true], 'limit' => $itemspage]); diff --git a/view/templates/wall_thread.tpl b/view/templates/wall_thread.tpl index 73e99cb1b..b869b996d 100644 --- a/view/templates/wall_thread.tpl +++ b/view/templates/wall_thread.tpl @@ -16,7 +16,7 @@ {{/if}} -
+
diff --git a/view/theme/frio/templates/threaded_conversation.tpl b/view/theme/frio/templates/threaded_conversation.tpl index b1039d947..f618da281 100644 --- a/view/theme/frio/templates/threaded_conversation.tpl +++ b/view/theme/frio/templates/threaded_conversation.tpl @@ -5,7 +5,7 @@ {{foreach $threads as $thread}}
-
+
{{* {{if $thread.type == tag}} {{include file="wall_item_tag.tpl" item=$thread}} diff --git a/view/theme/quattro/templates/threaded_conversation.tpl b/view/theme/quattro/templates/threaded_conversation.tpl index 0d90db186..33431361f 100644 --- a/view/theme/quattro/templates/threaded_conversation.tpl +++ b/view/theme/quattro/templates/threaded_conversation.tpl @@ -2,7 +2,7 @@ {{foreach $threads as $thread}} -
+
{{if $thread.type == tag}} diff --git a/view/theme/smoothly/templates/wall_thread.tpl b/view/theme/smoothly/templates/wall_thread.tpl index c9f258f6f..2e83a2482 100644 --- a/view/theme/smoothly/templates/wall_thread.tpl +++ b/view/theme/smoothly/templates/wall_thread.tpl @@ -11,7 +11,7 @@