From 5b0e86554e6b5b2b554a9d7d33458f2ee8b487ee Mon Sep 17 00:00:00 2001 From: Jerome Bakker Date: Fri, 28 Sep 2012 15:03:03 +0200 Subject: [PATCH] fixed: unable to edit a group as a normal user when limiting group creation (thanks to buraddo http://community.elgg.org/profile/buraddo) --- CHANGES.txt | 1 + lib/hooks.php | 16 ++++++++++++++++ start.php | 4 +--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index d3a6e924..cb5287b6 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -3,6 +3,7 @@ x.x: - added: filter groups based on a tag field in index_group widget - fixed: problem with group invite autocomplete on subfolder Elgg installations (thanks to Bruno Grossmann http://community.elgg.org/profile/bruno) +- fixed: unable to edit a group as a normal user when limiting group creation (thanks to buraddo http://community.elgg.org/profile/buraddo) - changed: group invitations (and add) no always goto mail - changed: some logic when (re)inviting for better system messages to the users - changed: discussion dasboard widget ordering to be inline with default Elgg diff --git a/lib/hooks.php b/lib/hooks.php index e8c17980..99ee1fc9 100644 --- a/lib/hooks.php +++ b/lib/hooks.php @@ -319,4 +319,20 @@ function group_tools_access_write_handler($hook, $type, $return_value, $params){ return $result; } + + function group_tools_action_handler($hook, $type, $return_value, $params){ + $result = $return_value; + + if($type == "groups/edit"){ + // group creation can be limited, but editing isn't + if(group_tools_is_group_creation_limited()){ + if(!get_input("group_guid") && !elgg_is_admin_logged_in()){ + // trying to create a group, but you're not an admin + $result = false; + } + } + } + + return $result; + } \ No newline at end of file diff --git a/start.php b/start.php index fb392e1c..11e05536 100644 --- a/start.php +++ b/start.php @@ -90,9 +90,7 @@ function group_tools_init(){ } // group creation can be limited to admins - if(!elgg_is_admin_logged_in() && group_tools_is_group_creation_limited()){ - elgg_unregister_action("groups/edit"); - } + elgg_register_plugin_hook_handler("action", "groups/edit", "group_tools_action_handler"); // register index widget to show latest discussions elgg_register_widget_type("discussion", elgg_echo("discussion:latest"), elgg_echo("widgets:discussion:description"), "index,dashboard", true);