aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/users.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib/users.php')
-rw-r--r--engine/lib/users.php62
1 files changed, 61 insertions, 1 deletions
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 68383d8e5..166225b9e 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -251,6 +251,16 @@
public function getObjects($subtype="", $limit = 10, $offset = 0) { return get_user_objects($this->getGUID(), $subtype, $limit, $offset); }
/**
+ * Counts the number of ElggObjects owned by this user
+ *
+ * @param string $subtype The subtypes of the objects, if any
+ * @return int The number of ElggObjects
+ */
+ public function countObjects($subtype = "") {
+ return count_user_objects($this->getGUID(), $subtype);
+ }
+
+ /**
* Get the collections associated with a user.
*
* @param string $subtype Optionally, the subtype of result we want to limit to
@@ -403,7 +413,7 @@
function get_user_friends($user_guid, $subtype = "", $limit = 10, $offset = 0) {
return get_entities_from_relationship("friend",$user_guid,false,"user",$subtype,0,"time_created desc",$limit,$offset);
}
-
+
/**
* Obtains a list of objects owned by a user
*
@@ -419,6 +429,56 @@
}
/**
+ * Counts the objects (optionally of a particular subtype) owned by a user
+ *
+ * @param int $user_guid The GUID of the owning user
+ * @param string $subtype Optionally, the subtype of objects
+ * @return int The number of objects the user owns (of this subtype)
+ */
+ function count_user_objects($user_guid, $subtype = "") {
+ $total = get_entities('object', $subtype, $user_guid, "time_created desc", null, null, true);
+ return $total;
+ }
+
+/**
+ * Obtains a list of objects owned by a user's friends
+ *
+ * @param int $user_guid The GUID of the user to get the friends of
+ * @param string $subtype Optionally, the subtype of objects
+ * @param int $limit The number of results to return (default 10)
+ * @param int $offset Indexing offset, if any
+ * @return false|array An array of ElggObjects or false, depending on success
+ */
+ function get_user_friends_objects($user_guid, $subtype = "", $limit = 10, $offset = 0) {
+ if ($friends = get_user_friends($user_guid, $subtype, 999999, 0)) {
+ $friendguids = array();
+ foreach($friends as $friend) {
+ $friendguids[] = $friend->getGUID();
+ }
+ return get_entities('object',$subtype,$friendguids, "time_created desc", $limit, $offset);
+ }
+ return false;
+ }
+
+ /**
+ * Counts the number of objects owned by a user's friends
+ *
+ * @param int $user_guid The GUID of the user to get the friends of
+ * @param string $subtype Optionally, the subtype of objects
+ * @return int The number of objects
+ */
+ function count_user_friends_objects($user_guid, $subtype = "") {
+ if ($friends = get_user_friends($user_guid, $subtype, 999999, 0)) {
+ $friendguids = array();
+ foreach($friends as $friend) {
+ $friendguids[] = $friend->getGUID();
+ }
+ return get_entities('object',$subtype,$friendguids, "time_created desc", $limit, $offset, true);
+ }
+ return 0;
+ }
+
+ /**
* Get a user object from a GUID.
*
* This function returns an ElggUser from a given GUID.