Skip to:
Content

BuddyPress.org

Changeset 4057


Ignore:
Timestamp:
02/21/2011 01:03:41 PM (15 years ago)
Author:
johnjamesjacoby
Message:

Switch individual group navigation to use current_item as slug instead of root_component, to avoid collisions in bp_options_nav resulting in single groups not being visible if the group->slug is the same as the group->root_slug. Adjust the bp_core_new_nav_item() and bp_core_new_subnav_item() functions to look for new current_item option. Should be backwards compatible with existing group extensions, but will need testing.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-buddybar.php

    r4027 r4057  
    5454
    5555        /***
    56          * If we are not viewing a user, and this is a root component, don't attach the
    57          * default subnav function so we can display a directory or something else.
     56         * If the nav item is visible, we are not viewing a user, and this is a root
     57         * component, don't attach the default subnav function so we can display a
     58         * directory or something else.
    5859         */
    59         if ( bp_is_root_component( $slug ) && !bp_displayed_user_id() )
     60        if ( ( -1 != $position ) && bp_is_root_component( $slug ) && !bp_displayed_user_id() )
    6061                return;
    6162
     63        // Look for current component
    6264        if ( bp_is_current_component( $slug ) && !bp_current_action() ) {
     65                if ( !is_object( $screen_function[0] ) )
     66                        add_action( 'bp_screens', $screen_function );
     67                else
     68                        add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ), 3 );
     69
     70                if ( !empty( $default_subnav_slug ) )
     71                        $bp->current_action = $default_subnav_slug;
     72
     73        // Look for current item
     74        } elseif ( bp_is_current_item( $slug ) && !bp_current_action() ) {
    6375                if ( !is_object( $screen_function[0] ) )
    6476                        add_action( 'bp_screens', $screen_function );
     
    186198        );
    187199
     200        // Look for current component
    188201        if ( ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) && $user_has_access ) {
     202                if ( !is_object( $screen_function[0] ) )
     203                        add_action( 'bp_screens', $screen_function );
     204                else
     205                        add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ) );
     206
     207        // Look for current item
     208        } elseif ( ( $bp->current_action == $slug && $bp->current_item == $parent_slug ) && $user_has_access ) {
    189209                if ( !is_object( $screen_function[0] ) )
    190210                        add_action( 'bp_screens', $screen_function );
  • trunk/bp-core/bp-core-template.php

    r4050 r4057  
    2222        $component_index = !empty( $bp->displayed_user ) ? $bp->current_component : bp_get_root_slug( $bp->current_component );
    2323
    24         if ( !isset( $bp->bp_options_nav[$component_index] ) || count( $bp->bp_options_nav[$component_index] ) < 1 )
    25                 return false;
     24        if ( !bp_is_single_item() ) {
     25                if ( !isset( $bp->bp_options_nav[$component_index] ) || count( $bp->bp_options_nav[$component_index] ) < 1 ) {
     26                        return false;
     27                } else {
     28                        $the_index = $component_index;
     29                }
     30        } else {
     31                if ( !isset( $bp->bp_options_nav[$bp->current_item] ) || count( $bp->bp_options_nav[$bp->current_item] ) < 1 ) {
     32                        return false;
     33                } else {
     34                        $the_index = $bp->current_item;
     35                }
     36        }
    2637
    2738        // Loop through each navigation item
    28         foreach ( (array)$bp->bp_options_nav[$component_index] as $subnav_item ) {
     39        foreach ( (array)$bp->bp_options_nav[$the_index] as $subnav_item ) {
    2940                if ( !$subnav_item['user_has_access'] )
    3041                        continue;
  • trunk/bp-groups/bp-groups-loader.php

    r3982 r4057  
    232232                if ( bp_is_groups_component() && bp_is_single_item() ) {
    233233
     234                        unset( $main_nav ); unset( $sub_nav );
     235
    234236                        // Add 'Groups' to the main navigation
    235237                        $main_nav = array(
    236238                                'name'                => __( 'Groups', 'buddypress' ),
    237                                 'slug'                => $this->root_slug,
     239                                'slug'                => $this->current_group->slug,
    238240                                'position'            => -1, // Do not show in BuddyBar
    239241                                'screen_function'     => 'groups_screen_group_home',
     
    249251                                'slug'            => 'home',
    250252                                'parent_url'      => $group_link,
    251                                 'parent_slug'     => $this->root_slug,
     253                                'parent_slug'     => $this->current_group->slug,
    252254                                'screen_function' => 'groups_screen_group_home',
    253255                                'position'        => 10,
     
    261263                                        'slug'            => 'admin',
    262264                                        'parent_url'      => $group_link,
    263                                         'parent_slug'     => $this->root_slug,
     265                                        'parent_slug'     => $this->current_group->slug,
    264266                                        'screen_function' => 'groups_screen_group_admin',
    265267                                        'position'        => 20,
     
    280282                                        'slug'               => 'request-membership',
    281283                                        'parent_url'         => $group_link,
    282                                         'parent_slug'        => $this->root_slug,
     284                                        'parent_slug'        => $this->current_group->slug,
    283285                                        'screen_function'    => 'groups_screen_group_request_membership',
    284286                                        'position'           => 30
     
    292294                                        'slug'            => 'forum',
    293295                                        'parent_url'      => $group_link,
    294                                         'parent_slug'     => $this->root_slug,
     296                                        'parent_slug'     => $this->current_group->slug,
    295297                                        'screen_function' => 'groups_screen_group_forum',
    296298                                        'position'        => 40,
     
    304306                                'slug'            => 'members',
    305307                                'parent_url'      => $group_link,
    306                                 'parent_slug'     => $this->root_slug,
     308                                'parent_slug'     => $this->current_group->slug,
    307309                                'screen_function' => 'groups_screen_group_members',
    308310                                'position'        => 60,
     
    317319                                                'slug'            => 'send-invites',
    318320                                                'parent_url'      => $group_link,
    319                                                 'parent_slug'     => $this->root_slug,
     321                                                'parent_slug'     => $this->current_group->slug,
    320322                                                'screen_function' => 'groups_screen_group_invite',
    321323                                                'item_css_id'     => 'invite',
Note: See TracChangeset for help on using the changeset viewer.