Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/07/2012 12:19:43 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Exclude existing group members and previously banned friends in group invites list. See #3969 (trunk)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-friends/bp-friends-classes.php

    r5302 r5676  
    295295
    296296        function get_invitable_friend_count( $user_id, $group_id ) {
    297                 global $wpdb, $bp;
    298 
    299                 $friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id );
    300 
     297
     298                // Setup some data we'll use below
     299                $is_group_admin  = BP_Groups_Member::check_is_admin( $user_id, $group_id );
     300                $friend_ids      = BP_Friends_Friendship::get_friend_user_ids( $user_id );
    301301                $invitable_count = 0;
     302
    302303                for ( $i = 0, $count = count( $friend_ids ); $i < $count; ++$i ) {
    303304
    304                         if ( BP_Groups_Member::check_is_member( (int)$friend_ids[$i], $group_id ) )
     305                        // If already a member, they cannot be invited again
     306                        if ( BP_Groups_Member::check_is_member( (int) $friend_ids[$i], $group_id ) )
    305307                                continue;
    306308
    307                         if ( BP_Groups_Member::check_has_invite( (int)$friend_ids[$i], $group_id )  )
     309                        // If user already has invite, they cannot be added
     310                        if ( BP_Groups_Member::check_has_invite( (int) $friend_ids[$i], $group_id )  )
     311                                continue;
     312
     313                        // If user is not group admin and friend is banned, they cannot be invited
     314                        if ( ( false === $is_group_admin ) && BP_Groups_Member::check_is_banned( (int) $friend_ids[$i], $group_id ) )
    308315                                continue;
    309316
Note: See TracChangeset for help on using the changeset viewer.