From b0248d2d7843cf8ecffc721dc0a522fdd0fd2530 Mon Sep 17 00:00:00 2001 From: Christian Schnegelberger Date: Sat, 23 Sep 2023 15:54:21 +0200 Subject: [PATCH] [ticket/17187] Repair mcp link to first unread post PHPBB3-17187 --- phpBB/includes/mcp/mcp_forum.php | 1 + phpBB/includes/mcp/mcp_topic.php | 15 +++++++++++++++ phpBB/styles/prosilver/template/mcp_topic.html | 3 +++ 3 files changed, 19 insertions(+) diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index d3532a727ac..b2cb0844c7e 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -344,6 +344,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info) } $topic_row = array_merge($topic_row, array( 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&f=$forum_id&t={$row_ary['topic_id']}&mode=topic_view"), + 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&f=$forum_id&t={$row_ary['topic_id']}&mode=topic_view&view=unread#unread"), 'S_SELECT_TOPIC' => ($merge_select && !in_array($row_ary['topic_id'], $source_topic_ids)) ? true : false, 'U_SELECT_TOPIC' => $u_select_topic, diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index 953ec95af14..80175e95adb 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -54,6 +54,7 @@ function mcp_topic_view($id, $mode, $action) $sort = isset($_POST['sort']) ? true : false; $submitted_id_list = $request->variable('post_ids', array(0)); $checked_ids = $post_id_list = $request->variable('post_id_list', array(0)); + $view = $request->variable('view', ''); // Resync Topic? if ($action == 'resync') @@ -179,6 +180,7 @@ function mcp_topic_view($id, $mode, $action) { $rowset[] = $row; $post_id_list[] = $row['post_id']; + $rowset_posttime['post_time'] = $row['post_time']; } $db->sql_freeresult($result); @@ -194,6 +196,16 @@ function mcp_topic_view($id, $mode, $action) $topic_tracking_info = get_complete_topic_tracking($topic_info['forum_id'], $topic_id); } + $first_unread = $post_unread = false; + + $post_unread = (isset($topic_tracking_info[$topic_id]) && $rowset_posttime['post_time'] > $topic_tracking_info[$topic_id]) ? true : false; + + $s_first_unread = false; + if (!$first_unread && $post_unread) + { + $s_first_unread = $first_unread = true; + } + $has_unapproved_posts = $has_deleted_posts = false; // Grab extensions @@ -287,10 +299,13 @@ function mcp_topic_view($id, $mode, $action) 'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED && $auth->acl_get('m_approve', $topic_info['forum_id'])), 'S_CHECKED' => (($submitted_id_list && !in_array(intval($row['post_id']), $submitted_id_list)) || in_array(intval($row['post_id']), $checked_ids)) ? true : false, 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, + 'S_FIRST_UNREAD' => $s_first_unread, + 'S_UNREAD_VIEW' => $view == 'unread', 'U_POST_DETAILS' => "$url&i=$id&p={$row['post_id']}&mode=post_details", 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $topic_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&p=' . $row['post_id']) : '', 'U_MCP_REPORT' => ($auth->acl_get('m_report', $topic_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&p=' . $row['post_id']) : '', + 'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . '#p' . $row['post_id'], ); /** diff --git a/phpBB/styles/prosilver/template/mcp_topic.html b/phpBB/styles/prosilver/template/mcp_topic.html index 18588a6a76b..8b2280a6eda 100644 --- a/phpBB/styles/prosilver/template/mcp_topic.html +++ b/phpBB/styles/prosilver/template/mcp_topic.html @@ -95,6 +95,9 @@