diff options
Diffstat (limited to 'mod/groups')
-rw-r--r-- | mod/groups/start.php | 69 | ||||
-rw-r--r-- | mod/groups/views/default/group/default.php | 41 | ||||
-rw-r--r-- | mod/groups/views/default/object/groupforumtopic.php | 6 |
3 files changed, 79 insertions, 37 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) { diff --git a/mod/groups/views/default/group/default.php b/mod/groups/views/default/group/default.php index 77b17402b..14bdc7aa3 100644 --- a/mod/groups/views/default/group/default.php +++ b/mod/groups/views/default/group/default.php @@ -9,41 +9,12 @@ $group = $vars['entity']; $icon = elgg_view_entity_icon($group, 'tiny'); -//get the membership type -$membership = $group->membership; -if ($membership == ACCESS_PUBLIC) { - $mem = elgg_echo("groups:open"); -} else { - $mem = elgg_echo("groups:closed"); -} - -// number of members -$num_members = get_group_members($group->guid, 10, 0, 0, true); -$members_string = elgg_echo('groups:member'); - -$metadata = "<ul class=\"elgg-menu elgg-menu-metadata\"><li>$mem</li>"; -$metadata .= "<li>$num_members $members_string</li>"; - -// 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"); - } - $feature_link = elgg_view('output/url', array( - 'href' => $url, - 'text' => $wording, - 'is_action' => true, - )); - $metadata .= "<li>$feature_link</li>"; -} - -$metadata .= elgg_view("entity/metadata", array('entity' => $group)); - -$metadata .= "</ul>"; +$metadata = elgg_view_menu('entity', array( + 'entity' => $group, + 'handler' => 'groups', + 'sort_by' => 'priority', + 'class' => 'elgg-menu-hz', +)); if (elgg_in_context('owner_block') || elgg_in_context('widgets')) { $metadata = ''; diff --git a/mod/groups/views/default/object/groupforumtopic.php b/mod/groups/views/default/object/groupforumtopic.php index b5efa0e6c..1b972c77f 100644 --- a/mod/groups/views/default/object/groupforumtopic.php +++ b/mod/groups/views/default/object/groupforumtopic.php @@ -45,9 +45,11 @@ if ($num_replies != 0) { )); } -$metadata = elgg_view('navigation/menu/metadata', array( - 'entity' => $topic, +$metadata = elgg_view_menu('entity', array( + 'entity' => $vars['entity'], 'handler' => 'discussion', + 'sort_by' => 'priority', + 'class' => 'elgg-menu-hz', )); // do not show the metadata and controls in widget view |