Skip to:
Content

bbPress.org

Changeset 907 for trunk/search.php


Ignore:
Timestamp:
07/16/2007 06:52:00 PM (19 years ago)
Author:
mdawaffe
Message:

More filterable search queries. Fixes #694

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/search.php

    r886 r907  
    55        $q = trim( @$_GET['q'] );
    66
    7 $likeit = preg_replace('/\s+/', '%', $q);
    8 
    9 if ( $likeit ) {
    10         $recent = $bbdb->get_results("SELECT $bbdb->posts.*, MAX(post_time) as post_time FROM $bbdb->posts RIGHT JOIN $bbdb->topics ON $bbdb->topics.topic_id = $bbdb->posts.topic_id
    11                                 WHERE LOWER(post_text) LIKE ('%$likeit%') AND post_status = 0 AND topic_status = 0
    12                                 GROUP BY $bbdb->topics.topic_id ORDER BY post_time DESC LIMIT 5");
    13 }
    14 
    15 $q = stripslashes( $q );
    16 
    177$bb_query_form = new BB_Query_Form;
    188
    19 if ( $q ) {
    20         $bb_query_form->BB_Query_Form( 'topic', array( 'search' => $q ), array( 'post_status' => 0, 'topic_status' => 0, 'search', 'forum_id', 'tag', 'topic_author' )  );
     9if ( $q = stripslashes( $q ) ) {
     10        add_filter( 'bb_recent_search_fields',   create_function( '$f', 'return $f . ", MAX(post_time) AS post_time";' ) );
     11        add_filter( 'bb_recent_search_group_by', create_function( '', 'return "t.topic_id";' ) );
     12        $bb_query_form->BB_Query_Form( 'post', array(), array( 'per_page' => 5, 'post_status' => 0, 'topic_status' => 0, 'post_text' => $q, 'forum_id', 'tag', 'topic_author', 'post_author' ), 'bb_recent_search' );
     13        $recent = $bb_query_form->results;
     14
     15        $bb_query_form->BB_Query_Form( 'topic', array( 'search' => $q ), array( 'post_status' => 0, 'topic_status' => 0, 'search', 'forum_id', 'tag', 'topic_author', 'post_author' ), 'bb_relevant_search' );
    2116        $relevant = $bb_query_form->results;
    2217
Note: See TracChangeset for help on using the changeset viewer.