aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/search.php
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2010-03-02 01:05:40 +0100
committerNils Adermann <naderman@naderman.de>2010-03-02 01:05:40 +0100
commit021c186be91095397d4e76801738373989360a52 (patch)
tree4a5b42c0ebcaeb0be77edacb839bf164fe2dadc0 /phpBB/search.php
parent4f9c3b8f5c0181c2ebf367436f3c0336d8f2251d (diff)
parent3ddedd5ff228cdcc3c0b05000affe3944afc7854 (diff)
downloadforums-021c186be91095397d4e76801738373989360a52.tar
forums-021c186be91095397d4e76801738373989360a52.tar.gz
forums-021c186be91095397d4e76801738373989360a52.tar.bz2
forums-021c186be91095397d4e76801738373989360a52.tar.xz
forums-021c186be91095397d4e76801738373989360a52.zip
Merge commit 'release-3.0.6-RC1'
Diffstat (limited to 'phpBB/search.php')
-rw-r--r--phpBB/search.php73
1 files changed, 65 insertions, 8 deletions
diff --git a/phpBB/search.php b/phpBB/search.php
index cf2e8615c2..258297d088 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -95,8 +95,16 @@ if ($keywords || $author || $author_id || $search_id || $submit)
}
}
+ // search for unread posts needs user to be logged in
+ // if topics tracking for guests is disabled
+ if ($search_id == 'unreadposts' && !$config['load_anon_lastread'] && !$user->data['is_registered'])
+ {
+ login_box('', $user->lang['LOGIN_EXPLAIN_UNREADSEARCH']);
+ }
+
// If we are looking for authors get their ids
$author_id_ary = array();
+ $sql_author_match = '';
if ($author_id)
{
$author_id_ary[] = $author_id;
@@ -113,7 +121,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$sql = 'SELECT user_id
FROM ' . USERS_TABLE . "
WHERE $sql_where
- AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
+ AND user_type <> " . USER_IGNORE;
$result = $db->sql_query_limit($sql, 100);
while ($row = $db->sql_fetchrow($result))
@@ -122,6 +130,22 @@ if ($keywords || $author || $author_id || $search_id || $submit)
}
$db->sql_freeresult($result);
+ $sql_where = (strpos($author, '*') !== false) ? ' post_username ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($author))) : " post_username = '" . $db->sql_escape(utf8_clean_string($author)) . "'";
+
+ $sql = 'SELECT 1 as guest_post
+ FROM ' . POSTS_TABLE . "
+ WHERE $sql_where
+ AND poster_id = " . ANONYMOUS;
+ $result = $db->sql_query_limit($sql, 1);
+ $found_guest_post = $db->sql_fetchfield('guest_post');
+ $db->sql_freeresult($result);
+
+ if ($found_guest_post)
+ {
+ $author_id_ary[] = ANONYMOUS;
+ $sql_author_match = (strpos($author, '*') !== false) ? ' ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($author))) : " = '" . $db->sql_escape(utf8_clean_string($author)) . "'";
+ }
+
if (!sizeof($author_id_ary))
{
trigger_error('NO_SEARCH_RESULTS');
@@ -155,7 +179,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$not_in_fid = (sizeof($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, fa.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
FROM ' . FORUMS_TABLE . ' f
LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa ON (fa.forum_id = f.forum_id
AND fa.session_id = '" . $db->sql_escape($user->session_id) . "')
@@ -173,6 +197,13 @@ if ($keywords || $author || $author_id || $search_id || $submit)
continue;
}
+ // Exclude forums from active topics
+ if (!($row['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) && ($search_id == 'active_topics'))
+ {
+ $ex_fid_ary[] = (int) $row['forum_id'];
+ continue;
+ }
+
if (sizeof($search_forum))
{
if ($search_child)
@@ -308,7 +339,6 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$last_post_time = '';
}
-
if ($sort_key == 'a')
{
$sort_join = USERS_TABLE . ' u, ';
@@ -341,6 +371,34 @@ if ($keywords || $author || $author_id || $search_id || $submit)
}
break;
+ case 'unreadposts':
+ $l_search_title = $user->lang['SEARCH_UNREAD'];
+ // force sorting
+ $show_results = 'topics';
+ $sort_key = 't';
+ $sort_by_sql['t'] = 't.topic_last_post_time';
+ $sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
+
+ $sql_where = 'AND t.topic_moved_id = 0
+ ' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
+ ' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
+
+ gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
+ $s_sort_key = $s_sort_dir = $u_sort_param = $s_limit_days = '';
+
+ $unread_list = array();
+ $unread_list = get_unread_topics($user->data['user_id'], $sql_where, $sql_sort);
+
+ if (!empty($unread_list))
+ {
+ $sql = 'SELECT t.topic_id
+ FROM ' . TOPICS_TABLE . ' t
+ WHERE ' . $db->sql_in_set('t.topic_id', array_keys($unread_list)) . "
+ $sql_sort";
+ $field = 'topic_id';
+ }
+ break;
+
case 'newposts':
$l_search_title = $user->lang['SEARCH_NEW'];
// force sorting
@@ -429,12 +487,12 @@ if ($keywords || $author || $author_id || $search_id || $submit)
if (!empty($search->search_query))
{
- $total_match_count = $search->keyword_search($show_results, $search_fields, $search_terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_id_ary, $id_ary, $start, $per_page);
+ $total_match_count = $search->keyword_search($show_results, $search_fields, $search_terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page);
}
else if (sizeof($author_id_ary))
{
$firstpost_only = ($search_fields === 'firstpost' || $search_fields == 'titleonly') ? true : false;
- $total_match_count = $search->author_search($show_results, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_id_ary, $id_ary, $start, $per_page);
+ $total_match_count = $search->author_search($show_results, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page);
}
// For some searches we need to print out the "no results" page directly to allow re-sorting/refining the search options.
@@ -484,12 +542,12 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$hilit = (strspn($hilit, '*') === strlen($hilit)) ? '' : $hilit;
$u_hilit = urlencode(htmlspecialchars_decode(str_replace('|', ' ', $hilit)));
- $u_show_results = ($show_results != 'posts') ? '&amp;sr=' . $show_results : '';
+ $u_show_results = '&amp;sr=' . $show_results;
$u_search_forum = implode('&amp;fid%5B%5D=', $search_forum);
$u_search = append_sid("{$phpbb_root_path}search.$phpEx", $u_sort_param . $u_show_results);
$u_search .= ($search_id) ? '&amp;search_id=' . $search_id : '';
- $u_search .= ($u_hilit) ? '&amp;keywords=' . urlencode(htmlspecialchars_decode($search->search_query)) : '';
+ $u_search .= ($u_hilit) ? '&amp;keywords=' . urlencode(htmlspecialchars_decode($keywords)) : '';
$u_search .= ($search_terms != 'all') ? '&amp;terms=' . $search_terms : '';
$u_search .= ($topic_id) ? '&amp;t=' . $topic_id : '';
$u_search .= ($author) ? '&amp;author=' . urlencode(htmlspecialchars_decode($author)) : '';
@@ -945,7 +1003,6 @@ if ($keywords || $author || $author_id || $search_id || $submit)
page_footer();
}
-
// Search forum
$s_forums = '';
$sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.left_id, f.right_id, f.forum_password, f.enable_indexing, fa.user_id