Changeset 3364
- Timestamp:
- 11/06/2010 05:54:55 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
bp-messages.php (modified) (2 diffs)
-
bp-themes/bp-default/_inc/ajax.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-messages.php
r3357 r3364 11 11 define ( 'BP_MESSAGES_SLUG', 'messages' ); 12 12 13 / * For internal identification */13 // For internal identification 14 14 $bp->messages->id = 'messages'; 15 15 … … 20 20 $bp->messages->format_notification_function = 'messages_format_notifications'; 21 21 22 / * Register this in the active components array */22 // Register this in the active components array 23 23 $bp->active_components[$bp->messages->slug] = $bp->messages->id; 24 25 // Include all members in the To: autocomplete? 26 $bp->messages->autocomplete_all = defined( 'BP_MESSAGES_AUTOCOMPLETE_ALL' ) ? true : false; 24 27 25 28 do_action( 'messages_setup_globals' ); -
trunk/bp-themes/bp-default/_inc/ajax.php
r3353 r3364 537 537 add_action( 'wp_ajax_messages_delete', 'bp_dtheme_ajax_messages_delete' ); 538 538 539 /* AJAX autocomplete your friends names on the compose screen */ 539 /** 540 * bp_dtheme_ajax_messages_autocomplete_results() 541 * 542 * AJAX handler for autocomplete. Displays friends only, unless BP_MESSAGES_AUTOCOMPLETE_ALL is defined 543 * 544 * @global object $bp The global BuddyPress settings variable created in bp_core_setup_globals() 545 * @return none 546 */ 540 547 function bp_dtheme_ajax_messages_autocomplete_results() { 541 548 global $bp; 542 549 550 // Include everyone in the autocomplete, or just friends? 551 if ( $bp->messages->slug == $bp->current_component ) 552 $autocomplete_all = $bp->messages->autocomplete_all; 553 543 554 $friends = false; 544 555 545 // Get the friend ids based on the search terms 546 if ( function_exists( 'friends_search_friends' ) ) 547 $friends = friends_search_friends( $_GET['q'], $bp->loggedin_user->id, $_GET['limit'], 1 ); 548 549 $friends = apply_filters( 'bp_friends_autocomplete_list', $friends, $_GET['q'], $_GET['limit'] ); 550 551 if ( $friends['friends'] ) { 552 foreach ( (array)$friends['friends'] as $user_id ) { 556 $limit = $_GET['limit'] ? $_GET['limit'] : apply_filters( 'bp_autocomplete_max_results', 10 ); 557 558 // Get the user ids based on the search terms 559 if ( $autocomplete_all ) { 560 $users = BP_Core_User::search_users( $_GET['q'], $limit, $pag_page ); 561 562 if ( !empty( $users['users'] ) ) { 563 // Build an array with the correct format 564 $user_ids = array(); 565 foreach( $users['users'] as $user ) { 566 if ( $user->id != $bp->loggedin_user->id ) 567 $user_ids[] = $user->id; 568 } 569 570 $user_ids = apply_filters( 'bp_core_autocomplete_ids', $user_ids, $_GET['q'], $limit ); 571 } 572 } else { 573 if ( function_exists( 'friends_search_friends' ) ) { 574 $users = friends_search_friends( $_GET['q'], $bp->loggedin_user->id, $limit, 1 ); 575 576 // Keeping the bp_friends_autocomplete_list filter for backward compatibility 577 $users = apply_filters( 'bp_friends_autocomplete_list', $users, $_GET['q'], $limit ); 578 579 if ( !empty( $users['friends'] ) ) 580 $user_ids = apply_filters( 'bp_friends_autocomplete_ids', $users['friends'], $_GET['q'], $limit ); 581 } 582 } 583 584 585 if ( $user_ids ) { 586 foreach ( $user_ids as $user_id ) { 553 587 $ud = get_userdata($user_id); 554 588 $username = $ud->user_login;
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)