Skip to:
Content

BuddyPress.org

Changeset 3563


Ignore:
Timestamp:
12/22/2010 02:46:17 PM (14 years ago)
Author:
boonebgorges
Message:

Refines the check to see whether a user has permissions to delete an activity item. Fixes #2770

File:
1 edited

Legend:

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

    r3525 r3563  
    611611
    612612        // Add the delete link if the user has permission on this item
    613         if ( ( is_user_logged_in() && $activities_template->activity->user_id == $bp->loggedin_user->id ) || $bp->is_item_admin || $bp->loggedin_user->is_super_admin )
     613        if ( bp_activity_user_can_delete() )
    614614             $content .= apply_filters( 'bp_activity_delete_link', ' · ' . bp_get_activity_delete_link(), $activities_template->activity );
    615615
    616616        return apply_filters( 'bp_insert_activity_meta', $content );
    617617    }
     618
     619function bp_activity_user_can_delete() {
     620    global $activities_template, $bp;
     621
     622    if ( !is_user_logged_in() )
     623        $can_delete = false;
     624   
     625    if ( $bp->loggedin_user->is_super_admin )
     626        $can_delete = true;
     627   
     628    if ( $activities_template->activity->user_id == $bp->loggedin_user->id )
     629        $can_delete = true;
     630       
     631    if ( $bp->is_item_admin && $bp->is_single_item )
     632        $can_delete = true;
     633   
     634    return apply_filters( 'bp_activity_user_can_delete', $can_delete );
     635}
    618636
    619637function bp_activity_parent_content( $args = '' ) {
Note: See TracChangeset for help on using the changeset viewer.