Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/21/2012 08:50:41 PM (15 years ago)
Author:
johnjamesjacoby
Message:

Add ajax search to Private Messages inbox and sentbox. Fixes #3993. Props sbrajesh.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-messages/bp-messages-template.php

    r5773 r5822  
    2828        var $pag_num;
    2929        var $pag_links;
     30        var $search_terms;
    3031
    3132        function bp_messages_box_template( $user_id, $box, $per_page, $max, $type ) {
    … …  
    3334        }
    3435
    35         function __construct( $user_id, $box, $per_page, $max, $type ) {
     36        function __construct( $user_id, $box, $per_page, $max, $type, $search_terms ) {
    3637                $this->pag_page = isset( $_GET['mpage'] ) ? intval( $_GET['mpage'] ) : 1;
    37                 $this->pag_num  = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page;
    38 
    39                 $this->user_id  = $user_id;
    40                 $this->box      = $box;
    41                 $this->type     = $type;
    42 
     38                $this->pag_num  = isset( $_GET['num'] )   ? intval( $_GET['num'] )   : $per_page;
     39
     40                $this->user_id      = $user_id;
     41                $this->box          = $box;
     42                $this->type         = $type;
     43                $this->search_terms = $search_terms;
     44               
    4345                if ( 'notices' == $this->box ) {
    4446                        $this->threads = BP_Messages_Notice::get_notices();
    4547                } else {
    46                         $threads = BP_Messages_Thread::get_current_threads_for_user( $this->user_id, $this->box, $this->type, $this->pag_num, $this->pag_page );
     48                        $threads = BP_Messages_Thread::get_current_threads_for_user( $this->user_id, $this->box, $this->type, $this->pag_num, $this->pag_page, $this->search_terms );
    4749
    4850                        $this->threads            = $threads['threads'];
    … …  
    169171
    170172        $defaults = array(
    171                 'user_id'  => bp_loggedin_user_id(),
    172                 'box'      => 'inbox',
    173                 'per_page' => 10,
    174                 'max'      => false,
    175                 'type'     => 'all'
     173                'user_id'      => bp_loggedin_user_id(),
     174                'box'          => 'inbox',
     175                'per_page'     => 10,
     176                'max'          => false,
     177                'type'         => 'all',
     178                'search_terms' => isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''
    176179        );
    177180
    … …  
    194197                }
    195198
    196                 $messages_template = new BP_Messages_Box_Template( $user_id, $box, $per_page, $max, $type );
     199                $messages_template = new BP_Messages_Box_Template( $user_id, $box, $per_page, $max, $type, $search_terms );
    197200        }
    198201
    … …  
    354357
    355358        echo sprintf( __( 'Viewing message %1$s to %2$s (of %3$s messages)', 'buddypress' ), $from_num, $to_num, $total ); ?><?php
     359}
     360
     361/**
     362 * Output the Private Message search form
     363 *
     364 * @since BuddyPress (1.6)
     365 */
     366function bp_message_search_form() {
     367
     368        $default_search_value = bp_get_search_default_text( 'messages' );
     369        $search_value         = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value; ?>
     370
     371        <form action="" method="get" id="search-message-form">
     372                <label><input type="text" name="s" id="messages_search" <?php if ( $search_value === $default_search_value ) : ?>placeholder="<?php echo esc_html( $search_value ); ?>"<?php endif; ?> <?php if ( $search_value !== $default_search_value ) : ?>value="<?php echo esc_html( $search_value ); ?>"<?php endif; ?> /></label>
     373                <input type="submit" id="messages_search_submit" name="messages_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
     374        </form>
     375
     376<?php
    356377}
    357378
Note: See TracChangeset for help on using the changeset viewer.