]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Added list groups and list friends class methods - will be handy for federation
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 23 Dec 2010 22:25:32 +0000 (22:25 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 23 Dec 2010 22:25:32 +0000 (22:25 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7715 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/classes/ElggUser.php

index 0e7323e82f0dd0b6806630221c2f7e05dfd056b8..eca011a36bd3bde9700f81167f42404a48474310 100644 (file)
@@ -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.
         *