aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/group.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib/group.php')
-rw-r--r--engine/lib/group.php127
1 files changed, 90 insertions, 37 deletions
diff --git a/engine/lib/group.php b/engine/lib/group.php
index f0ceb92fc..dee522099 100644
--- a/engine/lib/group.php
+++ b/engine/lib/group.php
@@ -16,7 +16,8 @@
* @class ElggGroup Class representing a container for other elgg entities.
* @author Marcus Povey
*/
- class ElggGroup extends ElggEntity
+ class ElggGroup extends ElggEntity
+ implements Friendable
{
protected function initialise_attributes()
{
@@ -118,62 +119,114 @@
{
return can_write_to_container($user_guid, $this->getGUID());
}
-
- /**
- * Get objects contained in this group.
- *
- * @param int $limit
- * @param int $offset
- * @param string $subtype
- * @param int $owner_guid
- * @param int $site_guid
- * @param string $order_by
- * @return mixed
- */
- public function getObjects($limit = 10, $offset = 0, $subtype = "", $owner_guid = 0, $site_guid = 0, $order_by = "")
- {
- return get_objects_in_group($this->getGUID(), $subtype, $owner_guid, $site_guid, $order_by, $limit, $offset, false);
- }
-
- /**
- * Get a list of group members.
- *
- * @param int $limit
- * @param int $offset
- * @return mixed
- */
- public function getMembers($limit = 10, $offset = 0, $count = false)
- {
- return get_group_members($this->getGUID(), $limit, $offset, 0 , $count);
- }
+
+ /**
+ * Start friendable compatibility block:
+ *
+ * public function addFriend($friend_guid);
+ public function removeFriend($friend_guid);
+ public function isFriend();
+ public function isFriendsWith($user_guid);
+ public function isFriendOf($user_guid);
+ public function getFriends($subtype = "", $limit = 10, $offset = 0);
+ public function getFriendsOf($subtype = "", $limit = 10, $offset = 0);
+ public function getObjects($subtype="", $limit = 10, $offset = 0);
+ public function getFriendsObjects($subtype = "", $limit = 10, $offset = 0);
+ public function countObjects($subtype = "");
+ */
+
+ /**
+ * For compatibility with Friendable
+ */
+ public function addFriend($friend_guid) {
+ return $this->join(get_entity($friend_guid));
+ }
+
+ /**
+ * For compatibility with Friendable
+ */
+ public function removeFriend($friend_guid) {
+ return $this->leave(get_entity($friend_guid));
+ }
+
+ /**
+ * For compatibility with Friendable
+ */
+ public function isFriend() {
+ return $this->isMember();
+ }
+
+ /**
+ * For compatibility with Friendable
+ */
+ public function isFriendsWith($user_guid) {
+ return $this->isMember($user_guid);
+ }
+
+ /**
+ * For compatibility with Friendable
+ */
+ public function isFriendOf($user_guid) {
+ return $this->isMember($user_guid);
+ }
/**
- * For compatibility with ElggUser
+ * For compatibility with Friendable
*/
public function getFriends($subtype = "", $limit = 10, $offset = 0) {
return get_group_members($this->getGUID(), $limit, $offset);
}
/**
- * For compatibility with ElggUser
+ * For compatibility with Friendable
*/
public function getFriendsOf($subtype = "", $limit = 10, $offset = 0) {
return get_group_members($this->getGUID(), $limit, $offset);
}
/**
- * For compatibility with ElggUser
+ * Get objects contained in this group.
+ *
+ * @param string $subtype
+ * @param int $limit
+ * @param int $offset
+ * @return mixed
*/
- public function isFriend() {
- return $this->isMember();
+ public function getObjects($subtype="", $limit = 10, $offset = 0)
+ {
+ return get_objects_in_group($this->getGUID(), $subtype, 0, 0, "", $limit, $offset, false);
}
/**
- * For compatibility with ElggUser
+ * For compatibility with Friendable
*/
- public function isFriendOf() {
- return $this->isMember();
+ public function getFriendsObjects($subtype = "", $limit = 10, $offset = 0) {
+ return get_objects_in_group($this->getGUID(), $subtype, 0, 0, "", $limit, $offset, false);
+ }
+
+ /**
+ * For compatibility with Friendable
+ */
+ public function countObjects($subtype = "") {
+ return get_objects_in_group($this->getGUID(), $subtype, 0, 0, "", 10, 0, true);
+ }
+
+ /**
+ * End friendable compatibility block
+ */
+
+ /**
+ * Get a list of group members.
+ *
+ * @param int $limit
+ * @param int $offset
+ * @return mixed
+ */
+ public function getMembers($limit = 10, $offset = 0, $count = false)
+ {
+ return get_group_members($this->getGUID(), $limit, $offset, 0 , $count);
}
+
/**
* Returns whether the current group is public membership or not.