diff options
author | Jeff Tilson <jrtilson@gmail.com> | 2011-06-13 14:38:46 -0400 |
---|---|---|
committer | Jeff Tilson <jrtilson@gmail.com> | 2011-06-13 14:38:46 -0400 |
commit | 6547efb9ae89c1477930c69ac2dbe73350673a66 (patch) | |
tree | 0201e0fc170701a7e8e71e87394897f3b4298d30 /mod/groups/start.php | |
parent | a420910a8b782bae53fbd7f86102db9f9b831388 (diff) | |
download | elgg-6547efb9ae89c1477930c69ac2dbe73350673a66.tar.gz elgg-6547efb9ae89c1477930c69ac2dbe73350673a66.tar.bz2 |
Added 'remove from group' link to the user hover menu (only appears when the page owner is a group)
Diffstat (limited to 'mod/groups/start.php')
-rw-r--r-- | mod/groups/start.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/mod/groups/start.php b/mod/groups/start.php index 73bdd08a9..9a375e89d 100644 --- a/mod/groups/start.php +++ b/mod/groups/start.php @@ -44,6 +44,7 @@ function groups_init() { elgg_register_action("groups/invite", "$action_base/invite.php"); elgg_register_action("groups/join", "$action_base/join.php"); elgg_register_action("groups/leave", "$action_base/leave.php"); + elgg_register_action("groups/remove", "$action_base/remove.php"); elgg_register_action("groups/killrequest", "$action_base/delete_request.php"); elgg_register_action("groups/killinvitation", "$action_base/delete_invite.php"); elgg_register_action("groups/addtogroup", "$action_base/add.php"); @@ -60,6 +61,9 @@ function groups_init() { // group entity menu elgg_register_plugin_hook_handler('register', 'menu:entity', 'groups_entity_menu_setup'); + + // group user hover menu + elgg_register_plugin_hook_handler('register', 'menu:user_hover', 'groups_user_entity_menu_setup'); //extend some views elgg_extend_view('css/elgg', 'groups/css'); @@ -367,6 +371,44 @@ function groups_entity_menu_setup($hook, $type, $return, $params) { } /** + * Add a remove user link to user hover menu when the page owner is a group + */ +function groups_user_entity_menu_setup($hook, $type, $return, $params) { + if (elgg_is_logged_in()) { + $group = elgg_get_page_owner_entity(); + + // Check for valid group + if (!elgg_instanceof($group, 'group')) { + return $return; + } + + $entity = $params['entity']; + + // Make sure we have a user and that user is a member of the group + if (!elgg_instanceof($entity, 'user') || !$group->isMember($entity)) { + return $return; + } + + // Add remove link if we can edit the group, and if we're not trying to remove the group owner + if ($group->canEdit() && $group->getOwnerGUID() != $entity->guid) { + $remove = elgg_view('output/confirmlink', array( + 'href' => "action/groups/remove?user_guid={$entity->guid}&group_guid={$group->guid}", + 'text' => elgg_echo('groups:removeuser'), + )); + + $options = array( + 'name' => 'removeuser', + 'text' => $remove, + 'priority' => 999, + ); + $return[] = ElggMenuItem::factory($options); + } + } + + return $return; +} + +/** * Groups created so create an access list for it */ function groups_create_event_listener($event, $object_type, $object) { |