Changeset 6410 for trunk/bp-activity/bp-activity-classes.php
- Timestamp:
- 10/15/2012 07:09:43 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-classes.php
r6342 r6410 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 459 } 460 461 / * Merge the comments with the activity items */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 ); 459 } 460 461 // Merge the comments with the activity items 462 462 foreach( (array) $activities as $key => $activity ) 463 463 if ( isset( $activity_comments[$activity->id] ) ) … … 476 476 * @param into $right Right-most node boundary 477 477 * @param bool $spam Optional; 'ham_only' (default), 'spam_only' or 'all'. 478 * @param int $top_level_parent_id The id of the root-level parent activity item 478 479 * @return array The updated activities with nested comments 479 480 * @since BuddyPress (1.2) 480 481 */ 481 function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only' ) { 482 global $wpdb, $bp; 482 function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only', $top_level_parent_id = 0 ) { 483 global $wpdb, $bp; 484 485 if ( empty( $top_level_parent_id ) ) { 486 $top_level_parent_id = $activity_id; 487 } 483 488 484 489 if ( !$comments = wp_cache_get( 'bp_activity_comments_' . $activity_id ) ) { … … 502 507 $spam_sql = ''; 503 508 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 ); 509 // The mptt BETWEEN clause allows us to limit returned descendants to the right part of the tree 510 $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 511 506 512 // Retrieve all descendants of the $root node
Note: See TracChangeset
for help on using the changeset viewer.