diff --git a/phpBB/search.php b/phpBB/search.php
index 22e24d4a78..c6379d2855 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -247,6 +247,15 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$ex_fid_ary = array_unique(array_merge(array_keys($auth->acl_getf('!f_read', true)), array_keys($auth->acl_getf('!f_search', true))));
}
+ // Consider if there are any forums where can read forum = no, can read topics = yes
+ // In these cases, the user should see the topic title in the search results but not the link to the topic (or any posts) because they don't have the permissions
+ if ($request->variable('sr', '') == 'topics' && $search_fields == 'titleonly')
+ {
+ // The user could get here from a quick search through the viewforum page, or by doing a main search displayed by topics and searching only the topic titles.
+ // Allow the 'can read topics = yes' forums back in to the search by removing from $ex_fid_ary any of the 'can read topics' forums
+ $ex_fid_ary = array_diff($ex_fid_ary, array_keys($auth->acl_getf('f_list_topics', true)));
+ }
+
$not_in_fid = (count($ex_fid_ary)) ? 'WHERE ' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . " OR (f.forum_password <> '' AND fa.user_id <> " . (int) $user->data['user_id'] . ')' : "";
$sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.right_id, f.forum_password, f.forum_flags, fa.user_id
@@ -1157,10 +1166,10 @@ if ($keywords || $author || $author_id || $search_id || $submit)
'S_TOPIC_DELETED' => $topic_deleted,
'S_HAS_POLL' => (bool) $row['poll_start'],
- 'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'],
+ 'U_LAST_POST' => $auth->acl_get('f_read', $forum_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'] : false,
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
- 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&view=unread') . '#unread',
+ 'U_NEWEST_POST' => $auth->acl_get('f_read', $forum_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&view=unread') . '#unread' : false,
'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=reports&t=' . $result_topic_id),
'U_MCP_QUEUE' => $u_mcp_queue,
);
@@ -1230,7 +1239,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
'TOPIC_REPLIES' => $replies,
'TOPIC_VIEWS' => $row['topic_views'],
- 'U_VIEW_TOPIC' => $view_topic_url,
+ 'U_VIEW_TOPIC' => $auth->acl_get('f_read', $forum_id) ? $view_topic_url : false,
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
'U_VIEW_POST' => (!empty($row['post_id'])) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id'] . (($u_hilit) ? '&hilit=' . $u_hilit : '')) . '#p' . $row['post_id'] : '',
));
diff --git a/phpBB/styles/prosilver/template/search_results.html b/phpBB/styles/prosilver/template/search_results.html
index 1e25f8656f..06a4e32c43 100644
--- a/phpBB/styles/prosilver/template/search_results.html
+++ b/phpBB/styles/prosilver/template/search_results.html
@@ -80,8 +80,26 @@
-
-
- {{ Icon('svg', {
+ {% if searchresults.U_NEWEST_POST and searchresults.S_UNREAD_TOPIC and not S_IS_BOT %}
+ {% set searchresults.U_ITEM_LINK = searchresults.U_NEWEST_POST %}
+ {% elseif searchresults.U_VIEW_TOPIC %}
+ {% set searchresults.U_ITEM_LINK = searchresults.U_VIEW_TOPIC %}
+ {% endif %}
+ {% if searchresults.U_ITEM_LINK is defined %}
+
+ {{ Icon('svg', {
+ 'globe' : searchresults.S_POST_GLOBAL,
+ 'bullhorn' : searchresults.S_POST_ANNOUNCE,
+ 'thumbtack' : searchresults.S_POST_STICKY,
+ 'lock' : searchresults.S_TOPIC_LOCKED,
+ 'arrow-right-bold' : searchresults.S_TOPIC_MOVED,
+ 'fire' : searchresults.S_TOPIC_HOT,
+ 'file-document-outline' : true,
+ }, '', true, 'c-forum-row-icon') }}
+
+ {% else %}
+
+ {{ Icon('svg', {
'globe' : searchresults.S_POST_GLOBAL,
'bullhorn' : searchresults.S_POST_ANNOUNCE,
'thumbtack' : searchresults.S_POST_STICKY,
@@ -89,8 +107,9 @@
'arrow-right-bold' : searchresults.S_TOPIC_MOVED,
'fire' : searchresults.S_TOPIC_HOT,
'file-document-outline' : true,
- }, '', true, 'c-forum-row-icon') }}
-
+ }, '', true, 'c-forum-row-icon') }}
+
+ {% endif %}
{% if lang(searchresults.TOPIC_AUTHOR) == S_USERNAME %}
{% endif%}
@@ -99,10 +118,12 @@
{% endif %}
- {% if searchresults.S_UNREAD_TOPIC and not S_IS_BOT %}
+ {% if searchresults.U_NEWEST_POST and searchresults.S_UNREAD_TOPIC and not S_IS_BOT %}
{{ searchresults.TOPIC_TITLE }}
- {% else %}
+ {% elseif searchresults.U_VIEW_TOPIC %}
{{ searchresults.TOPIC_TITLE }}
+ {% else %}
+
{{ searchresults.TOPIC_TITLE }}
{% endif %}
@@ -161,11 +182,11 @@
- {searchresults.TOPIC_VIEWS} {L_VIEWS}
-
{L_LAST_POST} {L_POST_BY_AUTHOR} {searchresults.LAST_POST_AUTHOR_FULL}
-
+ {% if not S_IS_BOT and searchresults.U_LAST_POST %}
{{ Icon('font', 'arrow-up-right-from-square', VIEW_LATEST_POST, true, 'fas c-last-post-icon') }}
-
+ {% endif %}
diff --git a/phpBB/styles/prosilver/template/viewforum_body.html b/phpBB/styles/prosilver/template/viewforum_body.html
index 8d784b6943..5a65d59eff 100644
--- a/phpBB/styles/prosilver/template/viewforum_body.html
+++ b/phpBB/styles/prosilver/template/viewforum_body.html
@@ -158,8 +158,26 @@
-
-
- {{ Icon('svg', {
+ {% if topicrow.U_NEWEST_POST and topicrow.S_UNREAD_TOPIC and not S_IS_BOT %}
+ {% set topicrow.U_ITEM_LINK = topicrow.U_NEWEST_POST %}
+ {% elseif topicrow.U_VIEW_TOPIC %}
+ {% set topicrow.U_ITEM_LINK = topicrow.U_VIEW_TOPIC %}
+ {% endif %}
+ {% if topicrow.U_ITEM_LINK is defined %}
+
+ {{ Icon('svg', {
+ 'globe' : topicrow.S_POST_GLOBAL,
+ 'bullhorn' : topicrow.S_POST_ANNOUNCE,
+ 'thumbtack' : topicrow.S_POST_STICKY,
+ 'lock' : topicrow.S_TOPIC_LOCKED,
+ 'arrow-right-bold' : topicrow.S_TOPIC_MOVED,
+ 'fire' : topicrow.S_TOPIC_HOT,
+ 'file-document-outline' : true,
+ }, '', true, 'c-forum-row-icon') }}
+
+ {% else %}
+
+ {{ Icon('svg', {
'globe' : topicrow.S_POST_GLOBAL,
'bullhorn' : topicrow.S_POST_ANNOUNCE,
'thumbtack' : topicrow.S_POST_STICKY,
@@ -167,8 +185,9 @@
'arrow-right-bold' : topicrow.S_TOPIC_MOVED,
'fire' : topicrow.S_TOPIC_HOT,
'file-document-outline' : true,
- }, '', true, 'c-forum-row-icon') }}
-
+ }, '', true, 'c-forum-row-icon') }}
+
+ {% endif %}
{% if lang(topicrow.TOPIC_AUTHOR) == S_USERNAME %}
{% endif%}
@@ -177,7 +196,7 @@
{% endif %}
- {% if topicrow.S_UNREAD_TOPIC and not S_IS_BOT %}
+ {% if topicrow.U_NEWEST_POST and topicrow.S_UNREAD_TOPIC and not S_IS_BOT %}
{{ topicrow.TOPIC_TITLE }}
{% elseif topicrow.U_VIEW_TOPIC %}
{{ topicrow.TOPIC_TITLE }}
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index f4f6d43485..94f967be7b 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -384,7 +384,18 @@ $post_alt = ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['FORUM_LO
// Display active topics?
$s_display_active = ($forum_data['forum_type'] == FORUM_CAT && ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) ? true : false;
-$s_search_hidden_fields = array('fid' => array($forum_id));
+// Send the forum id... and maybe some other fields, depending on permissions
+$s_search_hidden_fields = [
+ 'fid' => [$forum_id],
+];
+
+if ($auth->acl_get('f_list_topics', $forum_id) && !$auth->acl_get('f_read', $forum_id))
+{
+ // If the user has list access but not read access, then force the search to only be a topic title search
+ $s_search_hidden_fields['sr'] = 'topics';
+ $s_search_hidden_fields['sf'] = 'titleonly';
+}
+
if ($_SID)
{
$s_search_hidden_fields['sid'] = $_SID;
@@ -1018,7 +1029,7 @@ if (count($topic_list))
'S_TOPIC_HOT' => $config['hot_threshold'] && ($replies + 1) >= $config['hot_threshold'] && $row['topic_status'] != ITEM_LOCKED,
'U_NEWEST_POST' => $auth->acl_get('f_read', $forum_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&view=unread') . '#unread' : false,
- 'U_LAST_POST' => $auth->acl_get('f_read', $forum_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'] : false,
+ 'U_LAST_POST' => $auth->acl_get('f_read', $forum_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'] : false,
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
'U_VIEW_TOPIC' => $view_topic_url,