Changeset 2619 for trunk/bp-activity/bp-activity-classes.php
- Timestamp:
- 02/07/2010 08:05:19 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-classes.php
r2616 r2619 335 335 global $wpdb, $bp; 336 336 337 /* Select the user's fullname with the query so we don't have to fetch it for each comment */ 338 if ( function_exists( 'xprofile_install' ) ) { 339 $fullname_select = ", pd.value as user_fullname"; 340 $fullname_from = ", {$bp->profile->table_name_data} pd "; 341 $fullname_where = "AND pd.user_id = a.user_id AND pd.field_id = 1"; 342 } 343 344 /* Retrieve all descendants of the $root node */ 345 $descendants = $wpdb->get_results( $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' AND a.item_id = %d AND a.mptt_left BETWEEN %d AND %d ORDER BY a.date_recorded ASC", $activity_id, $left, $right ) ); 346 347 /* Loop descendants and build an assoc array */ 348 foreach ( (array)$descendants as $d ) { 349 $d->children = array(); 350 351 /* If we have a reference on the parent */ 352 if ( isset( $ref[ $d->secondary_item_id ] ) ) { 353 $ref[ $d->secondary_item_id ]->children[ $d->id ] = $d; 354 $ref[ $d->id ] =& $ref[ $d->secondary_item_id ]->children[ $d->id ]; 355 356 /* If we don't have a reference on the parent, put in the root level */ 357 } else { 358 $menu[ $d->id ] = $d; 359 $ref[ $d->id ] =& $menu[ $d->id ]; 360 } 361 } 362 363 return $menu; 337 if ( !$comments = wp_cache_get( 'bp_activity_comments_' . $activity_id ) ) { 338 /* Select the user's fullname with the query so we don't have to fetch it for each comment */ 339 if ( function_exists( 'xprofile_install' ) ) { 340 $fullname_select = ", pd.value as user_fullname"; 341 $fullname_from = ", {$bp->profile->table_name_data} pd "; 342 $fullname_where = "AND pd.user_id = a.user_id AND pd.field_id = 1"; 343 } 344 345 /* Retrieve all descendants of the $root node */ 346 $descendants = $wpdb->get_results( $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' AND a.item_id = %d AND a.mptt_left BETWEEN %d AND %d ORDER BY a.date_recorded ASC", $activity_id, $left, $right ) ); 347 348 /* Loop descendants and build an assoc array */ 349 foreach ( (array)$descendants as $d ) { 350 $d->children = array(); 351 352 /* If we have a reference on the parent */ 353 if ( isset( $ref[ $d->secondary_item_id ] ) ) { 354 $ref[ $d->secondary_item_id ]->children[ $d->id ] = $d; 355 $ref[ $d->id ] =& $ref[ $d->secondary_item_id ]->children[ $d->id ]; 356 357 /* If we don't have a reference on the parent, put in the root level */ 358 } else { 359 $comments[ $d->id ] = $d; 360 $ref[ $d->id ] =& $comments[ $d->id ]; 361 } 362 } 363 wp_cache_set( 'bp_activity_comments_' . $activity_id, $comments, 'bp' ); 364 } 365 366 return $comments; 364 367 } 365 368
Note: See TracChangeset
for help on using the changeset viewer.