diff --git a/html/inc/forum_mysql_dbh.inc b/html/inc/forum_mysql_dbh.inc index ecb9326349..12e2731156 100644 --- a/html/inc/forum_mysql_dbh.inc +++ b/html/inc/forum_mysql_dbh.inc @@ -1,4 +1,5 @@ $word) { $search_string.=mysql_escape_string($word)."%"; @@ -263,6 +264,9 @@ class MySQLDatabaseHandler extends DatabaseHandler { if ($time!="" && $user!="all") { $query.=" and timestamp > ".intval($time); } + if ($show_hidden == false) { + $query .= " AND thread.hidden = 0"; + } switch($sort_style) { case MODIFIED_NEW: $query .= ' ORDER BY timestamp DESC'; @@ -391,7 +395,7 @@ class MySQLDatabaseHandler extends DatabaseHandler { * by forum or user if specified. If time is given, only posts newer than that * are returned. **/ - function searchPosts($keyword_list, $forum="", $user="", $time="", $limit=200, $sort_style=CREATE_TIME_NEW){ + function searchPosts($keyword_list, $forum="", $user="", $time="", $limit=200, $sort_style=CREATE_TIME_NEW, $show_hidden = false){ $search_string="%"; foreach ($keyword_list as $key => $word){ $search_string.=mysql_escape_string($word)."%"; @@ -409,6 +413,9 @@ class MySQLDatabaseHandler extends DatabaseHandler { if ($time!="" && $user!="all"){ $query.=" and post.timestamp > ".intval($time); } + if ($show_hidden == false) { + $query .= " AND post.hidden = 0"; + } switch($sort_style) { case VIEWS_MOST: $query.= ' ORDER BY views DESC'; diff --git a/html/user/forum_search_action.php b/html/user/forum_search_action.php index 4a0d0e9b2f..a13bd98194 100644 --- a/html/user/forum_search_action.php +++ b/html/user/forum_search_action.php @@ -1,10 +1,9 @@ isSpecialUser(S_MODERATOR)){ + $show_hidden_posts = true; +} else { + $show_hidden_posts = false; +} page_head(tr(FORUM_SEARCH)); @@ -35,10 +39,9 @@ if ($search_author) $user = newUser($search_author); $dbhandler = $mainFactory->getDatabaseHandler(); // First search thread titles, if we get a hit there it's almost bound to be relevant -$thread_ids = $dbhandler->searchThreadTitles($search_list, $forum, $user, $min_timestamp, round($limit/7), $search_sort); +$thread_ids = $dbhandler->searchThreadTitles($search_list, $forum, $user, $min_timestamp, round($limit/7), $search_sort, $show_hidden_posts); // Display the threads while we search for posts -//STUB todo if ($thread_ids){ echo "

Perform another search

"; echo "

Threads found matching your search query:

"; @@ -63,7 +66,7 @@ if ($thread_ids){ } // Let's see if we can match anything in a post body as well: -$post_ids = $dbhandler->searchPosts($search_list, $forum, $user, $min_timestamp, $limit, $search_sort); +$post_ids = $dbhandler->searchPosts($search_list, $forum, $user, $min_timestamp, $limit, $search_sort, $show_hidden_posts); if ($post_ids){ echo "

Posts found matching your search query:

"; @@ -76,8 +79,8 @@ if ($post_ids){ foreach ($post_ids as $key => $post_id){ $post = new Post($post_id); $thread = $post->getThread(); - if ($thread->isHidden()) continue; - if ($post->isHidden()) continue; + if (($show_hidden_posts == false) && ($thread->isHidden())) continue; + if (($show_hidden_posts == false) && ($post->isHidden())) continue; $options->setHighlightTerms($search_list); $contents = output_transform($post->getContent(),$options); $thread_forum = $thread->getForum();