Skip to content

Commit

Permalink
fix(groups): link to membership requests page is visible again
Browse files Browse the repository at this point in the history
Page owner and context are now set before elgg_view() gets called for
the first time. This makes sure that they are available in the handler
that registers the menu item on [pagesetup, system] event.
  • Loading branch information
Juho Jaakkola committed Dec 29, 2015
1 parent 3d67ad6 commit 8e3bb84
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
20 changes: 13 additions & 7 deletions mod/groups/start.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function groups_init() {

// invitation request actions
elgg_register_plugin_hook_handler('register', 'menu:invitationrequest', 'groups_invitationrequest_menu_setup');

// group members tabs
elgg_register_plugin_hook_handler('register', 'menu:groups_members', 'groups_members_menu_setup');

Expand Down Expand Up @@ -106,7 +106,7 @@ function groups_init() {

// Add tests
elgg_register_plugin_hook_handler('unit_test', 'system', 'groups_test');

// allow to be liked
elgg_register_plugin_hook_handler('likes:is_likable', 'group:', 'Elgg\Values::getTrue');
}
Expand Down Expand Up @@ -266,10 +266,16 @@ function groups_page_handler($page) {
echo elgg_view_resource('groups/members', $vars);
}
break;
case 'profile':
// Page owner and context need to be set before elgg_view() is
// called so they'll be available in the [pagesetup, system] event
// that is used for registering items for the sidebar menu.
// @see groups_setup_sidebar_menus()
elgg_push_context('group_profile');
elgg_set_page_owner_guid($page[1]);
case 'activity':
case 'edit':
case 'invite':
case 'profile':
case 'requests':
echo elgg_view_resource("groups/{$page[0]}", [
'guid' => $page[1],
Expand Down Expand Up @@ -790,25 +796,25 @@ function groups_invitationrequest_menu_setup($hook, $type, $menu, $params) {
* @return void|ElggMenuItem[]
*/
function groups_members_menu_setup($hook, $type, $menu, $params) {

$entity = elgg_extract('entity', $params);
if (empty($entity) || !($entity instanceof ElggGroup)) {
return;
}

$menu[] = ElggMenuItem::factory([
'name' => 'alpha',
'text' => elgg_echo('sort:alpha'),
'href' => "groups/members/{$entity->getGUID()}",
'priority' => 100
]);

$menu[] = ElggMenuItem::factory([
'name' => 'newest',
'text' => elgg_echo('sort:newest'),
'href' => "groups/members/{$entity->getGUID()}/newest",
'priority' => 200
]);

return $menu;
}
3 changes: 0 additions & 3 deletions mod/groups/views/default/resources/groups/profile.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<?php

$guid = elgg_extract('guid', $vars);
elgg_set_page_owner_guid($guid);

// turn this into a core function
global $autofeed;
$autofeed = true;

elgg_push_context('group_profile');

elgg_entity_gatekeeper($guid, 'group');

$group = get_entity($guid);
Expand Down

0 comments on commit 8e3bb84

Please sign in to comment.