/** * Web service to obtains the people who have made a given user a friend * * @param string $username Username * @param int|string $limit Number of users to return * @param int|string $offset Indexing offset, if any * @return array * @throws InvalidParameterException */ function user_get_friends_of($username, $limit = 10, $offset = 0) { if (!$username) { $user = elgg_get_logged_in_user_entity(); } else { $user = get_user_by_username($username); } if (!$user) { throw new InvalidParameterException(elgg_echo('registration:usernamenotvalid')); } $friends = get_user_friends_of($user->guid, '', $limit, $offset); $success = false; foreach ($friends as $friend) { $return['guid'] = $friend->guid; $return['username'] = $friend->username; $return['name'] = $friend->name; $return['avatar_url'] = getProfileIcon($friend); //$friend->getIconURL('small'); $success = true; } if (!$success) { $return['error']['message'] = elgg_echo('friends:none'); } return $return; }
/** * Retrieves a list of people who have made this user a friend * * @param string $subtype Optionally, the subtype of user to filter to (leave blank for all) * @param int $limit The number of users to retrieve * @param int $offset Indexing offset, if any * @return array|false Array of ElggUsers, or false, depending on success */ function getFriendsOf($subtype = "", $limit = 10, $offset = 0) { return get_user_friends_of($this->getGUID(), $subtype, $limit, $offset); }
/** * Web service to obtains the people who have made a given user a friend * * @param string $username Username * @param string $limit Number of users to return * @param string $offset Indexing offset, if any * * @return array */ function user_get_friends_of($username, $limit = 10, $offset = 0) { $user = get_user_by_username($username); if (!$user) { throw new InvalidParameterException(elgg_echo('registration:usernamenotvalid')); } $friends = get_user_friends_of($user->guid, '', $limit, $offset); $success = false; foreach ($friends as $friend) { $return[$friend->guid]['username'] = $friend->username; $return[$friend->guid]['name'] = $friend->name; $success = true; } if (!$success) { $return['error']['message'] = elgg_echo('friends:none'); } return $return; }