Changeset 9995 for trunk/src/bp-friends/bp-friends-functions.php
- Timestamp:
- 07/04/2015 10:23:19 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-friends/bp-friends-functions.php
r9819 r9995 2 2 3 3 /** 4 * BuddyPress Friends Functions 4 * BuddyPress Friends Functions. 5 5 * 6 6 * Functions are where all the magic happens in BuddyPress. They will … … 19 19 * Create a new friendship. 20 20 * 21 * @param int $initiator_userid ID of the "initiator" user (the user who is 22 * sending the friendship request). 23 * @param int $friend_userid ID of the "friend" user (the user whose friendship 24 * is being requested). 25 * @param bool $force_accept Optional. Whether to force acceptance. When false, 26 * running friends_add_friend() will result in a friendship request. 27 * When true, running friends_add_friend() will result in an accepted 28 * friendship, with no notifications being sent. Default: false. 21 * @param int $initiator_userid ID of the "initiator" user (the user who is 22 * sending the friendship request). 23 * @param int $friend_userid ID of the "friend" user (the user whose friendship 24 * is being requested). 25 * @param bool $force_accept Optional. Whether to force acceptance. When false, 26 * running friends_add_friend() will result in a friendship request. 27 * When true, running friends_add_friend() will result in an accepted 28 * friendship, with no notifications being sent. Default: false. 29 * 29 30 * @return bool True on success, false on failure. 30 31 */ … … 76 77 * @since BuddyPress (1.0.0) 77 78 * 78 * @param int $id ID of the pending friendship connection.79 * @param int $id ID of the pending friendship connection. 79 80 * @param int $initiator_user_id ID of the friendship initiator. 80 * @param int $friend_user_id ID of the friend user.81 * @param object $friendship BuddyPress Friendship Object.81 * @param int $friend_user_id ID of the friend user. 82 * @param object $friendship BuddyPress Friendship Object. 82 83 */ 83 84 do_action( 'friends_friendship_' . $action, $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id, $friendship ); … … 92 93 * 93 94 * @param int $initiator_userid ID of the friendship initiator. 94 * @param int $friend_userid ID of the friend user. 95 * @param int $friend_userid ID of the friend user. 96 * 95 97 * @return bool True on success, false on failure. 96 98 */ … … 106 108 * @since BuddyPress (1.5.0) 107 109 * 108 * @param int $friendship_id ID of the friendship object, if any, between a pair of users.110 * @param int $friendship_id ID of the friendship object, if any, between a pair of users. 109 111 * @param int $initiator_userid ID of the friendship initiator. 110 * @param int $friend_userid ID of the friend user.112 * @param int $friend_userid ID of the friend user. 111 113 */ 112 114 do_action( 'friends_before_friendship_delete', $friendship_id, $initiator_userid, $friend_userid ); … … 123 125 * @since BuddyPress (1.0.0) 124 126 * 125 * @param int $friendship_id ID of the friendship object, if any, between a pair of users.127 * @param int $friendship_id ID of the friendship object, if any, between a pair of users. 126 128 * @param int $initiator_userid ID of the friendship initiator. 127 * @param int $friend_userid ID of the friend user.129 * @param int $friend_userid ID of the friend user. 128 130 */ 129 131 do_action( 'friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid ); … … 138 140 * 139 141 * @param int $initiator_userid ID of the friendship initiator. 140 * @param int $friend_userid ID of the friend user.142 * @param int $friend_userid ID of the friend user. 141 143 */ 142 144 do_action( 'friends_friendship_post_delete', $initiator_userid, $friend_userid ); … … 154 156 * 155 157 * @param int $friendship_id ID of the pending friendship object. 158 * 156 159 * @return bool True on success, false on failure. 157 160 */ … … 172 175 * @since BuddyPress (1.0.0) 173 176 * 174 * @param int $id ID of the pending friendship object.177 * @param int $id ID of the pending friendship object. 175 178 * @param int $initiator_user_id ID of the friendship initiator. 176 * @param int $friend_user_id ID of the user requested friendship with.177 * @param object $friendship BuddyPress Friendship Object.179 * @param int $friend_user_id ID of the user requested friendship with. 180 * @param object $friendship BuddyPress Friendship Object. 178 181 */ 179 182 do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id, $friendship ); … … 189 192 * 190 193 * @param int $friendship_id ID of the pending friendship object. 194 * 191 195 * @return bool True on success, false on failure. 192 196 */ … … 215 219 * 216 220 * @param int $initiator_userid ID of the friendship initiator - this is the 217 * user who requested the friendship, and is doing the withdrawing. 218 * @param int $friend_userid ID of the requested friend. 221 * user who requested the friendship, and is doing the withdrawing. 222 * @param int $friend_userid ID of the requested friend. 223 * 219 224 * @return bool True on success, false on failure. 220 225 */ … … 234 239 * 235 240 * @param int $friendship_id ID of the friendship. 236 * @param BP_Friends_Friendship $friendship Friendship object. Passed by reference.241 * @param BP_Friends_Friendship $friendship Friendship object. Passed by reference. 237 242 */ 238 243 do_action_ref_array( 'friends_friendship_withdrawn', array( $friendship_id, &$friendship ) ); … … 247 252 * Check whether two users are friends. 248 253 * 249 * @param int $user_id ID of the first user.254 * @param int $user_id ID of the first user. 250 255 * @param int $possible_friend_id ID of the other user. 256 * 251 257 * @return bool Returns true if the two users are friends, otherwise false. 252 258 */ … … 264 270 * Will return 'is_friends', 'not_friends', 'pending' or 'awaiting_response'. 265 271 * 266 * @param int $user_id ID of the first user.272 * @param int $user_id ID of the first user. 267 273 * @param int $possible_friend_id ID of the other user. 274 * 268 275 * @return string Friend status of the two users. 269 276 */ … … 291 298 * 292 299 * @param int $user_id ID of the user whose friends are being counted. 300 * 293 301 * @return int Friend count of the user. 294 302 */ … … 315 323 * 316 324 * @param int $user_id ID of the user whose friends are being checked. 325 * 317 326 * @return bool True if the user has friends, otherwise false. 318 327 */ … … 333 342 * 334 343 * @param int $initiator_user_id ID of the first user. 335 * @param int $friend_user_id ID of the second user. 344 * @param int $friend_user_id ID of the second user. 345 * 336 346 * @return int|bool ID of the friendship if found, otherwise false. 337 347 */ … … 343 353 * Get the IDs of a given user's friends. 344 354 * 345 * @param int $user_idID of the user whose friends are being retrieved.355 * @param int $user_id ID of the user whose friends are being retrieved. 346 356 * @param bool $friend_requests_only Optional. Whether to fetch unaccepted 347 * requests only. Default: false. 348 * @param bool $assoc_arr Optional. True to receive an array of arrays keyed as 349 * 'user_id' => $user_id; false to get a one-dimensional array of user 350 * IDs. Default: false. 357 * requests only. Default: false. 358 * @param bool $assoc_arr Optional. True to receive an array of arrays keyed as 359 * 'user_id' => $user_id; false to get a one-dimensional 360 * array of user IDs. Default: false. 361 * 362 * @return array 351 363 */ 352 364 function friends_get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false ) { … … 357 369 * Search the friends of a user by a search string. 358 370 * 359 * @param string $filter The search string, matched against xprofile fields (if 360 * available), or usermeta 'nickname' field. 361 * @param int $user_id ID of the user whose friends are being searched. 362 * @param int $limit Optional. Max number of friends to return. 363 * @param int $page Optional. The page of results to return. Default: null (no 364 * pagination - return all results). 371 * @param string $search_terms The search string, matched against xprofile fields (if 372 * available), or usermeta 'nickname' field. 373 * @param int $user_id ID of the user whose friends are being searched. 374 * @param int $pag_num Optional. Max number of friends to return. 375 * @param int $pag_page Optional. The page of results to return. Default: null (no 376 * pagination - return all results). 377 * 365 378 * @return array|bool On success, an array: { 366 379 * @type array $friends IDs of friends returned by the query. 367 * @type int $countTotal number of friends (disregarding368 * pagination) who match the search.380 * @type int $count Total number of friends (disregarding 381 * pagination) who match the search. 369 382 * }. Returns false on failure. 370 383 */ … … 376 389 * Get a list of IDs of users who have requested friendship of a given user. 377 390 * 378 * @param int $user_id The ID of the user who has received the friendship 379 * requests.391 * @param int $user_id The ID of the user who has received the friendship requests. 392 * 380 393 * @return array|bool An array of user IDs, or false if none are found. 381 394 */ … … 389 402 * @see BP_Core_User::get_users() for a description of return value. 390 403 * 391 * @param int $user_id ID of the user whose friends are being retrieved. 392 * @param int $per_page Optional. Number of results to return per page. 393 * Default: 0 (no pagination; show all results). 394 * @param int $page Optional. Number of the page of results to return. 395 * Default: 0 (no pagination; show all results). 396 * @param string $filter Optional. Limit results to those matching a search 397 * string. 404 * @param int $user_id ID of the user whose friends are being retrieved. 405 * @param int $per_page Optional. Number of results to return per page. 406 * Default: 0 (no pagination; show all results). 407 * @param int $page Optional. Number of the page of results to return. 408 * Default: 0 (no pagination; show all results). 409 * @param string $filter Optional. Limit results to those matching a search 410 * string. 411 * 398 412 * @return array See {@link BP_Core_User::get_users()}. 399 413 */ … … 418 432 * @see BP_Core_User::get_users() for a description of return value. 419 433 * 420 * @param int $user_id ID of the user whose friends are being retrieved. 421 * @param int $per_page Optional. Number of results to return per page. 422 * Default: 0 (no pagination; show all results). 423 * @param int $page Optional. Number of the page of results to return. 424 * Default: 0 (no pagination; show all results). 425 * @param string $filter Optional. Limit results to those matching a search 426 * string. 434 * @param int $user_id ID of the user whose friends are being retrieved. 435 * @param int $per_page Optional. Number of results to return per page. 436 * Default: 0 (no pagination; show all results). 437 * @param int $page Optional. Number of the page of results to return. 438 * Default: 0 (no pagination; show all results). 439 * @param string $filter Optional. Limit results to those matching a search 440 * string. 441 * 427 442 * @return array See {@link BP_Core_User::get_users()}. 428 443 */ … … 447 462 * @see BP_Core_User::get_users() for a description of return value. 448 463 * 449 * @param int $user_id ID of the user whose friends are being retrieved. 450 * @param int $per_page Optional. Number of results to return per page. 451 * Default: 0 (no pagination; show all results). 452 * @param int $page Optional. Number of the page of results to return. 453 * Default: 0 (no pagination; show all results). 454 * @param string $filter Optional. Limit results to those matching a search 455 * string. 464 * @param int $user_id ID of the user whose friends are being retrieved. 465 * @param int $per_page Optional. Number of results to return per page. 466 * Default: 0 (no pagination; show all results). 467 * @param int $page Optional. Number of the page of results to return. 468 * Default: 0 (no pagination; show all results). 469 * @param string $filter Optional. Limit results to those matching a search 470 * string. 471 * 456 472 * @return array See {@link BP_Core_User::get_users()}. 457 473 */ … … 477 493 * arguments and return value. 478 494 * 479 * @param array $user_ids See BP_Friends_Friendship::get_bulk_last_active(). 495 * @param array $friend_ids See BP_Friends_Friendship::get_bulk_last_active(). 496 * 480 497 * @return array $user_ids See BP_Friends_Friendship::get_bulk_last_active(). 481 498 */ … … 492 509 * @since BuddyPress (1.0.0) 493 510 * 494 * @param int $user_id User ID whose friends to see can be invited. Default:495 * ID of the logged-in user.511 * @param int $user_id User ID whose friends to see can be invited. Default: 512 * ID of the logged-in user. 496 513 * @param int $group_id Group to check possible invitations against. 514 * 497 515 * @return mixed False if no friends, array of users if friends. 498 516 */ … … 567 585 * @since BuddyPress (1.5.4) 568 586 * 569 * @param array|bool $friends Array friends available to invite or false for no friends.570 * @param int $user_id ID of the user checked for who they can invite.587 * @param array|bool $friends Array friends available to invite or false for no friends. 588 * @param int $user_id ID of the user checked for who they can invite. 571 589 * @param int $group_id ID of the group being checked on. 572 590 */ … … 583 601 * - users who have been banned from the group 584 602 * 585 * @param int $user_id ID of the user whose friends are being counted.603 * @param int $user_id ID of the user whose friends are being counted. 586 604 * @param int $group_id ID of the group friends are being invited to. 605 * 587 606 * @return int $invitable_count Eligible friend count. 588 607 */ … … 595 614 * 596 615 * @param int $user_id Optional. ID of the user whose friendships you are 597 * counting. Default: displayed user (if any), otherwise logged-in user. 616 * counting. Default: displayed user (if any), otherwise logged-in user. 617 * 598 618 * @return int Friend count for the user. 599 619 */ … … 606 626 * 607 627 * @param string $search_terms Search term to filter on. 608 * @param int $user_id ID of the user whose friends are being searched. 609 * @param int $pag_num Number of results to return per page. Default: 0 (no 610 * pagination - show all results). 611 * @param int $pag_num Number of the page being requested. Default: 0 (no 612 * pagination - show all results). 628 * @param int $user_id ID of the user whose friends are being searched. 629 * @param int $pag_num Number of results to return per page. Default: 0 (no 630 * pagination - show all results). 631 * @param int $pag_page Number of the page being requested. Default: 0 (no 632 * pagination - show all results). 633 * 613 634 * @return array Array of BP_Core_User objects corresponding to friends. 614 635 */ … … 631 652 * 632 653 * @param int $friendship_id The ID of the friendship being checked. 654 * 633 655 * @return bool True if the friendship is confirmed, otherwise false. 634 656 */ … … 645 667 * the cached values. 646 668 * 647 * @param int $initiator_user_id ID of the first user.648 * @param int $friend_user_idID of the second user.649 * @param string $status Optional. The friendship event that's been triggered.650 * 'add' will ++ each user's friend counts, while any other string651 * will --.669 * @param int $initiator_user_id ID of the first user. 670 * @param int $friend_user_id ID of the second user. 671 * @param string $status Optional. The friendship event that's been triggered. 672 * 'add' will ++ each user's friend counts, while any other string 673 * will --. 652 674 */ 653 675 function friends_update_friend_totals( $initiator_user_id, $friend_user_id, $status = 'add' ) { … … 667 689 * Removes the following: 668 690 * 669 * - Friendships of which the user is a member 670 * - Cached friend count for the user 671 * - Notifications of friendship requests sent by the user 691 * - Friendships of which the user is a member. 692 * - Cached friend count for the user. 693 * - Notifications of friendship requests sent by the user. 672 694 * 673 695 * @param int $user_id ID of the user whose friend data is being removed.
Note: See TracChangeset
for help on using the changeset viewer.