mirror of https://github.com/BOINC/boinc.git
Hide deleted posts when using the search (fix #191)
svn path=/trunk/boinc/; revision=13580
This commit is contained in:
parent
dd89e307c1
commit
ae628d1fcd
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit
|
||||||
|
|
||||||
require_once("../inc/db.inc");
|
require_once("../inc/db.inc");
|
||||||
/**
|
/**
|
||||||
|
@ -248,7 +249,7 @@ class MySQLDatabaseHandler extends DatabaseHandler {
|
||||||
* by forum or user if specified. If time is given, only posts newer than that
|
* by forum or user if specified. If time is given, only posts newer than that
|
||||||
* are returned.
|
* are returned.
|
||||||
**/
|
**/
|
||||||
function searchThreadTitles($keyword_list, $forum="", $user="", $time="", $limit=200, $sort_style=CREATE_TIME_NEW){
|
function searchThreadTitles($keyword_list, $forum="", $user="", $time="", $limit=200, $sort_style=CREATE_TIME_NEW, $show_hidden = false){
|
||||||
$search_string="%";
|
$search_string="%";
|
||||||
foreach ($keyword_list as $key => $word) {
|
foreach ($keyword_list as $key => $word) {
|
||||||
$search_string.=mysql_escape_string($word)."%";
|
$search_string.=mysql_escape_string($word)."%";
|
||||||
|
@ -263,6 +264,9 @@ class MySQLDatabaseHandler extends DatabaseHandler {
|
||||||
if ($time!="" && $user!="all") {
|
if ($time!="" && $user!="all") {
|
||||||
$query.=" and timestamp > ".intval($time);
|
$query.=" and timestamp > ".intval($time);
|
||||||
}
|
}
|
||||||
|
if ($show_hidden == false) {
|
||||||
|
$query .= " AND thread.hidden = 0";
|
||||||
|
}
|
||||||
switch($sort_style) {
|
switch($sort_style) {
|
||||||
case MODIFIED_NEW:
|
case MODIFIED_NEW:
|
||||||
$query .= ' ORDER BY timestamp DESC';
|
$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
|
* by forum or user if specified. If time is given, only posts newer than that
|
||||||
* are returned.
|
* 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="%";
|
$search_string="%";
|
||||||
foreach ($keyword_list as $key => $word){
|
foreach ($keyword_list as $key => $word){
|
||||||
$search_string.=mysql_escape_string($word)."%";
|
$search_string.=mysql_escape_string($word)."%";
|
||||||
|
@ -409,6 +413,9 @@ class MySQLDatabaseHandler extends DatabaseHandler {
|
||||||
if ($time!="" && $user!="all"){
|
if ($time!="" && $user!="all"){
|
||||||
$query.=" and post.timestamp > ".intval($time);
|
$query.=" and post.timestamp > ".intval($time);
|
||||||
}
|
}
|
||||||
|
if ($show_hidden == false) {
|
||||||
|
$query .= " AND post.hidden = 0";
|
||||||
|
}
|
||||||
switch($sort_style) {
|
switch($sort_style) {
|
||||||
case VIEWS_MOST:
|
case VIEWS_MOST:
|
||||||
$query.= ' ORDER BY views DESC';
|
$query.= ' ORDER BY views DESC';
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit
|
||||||
/**
|
/**
|
||||||
* This file allows people to search for posts or a thread. Takes input from
|
* This file allows people to search for posts or a thread. Takes input from
|
||||||
* forum_search.php
|
* forum_search.php
|
||||||
**/
|
**/
|
||||||
|
|
||||||
$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit
|
|
||||||
|
|
||||||
require_once('../inc/forum.inc');
|
require_once('../inc/forum.inc');
|
||||||
require_once('../inc/forum_std.inc');
|
require_once('../inc/forum_std.inc');
|
||||||
|
@ -12,6 +11,11 @@ require_once('../inc/forum_std.inc');
|
||||||
|
|
||||||
db_init();
|
db_init();
|
||||||
$logged_in_user = re_get_logged_in_user(false);
|
$logged_in_user = re_get_logged_in_user(false);
|
||||||
|
if ($logged_in_user && $logged_in_user->isSpecialUser(S_MODERATOR)){
|
||||||
|
$show_hidden_posts = true;
|
||||||
|
} else {
|
||||||
|
$show_hidden_posts = false;
|
||||||
|
}
|
||||||
|
|
||||||
page_head(tr(FORUM_SEARCH));
|
page_head(tr(FORUM_SEARCH));
|
||||||
|
|
||||||
|
@ -35,10 +39,9 @@ if ($search_author) $user = newUser($search_author);
|
||||||
$dbhandler = $mainFactory->getDatabaseHandler();
|
$dbhandler = $mainFactory->getDatabaseHandler();
|
||||||
|
|
||||||
// First search thread titles, if we get a hit there it's almost bound to be relevant
|
// 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
|
// Display the threads while we search for posts
|
||||||
//STUB todo
|
|
||||||
if ($thread_ids){
|
if ($thread_ids){
|
||||||
echo "<p><a href=\"forum_search.php\">Perform another search</a></p>";
|
echo "<p><a href=\"forum_search.php\">Perform another search</a></p>";
|
||||||
echo "<h2>Threads found matching your search query:</h2>";
|
echo "<h2>Threads found matching your search query:</h2>";
|
||||||
|
@ -63,7 +66,7 @@ if ($thread_ids){
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let's see if we can match anything in a post body as well:
|
// 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){
|
if ($post_ids){
|
||||||
echo "<h2>Posts found matching your search query:</h2>";
|
echo "<h2>Posts found matching your search query:</h2>";
|
||||||
|
@ -76,8 +79,8 @@ if ($post_ids){
|
||||||
foreach ($post_ids as $key => $post_id){
|
foreach ($post_ids as $key => $post_id){
|
||||||
$post = new Post($post_id);
|
$post = new Post($post_id);
|
||||||
$thread = $post->getThread();
|
$thread = $post->getThread();
|
||||||
if ($thread->isHidden()) continue;
|
if (($show_hidden_posts == false) && ($thread->isHidden())) continue;
|
||||||
if ($post->isHidden()) continue;
|
if (($show_hidden_posts == false) && ($post->isHidden())) continue;
|
||||||
$options->setHighlightTerms($search_list);
|
$options->setHighlightTerms($search_list);
|
||||||
$contents = output_transform($post->getContent(),$options);
|
$contents = output_transform($post->getContent(),$options);
|
||||||
$thread_forum = $thread->getForum();
|
$thread_forum = $thread->getForum();
|
||||||
|
|
Loading…
Reference in New Issue