mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-25 19:38:53 +00:00
[ticket/17157] Search to accomodate f_list_topics permission
PHPBB-17157
This commit is contained in:
parent
081f2391cb
commit
676905bff5
4 changed files with 50 additions and 14 deletions
|
@ -247,6 +247,32 @@ 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))));
|
||||
}
|
||||
|
||||
// There are two exceptional scenarios we want to consider if there are any forums where an 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 for that.
|
||||
$show_topic_title_only = false;
|
||||
|
||||
// Firstly, is someone doing a quick search from the viewforum page? If so, force it to be a topic-only search for that one forum
|
||||
// We know if this is the case due to the presence of this request var
|
||||
$forum_quick_search = $request->variable('viewforum', 0);
|
||||
if ($forum_quick_search && $auth->acl_get('f_list_topics', $forum_quick_search) && !$auth->acl_get('f_read', $forum_quick_search))
|
||||
{
|
||||
$show_topic_title_only = true;
|
||||
}
|
||||
|
||||
// Secondly, is someone doing a topic search from the main search page? If so, we will strip the topic links while still showing the name
|
||||
else if ($request->variable('sr', '') == 'topics' && $search_fields == 'titleonly')
|
||||
{
|
||||
// We will allow the 'can read topics = yes' forums back in to the search
|
||||
$show_topic_title_only = true;
|
||||
}
|
||||
|
||||
if ($show_topic_title_only)
|
||||
{
|
||||
// Remove from $ex_fid_ary any of the 'can read topics' forums (meaning they will not be excluded from the search)
|
||||
$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
|
||||
|
@ -349,6 +375,11 @@ if ($keywords || $author || $author_id || $search_id || $submit)
|
|||
$show_results = ($show_results == 'posts') ? 'posts' : 'topics';
|
||||
}
|
||||
|
||||
if ($show_topic_title_only)
|
||||
{
|
||||
$show_results = 'topics';
|
||||
}
|
||||
|
||||
// define some variables needed for retrieving post_id/topic_id information
|
||||
$sort_by_sql = [
|
||||
'a' => 'u.username_clean',
|
||||
|
@ -1157,10 +1188,10 @@ if ($keywords || $author || $author_id || $search_id || $submit)
|
|||
'S_TOPIC_DELETED' => $topic_deleted,
|
||||
'S_HAS_POLL' => ($row['poll_start']) ? true : false,
|
||||
|
||||
'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, true, $user->session_id),
|
||||
'U_MCP_QUEUE' => $u_mcp_queue,
|
||||
);
|
||||
|
@ -1230,7 +1261,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,15 +80,15 @@
|
|||
<li class="row<!-- IF searchresults.S_ROW_COUNT is even --> bg1<!-- ELSE --> bg2<!-- ENDIF -->">
|
||||
<dl class="row-item {searchresults.TOPIC_IMG_STYLE}">
|
||||
<dt<!-- IF searchresults.TOPIC_ICON_IMG --> style="background-image: url({T_ICONS_PATH}{searchresults.TOPIC_ICON_IMG}); background-repeat: no-repeat;"<!-- ENDIF --> title="{searchresults.TOPIC_FOLDER_IMG_ALT}">
|
||||
<!-- IF searchresults.S_UNREAD_TOPIC and not S_IS_BOT --><a href="{searchresults.U_NEWEST_POST}" class="row-item-link"></a><!-- ENDIF -->
|
||||
{% if searchresults.U_NEWEST_POST and searchresults.S_UNREAD_TOPIC and not S_IS_BOT %}<a href="{searchresults.U_NEWEST_POST}" class="row-item-link"></a>{% 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 class="unread" href="{searchresults.U_NEWEST_POST}">
|
||||
<i class="icon fa-file fa-fw icon-red icon-md" aria-hidden="true"></i><span class="sr-only">{L_NEW_POST}</span>
|
||||
</a>
|
||||
<!-- ENDIF -->
|
||||
<a href="{searchresults.U_VIEW_TOPIC}" class="topictitle">{searchresults.TOPIC_TITLE}</a>
|
||||
{% endif %}
|
||||
{% if searchresults.U_VIEW_TOPIC %}<a href="{searchresults.U_VIEW_TOPIC}" class="topictitle">{searchresults.TOPIC_TITLE}</a>{% else %}{searchresults.TOPIC_TITLE}{% endif %}
|
||||
<!-- IF searchresults.S_TOPIC_UNAPPROVED or searchresults.S_POSTS_UNAPPROVED -->
|
||||
<a href="{searchresults.U_MCP_QUEUE}" title="{L_TOPIC_UNAPPROVED}">
|
||||
<i class="icon fa-question fa-fw icon-blue" aria-hidden="true"></i><span class="sr-only">{L_TOPIC_UNAPPROVED}</span>
|
||||
|
@ -146,11 +146,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}">
|
||||
<i class="icon fa-external-link-square fa-fw icon-lightgray icon-md" aria-hidden="true"></i><span class="sr-only">{VIEW_LATEST_POST}</span>
|
||||
</a>
|
||||
<!-- ENDIF -->
|
||||
{% endif %}
|
||||
<br /><time datetime="{searchresults.LAST_POST_TIME_RFC3339}">{searchresults.LAST_POST_TIME}</time>
|
||||
</span>
|
||||
</dd>
|
||||
|
|
|
@ -158,14 +158,14 @@
|
|||
<!-- EVENT viewforum_body_topic_row_prepend -->
|
||||
<dl class="row-item {topicrow.TOPIC_IMG_STYLE}">
|
||||
<dt<!-- IF topicrow.TOPIC_ICON_IMG and S_TOPIC_ICONS --> style="background-image: url('{T_ICONS_PATH}{topicrow.TOPIC_ICON_IMG}'); background-repeat: no-repeat;"<!-- ENDIF --> title="{topicrow.TOPIC_FOLDER_IMG_ALT}">
|
||||
<!-- IF topicrow.S_UNREAD_TOPIC and not S_IS_BOT --><a href="{topicrow.U_NEWEST_POST}" class="row-item-link"></a><!-- ENDIF -->
|
||||
{% if topicrow.U_NEWEST_POST and topicrow.S_UNREAD_TOPIC and not S_IS_BOT %}<a href="{topicrow.U_NEWEST_POST}" class="row-item-link"></a>{% 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 class="unread" href="{topicrow.U_NEWEST_POST}">
|
||||
<i class="icon fa-file fa-fw icon-red icon-md" aria-hidden="true"></i><span class="sr-only">{NEW_POST}</span>
|
||||
</a>
|
||||
<!-- ENDIF -->
|
||||
{% endif %}
|
||||
<!-- IF topicrow.U_VIEW_TOPIC --><a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a><!-- ELSE -->{topicrow.TOPIC_TITLE}<!-- ENDIF -->
|
||||
<!-- IF topicrow.S_TOPIC_UNAPPROVED or topicrow.S_POSTS_UNAPPROVED -->
|
||||
<a href="{topicrow.U_MCP_QUEUE}" title="<!-- IF topicrow.S_TOPIC_UNAPPROVED -->{L_TOPIC_UNAPPROVED}<!-- ELSE -->{L_POSTS_UNAPPROVED}<!-- ENDIF -->">
|
||||
|
|
|
@ -384,7 +384,12 @@ $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 send a parameter to make it clear it's a quick search
|
||||
$s_search_hidden_fields = [
|
||||
'fid' => [$forum_id],
|
||||
'viewforum' => $forum_id,
|
||||
];
|
||||
|
||||
if ($_SID)
|
||||
{
|
||||
$s_search_hidden_fields['sid'] = $_SID;
|
||||
|
@ -1017,7 +1022,7 @@ if (count($topic_list))
|
|||
'S_TOPIC_MOVED' => ($row['topic_status'] == ITEM_MOVED) ? true : false,
|
||||
|
||||
'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,
|
||||
|
|
Loading…
Add table
Reference in a new issue