Changeset 5822
- Timestamp:
- 02/21/2012 08:50:41 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-template.php
r5783 r5822 1453 1453 } 1454 1454 1455 function bp_is_messages_conversation() { 1456 if ( bp_is_user_messages() && ( bp_is_current_action( 'view' ) ) ) 1457 return true; 1458 1459 return false; 1460 } 1455 1461 1456 1462 function bp_is_single( $component, $callback ) { -
trunk/bp-messages/bp-messages-classes.php
r5729 r5822 89 89 } 90 90 91 function get_current_threads_for_user( $user_id, $box = 'inbox', $type = 'all', $limit = null, $page = null ) {92 global $wpdb, $bp; 93 94 $pag_sql = $type_sql = '';91 function get_current_threads_for_user( $user_id, $box = 'inbox', $type = 'all', $limit = null, $page = null, $search_terms = '' ) { 92 global $wpdb, $bp; 93 94 $pag_sql = $type_sql = $search_sql = ''; 95 95 if ( $limit && $page ) 96 96 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); … … 101 101 $type_sql = $wpdb->prepare( " AND r.unread_count = 0 " ); 102 102 103 if ( !empty( $search_terms ) ) { 104 $search_terms = like_escape( $wpdb->escape( $search_terms ) ); 105 $search_sql = "AND ( subject LIKE '%%$search_terms%%' OR message LIKE '%%$search_terms%%' )"; 106 } 107 103 108 if ( 'sentbox' == $box ) { 104 $thread_ids = $wpdb->get_results( $wpdb->prepare( "SELECT m.thread_id, MAX(m.date_sent) AS date_sent FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_messages} m WHERE m.thread_id = r.thread_id AND m.sender_id = r.user_id AND m.sender_id = %d AND r.is_deleted = 0GROUP BY m.thread_id ORDER BY date_sent DESC {$pag_sql}", $user_id ) );105 $total_threads = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( DISTINCT m.thread_id ) FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_messages} m WHERE m.thread_id = r.thread_id AND m.sender_id = r.user_id AND m.sender_id = %d AND r.is_deleted = 0 ", $user_id ) );109 $thread_ids = $wpdb->get_results( $wpdb->prepare( "SELECT m.thread_id, MAX(m.date_sent) AS date_sent FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_messages} m WHERE m.thread_id = r.thread_id AND m.sender_id = r.user_id AND m.sender_id = %d AND r.is_deleted = 0 {$search_sql} GROUP BY m.thread_id ORDER BY date_sent DESC {$pag_sql}", $user_id ) ); 110 $total_threads = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( DISTINCT m.thread_id ) FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_messages} m WHERE m.thread_id = r.thread_id AND m.sender_id = r.user_id AND m.sender_id = %d AND r.is_deleted = 0 {$search_sql} ", $user_id ) ); 106 111 } else { 107 $thread_ids = $wpdb->get_results( $wpdb->prepare( "SELECT m.thread_id, MAX(m.date_sent) AS date_sent FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_messages} m WHERE m.thread_id = r.thread_id AND r.is_deleted = 0 AND r.user_id = %d AND r.sender_only = 0 {$type_sql} GROUP BY m.thread_id ORDER BY date_sent DESC {$pag_sql}", $user_id ) );108 $total_threads = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( DISTINCT m.thread_id ) FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_messages} m WHERE m.thread_id = r.thread_id AND r.is_deleted = 0 AND r.user_id = %d AND r.sender_only = 0 {$type_sql} ", $user_id ) );112 $thread_ids = $wpdb->get_results( $wpdb->prepare( "SELECT m.thread_id, MAX(m.date_sent) AS date_sent FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_messages} m WHERE m.thread_id = r.thread_id AND r.is_deleted = 0 AND r.user_id = %d AND r.sender_only = 0 {$type_sql} {$search_sql} GROUP BY m.thread_id ORDER BY date_sent DESC {$pag_sql}", $user_id ) ); 113 $total_threads = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( DISTINCT m.thread_id ) FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_messages} m WHERE m.thread_id = r.thread_id AND r.is_deleted = 0 AND r.user_id = %d AND r.sender_only = 0 {$type_sql} {$search_sql} ", $user_id ) ); 109 114 } 110 115 -
trunk/bp-messages/bp-messages-template.php
r5773 r5822 28 28 var $pag_num; 29 29 var $pag_links; 30 var $search_terms; 30 31 31 32 function bp_messages_box_template( $user_id, $box, $per_page, $max, $type ) { … … 33 34 } 34 35 35 function __construct( $user_id, $box, $per_page, $max, $type ) {36 function __construct( $user_id, $box, $per_page, $max, $type, $search_terms ) { 36 37 $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 43 45 if ( 'notices' == $this->box ) { 44 46 $this->threads = BP_Messages_Notice::get_notices(); 45 47 } 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 ); 47 49 48 50 $this->threads = $threads['threads']; … … 169 171 170 172 $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'] ) : '' 176 179 ); 177 180 … … 194 197 } 195 198 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 ); 197 200 } 198 201 … … 354 357 355 358 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 */ 366 function 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 356 377 } 357 378 -
trunk/bp-themes/bp-default/_inc/ajax.php
r5737 r5822 101 101 locate_template( array( "$object/$object-loop.php" ), true ); 102 102 } 103 add_action( 'wp_ajax_members_filter', 'bp_dtheme_object_template_loader' ); 104 add_action( 'wp_ajax_groups_filter', 'bp_dtheme_object_template_loader' ); 105 add_action( 'wp_ajax_blogs_filter', 'bp_dtheme_object_template_loader' ); 106 add_action( 'wp_ajax_forums_filter', 'bp_dtheme_object_template_loader' ); 103 add_action( 'wp_ajax_members_filter', 'bp_dtheme_object_template_loader' ); 104 add_action( 'wp_ajax_groups_filter', 'bp_dtheme_object_template_loader' ); 105 add_action( 'wp_ajax_blogs_filter', 'bp_dtheme_object_template_loader' ); 106 add_action( 'wp_ajax_forums_filter', 'bp_dtheme_object_template_loader' ); 107 add_action( 'wp_ajax_messages_filter', 'bp_dtheme_messages_template_loader' ); 108 109 /* 110 * Load messages when searched on the private message page 111 */ 112 113 function bp_dtheme_messages_template_loader(){ 114 locate_template( array( 'members/single/messages/messages-loop.php' ), true ); 115 } 107 116 108 117 // This function will load the activity loop template when activity is requested via AJAX -
trunk/bp-themes/bp-default/_inc/css/default-rtl.css
r5509 r5822 762 762 text-align: left; 763 763 } 764 div.message-search { 765 float: left; 766 } -
trunk/bp-themes/bp-default/_inc/css/default.css
r5797 r5822 2361 2361 } 2362 2362 2363 div.message-search { 2364 float: right; 2365 margin: 0 20px; 2366 } 2367 2363 2368 /*-------------------------------------------------------------- 2364 2369 6.9 - Extended Profiles -
trunk/bp-themes/bp-default/_inc/global.js
r5792 r5822 982 982 /** Private Messaging ******************************************/ 983 983 984 /** Message search*/ 985 jq('.message-search').click( function(event) { 986 if ( jq(this).hasClass('no-ajax') ) 987 return; 988 989 var target = jq(event.target); 990 991 if ( target.attr('type') == 'submit' ) { 992 //var css_id = jq('.item-list-tabs li.selected').attr('id').split( '-' ); 993 var object = 'messages'; 994 995 bp_filter_request( object, jq.cookie('bp-' + object + '-filter'), jq.cookie('bp-' + object + '-scope') , 'div.' + object, target.parent().children('label').children('input').val(), 1, jq.cookie('bp-' + object + '-extras') ); 996 997 return false; 998 } 999 }); 1000 984 1001 /* AJAX send reply functionality */ 985 1002 jq("input#send_reply_button").click( -
trunk/bp-themes/bp-default/members/single/messages.php
r3810 r5822 16 16 17 17 </ul> 18 19 <?php if ( bp_is_messages_inbox() || bp_is_messages_sentbox() ) : ?> 20 21 <div class="message-search"><?php bp_message_search_form(); ?></div> 22 23 <?php endif; ?> 24 18 25 </div><!-- .item-list-tabs --> 19 26 -
trunk/bp-themes/bp-default/members/single/messages/messages-loop.php
r5737 r5822 1 1 <?php do_action( 'bp_before_member_messages_loop' ); ?> 2 2 3 <?php if ( bp_has_message_threads( ) ) : ?>3 <?php if ( bp_has_message_threads( bp_ajax_querystring( 'messages' ) ) ) : ?> 4 4 5 5 <div class="pagination no-ajax" id="user-pag"> … … 16 16 17 17 <?php do_action( 'bp_after_member_messages_pagination' ); ?> 18 <?php do_action( 'bp_before_member_messages_threads' ); ?> 18 19 <?php do_action( 'bp_before_member_messages_threads' ); ?> 19 20 20 21 <table id="message-threads" class="messages-notices">
Note: See TracChangeset
for help on using the changeset viewer.