Skip to:
Content

BuddyPress.org

Ticket #5703: 5703.01.patch

File 5703.01.patch, 1.8 KB (added by r-a-y, 11 years ago)
  • src/bp-friends/bp-friends-filters.php

     
    3838                $friend_id = bp_loggedin_user_id() == $fs->initiator_user_id ? $fs->friend_user_id : $fs->initiator_user_id;
    3939
    4040                if ( isset( $user_query->results[ $friend_id ] ) ) {
    41                         $user_query->results[ $friend_id ]->is_friend = $fs->is_confirmed;
     41                        if ( 0 == $fs->is_confirmed ) {
     42                                $status = $fs->initiator_user_id == bp_loggedin_user_id() ? 'pending' : 'awaiting_response';
     43                        } else {
     44                                $status = 'is_friend';
     45                        }
     46
     47                        $user_query->results[ $friend_id ]->is_friend         = $fs->is_confirmed;
     48                        $user_query->results[ $friend_id ]->friendship_status = $status;
    4249                }
    4350        }
    4451}
  • src/bp-friends/bp-friends-functions.php

     
    195195/**
    196196 * Get the friendship status of two friends.
    197197 *
    198  * Will return 'is_friends', 'not_friends', or 'pending'.
     198 * Will return 'is_friends', 'not_friends', 'pending' or 'awaiting_response'.
    199199 *
    200200 * @param int $user_id ID of the first user.
    201201 * @param int $possible_friend_id ID of the other user.
    202202 * @return string Friend status of the two users.
    203203 */
    204204function friends_check_friendship_status( $user_id, $possible_friend_id ) {
     205        global $members_template;
     206
     207        // check the BP_User_Query first
     208        // @see bp_friends_filter_user_query_populate_extras()
     209        if ( ! empty( $members_template->in_the_loop ) ) {
     210                if ( isset( $members_template->member->friendship_status ) ) {
     211                        return $members_template->member->friendship_status;
     212                } else {
     213                        return 'not_friends';
     214                }
     215        }
     216
    205217        return BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id );
    206218}
    207219