aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2012-07-05 21:08:41 -0400
committerCash Costello <cash.costello@gmail.com>2012-07-05 21:08:41 -0400
commit13dbb61c599254b6ff59c771fdb69b2641cd1d3d (patch)
treea564f82efa1ab17161781a9123736cc0884741af
parentc1c54806694e78dfac23938b24abe999cb77e61a (diff)
downloadelgg-13dbb61c599254b6ff59c771fdb69b2641cd1d3d.tar.gz
elgg-13dbb61c599254b6ff59c771fdb69b2641cd1d3d.tar.bz2
Fixes #4362 better solution to registering menu items for group pages
-rw-r--r--mod/groups/lib/groups.php2
-rw-r--r--mod/groups/start.php51
2 files changed, 27 insertions, 26 deletions
diff --git a/mod/groups/lib/groups.php b/mod/groups/lib/groups.php
index 498766df0..536d416df 100644
--- a/mod/groups/lib/groups.php
+++ b/mod/groups/lib/groups.php
@@ -238,6 +238,8 @@ function groups_handle_profile_page($guid) {
global $autofeed;
$autofeed = true;
+ elgg_push_context('group_profile');
+
$group = get_entity($guid);
if (!$group) {
forward('groups/all');
diff --git a/mod/groups/start.php b/mod/groups/start.php
index 193b72a4e..48df338c0 100644
--- a/mod/groups/start.php
+++ b/mod/groups/start.php
@@ -141,35 +141,34 @@ function groups_setup_sidebar_menus() {
// Get the page owner entity
$page_owner = elgg_get_page_owner_entity();
- if (elgg_get_context() == 'groups') {
- if ($page_owner instanceof ElggGroup) {
- if (elgg_is_logged_in() && $page_owner->canEdit() && !$page_owner->isPublicMembership()) {
- $url = elgg_get_site_url() . "groups/requests/{$page_owner->getGUID()}";
- elgg_register_menu_item('page', array(
- 'name' => 'membership_requests',
- 'text' => elgg_echo('groups:membershiprequests'),
- 'href' => $url,
- ));
- }
- } else {
+ if (elgg_in_context('group_profile')) {
+ if (elgg_is_logged_in() && $page_owner->canEdit() && !$page_owner->isPublicMembership()) {
+ $url = elgg_get_site_url() . "groups/requests/{$page_owner->getGUID()}";
elgg_register_menu_item('page', array(
- 'name' => 'groups:all',
- 'text' => elgg_echo('groups:all'),
- 'href' => 'groups/all',
+ 'name' => 'membership_requests',
+ 'text' => elgg_echo('groups:membershiprequests'),
+ 'href' => $url,
));
+ }
+ }
+ if (elgg_get_context() == 'groups' && !elgg_instanceof($page_owner, 'group')) {
+ elgg_register_menu_item('page', array(
+ 'name' => 'groups:all',
+ 'text' => elgg_echo('groups:all'),
+ 'href' => 'groups/all',
+ ));
- $user = elgg_get_logged_in_user_entity();
- if ($user) {
- $url = "groups/owner/$user->username";
- $item = new ElggMenuItem('groups:owned', elgg_echo('groups:owned'), $url);
- elgg_register_menu_item('page', $item);
- $url = "groups/member/$user->username";
- $item = new ElggMenuItem('groups:member', elgg_echo('groups:yours'), $url);
- elgg_register_menu_item('page', $item);
- $url = "groups/invitations/$user->username";
- $item = new ElggMenuItem('groups:user:invites', elgg_echo('groups:invitations'), $url);
- elgg_register_menu_item('page', $item);
- }
+ $user = elgg_get_logged_in_user_entity();
+ if ($user) {
+ $url = "groups/owner/$user->username";
+ $item = new ElggMenuItem('groups:owned', elgg_echo('groups:owned'), $url);
+ elgg_register_menu_item('page', $item);
+ $url = "groups/member/$user->username";
+ $item = new ElggMenuItem('groups:member', elgg_echo('groups:yours'), $url);
+ elgg_register_menu_item('page', $item);
+ $url = "groups/invitations/$user->username";
+ $item = new ElggMenuItem('groups:user:invites', elgg_echo('groups:invitations'), $url);
+ elgg_register_menu_item('page', $item);
}
}
}