[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-friends/classes/ -> class-bp-friends-friendship.php (summary)

BuddyPress Friends Classes.

File Size: 1102 lines (36 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

BP_Friends_Friendship:: (25 methods):
  __construct()
  populate()
  save()
  delete()
  get_friendships()
  get_friendship_ids_for_user()
  get_friend_user_ids()
  get_friendship_id()
  get_friendship_request_user_ids()
  total_friend_count()
  search_friends()
  check_is_friend()
  update_bp_friends_cache()
  get_bulk_last_active()
  accept()
  withdraw()
  reject()
  search_users()
  search_users_count()
  sort_by_name()
  get_random_friends()
  get_invitable_friend_count()
  get_friendships_by_id()
  get_user_ids_for_friendship()
  delete_all_for_user()


Class: BP_Friends_Friendship  - X-Ref

BuddyPress Friendship object.

__construct( $id = null, $is_request = false, $populate_friend_details = true )   X-Ref
Constructor method.

param: int|null $id                      Optional. The ID of an existing friendship.
param: bool     $is_request              Deprecated.
param: bool     $populate_friend_details Optional. True if friend details should be queried.
since: 1.5.0
since: 10.0.0 Updated to add deprecated notice for `$is_request`.

populate()   X-Ref
Set up data about the current friendship.

since: 1.0.0

save()   X-Ref
Save the current friendship to the database.

return: bool True on success, false on failure.
since: 1.0.0

delete()   X-Ref
Delete the current friendship from the database.

return: bool|int
since: 1.0.0

get_friendships( $user_id, $args = array()   X-Ref
Get the friendships for a given user.

return: array $friendships Array of friendship objects.
param: int    $user_id  ID of the user whose friends are being retrieved.
param: array  $args     {
param: string $operator Optional. Operator to use in `wp_list_filter()`.
since: 2.6.0

get_friendship_ids_for_user( $user_id )   X-Ref
Get all friendship IDs for a user.

return: array
param: int $user_id ID of the user.
since: 2.7.0

get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false )   X-Ref
Get the IDs of a given user's friends.

return: array $fids IDs of friends for provided user.
param: int  $user_id              ID of the user whose friends are being retrieved.
param: bool $friend_requests_only Optional. Whether to fetch
param: bool $assoc_arr            Optional. True to receive an array of arrays
since: 1.0.0

get_friendship_id( $user_id, $friend_id )   X-Ref
Get the ID of the friendship object, if any, between a pair of users.

return: int|null The ID of the friendship object if found, otherwise null.
param: int $user_id   The ID of the first user.
param: int $friend_id The ID of the second user.
since: 1.0.0

get_friendship_request_user_ids( $user_id )   X-Ref
Get a list of IDs of users who have requested friendship of a given user.

return: array|bool An array of user IDs or false if none are found.
param: int $user_id The ID of the user who has received the
since: 1.2.0

total_friend_count( $user_id = 0 )   X-Ref
Get a total friend count for a given user.

return: int Friend count for the user.
param: int $user_id Optional. ID of the user whose friendships you
since: 1.0.0

search_friends( $filter, $user_id, $limit = null, $page = null )   X-Ref
Search the friends of a user by a search string.

return: array|bool On success, an array: {
param: string   $filter  The search string, matched against xprofile
param: int      $user_id ID of the user whose friends are being searched.
param: int|null $limit   Optional. Max number of friends to return.
param: int|null $page    Optional. The page of results to return. Default:
since: 1.0.0

check_is_friend( $initiator_userid, $possible_friend_userid )   X-Ref
Check friendship status between two users.

Note that 'pending' means that $initiator_userid has sent a friend
request to $possible_friend_userid that has not yet been approved,
while 'awaiting_response' is the other way around ($possible_friend_userid
sent the initial request).

return: string|false $value The friendship status, from among 'not_friends',
param: int $initiator_userid       The ID of the user who is the initiator
param: int $possible_friend_userid The ID of the user who is the
since: 1.0.0

update_bp_friends_cache( $user_id, $possible_friend_ids )   X-Ref
Find uncached friendships between a user and one or more other users and cache them.

param: int              $user_id             The ID of the primary user for whom we want
param: int|array|string $possible_friend_ids The IDs of the one or more users
since: 3.0.0

get_bulk_last_active( $user_ids )   X-Ref
Get the last active date of many users at once.

return: array $retval Array of last_active values + user_ids.
param: array $user_ids IDs of users whose last_active meta is
since: 1.0.0

accept( $friendship_id )   X-Ref
Mark a friendship as accepted.

return: int Number of database rows updated.
param: int $friendship_id ID of the friendship to be accepted.
since: 1.0.0

withdraw( $friendship_id )   X-Ref
Remove a friendship or a friendship request INITIATED BY the logged-in user.

return: int Number of database rows deleted.
param: int $friendship_id ID of the friendship to be withdrawn.
since: 1.6.0

reject( $friendship_id )   X-Ref
Remove a friendship or a friendship request MADE OF the logged-in user.

return: int Number of database rows deleted.
param: int $friendship_id ID of the friendship to be rejected.
since: 1.0.0

search_users( $filter, $user_id, $limit = null, $page = null )   X-Ref
Search users.

return: array $filtered_ids IDs of users who match the query.
param: string   $filter  String to search by.
param: int      $user_id A user ID param that is unused.
param: int|null $limit   Optional. Max number of records to return.
param: int|null $page    Optional. Number of the page to return. Default:
since: 1.0.0

search_users_count( $filter )   X-Ref
Get a count of users who match a search term.

return: int Count of users matching the search term.
param: string $filter Search term.
since: 1.0.0

sort_by_name( $user_ids )   X-Ref
Sort a list of user IDs by their display names.

return: array|bool User IDs, sorted by the associated display names.
param: array $user_ids Array of user IDs.
since: 1.0.0

get_random_friends( $user_id, $total_friends = 5 )   X-Ref
Get a list of random friend IDs.

return: array|false An array of random friend user IDs on success;
param: int $user_id       ID of the user whose friends are being retrieved.
param: int $total_friends Optional. Number of random friends to get.
since: 1.0.0

get_invitable_friend_count( $user_id, $group_id )   X-Ref
Get a count of a user's friends who can be invited to a given group.

Users can invite any of their friends except:

- users who are already in the group
- users who have a pending invite to the group
- users who have been banned from the group

return: bool|int False if group component is not active, and friend count.
param: int $user_id  ID of the user whose friends are being counted.
param: int $group_id ID of the group friends are being invited to.
since: 1.0.0

get_friendships_by_id( $friendship_ids )   X-Ref
Get friendship objects by ID (or an array of IDs).

return: array
param: int|string|array $friendship_ids Single friendship ID or comma-separated/array list of friendship IDs.
since: 2.7.0

get_user_ids_for_friendship( $friendship_id )   X-Ref
Get the friend user IDs for a given friendship.

return: null|stdClass
param: int $friendship_id ID of the friendship.
since: 1.0.0

delete_all_for_user( $user_id )   X-Ref
Delete all friendships and friend notifications related to a user.

param: int $user_id ID of the user being expunged.
since: 1.0.0



Generated: Thu Nov 21 01:00:57 2024 Cross-referenced by PHPXref 0.7.1