diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-03-07 12:15:38 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-03-07 12:15:38 +0000 |
commit | 142aef30294caab47a184393103aa6644131ba19 (patch) | |
tree | 495f2308c99f76f2e33bdac26ceff4f0c9ff5496 /mod/groups/start.php | |
parent | 5991e7a915191a0d7655b51794dfdc1ac05ce5d7 (diff) | |
download | elgg-142aef30294caab47a184393103aa6644131ba19.tar.gz elgg-142aef30294caab47a184393103aa6644131ba19.tar.bz2 |
Refs #2895 entity menu uses new menu system
git-svn-id: http://code.elgg.org/elgg/trunk@8622 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/groups/start.php')
-rw-r--r-- | mod/groups/start.php | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/mod/groups/start.php b/mod/groups/start.php index 08c0d1966..9a80fd366 100644 --- a/mod/groups/start.php +++ b/mod/groups/start.php @@ -58,6 +58,8 @@ function groups_init() { // add link to owner block elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'groups_activity_owner_block_menu'); + // group entity menu + elgg_register_plugin_hook_handler('register', 'menu:entity', 'groups_entity_menu_setup'); //extend some views elgg_extend_view('css/elgg', 'groups/css'); @@ -278,6 +280,73 @@ function groups_activity_owner_block_menu($hook, $type, $return, $params) { } /** + * Add links/info to entity menu particular to group entities + */ +function groups_entity_menu_setup($hook, $type, $return, $params) { + if (elgg_in_context('widgets')) { + return $return; + } + + $entity = $params['entity']; + $handler = elgg_extract('handler', $params, false); + if ($handler != 'groups') { + return $return; + } + + foreach ($return as $index => $item) { + if (in_array($item->getName(), array('access', 'likes', 'edit', 'delete'))) { + unset($return[$index]); + } + } + + // membership type + $membership = $entity->membership; + if ($membership == ACCESS_PUBLIC) { + $mem = elgg_echo("groups:open"); + } else { + $mem = elgg_echo("groups:closed"); + } + $options = array( + 'name' => 'membership', + 'text' => $mem, + 'href' => false, + 'priority' => 100, + ); + $return[] = ElggMenuItem::factory($options); + + // number of members + $num_members = get_group_members($entity->guid, 10, 0, 0, true); + $members_string = elgg_echo('groups:member'); + $options = array( + 'name' => 'members', + 'text' => $num_members . ' ' . $members_string, + 'href' => false, + 'priority' => 200, + ); + $return[] = ElggMenuItem::factory($options); + + // feature link + if (elgg_is_admin_logged_in()) { + if ($group->featured_group == "yes") { + $url = "action/groups/featured?group_guid={$group->guid}&action_type=unfeature"; + $wording = elgg_echo("groups:makeunfeatured"); + } else { + $url = "action/groups/featured?group_guid={$group->guid}&action_type=feature"; + $wording = elgg_echo("groups:makefeatured"); + } + $options = array( + 'name' => 'feature', + 'text' => $wording, + 'href' => $url, + 'priority' => 300, + ); + $return[] = ElggMenuItem::factory($options); + } + + return $return; +} + +/** * Groups created so create an access list for it */ function groups_create_event_listener($event, $object_type, $object) { |