Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/28/2016 09:02:10 PM (8 years ago)
Author:
r-a-y
Message:

Groups: Change logic for groups_check_user_has_invite() and groups_check_for_membership_request().

This commit changes the internal logic for groups_check_user_has_invite()
and groups_check_for_membership_request() to use the new group membership
caching logic introduced in #6327.

See #7078.

File:
1 edited

Legend:

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

    r10795 r10819  
    15421542 * @param string $type     Optional. Use 'sent' to check for sent invites,
    15431543 *                         'all' to check for all. Default: 'sent'.
    1544  * @return bool True if an invitation is found, otherwise false.
     1544 * @return int|bool ID of the membership if found, otherwise false.
    15451545 */
    15461546function groups_check_user_has_invite( $user_id, $group_id, $type = 'sent' ) {
    1547     return BP_Groups_Member::check_has_invite( $user_id, $group_id, $type );
     1547    $invite = false;
     1548
     1549    $args = array(
     1550        'is_confirmed' => false,
     1551        'is_banned'    => null,
     1552        'is_admin'     => null,
     1553        'is_mod'       => null,
     1554    );
     1555
     1556    if ( 'sent' === $type ) {
     1557        $args['invite_sent'] = true;
     1558    }
     1559
     1560    $user_groups = bp_get_user_groups( $user_id, $args );
     1561
     1562    if ( isset( $user_groups[ $group_id ] ) && 0 !== $user_groups[ $group_id ]->inviter_id ) {
     1563        $invite = $user_groups[ $group_id ]->id;
     1564    }
     1565
     1566    return $invite;
    15481567}
    15491568
     
    18901909 * @param int $user_id  ID of the user.
    18911910 * @param int $group_id ID of the group.
    1892  * @return int|null ID of the membership if found, otherwise false.
     1911 * @return int|bool ID of the membership if found, otherwise false.
    18931912 */
    18941913function groups_check_for_membership_request( $user_id, $group_id ) {
    1895     return BP_Groups_Member::check_for_membership_request( $user_id, $group_id );
     1914    $request = false;
     1915
     1916    $user_groups = bp_get_user_groups( $user_id, array(
     1917        'is_confirmed' => false,
     1918        'is_banned'    => false,
     1919        'is_admin'     => null,
     1920        'is_mod'       => null
     1921    ) );
     1922
     1923    if ( isset( $user_groups[ $group_id ] ) && 0 === $user_groups[ $group_id ]->inviter_id ) {
     1924        $request = $user_groups[ $group_id ]->id;
     1925    }
     1926
     1927    return $request;
    18961928}
    18971929
Note: See TracChangeset for help on using the changeset viewer.