Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/27/2011 09:15:35 PM (16 years ago)
Author:
johnjamesjacoby
Message:

First pass at replacing the 'Admin Options' menus for users and groups. Include additional functionality for moderating registered components and their associated data. Also introduce cap checks for allowing non-super-admins to have moderator abilities. Does not include action handlers, this is a first pass at getting the UI in place. Also adds button class to a few rogue links in the groups component.

File:
1 edited

Legend:

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

    r3917 r3955  
    4242                        'activity',
    4343                        'template',
     44                        'buddybar',
    4445                        'functions'
    4546                );
     
    229230                parent::_setup_nav( $main_nav, $sub_nav );
    230231
    231                 if ( bp_is_groups_component() ) {
    232                         if ( bp_is_single_item() ) {
    233 
    234                                 // Add 'Groups' to the main navigation
    235                                 $main_nav = array(
    236                                         'name'                => __( 'Groups', 'buddypress' ),
    237                                         'slug'                => $this->root_slug,
    238                                         'position'            => -1, // Do not show in BuddyBar
    239                                         'screen_function'     => 'groups_screen_group_home',
    240                                         'default_subnav_slug' => 'home',
    241                                         'item_css_id'         => $this->id
    242                                 );
    243 
    244                                 $group_link = trailingslashit( $bp->root_domain . '/' . $this->root_slug . '/' . $this->current_group->slug );
    245 
    246                                 // Add the "Home" subnav item, as this will always be present
     232                if ( bp_is_groups_component() && bp_is_single_item() ) {
     233
     234                        // Add 'Groups' to the main navigation
     235                        $main_nav = array(
     236                                'name'                => __( 'Groups', 'buddypress' ),
     237                                'slug'                => $this->root_slug,
     238                                'position'            => -1, // Do not show in BuddyBar
     239                                'screen_function'     => 'groups_screen_group_home',
     240                                'default_subnav_slug' => 'home',
     241                                'item_css_id'         => $this->id
     242                        );
     243
     244                        $group_link = trailingslashit( $bp->root_domain . '/' . $this->root_slug . '/' . $this->current_group->slug );
     245
     246                        // Add the "Home" subnav item, as this will always be present
     247                        $sub_nav[] = array(
     248                                'name'            => __( 'Home', 'buddypress' ),
     249                                'slug'            => 'home',
     250                                'parent_url'      => $group_link,
     251                                'parent_slug'     => $this->root_slug,
     252                                'screen_function' => 'groups_screen_group_home',
     253                                'position'        => 10,
     254                                'item_css_id'     => 'home'
     255                        );
     256
     257                        // If the user is a group mod or more, then show the group admin nav item
     258                        if ( bp_is_item_admin() || bp_is_item_mod() ) {
    247259                                $sub_nav[] = array(
    248                                         'name'            => __( 'Home', 'buddypress' ),
    249                                         'slug'            => 'home',
     260                                        'name'            => __( 'Admin', 'buddypress' ),
     261                                        'slug'            => 'admin',
    250262                                        'parent_url'      => $group_link,
    251263                                        'parent_slug'     => $this->root_slug,
    252                                         'screen_function' => 'groups_screen_group_home',
    253                                         'position'        => 10,
    254                                         'item_css_id'     => 'home'
     264                                        'screen_function' => 'groups_screen_group_admin',
     265                                        'position'        => 20,
     266                                        'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ),
     267                                        'item_css_id'     => 'admin'
    255268                                );
    256 
    257                                 // If the user is a group mod or more, then show the group admin nav item
    258                                 if ( bp_is_item_admin() || bp_is_item_mod() ) {
     269                        }
     270
     271                        // If this is a private group, and the user is not a member, show a "Request Membership" nav item.
     272                        if ( is_user_logged_in() &&
     273                                 !is_super_admin() &&
     274                                 !$this->current_group->is_user_member &&
     275                                 !groups_check_for_membership_request( $bp->loggedin_user->id, $this->current_group->id ) &&
     276                                 $this->current_group->status == 'private'
     277                                ) {
     278                                $sub_nav[] = array(
     279                                        'name'               => __( 'Request Membership', 'buddypress' ),
     280                                        'slug'               => 'request-membership',
     281                                        'parent_url'         => $group_link,
     282                                        'parent_slug'        => $this->root_slug,
     283                                        'screen_function'    => 'groups_screen_group_request_membership',
     284                                        'position'           => 30
     285                                );
     286                        }
     287
     288                        // Forums are enabled and turned on
     289                        if ( $this->current_group->enable_forum && bp_is_active( 'forums' ) ) {
     290                                $sub_nav[] = array(
     291                                        'name'            => __( 'Forum', 'buddypress' ),
     292                                        'slug'            => 'forum',
     293                                        'parent_url'      => $group_link,
     294                                        'parent_slug'     => $this->root_slug,
     295                                        'screen_function' => 'groups_screen_group_forum',
     296                                        'position'        => 40,
     297                                        'user_has_access' => $this->current_group->user_has_access,
     298                                        'item_css_id'     => 'forums'
     299                                );
     300                        }
     301
     302                        $sub_nav[] = array(
     303                                'name'            => sprintf( __( 'Members (%s)', 'buddypress' ), number_format( $this->current_group->total_member_count ) ),
     304                                'slug'            => 'members',
     305                                'parent_url'      => $group_link,
     306                                'parent_slug'     => $this->root_slug,
     307                                'screen_function' => 'groups_screen_group_members',
     308                                'position'        => 60,
     309                                'user_has_access' => $this->current_group->user_has_access,
     310                                'item_css_id'     => 'members'
     311                        );
     312
     313                        if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $this->current_group->id ) ) {
     314                                if ( bp_is_active( 'friends' ) ) {
    259315                                        $sub_nav[] = array(
    260                                                 'name'            => __( 'Admin', 'buddypress' ),
    261                                                 'slug'            => 'admin',
     316                                                'name'            => __( 'Send Invites', 'buddypress' ),
     317                                                'slug'            => 'send-invites',
    262318                                                'parent_url'      => $group_link,
    263319                                                'parent_slug'     => $this->root_slug,
    264                                                 'screen_function' => 'groups_screen_group_admin',
    265                                                 'position'        => 20,
    266                                                 'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ),
    267                                                 'item_css_id'     => 'admin'
     320                                                'screen_function' => 'groups_screen_group_invite',
     321                                                'item_css_id'     => 'invite',
     322                                                'position'        => 70,
     323                                                'user_has_access' => $this->current_group->user_has_access
    268324                                        );
    269325                                }
    270 
    271                                 // If this is a private group, and the user is not a member, show a "Request Membership" nav item.
    272                                 if ( is_user_logged_in() &&
    273                                          !is_super_admin() &&
    274                                          !$this->current_group->is_user_member &&
    275                                          !groups_check_for_membership_request( $bp->loggedin_user->id, $this->current_group->id ) &&
    276                                          $this->current_group->status == 'private'
    277                                         ) {
    278                                         $sub_nav[] = array(
    279                                                 'name'               => __( 'Request Membership', 'buddypress' ),
    280                                                 'slug'               => 'request-membership',
    281                                                 'parent_url'         => $group_link,
    282                                                 'parent_slug'        => $this->root_slug,
    283                                                 'screen_function'    => 'groups_screen_group_request_membership',
    284                                                 'position'           => 30
    285                                         );
    286                                 }
    287 
    288                                 // Forums are enabled and turned on
    289                                 if ( $this->current_group->enable_forum && bp_is_active( 'forums' ) ) {
    290                                         $sub_nav[] = array(
    291                                                 'name'            => __( 'Forum', 'buddypress' ),
    292                                                 'slug'            => 'forum',
    293                                                 'parent_url'      => $group_link,
    294                                                 'parent_slug'     => $this->root_slug,
    295                                                 'screen_function' => 'groups_screen_group_forum',
    296                                                 'position'        => 40,
    297                                                 'user_has_access' => $this->current_group->user_has_access,
    298                                                 'item_css_id'     => 'forums'
    299                                         );
    300                                 }
    301 
    302                                 $sub_nav[] = array(
    303                                         'name'            => sprintf( __( 'Members (%s)', 'buddypress' ), number_format( $this->current_group->total_member_count ) ),
    304                                         'slug'            => 'members',
    305                                         'parent_url'      => $group_link,
    306                                         'parent_slug'     => $this->root_slug,
    307                                         'screen_function' => 'groups_screen_group_members',
    308                                         'position'        => 60,
    309                                         'user_has_access' => $this->current_group->user_has_access,
    310                                         'item_css_id'     => 'members'
    311                                 );
    312 
    313                                 if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $this->current_group->id ) ) {
    314                                         if ( bp_is_active( 'friends' ) ) {
    315                                                 $sub_nav[] = array(
    316                                                         'name'            => __( 'Send Invites', 'buddypress' ),
    317                                                         'slug'            => 'send-invites',
    318                                                         'parent_url'      => $group_link,
    319                                                         'parent_slug'     => $this->root_slug,
    320                                                         'screen_function' => 'groups_screen_group_invite',
    321                                                         'item_css_id'     => 'invite',
    322                                                         'position'        => 70,
    323                                                         'user_has_access' => $this->current_group->user_has_access
    324                                                 );
    325                                         }
    326                                 }
    327 
    328                                 parent::_setup_nav( $main_nav, $sub_nav );
    329                         }
     326                        }
     327
     328                        parent::_setup_nav( $main_nav, $sub_nav );
    330329                }
    331330
Note: See TracChangeset for help on using the changeset viewer.