Skip to:
Content

BuddyPress.org

Changeset 2675


Ignore:
Timestamp:
02/11/2010 02:50:47 PM (15 years ago)
Author:
apeatling
Message:

Added missing pre_save filters to activity saving. Fixed bug where a user could leave/join a group quickly multiple times and flood the activity stream.

Location:
trunk
Files:
3 edited

Legend:

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

    r2644 r2675  
    4747        global $wpdb, $bp, $current_user;
    4848
    49         do_action( 'bp_activity_before_save', $this );
     49        do_action( 'bp_activity_before_save', &$this );
     50
     51        $this->id = apply_filters( 'bp_activity_id_before_save', $this->id, &$this );
     52        $this->item_id = apply_filters( 'bp_activity_item_id_before_save', $this->item_id, &$this );
     53        $this->secondary_item_id = apply_filters( 'bp_activity_secondary_item_id_before_save', $this->secondary_item_id, &$this );
     54        $this->user_id = apply_filters( 'bp_activity_user_id_before_save', $this->user_id, &$this );
     55        $this->primary_link = apply_filters( 'bp_activity_primary_link_before_save', $this->primary_link, &$this );
     56        $this->component = apply_filters( 'bp_activity_component_before_save', $this->component, &$this );
     57        $this->type = apply_filters( 'bp_activity_type_before_save', $this->type, &$this );
     58        $this->action = apply_filters( 'bp_activity_action_before_save', $this->action, &$this );
     59        $this->content = apply_filters( 'bp_activity_content_before_save', $this->content, &$this );
     60        $this->date_recorded = apply_filters( 'bp_activity_date_recorded_before_save', $this->date_recorded, &$this );
     61        $this->hide_sitewide = apply_filters( 'bp_activity_hide_sitewide_before_save', $this->hide_sitewide, &$this );
     62        $this->mptt_left = apply_filters( 'bp_activity_mptt_left_before_save', $this->mptt_left, &$this );
     63        $this->mptt_right = apply_filters( 'bp_activity_mptt_right_before_save', $this->mptt_right, &$this );
    5064
    5165        if ( !$this->component || !$this->type )
     
    6781            $this->id = $wpdb->insert_id;
    6882
    69         do_action( 'bp_activity_after_save', $this );
     83        do_action( 'bp_activity_after_save', &$this );
    7084        return true;
    7185    }
     
    280294            return false;
    281295
     296        error_log( $where_sql );
     297
    282298        /* Fetch the activity IDs so we can delete any comments for this activity item */
    283299        $activity_ids = $wpdb->get_col( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" ) );
  • trunk/bp-activity/bp-activity-filters.php

    r2672 r2675  
    22
    33/* Apply WordPress defined filters */
     4add_filter( 'bp_get_activity_action', 'bp_activity_filter_kses', 1 );
     5add_filter( 'bp_get_activity_content_body', 'bp_activity_filter_kses', 1 );
    46add_filter( 'bp_get_activity_content', 'bp_activity_filter_kses', 1 );
    57add_filter( 'bp_get_activity_parent_content', 'bp_activity_filter_kses', 1 );
    68add_filter( 'bp_get_activity_latest_update', 'bp_activity_filter_kses', 1 );
    79add_filter( 'bp_get_activity_feed_item_description', 'bp_activity_filter_kses', 1 );
     10add_filter( 'bp_activity_content_before_save', 'bp_activity_filter_kses', 1 );
     11add_filter( 'bp_activity_action_before_save', 'bp_activity_filter_kses', 1 );
    812
     13add_filter( 'bp_get_activity_action', 'force_balance_tags' );
     14add_filter( 'bp_get_activity_content_body', 'force_balance_tags' );
    915add_filter( 'bp_get_activity_content', 'force_balance_tags' );
    1016add_filter( 'bp_get_activity_latest_update', 'force_balance_tags' );
    1117add_filter( 'bp_get_activity_feed_item_description', 'force_balance_tags' );
    1218
     19add_filter( 'bp_get_activity_action', 'wptexturize' );
     20add_filter( 'bp_get_activity_content_body', 'wptexturize' );
    1321add_filter( 'bp_get_activity_content', 'wptexturize' );
    1422add_filter( 'bp_get_activity_parent_content', 'wptexturize' );
    1523add_filter( 'bp_get_activity_latest_update', 'wptexturize' );
    1624
     25add_filter( 'bp_get_activity_action', 'convert_smilies' );
     26add_filter( 'bp_get_activity_content_body', 'convert_smilies' );
    1727add_filter( 'bp_get_activity_content', 'convert_smilies' );
    1828add_filter( 'bp_get_activity_parent_content', 'convert_smilies' );
    1929add_filter( 'bp_get_activity_latest_update', 'convert_smilies' );
    2030
     31add_filter( 'bp_get_activity_action', 'convert_chars' );
     32add_filter( 'bp_get_activity_content_body', 'convert_chars' );
    2133add_filter( 'bp_get_activity_content', 'convert_chars' );
    2234add_filter( 'bp_get_activity_parent_content', 'convert_chars' );
    2335add_filter( 'bp_get_activity_latest_update', 'convert_chars' );
    2436
     37add_filter( 'bp_get_activity_action', 'wpautop' );
     38add_filter( 'bp_get_activity_content_body', 'wpautop' );
    2539add_filter( 'bp_get_activity_content', 'wpautop' );
    2640add_filter( 'bp_get_activity_feed_item_description', 'wpautop' );
    2741
     42add_filter( 'bp_get_activity_action', 'make_clickable' );
     43add_filter( 'bp_get_activity_content_body', 'make_clickable' );
    2844add_filter( 'bp_get_activity_content', 'make_clickable' );
    2945add_filter( 'bp_get_activity_parent_content', 'make_clickable' );
     
    3147add_filter( 'bp_get_activity_feed_item_description', 'make_clickable' );
    3248
     49add_filter( 'bp_get_activity_action', 'stripslashes_deep' );
    3350add_filter( 'bp_get_activity_content', 'stripslashes_deep' );
     51add_filter( 'bp_get_activity_content_body', 'stripslashes_deep' );
    3452add_filter( 'bp_get_activity_parent_content', 'stripslashes_deep' );
    3553add_filter( 'bp_get_activity_latest_update', 'stripslashes_deep' );
  • trunk/bp-groups.php

    r2662 r2675  
    16281628    }
    16291629
     1630    $membership = new BP_Groups_Member( $user_id, $group_id );
     1631
    16301632    // This is exactly the same as deleting an invite, just is_confirmed = 1 NOT 0.
    16311633    if ( !groups_uninvite_user( $user_id, $group_id ) )
     
    16371639    /* Modify user's group memberhip count */
    16381640    update_usermeta( $user_id, 'total_group_count', (int) get_usermeta( $user_id, 'total_group_count') - 1 );
     1641
     1642    /* If the user joined this group less than five minutes ago, remove the joined_group activity so
     1643     * users cannot flood the activity stream by joining/leaving the group in quick succession.
     1644     */
     1645    if ( function_exists( 'bp_activity_delete' ) && gmmktime() <= strtotime( '+5 minutes', (int)strtotime( $membership->date_modified ) ) )
     1646        bp_activity_delete( array( 'component' => $bp->groups->id, 'type' => 'joined_group', 'user_id' => $user_id, 'item_id' => $group_id ) );
    16391647
    16401648    bp_core_add_message( __( 'You successfully left the group.', 'buddypress' ) );
Note: See TracChangeset for help on using the changeset viewer.