From 302e5136f804aaa7d6bebb133767bfcbda249564 Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 23 Dec 2010 22:25:32 +0000 Subject: Added list groups and list friends class methods - will be handy for federation git-svn-id: http://code.elgg.org/elgg/trunk@7715 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/classes/ElggUser.php | 56 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) (limited to 'engine') diff --git a/engine/classes/ElggUser.php b/engine/classes/ElggUser.php index 0e7323e82..eca011a36 100644 --- a/engine/classes/ElggUser.php +++ b/engine/classes/ElggUser.php @@ -334,7 +334,7 @@ class ElggUser extends ElggEntity /** * Gets this user's friends * - * @param string $subtype Optionally, the subtype of user to filter to (leave blank for all) + * @param string $subtype Optionally, the user subtype (leave blank for all) * @param int $limit The number of users to retrieve * @param int $offset Indexing offset, if any * @@ -347,7 +347,7 @@ class ElggUser extends ElggEntity /** * Gets users who have made this user a friend * - * @param string $subtype Optionally, the subtype of user to filter to (leave blank for all) + * @param string $subtype Optionally, the user subtype (leave blank for all) * @param int $limit The number of users to retrieve * @param int $offset Indexing offset, if any * @@ -357,6 +357,32 @@ class ElggUser extends ElggEntity return get_user_friends_of($this->getGUID(), $subtype, $limit, $offset); } + /** + * Lists the user's friends + * + * @param string $subtype Optionally, the user subtype (leave blank for all) + * @param int $limit The number of users to retrieve + * @param int $offset Indexing offset, if any + * + * @return string + */ + function listFriends($subtype = "", $limit = 10, $offset = 0) { + $options = array( + 'type' => 'user', + 'relationship' => 'friend', + 'relationship_guid' => $this->guid, + 'limit' => $limit, + 'offset' => $offset, + 'full_view' => false, + ); + + if ($subtype) { + $options['subtype'] = $subtype; + } + + return elgg_list_entities_from_relationship($options); + } + /** * Gets the user's groups * @@ -382,6 +408,32 @@ class ElggUser extends ElggEntity return elgg_get_entities_from_relationship($options); } + /** + * Lists the user's groups + * + * @param string $subtype Optionally, the user subtype (leave blank for all) + * @param int $limit The number of users to retrieve + * @param int $offset Indexing offset, if any + * + * @return string + */ + function listGroups($subtype = "", $limit = 10, $offset = 0) { + $options = array( + 'type' => 'group', + 'relationship' => 'member', + 'relationship_guid' => $this->guid, + 'limit' => $limit, + 'offset' => $offset, + 'full_view' => false, + ); + + if ($subtype) { + $options['subtype'] = $subtype; + } + + return elgg_list_entities_from_relationship($options); + } + /** * Get an array of ElggObject owned by this user. * -- cgit v1.2.3