mirror of
https://github.com/phpbb/phpbb.git
synced 2025-10-05 20:21:53 +02:00
Merge pull request #6850 from marc1706/ticket/17175-master
[ticket/17175] Fix for allowing user to see search results for topics if f_list_topics = yes -- master version
This commit is contained in:
@@ -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'] : '',
|
||||
));
|
||||
|
@@ -80,8 +80,26 @@
|
||||
<li class="row<!-- IF searchresults.S_ROW_COUNT is even --> bg1<!-- ELSE --> bg2<!-- ENDIF -->">
|
||||
<dl class="row-item">
|
||||
<dt>
|
||||
<a class="row-item-link{% if searchresults.S_UNREAD_TOPIC %} unread{% else %} read{% endif %}" href="{searchresults.U_NEWEST_POST}" title="{searchresults.TOPIC_FOLDER_IMG_ALT}">
|
||||
{{ Icon('svg', {
|
||||
{% if searchresults.U_NEWEST_POST and searchresults.S_UNREAD_TOPIC and not S_IS_BOT %}
|
||||
{% set U_ITEM_LINK = searchresults.U_NEWEST_POST %}
|
||||
{% elseif searchresults.U_VIEW_TOPIC %}
|
||||
{% set U_ITEM_LINK = searchresults.U_VIEW_TOPIC %}
|
||||
{% endif %}
|
||||
{% if U_ITEM_LINK is defined %}
|
||||
<a class="row-item-link{% if searchresults.S_UNREAD_TOPIC %} unread{% else %} read{% endif %}" href="{{ U_ITEM_LINK }}" title="{searchresults.TOPIC_FOLDER_IMG_ALT}">
|
||||
{{ 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') }}
|
||||
</a>
|
||||
{% else %}
|
||||
<span class="row-item-link{% if searchresults.S_UNREAD_TOPIC %} unread{% else %} read{% endif %}" title="{searchresults.TOPIC_FOLDER_IMG_ALT}">
|
||||
{{ 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') }}
|
||||
</a>
|
||||
}, '', true, 'c-forum-row-icon') }}
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if lang(searchresults.TOPIC_AUTHOR) == S_USERNAME %}
|
||||
<span class="row-item-link-mine"></span>
|
||||
{% endif%}
|
||||
@@ -99,10 +118,12 @@
|
||||
{% endif %}
|
||||
<div class="list-inner">
|
||||
<!-- EVENT topiclist_row_prepend -->
|
||||
{% 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 %}
|
||||
<a href="{{ searchresults.U_NEWEST_POST }}" class="topictitle unread">{{ searchresults.TOPIC_TITLE }}</a>
|
||||
{% else %}
|
||||
{% elseif searchresults.U_VIEW_TOPIC %}
|
||||
<a href="{{ searchresults.U_VIEW_TOPIC }}" class="topictitle">{{ searchresults.TOPIC_TITLE }}</a>
|
||||
{% else %}
|
||||
<span class="topictitle">{{ searchresults.TOPIC_TITLE }}</span>
|
||||
{% endif %}
|
||||
<!-- IF searchresults.S_TOPIC_UNAPPROVED or searchresults.S_POSTS_UNAPPROVED -->
|
||||
<a href="{searchresults.U_MCP_QUEUE}" title="{L_TOPIC_UNAPPROVED}">
|
||||
@@ -161,11 +182,11 @@
|
||||
<dd class="views">{searchresults.TOPIC_VIEWS} <dfn>{L_VIEWS}</dfn></dd>
|
||||
<dd class="lastpost">
|
||||
<span><dfn>{L_LAST_POST} </dfn>{L_POST_BY_AUTHOR} <!-- EVENT search_results_last_post_author_username_prepend -->{searchresults.LAST_POST_AUTHOR_FULL}<!-- EVENT search_results_last_post_author_username_append -->
|
||||
<!-- IF not S_IS_BOT -->
|
||||
{% if not S_IS_BOT and searchresults.U_LAST_POST %}
|
||||
<a href="{searchresults.U_LAST_POST}" title="{L_GOTO_LAST_POST}">
|
||||
{{ Icon('font', 'arrow-up-right-from-square', VIEW_LATEST_POST, true, 'fas c-last-post-icon') }}
|
||||
</a>
|
||||
<!-- ENDIF -->
|
||||
{% endif %}
|
||||
<br /><time datetime="{searchresults.LAST_POST_TIME_RFC3339}">{searchresults.LAST_POST_TIME}</time>
|
||||
</span>
|
||||
</dd>
|
||||
|
@@ -158,8 +158,26 @@
|
||||
<!-- EVENT viewforum_body_topic_row_prepend -->
|
||||
<dl class="row-item">
|
||||
<dt>
|
||||
<a class="row-item-link{% if topicrow.S_UNREAD_TOPIC %} unread{% else %} read{% endif %}" href="{topicrow.U_NEWEST_POST}" title="{topicrow.TOPIC_FOLDER_IMG_ALT}">
|
||||
{{ Icon('svg', {
|
||||
{% if topicrow.U_NEWEST_POST and topicrow.S_UNREAD_TOPIC and not S_IS_BOT %}
|
||||
{% set U_ITEM_LINK = topicrow.U_NEWEST_POST %}
|
||||
{% elseif topicrow.U_VIEW_TOPIC %}
|
||||
{% set U_ITEM_LINK = topicrow.U_VIEW_TOPIC %}
|
||||
{% endif %}
|
||||
{% if U_ITEM_LINK is defined %}
|
||||
<a class="row-item-link{% if topicrow.S_UNREAD_TOPIC %} unread{% else %} read{% endif %}" href="{{ U_ITEM_LINK }}" title="{topicrow.TOPIC_FOLDER_IMG_ALT}">
|
||||
{{ 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') }}
|
||||
</a>
|
||||
{% else %}
|
||||
<span class="row-item-link{% if topicrow.S_UNREAD_TOPIC %} unread{% else %} read{% endif %}" title="{topicrow.TOPIC_FOLDER_IMG_ALT}">
|
||||
{{ 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') }}
|
||||
</a>
|
||||
}, '', true, 'c-forum-row-icon') }}
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if lang(topicrow.TOPIC_AUTHOR) == S_USERNAME %}
|
||||
<span class="row-item-link-mine"></span>
|
||||
{% endif%}
|
||||
@@ -177,7 +196,7 @@
|
||||
{% endif %}
|
||||
<div class="list-inner">
|
||||
<!-- EVENT topiclist_row_prepend -->
|
||||
{% 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 %}
|
||||
<a href="{{ topicrow.U_NEWEST_POST }}" class="topictitle unread">{{ topicrow.TOPIC_TITLE }}</a>
|
||||
{% elseif topicrow.U_VIEW_TOPIC %}
|
||||
<a href="{{ topicrow.U_VIEW_TOPIC }}" class="topictitle">{{ topicrow.TOPIC_TITLE }}</a>
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user