Skip to:
Content

BuddyPress.org

Changeset 10687


Ignore:
Timestamp:
04/05/2016 02:46:58 PM (5 years ago)
Author:
dcavins
Message:

Make sure invites include an inviter_id.

  • When creating an invite, make sure that the

inviter_id is not 0.

  • Add tests for empty values for user_id,

group_id and inviter_id in
groups_send_invites().

Props danbrellis.

Fixes #6941.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-functions.php

    r10454 r10687  
    11011101    extract( $args, EXTR_SKIP );
    11021102
    1103     if ( empty( $user_id ) || empty( $group_id ) )
    1104         return false;
     1103    if ( ! $user_id || ! $group_id || ! $inviter_id ) {
     1104        return false;
     1105    }
    11051106
    11061107    // If the user has already requested membership, accept the request.
  • trunk/tests/phpunit/testcases/groups/class-bp-groups-member.php

    r10487 r10687  
    10871087
    10881088    /**
     1089     * @group groups_invite_user
     1090     * @group group_invitations
     1091     * @group group_membership
     1092     */
     1093    public function test_groups_send_invites_fail_on_empty_group_id() {
     1094        $u1 = $this->factory->user->create();
     1095        $u2 = $this->factory->user->create();
     1096
     1097        // Create draft invitation with empty inviter_id
     1098        $invite_created = groups_invite_user( array(
     1099            'user_id'       => $u2,
     1100            'group_id'      => 0,
     1101            'inviter_id'    => $u1,
     1102            'date_modified' => bp_core_current_time(),
     1103            'is_confirmed'  => 0
     1104        ) );
     1105
     1106        $this->assertFalse( $invite_created );
     1107    }
     1108
     1109    /**
     1110     * @group groups_invite_user
     1111     * @group group_invitations
     1112     * @group group_membership
     1113     */
     1114    public function test_groups_send_invites_fail_on_empty_user_id() {
     1115        $u1 = $this->factory->user->create();
     1116        $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
     1117
     1118        // Create draft invitation with empty inviter_id
     1119        $invite_created = groups_invite_user( array(
     1120            'user_id'       => 0,
     1121            'group_id'      => $g1,
     1122            'inviter_id'    => $u1,
     1123            'date_modified' => bp_core_current_time(),
     1124            'is_confirmed'  => 0
     1125        ) );
     1126
     1127        $this->assertFalse( $invite_created );
     1128    }
     1129
     1130    /**
     1131     * @group groups_invite_user
     1132     * @group group_invitations
     1133     * @group group_membership
     1134     */
     1135    public function test_groups_send_invites_fail_on_empty_inviter_id() {
     1136        $u1 = $this->factory->user->create();
     1137        $u2 = $this->factory->user->create();
     1138        $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
     1139
     1140        // Create draft invitation with empty inviter_id
     1141        $invite_created = groups_invite_user( array(
     1142            'user_id'       => $u2,
     1143            'group_id'      => $g1,
     1144            'inviter_id'    => 0,
     1145            'date_modified' => bp_core_current_time(),
     1146            'is_confirmed'  => 0
     1147        ) );
     1148
     1149        $this->assertFalse( $invite_created );
     1150    }
     1151
     1152    /**
    10891153     * @group groups_send_membership_request
    10901154     * @group group_membership_requests
Note: See TracChangeset for help on using the changeset viewer.