|
247 | 247 | $ex_fid_ary = array_unique(array_merge(array_keys($auth->acl_getf('!f_read', true)), array_keys($auth->acl_getf('!f_search', true)))); |
248 | 248 | } |
249 | 249 |
|
| 250 | + // There are two exceptional scenarios we want to consider if there are any forums where an read forum = no, can read topics = yes |
| 251 | + // 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 |
| 252 | + // they don't have the permissions for that. |
| 253 | + $show_topic_title_only = false; |
| 254 | + |
| 255 | + // 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 |
| 256 | + // We know if this is the case due to the presence of this request var |
| 257 | + $forum_quick_search = $request->variable('viewforum', 0); |
| 258 | + if ($forum_quick_search && $auth->acl_get('f_list_topics', $forum_quick_search) && !$auth->acl_get('f_read', $forum_quick_search)) |
| 259 | + { |
| 260 | + $show_topic_title_only = true; |
| 261 | + } |
| 262 | + |
| 263 | + // 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 |
| 264 | + else if ($request->variable('sr', '') == 'topics' && $search_fields == 'titleonly') |
| 265 | + { |
| 266 | + // We will allow the 'can read topics = yes' forums back in to the search |
| 267 | + $show_topic_title_only = true; |
| 268 | + } |
| 269 | + |
| 270 | + if ($show_topic_title_only) |
| 271 | + { |
| 272 | + // Remove from $ex_fid_ary any of the 'can read topics' forums (meaning they will not be excluded from the search) |
| 273 | + $ex_fid_ary = array_diff($ex_fid_ary, array_keys($auth->acl_getf('f_list_topics', true))); |
| 274 | + } |
| 275 | + |
250 | 276 | $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'] . ')' : ""; |
251 | 277 |
|
252 | 278 | $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 | 375 | $show_results = ($show_results == 'posts') ? 'posts' : 'topics'; |
350 | 376 | } |
351 | 377 |
|
| 378 | + if ($show_topic_title_only) |
| 379 | + { |
| 380 | + $show_results = 'topics'; |
| 381 | + } |
| 382 | + |
352 | 383 | // define some variables needed for retrieving post_id/topic_id information |
353 | 384 | $sort_by_sql = [ |
354 | 385 | 'a' => 'u.username_clean', |
|
1157 | 1188 | 'S_TOPIC_DELETED' => $topic_deleted, |
1158 | 1189 | 'S_HAS_POLL' => ($row['poll_start']) ? true : false, |
1159 | 1190 |
|
1160 | | - 'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'], |
| 1191 | + '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, |
1161 | 1192 | 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), |
1162 | 1193 | 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), |
1163 | | - 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&view=unread') . '#unread', |
| 1194 | + '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, |
1164 | 1195 | 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=reports&t=' . $result_topic_id, true, $user->session_id), |
1165 | 1196 | 'U_MCP_QUEUE' => $u_mcp_queue, |
1166 | 1197 | ); |
|
1230 | 1261 | 'TOPIC_REPLIES' => $replies, |
1231 | 1262 | 'TOPIC_VIEWS' => $row['topic_views'], |
1232 | 1263 |
|
1233 | | - 'U_VIEW_TOPIC' => $view_topic_url, |
| 1264 | + 'U_VIEW_TOPIC' => $auth->acl_get('f_read', $forum_id) ? $view_topic_url : false, |
1234 | 1265 | 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id), |
1235 | 1266 | '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'] : '', |
1236 | 1267 | )); |
|
0 commit comments