Skip to:
Content

BuddyPress.org

Changeset 2542 for trunk/bp-activity.php


Ignore:
Timestamp:
02/02/2010 06:29:33 PM (15 years ago)
Author:
apeatling
Message:

Fixes #1767

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity.php

    r2539 r2542  
    333333
    334334    $activity_id = $bp->action_variables[0];
     335    $activity = new BP_Activity_Activity( $activity_id );
    335336
    336337    /* Check access */
    337     if ( !is_site_admin() ) {
    338         $activity = new BP_Activity_Activity( $activity_id );
    339 
    340         if ( $activity->user_id != $bp->loggedin_user->id )
    341             return false;
    342     }
     338    if ( !is_site_admin() && $activity->user_id != $bp->loggedin_user->id )
     339        return false;
    343340
    344341    /* Now delete the activity item */
    345     if ( bp_activity_delete_by_activity_id( $activity_id ) )
     342    if ( bp_activity_delete( array( 'id' => $activity_id, 'user_id' => $activity->user_id  ) ) )
    346343        bp_core_add_message( __( 'Activity deleted', 'buddypress' ) );
    347344    else
     
    350347    do_action( 'bp_activity_action_delete_activity', $activity_id );
    351348
    352     bp_core_redirect( $_SERVER['HTTP_REFERER'] );
     349    bp_core_redirect( wp_get_referer() );
    353350}
    354351add_action( 'wp', 'bp_activity_action_delete_activity', 3 );
     
    697694        return false;
    698695
     696    /* Check if the user's latest update has been deleted */
     697    if ( empty( $args['user_id'] ) )
     698        $user_id = $bp->loggedin_user->id;
     699    else
     700        $user_id = $args['user_id'];
     701
     702    $latest_update = get_usermeta( $user_id, 'bp_latest_update' );
     703    if ( !empty( $latest_update ) ) {
     704        if ( in_array( (int)$latest_update['id'], (array)$activity_ids_deleted ) )
     705            delete_usermeta( $user_id, 'bp_latest_update' );
     706    }
     707
    699708    do_action( 'bp_activity_delete', $args );
    700709    do_action( 'bp_activity_deleted_activities', $activity_ids_deleted );
Note: See TracChangeset for help on using the changeset viewer.