Skip to content

Commit

Permalink
Merge pull request phpbb#6543 from Crizz0/ticket/17187
Browse files Browse the repository at this point in the history
[ticket/17187] Repair mcp link to first unread post
  • Loading branch information
marc1706 committed Oct 30, 2023
2 parents 7e6c5df + b0248d2 commit eed57fd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions phpBB/includes/mcp/mcp_forum.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 15 additions & 0 deletions phpBB/includes/mcp/mcp_topic.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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);

Expand All @@ -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
Expand Down Expand Up @@ -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'],
);

/**
Expand Down
3 changes: 3 additions & 0 deletions phpBB/styles/prosilver/template/mcp_topic.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ <h3 id="review" class="review">
<div id="topicreview" class="topicreview">
<!-- BEGIN postrow -->
<!-- EVENT mcp_topic_postrow_post_before -->
<!-- IF postrow.S_FIRST_UNREAD -->
<a id="unread" class="anchor"<!-- IF S_UNREAD_VIEW --> data-url="{postrow.U_MINI_POST}"<!-- ENDIF -->></a>
<!-- ENDIF -->
<div class="post <!-- IF postrow.S_ROW_COUNT is odd -->bg1<!-- ELSE -->bg2<!-- ENDIF -->">
<div class="inner">

Expand Down

0 comments on commit eed57fd

Please sign in to comment.