Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/30/2016 11:40:55 AM (8 years ago)
Author:
imath
Message:

Only delete the "new_blog" activity when its author is removed from the Blog.

Before this commit, as soon as any contributor was removed from the blog, the "new_blog" activity was also removed although the removed user was not the author of the activity.
It is no more the case. This activity will only be deleted if the user who created the blog is removed from it.
This commit also make sure this activity is not deleted twice as some duplicate code has been left when moving the activity code inside the bp-blogs-activity.php file during the 2.6 dev-cycle.

Fixes #7199 (trunk)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-blogs/bp-blogs-activity.php

    r10947 r10971  
    640640 * @param int $blog_id Site ID.
    641641 */
    642 function bp_blogs_delete_new_blog_activity_for_site( $blog_id ) {
    643     bp_blogs_delete_activity( array(
     642function bp_blogs_delete_new_blog_activity_for_site( $blog_id, $user_id = 0 ) {
     643    $args = array(
    644644        'item_id'   => $blog_id,
    645645        'component' => buddypress()->blogs->id,
    646646        'type'      => 'new_blog'
    647     ) );
    648 }
    649 add_action( 'bp_blogs_remove_blog',          'bp_blogs_delete_new_blog_activity_for_site' );
    650 add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_delete_new_blog_activity_for_site' );
     647    );
     648
     649    /**
     650     * In the case a user is removed, make sure he is the author of the 'new_blog' activity
     651     * when trying to delete it.
     652     */
     653    if ( ! empty( $user_id ) ) {
     654        $args['user_id'] = $user_id;
     655    }
     656
     657    bp_blogs_delete_activity( $args );
     658}
     659add_action( 'bp_blogs_remove_blog',          'bp_blogs_delete_new_blog_activity_for_site', 10, 1 );
     660add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_delete_new_blog_activity_for_site', 10, 2 );
    651661
    652662/**
Note: See TracChangeset for help on using the changeset viewer.