Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/01/2011 11:21:59 PM (14 years ago)
Author:
djpaul
Message:

Second pass of Akismet support for the Activity component. See #3660

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-classes.php

    r5259 r5262  
    9999
    100100    // 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' ) {
    102102        global $wpdb, $bp;
    103103
     
    111111
    112112        // Spam
    113         if ( $hide_spam )
     113        if ( 'ham_only' == $spam )
    114114            $where_conditions['spam_sql'] = 'a.is_spam = 0';
     115        elseif ( 'spam_only' == $spam )
     116            $where_conditions['spam_sql'] = 'a.is_spam = 1';
    115117
    116118        // Searching
     
    191193
    192194        if ( $activities && $display_comments )
    193             $activities = BP_Activity_Activity::append_comments( $activities, $hide_spam );
     195            $activities = BP_Activity_Activity::append_comments( $activities, $spam );
    194196
    195197        // If $max is set, only return up to the max results
     
    362364     * @global wpdb $wpdb WordPress database object
    363365     * @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'.
    365367     * @return array The updated activities with nested comments
    366368     * @since 1.2
    367369     */
    368     function append_comments( $activities, $hide_spam = true ) {
     370    function append_comments( $activities, $spam = 'ham_only' ) {
    369371        global $bp, $wpdb;
    370372
     
    374376        foreach( (array)$activities as $activity ) {
    375377            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 );
    377379        }
    378380
     
    393395     * @param int $left Left-most node boundary
    394396     * @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'.
    396398     * @return array The updated activities with nested comments
    397399     * @since 1.2
    398400     */
    399     function get_activity_comments( $activity_id, $left, $right, $hide_spam = true ) {
     401    function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only' ) {
    400402        global $wpdb, $bp;
    401403
     
    413415
    414416            // Don't retrieve activity comments marked as spam
    415             if ( $hide_spam )
     417            if ( 'ham_only' == $spam )
    416418                $spam_sql = 'AND a.is_spam = 0';
     419            elseif ( 'spam_only' == $spam )
     420                $spam_sql = 'AND a.is_spam = 1';
    417421            else
    418422                $spam_sql = '';
    419423
    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 );
    421425
    422426            // Retrieve all descendants of the $root node
Note: See TracChangeset for help on using the changeset viewer.