aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/ElggUser.php
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-23 22:09:46 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-23 22:09:46 +0000
commit3851aab30105f1b35eb344b30181b3427046db80 (patch)
tree6fbf9c44f0c8fbf2a4c2fb987d2935835b9d2bf7 /engine/classes/ElggUser.php
parent42ce080c2569a98d38dd431c5a2d83970a61834d (diff)
downloadelgg-3851aab30105f1b35eb344b30181b3427046db80.tar.gz
elgg-3851aab30105f1b35eb344b30181b3427046db80.tar.bz2
added a class math to get a user's groups and cleaned up some documentation
git-svn-id: http://code.elgg.org/elgg/trunk@7714 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/classes/ElggUser.php')
-rw-r--r--engine/classes/ElggUser.php45
1 files changed, 35 insertions, 10 deletions
diff --git a/engine/classes/ElggUser.php b/engine/classes/ElggUser.php
index 071806529..0e7323e82 100644
--- a/engine/classes/ElggUser.php
+++ b/engine/classes/ElggUser.php
@@ -279,7 +279,7 @@ class ElggUser extends ElggEntity
}
/**
- * Adds a user to this user's friends list
+ * Adds a user as a friend
*
* @param int $friend_guid The GUID of the user to add
*
@@ -290,7 +290,7 @@ class ElggUser extends ElggEntity
}
/**
- * Removes a user from this user's friends list
+ * Removes a user as a friend
*
* @param int $friend_guid The GUID of the user to remove
*
@@ -306,13 +306,13 @@ class ElggUser extends ElggEntity
* @return true|false
*/
function isFriend() {
- return user_is_friend(get_loggedin_userid(), $this->getGUID());
+ return $this->isFriendsWith(get_loggedin_userid());
}
/**
* Determines whether this user is friends with another user
*
- * @param int $user_guid The GUID of the user to check is on this user's friends list
+ * @param int $user_guid The GUID of the user to check against
*
* @return true|false
*/
@@ -321,7 +321,7 @@ class ElggUser extends ElggEntity
}
/**
- * Determines whether or not this user is on another user's friends list
+ * Determines whether or not this user is another user's friend
*
* @param int $user_guid The GUID of the user to check against
*
@@ -332,33 +332,58 @@ class ElggUser extends ElggEntity
}
/**
- * Retrieves a list of this user's friends
+ * Gets this user's friends
*
* @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
+ * @return array|false Array of ElggUser, or false, depending on success
*/
function getFriends($subtype = "", $limit = 10, $offset = 0) {
return get_user_friends($this->getGUID(), $subtype, $limit, $offset);
}
/**
- * Retrieves a list of people who have made this user a friend
+ * 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 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
+ * @return array|false Array of ElggUser, or false, depending on success
*/
function getFriendsOf($subtype = "", $limit = 10, $offset = 0) {
return get_user_friends_of($this->getGUID(), $subtype, $limit, $offset);
}
/**
- * Get an array of ElggObjects owned by this user.
+ * Gets the user's groups
+ *
+ * @param string $subtype Optionally, the subtype of user to filter to (leave blank for all)
+ * @param int $limit The number of groups to retrieve
+ * @param int $offset Indexing offset, if any
+ *
+ * @return array|false Array of ElggGroup, or false, depending on success
+ */
+ function getGroups($subtype = "", $limit = 10, $offset = 0) {
+ $options = array(
+ 'type' => 'group',
+ 'relationship' => 'member',
+ 'relationship_guid' => $this->guid,
+ 'limit' => $limit,
+ 'offset' => $offset,
+ );
+
+ if ($subtype) {
+ $options['subtype'] = $subtype;
+ }
+
+ return elgg_get_entities_from_relationship($options);
+ }
+
+ /**
+ * Get an array of ElggObject owned by this user.
*
* @param string $subtype The subtype of the objects, if any
* @param int $limit Number of results to return