aboutsummaryrefslogtreecommitdiff
path: root/mod/groups
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-08-05 19:20:17 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-08-05 19:20:17 +0000
commit8422a0502f87ff85c0898287a3578cf387965586 (patch)
treec97ecea8e7b378651e62526f427476fc205970b5 /mod/groups
parente02e8f05a0e4d097a964cf9869119bd0f0e2a2e3 (diff)
downloadelgg-8422a0502f87ff85c0898287a3578cf387965586.tar.gz
elgg-8422a0502f87ff85c0898287a3578cf387965586.tar.bz2
Fixed group-specific access controls, and site-specific access controls
git-svn-id: https://code.elgg.org/elgg/trunk@1720 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/groups')
-rw-r--r--mod/groups/start.php45
1 files changed, 38 insertions, 7 deletions
diff --git a/mod/groups/start.php b/mod/groups/start.php
index 6363a97ca..3a1a912d2 100644
--- a/mod/groups/start.php
+++ b/mod/groups/start.php
@@ -63,6 +63,9 @@
extend_view('profile/icon','groups/icon');
+ // Write access permissions
+ register_plugin_hook('access:collections:write', 'all', 'groups_write_acl_plugin_hook');
+
// For now, we'll hard code the groups profile items as follows:
// TODO make this user configurable
@@ -221,6 +224,7 @@
*/
function groups_read_acl_plugin_hook($hook, $entity_type, $returnvalue, $params)
{
+
//error_log("READ: " . var_export($returnvalue));
$user = $_SESSION['user'];
if ($user)
@@ -231,7 +235,6 @@
{
foreach ($membership as $group)
$returnvalue[$user->guid][$group->group_acl] = elgg_echo('groups:group') . ": " . $group->name;
-
return $returnvalue;
}
}
@@ -265,19 +268,47 @@
return true;
}
+ /**
+ * Listens to a group join event and adds a user to the group's access control
+ *
+ */
+ function groups_user_join_event_listener($event, $object_type, $object) {
+
+ $group = $object['group'];
+ $user = $object['user'];
+ $acl = $group->group_acl;
+
+ add_user_to_access_collection($user->guid, $acl);
+
+ return true;
+
+ }
+
+ /**
+ * Listens to a group leave event and removes a user from the group's access control
+ *
+ */
+ function groups_user_leave_event_listener($event, $object_type, $object) {
+
+ $group = $object['group'];
+ $user = $object['user'];
+ $acl = $group->group_acl;
+
+ remove_user_from_access_collection($user->guid, $acl);
+
+ return true;
+
+ }
+
// Register a handler for create groups
register_elgg_event_handler('create', 'group', 'groups_create_event_listener');
// Register a handler for delete groups
register_elgg_event_handler('delete', 'group', 'groups_delete_event_listener');
- // Read access permissions
- register_plugin_hook('access:collections', 'all', 'groups_read_acl_plugin_hook');
-
- // Write access permissions
- register_plugin_hook('access:collections:write', 'all', 'groups_write_acl_plugin_hook');
-
// Make sure the groups initialisation function is called on initialisation
register_elgg_event_handler('init','system','groups_init');
+ register_elgg_event_handler('join','group','groups_user_join_event_listener');
+ register_elgg_event_handler('leave','group','groups_user_leave_event_listener');
register_elgg_event_handler('pagesetup','system','groups_submenus');
?> \ No newline at end of file