Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/10/2012 06:47:31 PM (13 years ago)
Author:
johnjamesjacoby
Message:

Toggle displayed/logged-in user for sub-nav. Bail if no menu should be available. Add 'user_has_access' checks where applicable. Reverts r6519. Fixes #4661.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-loader.php

    r6353 r6622  
    352352        );
    353353
    354         $groups_link = trailingslashit( bp_loggedin_user_domain() . $this->slug );
    355 
    356         // Add the My Groups nav item
    357         $sub_nav[] = array(
    358             'name'            => __( 'Memberships', 'buddypress' ),
    359             'slug'            => 'my-groups',
    360             'parent_url'      => $groups_link,
    361             'parent_slug'     => $this->slug,
    362             'screen_function' => 'groups_screen_my_groups',
    363             'position'        => 10,
    364             'item_css_id'     => 'groups-my-groups'
    365         );
    366 
    367         // Add the Group Invites nav item
    368         $sub_nav[] = array(
    369             'name'            => __( 'Invitations', 'buddypress' ),
    370             'slug'            => 'invites',
    371             'parent_url'      => $groups_link,
    372             'parent_slug'     => $this->slug,
    373             'screen_function' => 'groups_screen_group_invites',
    374             'user_has_access' =>  bp_is_my_profile(),
    375             'position'        => 30
    376         );
    377 
    378         parent::setup_nav( $main_nav, $sub_nav );
     354        // Determine user to use
     355        if ( bp_displayed_user_domain() ) {
     356            $user_domain = bp_displayed_user_domain();
     357        } elseif ( bp_loggedin_user_domain() ) {
     358            $user_domain = bp_loggedin_user_domain();
     359        } else {
     360            $user_domain = false;
     361        }
     362
     363        if ( !empty( $user_domain ) ) {
     364            $groups_link = trailingslashit( $user_domain . $this->slug );
     365
     366            // Add the My Groups nav item
     367            $sub_nav[] = array(
     368                'name'            => __( 'Memberships', 'buddypress' ),
     369                'slug'            => 'my-groups',
     370                'parent_url'      => $groups_link,
     371                'parent_slug'     => $this->slug,
     372                'screen_function' => 'groups_screen_my_groups',
     373                'position'        => 10,
     374                'item_css_id'     => 'groups-my-groups'
     375            );
     376
     377            // Add the Group Invites nav item
     378            $sub_nav[] = array(
     379                'name'            => __( 'Invitations', 'buddypress' ),
     380                'slug'            => 'invites',
     381                'parent_url'      => $groups_link,
     382                'parent_slug'     => $this->slug,
     383                'screen_function' => 'groups_screen_group_invites',
     384                'user_has_access' => bp_core_can_edit_settings(),
     385                'position'        => 30
     386            );
     387
     388            parent::setup_nav( $main_nav, $sub_nav );
     389        }
    379390
    380391        if ( bp_is_groups_component() && bp_is_single_item() ) {
Note: See TracChangeset for help on using the changeset viewer.