Skip to:
Content

BuddyPress.org

Ticket #8728: 8728.03.patch

File 8728.03.patch, 1.8 KB (added by emaralive, 2 years ago)

Replacement for 8728.02.patch

  • 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..dcbcf4e51 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        if ( isset( $activity->component ) && 'groups' !== $activity->component ) {
    659661                return $retval;
    660662        }
    661663
    662         // Trust the passed value for administrators.
    663         if ( bp_current_user_can( 'bp_moderate' ) ) {
     664        // The second conditional statement does not allow "site admin" activity posts to be deleted by "non site admins".
     665        if ( bp_current_user_can( 'bp_moderate' ) || bp_user_can( $activity->user_id, 'bp_moderate' ) ) {
    664666                return $retval;
    665667        }
    666668
    667         // Group administrators or moderators can delete content in that group that doesn't belong to them.
    668669        $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
     671        // Group creator, administrators or moderators can delete content in which deletions are allowed for that group.
     672        // Todo: break this out into additional conditionals that provide granularity as to who can to what, when.
     673        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 ) ) {
    670674                $retval = true;
    671675        }
    672676