Changeset 5262 for trunk/bp-activity/bp-activity-classes.php
- Timestamp:
- 11/01/2011 11:21:59 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-classes.php
r5259 r5262 99 99 100 100 // Static Functions 101 function get( $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false, $exclude = false, $in = false, $ hide_spam = true) {101 function get( $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false, $exclude = false, $in = false, $spam = 'ham_only' ) { 102 102 global $wpdb, $bp; 103 103 … … 111 111 112 112 // Spam 113 if ( $hide_spam )113 if ( 'ham_only' == $spam ) 114 114 $where_conditions['spam_sql'] = 'a.is_spam = 0'; 115 elseif ( 'spam_only' == $spam ) 116 $where_conditions['spam_sql'] = 'a.is_spam = 1'; 115 117 116 118 // Searching … … 191 193 192 194 if ( $activities && $display_comments ) 193 $activities = BP_Activity_Activity::append_comments( $activities, $ hide_spam );195 $activities = BP_Activity_Activity::append_comments( $activities, $spam ); 194 196 195 197 // If $max is set, only return up to the max results … … 362 364 * @global wpdb $wpdb WordPress database object 363 365 * @param array $activities 364 * @param bool $ hide_spam Optional. Defaults to true (don't retrieve spammed items).366 * @param bool $spam Optional; 'ham_only' (default), 'spam_only' or 'all'. 365 367 * @return array The updated activities with nested comments 366 368 * @since 1.2 367 369 */ 368 function append_comments( $activities, $ hide_spam = true) {370 function append_comments( $activities, $spam = 'ham_only' ) { 369 371 global $bp, $wpdb; 370 372 … … 374 376 foreach( (array)$activities as $activity ) { 375 377 if ( 'activity_comment' != $activity->type && $activity->mptt_left && $activity->mptt_right ) 376 $activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right, $ hide_spam );378 $activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right, $spam ); 377 379 } 378 380 … … 393 395 * @param int $left Left-most node boundary 394 396 * @param into $right Right-most node boundary 395 * @param bool $ hide_spam Optional. Defaults to true (don't retrieve spammed items).397 * @param bool $spam Optional; 'ham_only' (default), 'spam_only' or 'all'. 396 398 * @return array The updated activities with nested comments 397 399 * @since 1.2 398 400 */ 399 function get_activity_comments( $activity_id, $left, $right, $ hide_spam = true) {401 function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only' ) { 400 402 global $wpdb, $bp; 401 403 … … 413 415 414 416 // Don't retrieve activity comments marked as spam 415 if ( $hide_spam )417 if ( 'ham_only' == $spam ) 416 418 $spam_sql = 'AND a.is_spam = 0'; 419 elseif ( 'spam_only' == $spam ) 420 $spam_sql = 'AND a.is_spam = 1'; 417 421 else 418 422 $spam_sql = ''; 419 423 420 $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, $ hide_spam);424 $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 ); 421 425 422 426 // Retrieve all descendants of the $root node
Note: See TracChangeset
for help on using the changeset viewer.