Plugin Directory

Changeset 3263514


Ignore:
Timestamp:
03/28/2025 12:57:59 PM (11 months ago)
Author:
needle
Message:

Release 0.5.3

Location:
bp-groups-civicrm-sync/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • bp-groups-civicrm-sync/trunk/bp-groups-civicrm-sync.php

    r3147635 r3263514  
    55 * Plugin Name:       BP Groups CiviCRM Sync
    66 * Description:       Enables two-way synchronisation between BuddyPress Groups and CiviCRM Groups.
    7  * Version:           0.5.2
     7 * Version:           0.5.3
    88 * Plugin URI:        https://github.com/christianwach/bp-groups-civicrm-sync
    99 * GitHub Plugin URI: https://github.com/christianwach/bp-groups-civicrm-sync
     
    1818 *
    1919 * @package BP_Groups_CiviCRM_Sync
     20 * @link    https://github.com/christianwach/bp-groups-civicrm-sync
     21 * @license GPL v2 or later
     22 *
     23 * This program is free software; you can redistribute it and/or modify
     24 * it under the terms of the GNU General Public License as published by
     25 * the Free Software Foundation; either version 2 of the License, or
     26 * (at your option) any later version.
     27 *
     28 * This program is distributed in the hope that it will be useful,
     29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     31 * GNU General Public License for more details.
    2032 */
    2133
     
    2436
    2537// Set our version here.
    26 define( 'BP_GROUPS_CIVICRM_SYNC_VERSION', '0.5.2' );
     38define( 'BP_GROUPS_CIVICRM_SYNC_VERSION', '0.5.3' );
    2739
    2840// Store reference to this file.
     
    267279
    268280        // Load translations if there are any.
     281        // phpcs:ignore WordPress.WP.DeprecatedParameters.Load_plugin_textdomainParam2Found
    269282        load_plugin_textdomain(
    270283            'bp-groups-civicrm-sync', // Unique name.
  • bp-groups-civicrm-sync/trunk/includes/buddypress/class-buddypress-group-member.php

    r3035828 r3263514  
    3939
    4040    /**
    41      * Store for previous Group Status.
    42      *
    43      * @since 0.5.0
     41     * Store for bridging data between pre and post callbacks.
     42     *
     43     * @since 0.5.3
    4444     * @access private
    4545     * @var array
    4646     */
    47     public $old_status = [];
     47    public $bridging_array = [];
    4848
    4949    /**
     
    9494        $this->register_hooks_group_members();
    9595
    96         // Catch Groups admin page load.
    97         add_action( 'bp_groups_admin_load', [ $this, 'register_hooks_bp_groups_admin' ], 10, 1 );
    98 
    9996    }
    10097
     
    121118    public function register_hooks_group_members() {
    122119
    123         // User joins or leaves Group.
    124         add_action( 'groups_join_group', [ $this, 'member_just_joined_group' ], 5, 2 );
    125         add_action( 'groups_leave_group', [ $this, 'civicrm_group_membership_delete' ], 5, 2 );
    126 
    127         // User's Group Membership was removed.
    128         add_action( 'groups_removed_member', [ $this, 'member_removed_from_group' ], 10, 2 );
    129 
    130         // Group Membership status is being reduced.
    131         add_action( 'groups_demote_member', [ $this, 'member_reduce_status' ], 10, 2 );
    132         add_action( 'groups_ban_member', [ $this, 'member_reduce_status' ], 10, 2 );
    133 
    134         // Group Membership modified.
    135         add_action( 'groups_promoted_member', [ $this, 'member_changed_status' ], 10, 2 );
    136         add_action( 'groups_demoted_member', [ $this, 'member_changed_status' ], 10, 2 );
    137         add_action( 'groups_unbanned_member', [ $this, 'member_changed_status' ], 10, 2 );
    138         add_action( 'groups_banned_member', [ $this, 'member_changed_status' ], 10, 2 );
    139         add_action( 'groups_membership_accepted', [ $this, 'member_changed_status' ], 10, 2 );
    140         add_action( 'groups_accept_invite', [ $this, 'member_changed_status' ], 10, 2 );
     120        // Before and after a Group Membership is saved.
     121        add_action( 'groups_member_before_save', [ $this, 'member_save_pre' ], 9 );
     122        add_action( 'groups_member_after_save', [ $this, 'member_save_post' ], 9 );
     123
     124        // Before and after a Group Membership is removed.
     125        add_action( 'groups_member_before_remove', [ $this, 'member_remove_pre' ], 9 );
     126        add_action( 'groups_member_after_remove', [ $this, 'member_remove_post' ], 9 );
     127
     128        // Before and after a Group Membership is deleted.
     129        add_action( 'bp_groups_member_before_delete', [ $this, 'member_delete_pre' ], 9, 2 );
     130        add_action( 'bp_groups_member_after_delete', [ $this, 'member_delete_post' ], 9, 2 );
    141131
    142132    }
     
    151141
    152142        // Remove callbacks.
    153         remove_action( 'groups_join_group', [ $this, 'member_just_joined_group' ], 5 );
    154         remove_action( 'groups_leave_group', [ $this, 'civicrm_group_membership_delete' ], 5 );
    155         remove_action( 'groups_removed_member', [ $this, 'member_removed_from_group' ], 10 );
    156         remove_action( 'groups_demote_member', [ $this, 'member_reduce_status' ], 10 );
    157         remove_action( 'groups_ban_member', [ $this, 'member_reduce_status' ], 10 );
    158         remove_action( 'groups_promoted_member', [ $this, 'member_changed_status' ], 10 );
    159         remove_action( 'groups_demoted_member', [ $this, 'member_changed_status' ], 10 );
    160         remove_action( 'groups_unbanned_member', [ $this, 'member_changed_status' ], 10 );
    161         remove_action( 'groups_banned_member', [ $this, 'member_changed_status' ], 10 );
    162         remove_action( 'groups_membership_accepted', [ $this, 'member_changed_status' ], 10 );
    163         remove_action( 'groups_accept_invite', [ $this, 'member_changed_status' ], 10 );
    164 
    165     }
    166 
    167     /**
    168      * Adds hooks when the Groups admin page is loaded.
    169      *
    170      * None of the "past tense" actions fire on the Groups admin page, so we
    171      * have to hook into the "present tense" actions and figure out what's going
    172      * on at that point.
    173      *
    174      * @since 0.2.2
    175      * @since 0.5.0 Moved to this class.
    176      *
    177      * @param string $doaction Current $_GET action being performed in admin screen.
    178      */
    179     public function register_hooks_bp_groups_admin( $doaction ) {
    180 
    181         // Only add hooks if saving data.
    182         if ( $doaction && 'save' === $doaction ) {
    183 
    184             // Group Membership hooks: Group Membership status is being modified.
    185             add_action( 'groups_promote_member', [ $this, 'member_changing_status' ], 10, 3 );
    186             add_action( 'groups_demote_member', [ $this, 'member_changing_status' ], 10, 2 );
    187             add_action( 'groups_unban_member', [ $this, 'member_changing_status' ], 10, 2 );
    188             add_action( 'groups_ban_member', [ $this, 'member_changing_status' ], 10, 2 );
    189 
    190             // User is being removed from Group.
    191             add_action( 'groups_remove_member', [ $this, 'civicrm_group_membership_delete' ], 10, 2 );
    192 
    193         }
     143        remove_action( 'groups_member_before_save', [ $this, 'member_save_pre' ], 9 );
     144        remove_action( 'groups_member_after_save', [ $this, 'member_save_post' ], 9 );
     145        remove_action( 'groups_member_before_remove', [ $this, 'member_remove_pre' ], 9 );
     146        remove_action( 'groups_member_after_remove', [ $this, 'member_remove_post' ], 9 );
     147        remove_action( 'bp_groups_member_before_delete', [ $this, 'member_delete_pre' ], 9 );
     148        remove_action( 'bp_groups_member_after_delete', [ $this, 'member_delete_post' ], 9 );
    194149
    195150    }
     
    198153
    199154    /**
    200      * Called when User joins Group.
    201      *
    202      * @since 0.1
    203      * @since 0.5.0 Moved to this class.
    204      *
    205      * @param int $group_id The numeric ID of the BuddyPress Group.
    206      * @param int $user_id The numeric ID of the WordPress User.
    207      */
    208     public function member_just_joined_group( $group_id, $user_id ) {
    209 
    210         // Call update method.
    211         $this->civicrm_group_membership_update( $user_id, $group_id );
    212 
    213     }
    214 
    215     /**
    216      * Called when User's Group status is about to change.
    217      *
    218      * Parameter order ($group_id, $user_id) is the opposite of the "past tense"
    219      * hooks. Compare, for example, 'groups_promoted_member'.
    220      *
    221      * @see $this->register_hooks_bp_groups_admin()
    222      *
    223      * @since 0.2.2
    224      * @since 0.5.0 Moved to this class.
    225      *
    226      * @param int    $group_id The numeric ID of the BuddyPress Group.
    227      * @param int    $user_id The numeric ID of the WordPress User.
    228      * @param string $status New status being changed to.
    229      */
    230     public function member_changing_status( $group_id, $user_id, $status = '' ) {
    231 
    232         // If we have no status, check if User is Group Admin.
    233         if ( empty( $status ) ) {
    234             $status = groups_is_user_admin( $user_id, $group_id ) ? 'admin' : '';
    235         }
    236 
    237         /*
    238          * Group Admins cannot be banned.
    239          * @see BP_Groups_Member::ban()
    240          */
    241         if ( 'admin' === $status && current_action() === 'groups_ban_member' ) {
    242             return;
    243         }
    244 
    245         // If a Group Admin is being demoted, set special status.
    246         if ( 'admin' === $status && current_action() === 'groups_demote_member' ) {
    247             $status = 'ex-admin';
    248         }
     155     * Called before a Group Membership is saved.
     156     *
     157     * @since 0.5.3
     158     *
     159     * @param BP_Groups_Member $member The BP Groups Member instance.
     160     */
     161    public function member_save_pre( $member ) {
     162
     163        // Sanity check.
     164        if ( ! ( $member instanceof BP_Groups_Member ) ) {
     165            return;
     166        }
     167
     168        // Get the previous Group Membership.
     169        $previous_member = new BP_Groups_Member( $member->user_id, $member->group_id );
     170
     171        // Add Group Membership object to the bridging array.
     172        $this->bridging_array['save'][ $member->group_id ][ $member->user_id ] = $previous_member;
     173
     174    }
     175
     176    /**
     177     * Called after a Group Membership is saved.
     178     *
     179     * @since 0.5.3
     180     *
     181     * @param BP_Groups_Member $member The BP Groups Member instance.
     182     */
     183    public function member_save_post( BP_Groups_Member $member ) {
     184
     185        // Bail if we do not have an entry in the bridging array.
     186        if ( empty( $this->bridging_array['save'][ $member->group_id ][ $member->user_id ] ) ) {
     187            return;
     188        }
     189
     190        // Okay, let's get it.
     191        $previous = $this->bridging_array['save'][ $member->group_id ][ $member->user_id ];
     192        unset( $this->bridging_array['save'][ $member->group_id ][ $member->user_id ] );
    249193
    250194        // Is this User being banned?
    251195        $is_active = 1;
    252         if ( current_action() === 'groups_ban_member' ) {
     196        if ( 0 === (int) $previous->is_banned && 1 === (int) $member->is_banned ) {
    253197            $is_active = 0;
     198        }
     199
     200        // Our "status" is simply to distinguish between admins and others.
     201        $status = ( 1 === (int) $member->is_admin ) ? 'admin' : '';
     202
     203        // If a Group Admin is being demoted, set special status.
     204        if ( '' === $status && 1 === $previous->is_admin ) {
     205            $status = 'ex-admin';
    254206        }
    255207
     
    257209        $args = [
    258210            'action'    => 'add',
     211            'group_id'  => $member->group_id,
     212            'user_id'   => $member->user_id,
     213            'status'    => $status,
     214            'is_active' => $is_active,
     215        ];
     216
     217        // Update the corresponding CiviCRM Group memberships.
     218        $this->plugin->civicrm->group_contact->memberships_sync( $args );
     219
     220    }
     221
     222    /**
     223     * Called before a Group Membership is removed.
     224     *
     225     * @since 0.5.3
     226     *
     227     * @param BP_Groups_Member $member The BP Groups Member instance.
     228     */
     229    public function member_remove_pre( BP_Groups_Member $member ) {
     230
     231        // Sanity check.
     232        if ( ! ( $member instanceof BP_Groups_Member ) ) {
     233            return;
     234        }
     235
     236        // Get the previous Group Membership.
     237        $previous_member = new BP_Groups_Member( $member->user_id, $member->group_id );
     238
     239        // Add Group Membership object to the bridging array.
     240        $this->bridging_array['remove'][ $member->group_id ][ $member->user_id ] = $previous_member;
     241
     242    }
     243
     244    /**
     245     * Called after a Group Membership is removed.
     246     *
     247     * @since 0.5.3
     248     *
     249     * @param BP_Groups_Member $member The BP Groups Member instance.
     250     */
     251    public function member_remove_post( BP_Groups_Member $member ) {
     252
     253        // Bail if we do not have an entry in the bridging array.
     254        if ( empty( $this->bridging_array['remove'][ $member->group_id ][ $member->user_id ] ) ) {
     255            return;
     256        }
     257
     258        // Okay, let's get it.
     259        $previous = $this->bridging_array['remove'][ $member->group_id ][ $member->user_id ];
     260        unset( $this->bridging_array['remove'][ $member->group_id ][ $member->user_id ] );
     261
     262        // Our "status" is simply to distinguish between admins and others.
     263        $status = ( 1 === (int) $member->is_admin ) ? 'admin' : '';
     264
     265        // Update Membership of CiviCRM Group.
     266        $args = [
     267            'action'    => 'delete',
     268            'group_id'  => $member->group_id,
     269            'user_id'   => $member->user_id,
     270            'status'    => $status,
     271            'is_active' => 0,
     272        ];
     273
     274        // Update the corresponding CiviCRM Group memberships.
     275        $this->plugin->civicrm->group_contact->memberships_sync( $args );
     276
     277    }
     278
     279    /**
     280     * Called before a Group Membership is deleted.
     281     *
     282     * @since 0.5.3
     283     *
     284     * @param int $user_id The numeric ID of the WordPress User.
     285     * @param int $group_id The numeric ID of the BuddyPress Group.
     286     */
     287    public function member_delete_pre( $user_id, $group_id ) {
     288
     289        // Get the previous Group Membership.
     290        $previous_member = new BP_Groups_Member( $user_id, $group_id );
     291
     292        // Add Group Membership object to the bridging array.
     293        $this->bridging_array['delete'][ $group_id ][ $user_id ] = $previous_member;
     294
     295    }
     296
     297    /**
     298     * Called after a Group Membership is deleted.
     299     *
     300     * @since 0.5.3
     301     *
     302     * @param int $user_id The numeric ID of the WordPress User.
     303     * @param int $group_id The numeric ID of the BuddyPress Group.
     304     */
     305    public function member_delete_post( $user_id, $group_id ) {
     306
     307        // Bail if we do not have an entry in the bridging array.
     308        if ( empty( $this->bridging_array['delete'][ $group_id ][ $user_id ] ) ) {
     309            return;
     310        }
     311
     312        // Okay, let's get it.
     313        $previous = $this->bridging_array['delete'][ $group_id ][ $user_id ];
     314        unset( $this->bridging_array['delete'][ $group_id ][ $user_id ] );
     315
     316        // Our "status" is simply to distinguish between admins and others.
     317        $status = ( 1 === (int) $previous->is_admin ) ? 'admin' : '';
     318
     319        // Update Membership of CiviCRM Group.
     320        $args = [
     321            'action'    => 'delete',
    259322            'group_id'  => $group_id,
    260323            'user_id'   => $user_id,
    261324            'status'    => $status,
    262             'is_active' => $is_active,
     325            'is_active' => 0,
    263326        ];
    264327
    265328        // Update the corresponding CiviCRM Group memberships.
    266329        $this->plugin->civicrm->group_contact->memberships_sync( $args );
    267 
    268     }
    269 
    270     /**
    271      * Called when User's Group status is being reduced.
    272      *
    273      * @since 0.4
    274      * @since 0.5.0 Moved to this class.
    275      *
    276      * @param int $group_id The numeric ID of the BuddyPress Group.
    277      * @param int $user_id The numeric ID of the WordPress User.
    278      */
    279     public function member_reduce_status( $group_id, $user_id ) {
    280 
    281         // Bail if not on front-end.
    282         if ( is_admin() ) {
    283             return;
    284         }
    285 
    286         // Check if User is Group Admin.
    287         $status = groups_is_user_admin( $user_id, $group_id ) ? 'admin' : '';
    288 
    289         /*
    290          * Group Admins cannot be banned.
    291          * @see BP_Groups_Member::ban()
    292          */
    293         if ( 'admin' === $status && current_action() === 'groups_ban_member' ) {
    294             return;
    295         }
    296 
    297         // If a Group Admin is being demoted, set special status.
    298         if ( 'admin' === $status && current_action() === 'groups_demote_member' ) {
    299             $status = 'ex-admin';
    300         }
    301 
    302         // Set a flag for use in "past tense" callback.
    303         $this->old_status[ $group_id ][ $user_id ] = $status;
    304 
    305     }
    306 
    307     /**
    308      * Called when User's Group status has changed.
    309      *
    310      * Parameter order ($user_id, $group_id) is reversed for these "past tense"
    311      * hooks. Compare, for example, 'groups_join_group', 'groups_promote_member'
    312      * and other "present tense" hooks.
    313      *
    314      * @since 0.1
    315      * @since 0.5.0 Moved to this class.
    316      *
    317      * @param int $user_id The numeric ID of the WordPress User.
    318      * @param int $group_id The numeric ID of the BuddyPress Group.
    319      */
    320     public function member_changed_status( $user_id, $group_id ) {
    321 
    322         // Call update method.
    323         $this->civicrm_group_membership_update( $user_id, $group_id );
    324 
    325     }
    326 
    327     /**
    328      * Called when a User has been removed from a Group.
    329      *
    330      * Parameter order ($user_id, $group_id) is reversed for this "past tense"
    331      * hook. Compare, for example, 'groups_join_group'.
    332      *
    333      * @since 0.2.2
    334      * @since 0.5.0 Moved to this class.
    335      *
    336      * @param int $user_id The numeric ID of the WordPress User.
    337      * @param int $group_id The numeric ID of the BuddyPress Group.
    338      */
    339     public function member_removed_from_group( $user_id, $group_id ) {
    340 
    341         // Call delete method.
    342         $this->civicrm_group_membership_delete( $group_id, $user_id );
    343330
    344331    }
     
    364351
    365352        // Get current Member status.
    366         $status = $this->status_get_for_user( $user_id, $group_id );
    367 
    368         // Check previous Member status.
    369         if ( ! empty( $this->old_status[ $group_id ][ $user_id ] ) && 'ex-admin' === $this->old_status[ $group_id ][ $user_id ] ) {
    370             $status = $this->old_status[ $group_id ][ $user_id ];
    371             unset( $this->old_status[ $group_id ][ $user_id ] );
     353        $status = false;
     354        if ( groups_is_user_admin( $user_id, $group_id ) ) {
     355            $status = 'admin';
     356        } elseif ( groups_is_user_mod( $user_id, $group_id ) ) {
     357            $status = 'mod';
     358        } elseif ( groups_is_user_member( $user_id, $group_id ) ) {
     359            $status = 'member';
    372360        }
    373361
     
    395383    }
    396384
    397     /**
    398      * Inform CiviCRM of Membership status change.
    399      *
    400      * @since 0.1
    401      * @since 0.5.0 Moved to this class.
    402      *
    403      * @param int $group_id The numeric ID of the BuddyPress Group.
    404      * @param int $user_id The numeric ID of the WordPress User.
    405      * @return array|bool $result The result of the update, or false on failure.
    406      */
    407     public function civicrm_group_membership_delete( $group_id, $user_id ) {
    408 
    409         // Bail if sync should not happen for this Group.
    410         if ( ! $this->bp->group->should_be_synced( $group_id ) ) {
    411             return;
    412         }
    413 
    414         // Get current User status.
    415         $status = $this->status_get_for_user( $user_id, $group_id );
    416 
    417         // Remove Membership of CiviCRM Groups.
    418         $args = [
    419             'action'    => 'delete',
    420             'group_id'  => $group_id,
    421             'user_id'   => $user_id,
    422             'status'    => $status,
    423             'is_active' => 0,
    424         ];
    425 
    426         // Remove the corresponding CiviCRM Group memberships.
    427         $result = $this->plugin->civicrm->group_contact->memberships_sync( $args );
    428 
    429         // --<
    430         return $result;
    431 
    432     }
    433 
    434385    // -----------------------------------------------------------------------------------
    435386
     
    805756
    806757        // Unhook our action to prevent BuddyPress->CiviCRM sync.
    807         remove_action( 'groups_join_group', [ $this, 'member_just_joined_group' ], 5 );
     758        $this->unregister_hooks_group_members();
    808759
    809760        // Use BuddyPress function.
     
    811762
    812763        // Re-hook our action to enable BuddyPress->CiviCRM sync.
    813         add_action( 'groups_join_group', [ $this, 'member_just_joined_group' ], 5, 2 );
     764        $this->register_hooks_group_members();
    814765
    815766        /*
     
    881832        do_action( 'groups_remove_member', $group_id, $user_id );
    882833
     834        // Unhook our action to prevent BuddyPress->CiviCRM sync.
     835        $this->unregister_hooks_group_members();
     836
    883837        // Remove Member.
    884838        $success = $member->remove();
     839
     840        // Re-hook our action to enable BuddyPress->CiviCRM sync.
     841        $this->register_hooks_group_members();
    885842
    886843        // --<
     
    932889        do_action( 'groups_demote_member', $group_id, $user_id );
    933890
     891        // Unhook our action to prevent BuddyPress->CiviCRM sync.
     892        $this->unregister_hooks_group_members();
     893
    934894        // Demote them.
    935895        $success = $member->demote();
     896
     897        // Re-hook our action to enable BuddyPress->CiviCRM sync.
     898        $this->register_hooks_group_members();
    936899
    937900        // --<
     
    985948        do_action( 'groups_promote_member', $group_id, $user_id, $status );
    986949
     950        // Unhook our action to prevent BuddyPress->CiviCRM sync.
     951        $this->unregister_hooks_group_members();
     952
    987953        // Promote them.
    988954        $success = $member->promote( $status );
    989955
     956        // Re-hook our action to enable BuddyPress->CiviCRM sync.
     957        $this->register_hooks_group_members();
     958
    990959        // --<
    991960        return $success;
    992 
    993     }
    994 
    995     // -----------------------------------------------------------------------------------
    996 
    997     /**
    998      * Get BuddyPress Group Membership status for a User.
    999      *
    1000      * The following is modified code from the BuddyPress Groupblog plugin.
    1001      *
    1002      * @see bp_groupblog_upgrade_user()
    1003      *
    1004      * @since 0.1
    1005      * @since 0.5.0 Moved to this class.
    1006      *
    1007      * @param int $user_id The numeric ID of the WordPress User.
    1008      * @param int $group_id The numeric ID of the BuddyPress Group.
    1009      * @return string $user_group_status The Membership status for a User.
    1010      */
    1011     public function status_get_for_user( $user_id, $group_id ) {
    1012 
    1013         // Check BuddyPress config.
    1014         if ( ! $this->bp->is_configured() ) {
    1015             return false;
    1016         }
    1017 
    1018         // Init return.
    1019         $user_group_status = false;
    1020 
    1021         // Fall back to BuddyPress functions if not set.
    1022         if ( groups_is_user_admin( $user_id, $group_id ) ) {
    1023             $user_group_status = 'admin';
    1024         } elseif ( groups_is_user_mod( $user_id, $group_id ) ) {
    1025             $user_group_status = 'mod';
    1026         } elseif ( groups_is_user_member( $user_id, $group_id ) ) {
    1027             $user_group_status = 'member';
    1028         }
    1029 
    1030         // Are we promoting or demoting?
    1031         if ( bp_action_variable( 1 ) && bp_action_variable( 2 ) ) {
    1032 
    1033             // Change User status based on promotion / demotion.
    1034             switch ( bp_action_variable( 1 ) ) {
    1035 
    1036                 case 'promote':
    1037                     $user_group_status = bp_action_variable( 2 );
    1038                     break;
    1039 
    1040                 case 'demote':
    1041                 case 'ban':
    1042                 case 'unban':
    1043                     $user_group_status = 'member';
    1044                     break;
    1045 
    1046             }
    1047 
    1048         }
    1049 
    1050         // --<
    1051         return $user_group_status;
    1052961
    1053962    }
  • bp-groups-civicrm-sync/trunk/includes/civicrm/class-civicrm-group-contact.php

    r3147635 r3263514  
    337337        $this->register_hooks();
    338338
    339         // Skip ACL Group unless we have a Group Admin or a Group Admin is being demoted.
    340         if ( ! in_array( $args['status'], [ 'admin', 'ex-admin' ] ) ) {
     339        /*
     340         * Skip ACL Group unless we have a Group Admin or a Group Admin is being demoted.
     341         * We also need to account for AJAX "Leave Group" requests that cannot be checked
     342         * prior to the Group membership being deleted.
     343         */
     344        if ( ! in_array( $args['status'], [ 'admin', 'ex-admin' ], true ) ) {
    341345            return $result;
    342346        }
  • bp-groups-civicrm-sync/trunk/includes/civicrm/class-civicrm-group-meta.php

    r3035828 r3263514  
    330330
    331331            // Skip if the parent is not the container Group.
    332             if ( ! in_array( (int) $meta_group_id, $group['parents'] ) ) {
     332            if ( ! in_array( (int) $meta_group_id, $group['parents'], true ) ) {
    333333                continue;
    334334            }
  • bp-groups-civicrm-sync/trunk/includes/civicrm/class-civicrm-group.php

    r3035828 r3263514  
    179179        }
    180180
    181         // Maybe assing to Meta Group.
     181        // Maybe assign to Meta Group.
    182182        $this->civicrm->group_nesting->nesting_update( $bp_group->id );
    183183
     
    13481348
    13491349        // Allow the relevant ones.
    1350         if ( in_array( strtolower( $permission ), $permissions ) ) {
     1350        if ( in_array( strtolower( $permission ), $permissions, true ) ) {
    13511351            $granted = 1;
    13521352        }
  • bp-groups-civicrm-sync/trunk/includes/wp-cli/commands/command-job.php

    r3035828 r3263514  
    242242
    243243                // Show feedback each time Group changes.
    244                 if ( ! in_array( $bp_group_id, $bp_group_ids ) ) {
     244                if ( ! in_array( (int) $bp_group_id, $bp_group_ids, true ) ) {
    245245
    246246                    // Try the pseudo-cache for the BuddyPress Group.
     
    250250                    WP_CLI::log( sprintf( WP_CLI::colorize( '%gDeleting Contacts not in BuddyPress Group%n %Y%s%n %y(ID: %d)%n' ), $bp_group_data['title'], $bp_group_id ) );
    251251
    252                     $bp_group_ids[] = $bp_group_id;
     252                    $bp_group_ids[] = (int) $bp_group_id;
    253253
    254254                }
  • bp-groups-civicrm-sync/trunk/languages/bp-groups-civicrm-sync.pot

    r3147635 r3263514  
    1 # Copyright (C) 2024 Christian Wach
     1# Copyright (C) 2025 Christian Wach
    22# This file is distributed under the GPLv2 or later.
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: BP Groups CiviCRM Sync 0.5.2a\n"
     5"Project-Id-Version: BP Groups CiviCRM Sync 0.5.3a\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/bp-groups-civicrm-sync\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2024-09-06T15:08:45+00:00\n"
     12"POT-Creation-Date: 2025-03-28T12:56:32+00:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    14 "X-Generator: WP-CLI 2.10.0\n"
     14"X-Generator: WP-CLI 2.11.0\n"
    1515"X-Domain: bp-groups-civicrm-sync\n"
    1616
     
    128128msgstr ""
    129129
    130 #: bp-groups-civicrm-sync.php:362
     130#: bp-groups-civicrm-sync.php:375
    131131#: includes/admin/class-page-settings.php:127
    132132#: includes/admin/class-page-settings.php:130
     
    134134msgstr ""
    135135
    136 #: bp-groups-civicrm-sync.php:366
     136#: bp-groups-civicrm-sync.php:379
    137137msgid "Donate!"
    138138msgstr ""
     
    351351
    352352#: includes/civicrm/class-civicrm-group-contact.php:122
    353 #: includes/civicrm/class-civicrm-group-contact.php:840
    354 #: includes/civicrm/class-civicrm-group-contact.php:894
     353#: includes/civicrm/class-civicrm-group-contact.php:844
     354#: includes/civicrm/class-civicrm-group-contact.php:898
    355355#: includes/civicrm/class-civicrm-group.php:367
    356356#: includes/civicrm/class-civicrm-group.php:430
  • bp-groups-civicrm-sync/trunk/readme.txt

    r3147635 r3263514  
    44Tags: civicrm, buddypress, user, groups, sync
    55Requires at least: 4.9
    6 Tested up to: 6.6
    7 Stable tag: 0.5.2
     6Tested up to: 6.8
     7Stable tag: 0.5.3
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
     
    2626### Requirements
    2727
    28 This plugin requires a minimum of *WordPress 4.9*, *BuddyPress 1.8* and *CiviCRM 5.19*. Having the latest version of each plugin active is, of course, highly recommended.
     28This plugin requires a minimum of *WordPress 4.9*, *BuddyPress 2.3* and *CiviCRM 5.19*. Having the latest version of each plugin active is, of course, highly recommended.
    2929
    3030### Plugin Development
     
    4444
    4545== Changelog ==
     46
     47= 0.5.3 =
     48
     49* Reworks BuddyPress Group Member logic to use before and after SQL hooks
     50* Accounts for Group Admins leaving via the Groups Directory button
    4651
    4752= 0.5.2 =
Note: See TracChangeset for help on using the changeset viewer.