mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
- new default result mode: posts
- make use of f_search permission git-svn-id: file:///svn/phpbb/trunk@5552 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
107297f1e6
commit
3f323153b5
2 changed files with 36 additions and 21 deletions
|
@ -31,7 +31,7 @@ $view = request_var('view', '');
|
||||||
$keywords = request_var('keywords', '');
|
$keywords = request_var('keywords', '');
|
||||||
$add_keywords = request_var('add_keywords', '');
|
$add_keywords = request_var('add_keywords', '');
|
||||||
$author = request_var('author', '');
|
$author = request_var('author', '');
|
||||||
$show_results = ($topic_id) ? 'posts' : request_var('sr', 'topics');
|
$show_results = ($topic_id) ? 'posts' : request_var('sr', 'posts');
|
||||||
$search_terms = request_var('terms', 'all');
|
$search_terms = request_var('terms', 'all');
|
||||||
$search_fields = request_var('sf', 'all');
|
$search_fields = request_var('sf', 'all');
|
||||||
$search_child = request_var('sc', true);
|
$search_child = request_var('sc', true);
|
||||||
|
@ -49,7 +49,7 @@ if ($search_forum == array(0))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is user able to search? Has search been disabled?
|
// Is user able to search? Has search been disabled?
|
||||||
if (!$auth->acl_get('u_search') || !$config['load_search'])
|
if (!$auth->acl_get('u_search') || !$auth->acl_getf_global('f_search') || !$config['load_search'])
|
||||||
{
|
{
|
||||||
trigger_error($user->lang['NO_SEARCH']);
|
trigger_error($user->lang['NO_SEARCH']);
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ if ($keywords || $author || $search_id)
|
||||||
$id_ary = array();
|
$id_ary = array();
|
||||||
|
|
||||||
// Which forums should not be searched?
|
// Which forums should not be searched?
|
||||||
$ex_fid_ary = array_keys($auth->acl_getf('!f_read', true));
|
$ex_fid_ary = array_unique(array_merge(array_keys($auth->acl_getf('!f_read', true)), array_keys($auth->acl_getf('!f_search', true))));
|
||||||
|
|
||||||
$not_in_fid = (sizeof($ex_fid_ary)) ? 'f.forum_id NOT IN (' . implode(', ', $ex_fid_ary) . ') OR ' : '';
|
$not_in_fid = (sizeof($ex_fid_ary)) ? 'f.forum_id NOT IN (' . implode(', ', $ex_fid_ary) . ') OR ' : '';
|
||||||
$sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.right_id, f.forum_password, fa.user_id
|
$sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.right_id, f.forum_password, fa.user_id
|
||||||
|
@ -213,7 +213,7 @@ if ($keywords || $author || $search_id)
|
||||||
if (!$keywords && sizeof($author_id_ary))
|
if (!$keywords && sizeof($author_id_ary))
|
||||||
{
|
{
|
||||||
// default to showing results as posts when performing an author search
|
// default to showing results as posts when performing an author search
|
||||||
$show_results = ($topic_id) ? 'posts' : request_var('sr', 'posts');
|
$show_results = ($topic_id) ? 'posts' : request_var('sr', ($search_id == 'egosearch') ? 'topics' : 'posts');
|
||||||
}
|
}
|
||||||
|
|
||||||
// define some variables needed for retrieving post_id/topic_id information
|
// define some variables needed for retrieving post_id/topic_id information
|
||||||
|
@ -255,6 +255,10 @@ if ($keywords || $author || $search_id)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'unanswered':
|
case 'unanswered':
|
||||||
|
$show_results = request_var('sr', 'topics');
|
||||||
|
$sort_by_sql['t'] = ($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time';
|
||||||
|
$sort_by_sql['s'] = ($show_results == 'posts') ? 'p.post_subject' : 't.topic_title';
|
||||||
|
|
||||||
$sort_join = ($sort_key == 'f') ? FORUMS_TABLE . ' f, ' : '';
|
$sort_join = ($sort_key == 'f') ? FORUMS_TABLE . ' f, ' : '';
|
||||||
$sql_sort = ($sort_key == 'f') ? ' AND f.forum_id = p.forum_id ' . $sql_sort : $sql_sort;
|
$sql_sort = ($sort_key == 'f') ? ' AND f.forum_id = p.forum_id ' . $sql_sort : $sql_sort;
|
||||||
if ($show_results == 'posts')
|
if ($show_results == 'posts')
|
||||||
|
@ -285,6 +289,10 @@ if ($keywords || $author || $search_id)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'newposts':
|
case 'newposts':
|
||||||
|
$show_results = request_var('sr', 'topics');
|
||||||
|
$sort_by_sql['t'] = ($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time';
|
||||||
|
$sort_by_sql['s'] = ($show_results == 'posts') ? 'p.post_subject' : 't.topic_title';
|
||||||
|
|
||||||
$sort_join = ($sort_key == 'f') ? FORUMS_TABLE . ' f, ' : '';
|
$sort_join = ($sort_key == 'f') ? FORUMS_TABLE . ' f, ' : '';
|
||||||
$sql_sort = ($sort_key == 'f') ? ' AND f.forum_id = p.forum_id ' . $sql_sort : $sql_sort;
|
$sql_sort = ($sort_key == 'f') ? ' AND f.forum_id = p.forum_id ' . $sql_sort : $sql_sort;
|
||||||
if ($show_results == 'posts')
|
if ($show_results == 'posts')
|
||||||
|
@ -443,15 +451,17 @@ if ($keywords || $author || $search_id)
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
$sql = 'SELECT p.*, f.forum_id, f.forum_name, t.*, u.username, u.user_sig, u.user_sig_bbcode_uid
|
$sql = 'SELECT p.*, f.forum_id, f.forum_name, t.*, u.username, u.user_sig, u.user_sig_bbcode_uid
|
||||||
FROM (' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u, ' . POSTS_TABLE . ' p)
|
FROM ' . POSTS_TABLE . ' p
|
||||||
LEFT JOIN ' . FORUMS_TABLE . " f ON (p.forum_id = f.forum_id)
|
LEFT JOIN ' . TOPICS_TABLE . ' t ON (p.topic_id = t.topic_id)
|
||||||
WHERE $sql_where
|
LEFT JOIN ' . FORUMS_TABLE . ' f ON (p.forum_id = f.forum_id)
|
||||||
AND p.topic_id = t.topic_id
|
LEFT JOIN ' . USERS_TABLE . " u ON (p.poster_id = u.user_id)
|
||||||
AND p.poster_id = u.user_id";
|
WHERE $sql_where";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql_from = TOPICS_TABLE . ' t' . (($sort_key == 'a') ? ', ' . USERS_TABLE . ' u' : '');
|
$sql_from = TOPICS_TABLE . ' t
|
||||||
|
LEFT JOIN ' . FORUMS_TABLE . ' f ON (f.forum_id = t.forum_id)
|
||||||
|
' . (($sort_key == 'a') ? ' LEFT JOIN ' . USERS_TABLE . ' u ON (u.user_id = t.topic_poster) ' : '');
|
||||||
$sql_select = 't.*, f.forum_id, f.forum_name';
|
$sql_select = 't.*, f.forum_id, f.forum_name';
|
||||||
if ($user->data['is_registered'])
|
if ($user->data['is_registered'])
|
||||||
{
|
{
|
||||||
|
@ -477,15 +487,14 @@ if ($keywords || $author || $search_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT $sql_select
|
$sql = "SELECT $sql_select
|
||||||
FROM ($sql_from)
|
FROM $sql_from
|
||||||
LEFT JOIN " . FORUMS_TABLE . " f ON (f.forum_id = t.forum_id)
|
WHERE $sql_where";
|
||||||
WHERE $sql_where" . (($sort_key == 'a') ? ' AND u.user_id = t.topic_poster' : '');
|
|
||||||
}
|
}
|
||||||
$sql .= ' ORDER BY ' . $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
|
$sql .= ' ORDER BY ' . $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
$result_topic_id = 0;
|
$result_topic_id = 0;
|
||||||
|
|
||||||
if ($show_results = 'topics')
|
if ($show_results == 'topics')
|
||||||
{
|
{
|
||||||
$forums = $rowset = array();
|
$forums = $rowset = array();
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
@ -583,7 +592,7 @@ if ($keywords || $author || $search_id)
|
||||||
'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_gets('m_', $forum_id)) ? true : false,
|
'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_gets('m_', $forum_id)) ? true : false,
|
||||||
'S_TOPIC_UNAPPROVED' => (!$row['topic_approved'] && $auth->acl_gets('m_approve', $forum_id)) ? true : false,
|
'S_TOPIC_UNAPPROVED' => (!$row['topic_approved'] && $auth->acl_gets('m_approve', $forum_id)) ? true : false,
|
||||||
|
|
||||||
'U_LAST_POST' => $view_topic_url . '&p=' . $row['topic_last_post_id'] . '#' . $row['topic_last_post_id'],
|
'U_LAST_POST' => $view_topic_url . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id'],
|
||||||
'U_LAST_POST_AUTHOR'=> ($row['topic_last_poster_id'] != ANONYMOUS && $row['topic_last_poster_id']) ? "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&u={$row['topic_last_poster_id']}" : '',
|
'U_LAST_POST_AUTHOR'=> ($row['topic_last_poster_id'] != ANONYMOUS && $row['topic_last_poster_id']) ? "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&u={$row['topic_last_poster_id']}" : '',
|
||||||
'U_MCP_REPORT' => "{$phpbb_root_path}mcp.$phpEx?sid={$user->session_id}&mode=reports&t=$result_topic_id",
|
'U_MCP_REPORT' => "{$phpbb_root_path}mcp.$phpEx?sid={$user->session_id}&mode=reports&t=$result_topic_id",
|
||||||
'U_MCP_QUEUE' => "{$phpbb_root_path}mcp.$phpEx?sid={$user->session_id}&i=queue&mode=approve_details&t=$result_topic_id"
|
'U_MCP_QUEUE' => "{$phpbb_root_path}mcp.$phpEx?sid={$user->session_id}&i=queue&mode=approve_details&t=$result_topic_id"
|
||||||
|
@ -596,7 +605,7 @@ if ($keywords || $author || $search_id)
|
||||||
$template->assign_block_vars('searchresults', array(
|
$template->assign_block_vars('searchresults', array(
|
||||||
'S_IGNORE_POST' => true,
|
'S_IGNORE_POST' => true,
|
||||||
|
|
||||||
'L_IGNORE_POST' => sprintf($user->lang['POST_BY_FOE'], $row['username'], "<a href=\"$u_search&p=" . $row['post_id'] . '&view=show#' . $row['post_id'] . '">', '</a>'))
|
'L_IGNORE_POST' => sprintf($user->lang['POST_BY_FOE'], $row['username'], "<a href=\"$u_search&p=" . $row['post_id'] . '&view=show#p' . $row['post_id'] . '">', '</a>'))
|
||||||
);
|
);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -644,7 +653,7 @@ if ($keywords || $author || $search_id)
|
||||||
|
|
||||||
'U_VIEW_TOPIC' => $view_topic_url,
|
'U_VIEW_TOPIC' => $view_topic_url,
|
||||||
'U_VIEW_FORUM' => "{$phpbb_root_path}viewforum.$phpEx$SID&f=$forum_id",
|
'U_VIEW_FORUM' => "{$phpbb_root_path}viewforum.$phpEx$SID&f=$forum_id",
|
||||||
'U_VIEW_POST' => (!empty($row['post_id'])) ? "{$phpbb_root_path}viewtopic.$phpEx$SID&f=$forum_id&t=" . $row['topic_id'] . '&p=' . $row['post_id'] . '&hilit=' . $u_hilit . '#' . $row['post_id'] : '')
|
'U_VIEW_POST' => (!empty($row['post_id'])) ? "{$phpbb_root_path}viewtopic.$phpEx$SID&f=$forum_id&t=" . $row['topic_id'] . '&p=' . $row['post_id'] . '&hilit=' . $u_hilit . '#p' . $row['post_id'] : '')
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,7 +701,7 @@ while ($row = $db->sql_fetchrow($result))
|
||||||
|
|
||||||
if (!$auth->acl_get('f_list', $row['forum_id']) || $row['forum_type'] == FORUM_LINK || ($row['forum_password'] && !$row['user_id']))
|
if (!$auth->acl_get('f_list', $row['forum_id']) || $row['forum_type'] == FORUM_LINK || ($row['forum_password'] && !$row['user_id']))
|
||||||
{
|
{
|
||||||
// if the user does not have permissions to list this forum skip
|
// if the user does not have permissions to list this forum skip to the next branch
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -708,7 +717,13 @@ while ($row = $db->sql_fetchrow($result))
|
||||||
|
|
||||||
$right = $row['right_id'];
|
$right = $row['right_id'];
|
||||||
|
|
||||||
$selected = (!sizeof($search_forum) || in_array($row['forum_id'], $search_forum)) ? ' selected="selected"' : '';
|
if (!$auth->acl_get('f_search', $row['forum_id']))
|
||||||
|
{
|
||||||
|
// if the user does not have permissions to search this forum skip only this forum/category
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$selected = (in_array($row['forum_id'], $search_forum)) ? ' selected="selected"' : '';
|
||||||
|
|
||||||
if ($row['left_id'] > $cat_right)
|
if ($row['left_id'] > $cat_right)
|
||||||
{
|
{
|
||||||
|
@ -744,7 +759,7 @@ for ($i = 100; $i <= 1000 ; $i += 100)
|
||||||
|
|
||||||
$template->assign_vars(array(
|
$template->assign_vars(array(
|
||||||
'S_SEARCH_ACTION' => "{$phpbb_root_path}search.$phpEx",
|
'S_SEARCH_ACTION' => "{$phpbb_root_path}search.$phpEx",
|
||||||
'S_HIDDEN_FIELDS' => build_hidden_fields(array('sid' => $user->session_id)),
|
'S_HIDDEN_FIELDS' => build_hidden_fields(array('sid' => $user->session_id, 't' => $topic_id)),
|
||||||
'S_CHARACTER_OPTIONS' => $s_characters,
|
'S_CHARACTER_OPTIONS' => $s_characters,
|
||||||
'S_FORUM_OPTIONS' => $s_forums,
|
'S_FORUM_OPTIONS' => $s_forums,
|
||||||
'S_SELECT_SORT_DIR' => $s_sort_dir,
|
'S_SELECT_SORT_DIR' => $s_sort_dir,
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
<td class="row1"><b class="genmed">{L_RESULT_SORT}: </b></td>
|
<td class="row1"><b class="genmed">{L_RESULT_SORT}: </b></td>
|
||||||
<td class="row2" nowrap="nowrap">{S_SELECT_SORT_KEY}<br /><input type="radio" name="sd" value="a" /> <span class="genmed">{L_SORT_ASCENDING}</span><br /><input type="radio" name="sd" value="d" checked="checked" /> <span class="genmed">{L_SORT_DESCENDING}</span></td>
|
<td class="row2" nowrap="nowrap">{S_SELECT_SORT_KEY}<br /><input type="radio" name="sd" value="a" /> <span class="genmed">{L_SORT_ASCENDING}</span><br /><input type="radio" name="sd" value="d" checked="checked" /> <span class="genmed">{L_SORT_DESCENDING}</span></td>
|
||||||
<td class="row1" nowrap="nowrap"><b class="genmed">{L_DISPLAY_RESULTS}: </b></td>
|
<td class="row1" nowrap="nowrap"><b class="genmed">{L_DISPLAY_RESULTS}: </b></td>
|
||||||
<td class="row2" nowrap="nowrap"><input type="radio" name="sr" value="posts" /> <span class="genmed">{L_POSTS}</span> <input type="radio" name="sr" value="topics" checked="checked" /> <span class="genmed">{L_TOPICS}</td>
|
<td class="row2" nowrap="nowrap"><input type="radio" name="sr" value="posts" checked="checked" /> <span class="genmed">{L_POSTS}</span> <input type="radio" name="sr" value="topics" /> <span class="genmed">{L_TOPICS}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="row1" width="25%"><b class="genmed">{L_RESULT_DAYS}: </b></td>
|
<td class="row1" width="25%"><b class="genmed">{L_RESULT_DAYS}: </b></td>
|
||||||
|
|
Loading…
Add table
Reference in a new issue