Changeset 7776
- Timestamp:
- 02/04/2014 01:16:32 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-classes.php
r7773 r7776 419 419 420 420 // Get the fullnames of users so we don't have to query in the loop 421 if ( bp_is_active( 'xprofile' ) && !empty( $activities ) ) { 422 $activity_user_ids = wp_list_pluck( $activities, 'user_id' ); 423 $activity_user_ids = implode( ',', wp_parse_id_list( $activity_user_ids ) ); 424 425 if ( !empty( $activity_user_ids ) ) { 426 if ( $names = $wpdb->get_results( "SELECT user_id, value AS user_fullname FROM {$bp->profile->table_name_data} WHERE field_id = 1 AND user_id IN ({$activity_user_ids})" ) ) { 427 428 foreach ( (array) $names as $name ) { 429 $tmp_names[$name->user_id] = $name->user_fullname; 430 } 431 432 foreach ( (array) $activities as $i => $activity ) { 433 if ( !empty( $tmp_names[$activity->user_id] ) ) { 434 $activities[$i]->user_fullname = $tmp_names[$activity->user_id]; 435 } 436 } 437 438 unset( $names ); 439 unset( $tmp_names ); 440 } 441 } 442 } 421 $activities = self::append_user_fullnames( $activities ); 443 422 444 423 // Get activity meta … … 536 515 $activities[ $a_index ]->user_login = $a_user->user_login; 537 516 $activities[ $a_index ]->display_name = $a_user->display_name; 517 } 518 } 519 520 return $activities; 521 } 522 523 /** 524 * Append xProfile fullnames to an activity array. 525 * 526 * @since BuddyPress (2.0.0) 527 * 528 * @param array $activities Activities array. 529 * @return array 530 */ 531 protected function append_user_fullnames( $activities ) { 532 global $wpdb; 533 534 if ( bp_is_active( 'xprofile' ) && ! empty( $activities ) ) { 535 $activity_user_ids = wp_list_pluck( $activities, 'user_id' ); 536 $activity_user_ids = implode( ',', wp_parse_id_list( $activity_user_ids ) ); 537 538 if ( ! empty( $activity_user_ids ) ) { 539 $bp = buddypress(); 540 541 if ( $names = $wpdb->get_results( "SELECT user_id, value AS user_fullname FROM {$bp->profile->table_name_data} WHERE field_id = 1 AND user_id IN ({$activity_user_ids})" ) ) { 542 543 $tmp_names = array(); 544 545 foreach ( (array) $names as $name ) { 546 $tmp_names[ $name->user_id ] = $name->user_fullname; 547 } 548 549 foreach ( (array) $activities as $i => $activity ) { 550 if ( ! empty( $tmp_names[ $activity->user_id ] ) ) { 551 $activities[ $i ]->user_fullname = $tmp_names[ $activity->user_id ]; 552 } 553 } 554 555 unset( $names ); 556 unset( $tmp_names ); 557 } 538 558 } 539 559 }
Note: See TracChangeset
for help on using the changeset viewer.