Skip to:
Content

BuddyPress.org

Ticket #8728: 8728.02.patch

File 8728.02.patch, 1.8 KB (added by emaralive, 13 months ago)

Proposed change to callback

  • src/bp-groups/bp-groups-activity.php

    diff --git src/bp-groups/bp-groups-activity.php src/bp-groups/bp-groups-activity.php
    index 1cafacd66..ce89642fd 100644
    function groups_post_update( $args = '' ) { 
    651651 */
    652652function bp_groups_filter_activity_user_can_delete( $retval, $activity ) {
    653653        // Bail if no current user.
     654        // Todo: add second conditional statement to check the state to allow group activity deletions.
     655        // e.g., "|| ! bp_enable_group_activity_deletions()".
    654656        if ( ! is_user_logged_in() ) {
    655657                return $retval;
    656658        }
    657659
    658         if ( isset( $activity->component ) || 'groups' !== $activity->component ) {
     660        // The second conditional statement does not allow "site admin" activity posts to be deleted by "non site admins".
     661        if ( bp_current_user_can( 'bp_moderate' ) || bp_user_can( $activity->user_id, 'bp_moderate' ) ) {
    659662                return $retval;
    660663        }
    661664
    662         // Trust the passed value for administrators.
    663         if ( bp_current_user_can( 'bp_moderate' ) ) {
    664                 return $retval;
    665         }
     665        $bp = buddypress();
    666666
    667         // Group administrators or moderators can delete content in that group that doesn't belong to them.
    668         $group_id = $activity->item_id;
    669         if ( groups_is_user_admin( bp_loggedin_user_id(), $group_id ) || groups_is_user_mod( bp_loggedin_user_id(), $group_id ) ) {
    670                 $retval = true;
     667        // Confine group activity deletion to the confines of the respective group where it is allowed.
     668        if ( ! empty( $bp->groups->current_group->id ) ) {
     669                $group_id = $bp->groups->current_group->id;
     670
     671                // Todo: break this out into additional conditionals that provide granularity as to who can to what, when.
     672                if ( groups_is_user_creator( bp_loggedin_user_id(), $group_id ) || groups_is_user_admin( bp_loggedin_user_id(), $group_id ) || groups_is_user_mod( bp_loggedin_user_id(), $group_id ) ) {
     673                        $retval = true;
     674                }
    671675        }
    672676
    673677        return $retval;