Ticket #4600: bp-activity-classes.php.patch
| File bp-activity-classes.php.patch, 2.9 KB (added by , 13 years ago) |
|---|
-
bp-activity/bp-activity-classes.php
452 452 453 453 $activity_comments = array(); 454 454 455 / * Now fetch the activity comments and parse them into the correct position in the activities array. */455 // Now fetch the activity comments and parse them into the correct position in the activities array. 456 456 foreach( (array) $activities as $activity ) { 457 if ( 'activity_comment' != $activity->type && $activity->mptt_left && $activity->mptt_right )458 $activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right, $spam);457 $top_level_parent_id = 'activity_comment' == $activity->type ? $activity->item_id : 0; 458 $activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right, $spam, $top_level_parent_id ); 459 459 } 460 460 461 461 /* Merge the comments with the activity items */ … … 478 478 * @return array The updated activities with nested comments 479 479 * @since 1.2 480 480 */ 481 function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only' ) {481 function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only',$top_level_parent_id = 0 ) { 482 482 global $wpdb, $bp; 483 483 484 if ( empty( $top_level_parent_id ) ) { 485 $top_level_parent_id = $activity_id; 486 } 487 484 488 if ( !$comments = wp_cache_get( 'bp_activity_comments_' . $activity_id ) ) { 485 489 // Select the user's fullname with the query 486 490 if ( bp_is_active( 'xprofile' ) ) { … … 501 505 else 502 506 $spam_sql = ''; 503 507 504 $sql = apply_filters( 'bp_activity_comments_user_join_filter', $wpdb->prepare( "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name{$fullname_select} FROM {$bp->activity->table_name} a, {$wpdb->users} u{$fullname_from} WHERE u.ID = a.user_id {$fullname_where} AND a.type = 'activity_comment' ${spam_sql} AND a.item_id = %d AND a.mptt_left BETWEEN %d AND %d ORDER BY a.date_recorded ASC", $activity_id, $left, $right ), $activity_id, $left, $right, $spam_sql ); 508 // The mptt BETWEEN clause allows us to limit returned descendants to the right part of the tree 509 $sql = apply_filters( 'bp_activity_comments_user_join_filter', $wpdb->prepare( "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name{$fullname_select} FROM {$bp->activity->table_name} a, {$wpdb->users} u{$fullname_from} WHERE u.ID = a.user_id {$fullname_where} AND a.type = 'activity_comment' ${spam_sql} AND a.item_id = %d AND a.mptt_left BETWEEN %d AND %d ORDER BY a.date_recorded ASC", $top_level_parent_id, $left, $right ), $activity_id, $left, $right, $spam_sql ); 505 510 506 511 // Retrieve all descendants of the $root node 507 512 $descendants = $wpdb->get_results( $sql );