aboutsummaryrefslogtreecommitdiff
path: root/mod/groups
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-04 02:54:37 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-04 02:54:37 +0000
commitd821e8e2634f56b60446e016f103fe2b311cd090 (patch)
tree7db950cb38d703d1ca8caa27e7e31a0a1992c81d /mod/groups
parent693c78e16e51b80f0eaba5d8c27c3d942924b398 (diff)
downloadelgg-d821e8e2634f56b60446e016f103fe2b311cd090.tar.gz
elgg-d821e8e2634f56b60446e016f103fe2b311cd090.tar.bz2
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
Diffstat (limited to 'mod/groups')
-rw-r--r--mod/groups/start.php26
1 files changed, 25 insertions, 1 deletions
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');
}
@@ -376,6 +378,15 @@ function groups_user_join_event_listener($event, $object_type, $object) {
}
/**
+ * 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);