Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/02/2015 02:07:44 AM (11 years ago)
Author:
tw2113
Message:

More docs cleanup for Friends component.

See #6400.

File:
1 edited

Legend:

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

    r10147 r10323  
    2626 *                               When true, running friends_add_friend() will result in an accepted
    2727 *                               friendship, with no notifications being sent. Default: false.
    28  *
    2928 * @return bool True on success, false on failure.
    3029 */
    … …  
    3635        }
    3736
    38         // Check if already friends, and bail if so
     37        // Check if already friends, and bail if so.
    3938        if ( friends_check_friendship( $initiator_userid, $friend_userid ) ) {
    4039                return true;
    4140        }
    4241
    43         // Setup the friendship data
     42        // Setup the friendship data.
    4443        $friendship = new BP_Friends_Friendship;
    4544        $friendship->initiator_user_id = $initiator_userid;
    … …  
    5352        }
    5453
    55         // Bail if friendship could not be saved (how sad!)
     54        // Bail if friendship could not be saved (how sad!).
    5655        if ( ! $friendship->save() ) {
    5756                return false;
    5857        }
    5958
    60         // Send notifications
     59        // Send notifications.
    6160        if ( empty( $force_accept ) ) {
    6261                $action = 'requested';
    6362
    64         // Update friend totals
     63        // Update friend totals.
    6564        } else {
    6665                $action = 'accepted';
    … …  
    9392 * @param int $initiator_userid ID of the friendship initiator.
    9493 * @param int $friend_userid    ID of the friend user.
    95  *
    9694 * @return bool True on success, false on failure.
    9795 */
    … …  
    113111        do_action( 'friends_before_friendship_delete', $friendship_id, $initiator_userid, $friend_userid );
    114112
    115         // Remove the activity stream items about the friendship id
     113        // Remove the activity stream items about the friendship id.
    116114        friends_delete_activity( array( 'item_id' => $friendship_id, 'type' => 'friendship_created', 'user_id' => 0 ) );
    117115
    … …  
    155153 *
    156154 * @param int $friendship_id ID of the pending friendship object.
    157  *
    158155 * @return bool True on success, false on failure.
    159156 */
    160157function friends_accept_friendship( $friendship_id ) {
    161158
    162         // Get the friendship data
     159        // Get the friendship data.
    163160        $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
    164161
    165         // Accepting friendship
     162        // Accepting friendship.
    166163        if ( empty( $friendship->is_confirmed ) && BP_Friends_Friendship::accept( $friendship_id ) ) {
    167164
    168                 // Bump the friendship counts
     165                // Bump the friendship counts.
    169166                friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id );
    170167
    … …  
    191188 *
    192189 * @param int $friendship_id ID of the pending friendship object.
    193  *
    194190 * @return bool True on success, false on failure.
    195191 */
    … …  
    220216 *                              user who requested the friendship, and is doing the withdrawing.
    221217 * @param int $friend_userid    ID of the requested friend.
    222  *
    223218 * @return bool True on success, false on failure.
    224219 */
    … …  
    253248 * @param int $user_id            ID of the first user.
    254249 * @param int $possible_friend_id ID of the other user.
    255  *
    256250 * @return bool Returns true if the two users are friends, otherwise false.
    257251 */
    … …  
    271265 * @param int $user_id            ID of the first user.
    272266 * @param int $possible_friend_id ID of the other user.
    273  *
    274267 * @return string Friend status of the two users.
    275268 */
    … …  
    277270        global $members_template;
    278271
    279         // check the BP_User_Query first
    280         // @see bp_friends_filter_user_query_populate_extras()
     272        // Check the BP_User_Query first
     273        // @see bp_friends_filter_user_query_populate_extras().
    281274        if ( ! empty( $members_template->in_the_loop ) ) {
    282275                if ( isset( $members_template->member->friendship_status ) ) {
    … …  
    292285 *
    293286 * @param int $user_id ID of the user whose friends are being counted.
    294  *
    295287 * @return int Friend count of the user.
    296288 */
    … …  
    317309 *
    318310 * @param int $user_id ID of the user whose friends are being checked.
    319  *
    320311 * @return bool True if the user has friends, otherwise false.
    321312 */
    … …  
    337328 * @param int $initiator_user_id ID of the first user.
    338329 * @param int $friend_user_id    ID of the second user.
    339  *
    340330 * @return int|bool ID of the friendship if found, otherwise false.
    341331 */
    … …  
    353343 *                                   'user_id' => $user_id; false to get a one-dimensional
    354344 *                                   array of user IDs. Default: false.
    355  *
    356345 * @return array
    357346 */
    … …  
    369358 * @param int    $pag_page     Optional. The page of results to return. Default: null (no
    370359 *                             pagination - return all results).
    371  *
    372360 * @return array|bool On success, an array: {
    373361 *     @type array $friends IDs of friends returned by the query.
    … …  
    384372 *
    385373 * @param int $user_id The ID of the user who has received the friendship requests.
    386  *
    387374 * @return array|bool An array of user IDs, or false if none are found.
    388375 */
    … …  
    403390 * @param string $filter   Optional. Limit results to those matching a search
    404391 *                         string.
    405  *
    406392 * @return array See {@link BP_Core_User::get_users()}.
    407393 */
    … …  
    433419 * @param string $filter   Optional. Limit results to those matching a search
    434420 *                         string.
    435  *
    436421 * @return array See {@link BP_Core_User::get_users()}.
    437422 */
    … …  
    463448 * @param string $filter   Optional. Limit results to those matching a search
    464449 *                         string.
    465  *
    466450 * @return array See {@link BP_Core_User::get_users()}.
    467451 */
    … …  
    488472 *
    489473 * @param array $friend_ids See BP_Friends_Friendship::get_bulk_last_active().
    490  *
    491474 * @return array $user_ids See BP_Friends_Friendship::get_bulk_last_active().
    492475 */
    … …  
    506489 *                      ID of the logged-in user.
    507490 * @param int $group_id Group to check possible invitations against.
    508  *
    509491 * @return mixed False if no friends, array of users if friends.
    510492 */
    511493function friends_get_friends_invite_list( $user_id = 0, $group_id = 0 ) {
    512494
    513         // Default to logged in user id
     495        // Default to logged in user id.
    514496        if ( empty( $user_id ) )
    515497                $user_id = bp_loggedin_user_id();
    516498
    517         // Only group admins can invited previously banned users
     499        // Only group admins can invited previously banned users.
    518500        $user_is_admin = (bool) groups_is_user_admin( $user_id, $group_id );
    519501
    520         // Assume no friends
     502        // Assume no friends.
    521503        $friends = array();
    522504
    … …  
    534516        ) );
    535517
    536         // User has friends
     518        // User has friends.
    537519        if ( bp_has_members( $args ) ) {
    538520
    … …  
    547529                while ( bp_members() ) :
    548530
    549                         // Load the member
     531                        // Load the member.
    550532                        bp_the_member();
    551533
    552                         // Get the user ID of the friend
     534                        // Get the user ID of the friend.
    553535                        $friend_user_id = bp_get_member_user_id();
    554536
    555                         // Skip friend if already in the group
     537                        // Skip friend if already in the group.
    556538                        if ( groups_is_user_member( $friend_user_id, $group_id ) )
    557539                                continue;
    558540
    559                         // Skip friend if not group admin and user banned from group
     541                        // Skip friend if not group admin and user banned from group.
    560542                        if ( ( false === $user_is_admin ) && groups_is_user_banned( $friend_user_id, $group_id ) )
    561543                                continue;
    562544
    563                         // Friend is safe, so add it to the array of possible friends
     545                        // Friend is safe, so add it to the array of possible friends.
    564546                        $friends[] = array(
    565547                                'id'        => $friend_user_id,
    … …  
    570552        }
    571553
    572         // If no friends, explicitly set to false
     554        // If no friends, explicitly set to false.
    573555        if ( empty( $friends ) )
    574556                $friends = false;
    … …  
    597579 * @param int $user_id  ID of the user whose friends are being counted.
    598580 * @param int $group_id ID of the group friends are being invited to.
    599  *
    600581 * @return int $invitable_count Eligible friend count.
    601582 */
    … …  
    609590 * @param int $user_id Optional. ID of the user whose friendships you are
    610591 *                     counting. Default: displayed user (if any), otherwise logged-in user.
    611  *
    612592 * @return int Friend count for the user.
    613593 */
    … …  
    625605 * @param int    $pag_page     Number of the page being requested. Default: 0 (no
    626606 *                             pagination - show all results).
    627  *
    628607 * @return array Array of BP_Core_User objects corresponding to friends.
    629608 */
    … …  
    646625 *
    647626 * @param int $friendship_id The ID of the friendship being checked.
    648  *
    649627 * @return bool True if the friendship is confirmed, otherwise false.
    650628 */
    … …  
    702680        BP_Friends_Friendship::delete_all_for_user( $user_id );
    703681
    704         // Remove usermeta
     682        // Remove usermeta.
    705683        bp_delete_user_meta( $user_id, 'total_friend_count' );
    706684
    … …  
    740718
    741719        $friends_query = array(
    742                 'count_total'     => '',                    // Prevents total count
     720                'count_total'     => '',                    // Prevents total count.
    743721                'populate_extras' => false,
    744722
Note: See TracChangeset for help on using the changeset viewer.