From 361bff59658e6119b76e7ff31cd67c6054c93c8f Mon Sep 17 00:00:00 2001 From: ben Date: Fri, 18 Jul 2008 18:23:50 +0000 Subject: Moved container_guid to entities, modified a bunch of functions. git-svn-id: https://code.elgg.org/elgg/trunk@1473 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/group.php | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) (limited to 'engine/lib/group.php') diff --git a/engine/lib/group.php b/engine/lib/group.php index b0c6d3346..90ee650f3 100644 --- a/engine/lib/group.php +++ b/engine/lib/group.php @@ -146,6 +146,34 @@ { return get_group_members($this->getGUID(), $limit, $offset, 0 , $count); } + + /** + * For compatibility with ElggUser + */ + public function getFriends($subtype = "", $limit = 10, $offset = 0) { + return get_group_members($this->getGUID(), $limit, $offset); + } + + /** + * For compatibility with ElggUser + */ + public function getFriendsOf($subtype = "", $limit = 10, $offset = 0) { + return get_group_members($this->getGUID(), $limit, $offset); + } + + /** + * For compatibility with ElggUser + */ + public function isFriend() { + return $this->isMember(); + } + + /** + * For compatibility with ElggUser + */ + public function isFriendOf() { + return $this->isMember(); + } /** * Returns whether the current group is public membership or not. @@ -165,8 +193,9 @@ * @param ElggUser $user The user * @return bool */ - public function isMember(ElggUser $user) - { + public function isMember($user = 0) + { + if ($user == 0) $user = $_SESSION['user']; return is_group_member($this->getGUID(), $user->getGUID()); } @@ -266,8 +295,9 @@ if (($container) && ($user)) { - // Basics, see if the user is a member of the group. - if (!$container->isMember($user)) return false; + // Basics, see if the user is a member of the group. + if ($container instanceof ElggGroup) + if (!$container->isMember($user)) return false; // See if anyone else has anything to say return trigger_plugin_hook('group_permissions_check',$entity->type,array('container' => $container, 'user' => $user), false); @@ -358,6 +388,7 @@ return false; } + /** * Delete a group's extra data. @@ -490,7 +521,7 @@ $where[] = "e.site_guid = {$site_guid}"; if ($container_guid > 0) - $where[] = "o.container_guid = {$container_guid}"; + $where[] = "e.container_guid = {$container_guid}"; if (!$count) { $query = "SELECT * from {$CONFIG->dbprefix}entities e join {$CONFIG->dbprefix}objects_entity o on e.guid=o.guid where "; @@ -569,7 +600,7 @@ if ($site_guid > 0) $where[] = "e.site_guid = {$site_guid}"; if ($container_guid > 0) - $where[] = "o.container_guid = {$container_guid}"; + $where[] = "e.container_guid = {$container_guid}"; if (is_array($owner_guid)) { $where[] = "e.owner_guid in (".implode(",",$owner_guid).")"; } else if ($owner_guid > 0) @@ -656,7 +687,7 @@ if ($owner_guid > 0) $where[] = "e.owner_guid = {$owner_guid}"; if ($container_guid > 0) - $where[] = "o.container_guid = {$container_guid}"; + $where[] = "e.container_guid = {$container_guid}"; if ($count) { $query = "SELECT count(e.guid) as total "; -- cgit v1.2.3