/** * Execute the Friends.areFriends method * * @return An array of values as xml. There is one element in the outer array * named 'friend_info'. This element is an array made up of 3 sub-elements which are defined as * 'uid1', 'uid2', 'are_friends'. 'uid1' is user id 1, 'uid2' is user id 2, and 'are_friends' is * either a 0 or 1. * * For example if the uids in the get request look like * http://www.acme.com/foo?uid1=1,1,1&uid2=2,3,4 and assuming 1 and 2 are friends and 1 and 3 are friends * and 1 and 4 are not friends then the return value would be * array( * 'friend_info' => array( * array( 'uid1'=>1, 'uid2'=>2, 'are_friends'=>1 ), * array( 'uid1'=>1, 'uid2'=>3, 'are_friends'=>1 ), * array( 'uid1'=>1, 'uid2'=>4, 'are_friends'=>0 ) * ) * ) */ public function execute() { return Api_Bo_Friends::getFriendsAreFriends($this->uid1, $this->uid2); }
/** * Checks to see if two users are friends, if they are returns true, otherwise false * * @param int $loggedInUserId * @param int $uid * @return boolean */ public static function checkFriends($loggedInUserId, $uid) { // Indeed, you are friends with yourself if ($uid == $loggedInUserId) { return true; } if ($uid != null) { $faf = Api_Bo_Friends::getFriendsAreFriends($loggedInUserId, $uid); if ($faf['friend_info'][0]['are_friends'] == 1) { return true; } } return false; }