From d821e8e2634f56b60446e016f103fe2b311cd090 Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 4 Mar 2011 02:54:37 +0000 Subject: Refs #1926 user is now being added to access collection of invisible group git-svn-id: http://code.elgg.org/elgg/trunk@8577 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/groups/start.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'mod/groups') diff --git a/mod/groups/start.php b/mod/groups/start.php index 04f50919a..d4649c90b 100644 --- a/mod/groups/start.php +++ b/mod/groups/start.php @@ -85,6 +85,8 @@ function groups_init() { elgg_register_event_handler('pagesetup', 'system', 'groups_submenus'); elgg_register_event_handler('annotate', 'all', 'group_object_notifications'); + elgg_register_plugin_hook_handler('access:collections:add_user', 'collection', 'groups_access_collection_override'); + elgg_register_event_handler('upgrade', 'system', 'groups_run_upgrades'); } @@ -375,6 +377,15 @@ function groups_user_join_event_listener($event, $object_type, $object) { return true; } +/** + * Make sure users are added to the access collection + */ +function groups_access_collection_override($hook, $entity_type, $returnvalue, $params) { + if (elgg_instanceof(get_entity($params['collection']->owner_guid), 'group')) { + return true; + } +} + /** * Listens to a group leave event and removes a user from the group's access control * @@ -421,8 +432,21 @@ function groups_get_invited_groups($user_guid, $return_guids = FALSE) { return $groups; } +/** + * Join a user to a group, add river event, clean-up invitations + * + * @param ElggGroup $group + * @param ElggUser $user + * @return bool + */ function groups_join_group($group, $user) { - if ($group->join($user)) { + + // access ignore so user can be added to access collection of invisible group + $ia = elgg_set_ignore_access(TRUE); + $result = $group->join($user); + elgg_set_ignore_access($ia); + + if ($result) { // Remove any invite or join request flags remove_entity_relationship($group->guid, 'invited', $user->guid); remove_entity_relationship($user->guid, 'membership_request', $group->guid); -- cgit v1.2.3