Changeset 10323 for trunk/src/bp-friends/bp-friends-functions.php
- Timestamp:
- 11/02/2015 02:07:44 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-friends/bp-friends-functions.php
r10147 r10323 26 26 * When true, running friends_add_friend() will result in an accepted 27 27 * friendship, with no notifications being sent. Default: false. 28 *29 28 * @return bool True on success, false on failure. 30 29 */ … … 36 35 } 37 36 38 // Check if already friends, and bail if so 37 // Check if already friends, and bail if so. 39 38 if ( friends_check_friendship( $initiator_userid, $friend_userid ) ) { 40 39 return true; 41 40 } 42 41 43 // Setup the friendship data 42 // Setup the friendship data. 44 43 $friendship = new BP_Friends_Friendship; 45 44 $friendship->initiator_user_id = $initiator_userid; … … 53 52 } 54 53 55 // Bail if friendship could not be saved (how sad!) 54 // Bail if friendship could not be saved (how sad!). 56 55 if ( ! $friendship->save() ) { 57 56 return false; 58 57 } 59 58 60 // Send notifications 59 // Send notifications. 61 60 if ( empty( $force_accept ) ) { 62 61 $action = 'requested'; 63 62 64 // Update friend totals 63 // Update friend totals. 65 64 } else { 66 65 $action = 'accepted'; … … 93 92 * @param int $initiator_userid ID of the friendship initiator. 94 93 * @param int $friend_userid ID of the friend user. 95 *96 94 * @return bool True on success, false on failure. 97 95 */ … … 113 111 do_action( 'friends_before_friendship_delete', $friendship_id, $initiator_userid, $friend_userid ); 114 112 115 // Remove the activity stream items about the friendship id 113 // Remove the activity stream items about the friendship id. 116 114 friends_delete_activity( array( 'item_id' => $friendship_id, 'type' => 'friendship_created', 'user_id' => 0 ) ); 117 115 … … 155 153 * 156 154 * @param int $friendship_id ID of the pending friendship object. 157 *158 155 * @return bool True on success, false on failure. 159 156 */ 160 157 function friends_accept_friendship( $friendship_id ) { 161 158 162 // Get the friendship data 159 // Get the friendship data. 163 160 $friendship = new BP_Friends_Friendship( $friendship_id, true, false ); 164 161 165 // Accepting friendship 162 // Accepting friendship. 166 163 if ( empty( $friendship->is_confirmed ) && BP_Friends_Friendship::accept( $friendship_id ) ) { 167 164 168 // Bump the friendship counts 165 // Bump the friendship counts. 169 166 friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id ); 170 167 … … 191 188 * 192 189 * @param int $friendship_id ID of the pending friendship object. 193 *194 190 * @return bool True on success, false on failure. 195 191 */ … … 220 216 * user who requested the friendship, and is doing the withdrawing. 221 217 * @param int $friend_userid ID of the requested friend. 222 *223 218 * @return bool True on success, false on failure. 224 219 */ … … 253 248 * @param int $user_id ID of the first user. 254 249 * @param int $possible_friend_id ID of the other user. 255 *256 250 * @return bool Returns true if the two users are friends, otherwise false. 257 251 */ … … 271 265 * @param int $user_id ID of the first user. 272 266 * @param int $possible_friend_id ID of the other user. 273 *274 267 * @return string Friend status of the two users. 275 268 */ … … 277 270 global $members_template; 278 271 279 // check the BP_User_Query first280 // @see bp_friends_filter_user_query_populate_extras() 272 // Check the BP_User_Query first 273 // @see bp_friends_filter_user_query_populate_extras(). 281 274 if ( ! empty( $members_template->in_the_loop ) ) { 282 275 if ( isset( $members_template->member->friendship_status ) ) { … … 292 285 * 293 286 * @param int $user_id ID of the user whose friends are being counted. 294 *295 287 * @return int Friend count of the user. 296 288 */ … … 317 309 * 318 310 * @param int $user_id ID of the user whose friends are being checked. 319 *320 311 * @return bool True if the user has friends, otherwise false. 321 312 */ … … 337 328 * @param int $initiator_user_id ID of the first user. 338 329 * @param int $friend_user_id ID of the second user. 339 *340 330 * @return int|bool ID of the friendship if found, otherwise false. 341 331 */ … … 353 343 * 'user_id' => $user_id; false to get a one-dimensional 354 344 * array of user IDs. Default: false. 355 *356 345 * @return array 357 346 */ … … 369 358 * @param int $pag_page Optional. The page of results to return. Default: null (no 370 359 * pagination - return all results). 371 *372 360 * @return array|bool On success, an array: { 373 361 * @type array $friends IDs of friends returned by the query. … … 384 372 * 385 373 * @param int $user_id The ID of the user who has received the friendship requests. 386 *387 374 * @return array|bool An array of user IDs, or false if none are found. 388 375 */ … … 403 390 * @param string $filter Optional. Limit results to those matching a search 404 391 * string. 405 *406 392 * @return array See {@link BP_Core_User::get_users()}. 407 393 */ … … 433 419 * @param string $filter Optional. Limit results to those matching a search 434 420 * string. 435 *436 421 * @return array See {@link BP_Core_User::get_users()}. 437 422 */ … … 463 448 * @param string $filter Optional. Limit results to those matching a search 464 449 * string. 465 *466 450 * @return array See {@link BP_Core_User::get_users()}. 467 451 */ … … 488 472 * 489 473 * @param array $friend_ids See BP_Friends_Friendship::get_bulk_last_active(). 490 *491 474 * @return array $user_ids See BP_Friends_Friendship::get_bulk_last_active(). 492 475 */ … … 506 489 * ID of the logged-in user. 507 490 * @param int $group_id Group to check possible invitations against. 508 *509 491 * @return mixed False if no friends, array of users if friends. 510 492 */ 511 493 function friends_get_friends_invite_list( $user_id = 0, $group_id = 0 ) { 512 494 513 // Default to logged in user id 495 // Default to logged in user id. 514 496 if ( empty( $user_id ) ) 515 497 $user_id = bp_loggedin_user_id(); 516 498 517 // Only group admins can invited previously banned users 499 // Only group admins can invited previously banned users. 518 500 $user_is_admin = (bool) groups_is_user_admin( $user_id, $group_id ); 519 501 520 // Assume no friends 502 // Assume no friends. 521 503 $friends = array(); 522 504 … … 534 516 ) ); 535 517 536 // User has friends 518 // User has friends. 537 519 if ( bp_has_members( $args ) ) { 538 520 … … 547 529 while ( bp_members() ) : 548 530 549 // Load the member 531 // Load the member. 550 532 bp_the_member(); 551 533 552 // Get the user ID of the friend 534 // Get the user ID of the friend. 553 535 $friend_user_id = bp_get_member_user_id(); 554 536 555 // Skip friend if already in the group 537 // Skip friend if already in the group. 556 538 if ( groups_is_user_member( $friend_user_id, $group_id ) ) 557 539 continue; 558 540 559 // Skip friend if not group admin and user banned from group 541 // Skip friend if not group admin and user banned from group. 560 542 if ( ( false === $user_is_admin ) && groups_is_user_banned( $friend_user_id, $group_id ) ) 561 543 continue; 562 544 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. 564 546 $friends[] = array( 565 547 'id' => $friend_user_id, … … 570 552 } 571 553 572 // If no friends, explicitly set to false 554 // If no friends, explicitly set to false. 573 555 if ( empty( $friends ) ) 574 556 $friends = false; … … 597 579 * @param int $user_id ID of the user whose friends are being counted. 598 580 * @param int $group_id ID of the group friends are being invited to. 599 *600 581 * @return int $invitable_count Eligible friend count. 601 582 */ … … 609 590 * @param int $user_id Optional. ID of the user whose friendships you are 610 591 * counting. Default: displayed user (if any), otherwise logged-in user. 611 *612 592 * @return int Friend count for the user. 613 593 */ … … 625 605 * @param int $pag_page Number of the page being requested. Default: 0 (no 626 606 * pagination - show all results). 627 *628 607 * @return array Array of BP_Core_User objects corresponding to friends. 629 608 */ … … 646 625 * 647 626 * @param int $friendship_id The ID of the friendship being checked. 648 *649 627 * @return bool True if the friendship is confirmed, otherwise false. 650 628 */ … … 702 680 BP_Friends_Friendship::delete_all_for_user( $user_id ); 703 681 704 // Remove usermeta 682 // Remove usermeta. 705 683 bp_delete_user_meta( $user_id, 'total_friend_count' ); 706 684 … … 740 718 741 719 $friends_query = array( 742 'count_total' => '', // Prevents total count 720 'count_total' => '', // Prevents total count. 743 721 'populate_extras' => false, 744 722
Note: See TracChangeset
for help on using the changeset viewer.