Changeset 9936 for trunk/src/bp-groups/bp-groups-loader.php
- Timestamp:
- 06/11/2015 06:53:59 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-loader.php
r9906 r9936 121 121 ); 122 122 123 if ( is_admin() ) 123 if ( is_admin() ) { 124 124 $includes[] = 'admin'; 125 } 125 126 126 127 parent::includes( $includes ); … … 143 144 144 145 // Define a slug, if necessary 145 if ( ! defined( 'BP_GROUPS_SLUG' ) )146 if ( ! defined( 'BP_GROUPS_SLUG' ) ) { 146 147 define( 'BP_GROUPS_SLUG', $this->id ); 148 } 147 149 148 150 // Global tables for groups component … … 214 216 215 217 // Using "item" not "group" for generic support in other components. 216 if ( bp_current_user_can( 'bp_moderate' ) ) 218 if ( bp_current_user_can( 'bp_moderate' ) ) { 217 219 bp_update_is_item_admin( true, 'groups' ); 218 else220 } else { 219 221 bp_update_is_item_admin( groups_is_user_admin( bp_loggedin_user_id(), $this->current_group->id ), 'groups' ); 222 } 220 223 221 224 // If the user is not an admin, check if they are a moderator 222 if ( ! bp_is_item_admin() )225 if ( ! bp_is_item_admin() ) { 223 226 bp_update_is_item_mod ( groups_is_user_mod ( bp_loggedin_user_id(), $this->current_group->id ), 'groups' ); 227 } 224 228 225 229 // Is the logged in user a member of the group? 226 if ( ( is_user_logged_in() && groups_is_user_member( bp_loggedin_user_id(), $this->current_group->id ) ) ) 230 if ( ( is_user_logged_in() && groups_is_user_member( bp_loggedin_user_id(), $this->current_group->id ) ) ) { 227 231 $this->current_group->is_user_member = true; 228 else232 } else { 229 233 $this->current_group->is_user_member = false; 234 } 230 235 231 236 // Should this group be visible to the logged in user? 232 if ( 'public' == $this->current_group->status || $this->current_group->is_user_member ) 237 if ( 'public' == $this->current_group->status || $this->current_group->is_user_member ) { 233 238 $this->current_group->is_visible = true; 234 else239 } else { 235 240 $this->current_group->is_visible = false; 241 } 236 242 237 243 // If this is a private or hidden group, does the user have access? 238 244 if ( 'private' == $this->current_group->status || 'hidden' == $this->current_group->status ) { 239 if ( $this->current_group->is_user_member && is_user_logged_in() || bp_current_user_can( 'bp_moderate' ) ) 245 if ( $this->current_group->is_user_member && is_user_logged_in() || bp_current_user_can( 'bp_moderate' ) ) { 240 246 $this->current_group->user_has_access = true; 241 else247 } else { 242 248 $this->current_group->user_has_access = false; 249 } 243 250 } else { 244 251 $this->current_group->user_has_access = true; … … 346 353 } 347 354 348 349 355 /** 350 356 * Filters the default groups extension. … … 357 363 $this->default_extension = apply_filters( 'bp_groups_default_extension', defined( 'BP_GROUPS_DEFAULT_EXTENSION' ) ? BP_GROUPS_DEFAULT_EXTENSION : 'home' ); 358 364 359 if ( !bp_current_action() ) { 360 buddypress()->current_action = $this->default_extension; 365 $bp = buddypress(); 366 367 if ( ! bp_current_action() ) { 368 $bp->current_action = $this->default_extension; 361 369 } 362 370 363 371 // Prepare for a redirect to the canonical URL 364 buddypress()->canonical_stack['base_url'] = bp_get_group_permalink( $this->current_group );372 $bp->canonical_stack['base_url'] = bp_get_group_permalink( $this->current_group ); 365 373 366 374 if ( bp_current_action() ) { 367 buddypress()->canonical_stack['action'] = bp_current_action();368 } 369 370 if ( ! empty( buddypress()->action_variables ) ) {371 buddypress()->canonical_stack['action_variables'] = bp_action_variables();375 $bp->canonical_stack['action'] = bp_current_action(); 376 } 377 378 if ( ! empty( $bp->action_variables ) ) { 379 $bp->canonical_stack['action_variables'] = bp_action_variables(); 372 380 } 373 381 … … 375 383 // that extension's slug, unless more has been tacked onto the URL via 376 384 // action variables 377 if ( bp_is_current_action( $this->default_extension ) && empty( buddypress()->action_variables ) ) {378 unset( buddypress()->canonical_stack['action'] );385 if ( bp_is_current_action( $this->default_extension ) && empty( $bp->action_variables ) ) { 386 unset( $bp->canonical_stack['action'] ); 379 387 } 380 388 } … … 391 399 */ 392 400 public function setup_nav( $main_nav = array(), $sub_nav = array() ) { 393 394 // Only grab count if we're on a user page395 if ( bp_is_user() ) {396 $count = bp_get_total_group_count_for_user();397 $class = ( 0 === $count ) ? 'no-count' : 'count';398 $nav_name = sprintf( _x( 'Groups <span class="%s">%s</span>', 'Group screen nav with counter', 'buddypress' ), esc_attr( $class ), number_format_i18n( $count ) );399 } else {400 $nav_name = _x( 'Groups', 'Group screen nav without counter', 'buddypress' );401 }402 403 // Add 'Groups' to the main navigation404 $main_nav = array(405 'name' => $nav_name,406 'slug' => $this->slug,407 'position' => 70,408 'screen_function' => 'groups_screen_my_groups',409 'default_subnav_slug' => 'my-groups',410 'item_css_id' => $this->id411 );412 401 413 402 // Determine user to use … … 420 409 } 421 410 422 if ( !empty( $user_domain ) ) { 423 $groups_link = trailingslashit( $user_domain . $this->slug ); 411 // Only grab count if we're on a user page 412 if ( bp_is_user() ) { 413 $count = bp_get_total_group_count_for_user(); 414 $class = ( 0 === $count ) ? 'no-count' : 'count'; 415 $nav_name = sprintf( _x( 'Groups <span class="%s">%s</span>', 'Group screen nav with counter', 'buddypress' ), esc_attr( $class ), bp_core_number_format( $count ) ); 416 } else { 417 $nav_name = _x( 'Groups', 'Group screen nav without counter', 'buddypress' ); 418 } 419 420 $slug = bp_get_groups_slug(); 421 422 // Add 'Groups' to the main navigation 423 $main_nav = array( 424 'name' => $nav_name, 425 'slug' => $slug, 426 'position' => 70, 427 'screen_function' => 'groups_screen_my_groups', 428 'default_subnav_slug' => 'my-groups', 429 'item_css_id' => $this->id 430 ); 431 432 if ( ! empty( $user_domain ) ) { 433 $access = bp_core_can_edit_settings(); 434 $groups_link = trailingslashit( $user_domain . $slug ); 424 435 425 436 // Add the My Groups nav item … … 428 439 'slug' => 'my-groups', 429 440 'parent_url' => $groups_link, 430 'parent_slug' => $ this->slug,441 'parent_slug' => $slug, 431 442 'screen_function' => 'groups_screen_my_groups', 432 443 'position' => 10, … … 439 450 'slug' => 'invites', 440 451 'parent_url' => $groups_link, 441 'parent_slug' => $ this->slug,452 'parent_slug' => $slug, 442 453 'screen_function' => 'groups_screen_group_invites', 443 'user_has_access' => bp_core_can_edit_settings(),454 'user_has_access' => $access, 444 455 'position' => 30 445 456 ); … … 487 498 488 499 $sub_nav[] = array( 489 'name' 490 'slug' 491 'parent_url' 492 'parent_slug' 493 'screen_function' 494 'position' 500 'name' => _x( 'Request Membership','Group screen nav', 'buddypress' ), 501 'slug' => 'request-membership', 502 'parent_url' => $group_link, 503 'parent_slug' => $this->current_group->slug, 504 'screen_function' => 'groups_screen_group_request_membership', 505 'position' => 30 495 506 ); 496 507 } … … 562 573 563 574 $sub_nav[] = array_merge( array( 564 'name' 565 'slug' 566 'position' 575 'name' => __( 'Details', 'buddypress' ), 576 'slug' => 'edit-details', 577 'position' => 0, 567 578 ), $default_params ); 568 579 569 580 $sub_nav[] = array_merge( array( 570 'name' 571 'slug' 572 'position' 581 'name' => __( 'Settings', 'buddypress' ), 582 'slug' => 'group-settings', 583 'position' => 10, 573 584 ), $default_params ); 574 585 575 586 if ( ! bp_disable_group_avatar_uploads() && buddypress()->avatar->show_avatars ) { 576 587 $sub_nav[] = array_merge( array( 577 'name' 578 'slug' 579 'position' 588 'name' => __( 'Photo', 'buddypress' ), 589 'slug' => 'group-avatar', 590 'position' => 20, 580 591 ), $default_params ); 581 592 } 582 593 583 594 $sub_nav[] = array_merge( array( 584 'name' 585 'slug' 586 'position' 595 'name' => __( 'Members', 'buddypress' ), 596 'slug' => 'manage-members', 597 'position' => 30, 587 598 ), $default_params ); 588 599 589 600 if ( 'private' == $this->current_group->status ) { 590 601 $sub_nav[] = array_merge( array( 591 'name' 592 'slug' 593 'position' 602 'name' => __( 'Requests', 'buddypress' ), 603 'slug' => 'membership-requests', 604 'position' => 40, 594 605 ), $default_params ); 595 606 } 596 607 597 608 $sub_nav[] = array_merge( array( 598 'name' 599 'slug' 600 'position' 609 'name' => __( 'Delete', 'buddypress' ), 610 'slug' => 'delete-group', 611 'position' => 1000, 601 612 ), $default_params ); 602 613 } … … 631 642 */ 632 643 public function setup_admin_bar( $wp_admin_nav = array() ) { 633 $bp = buddypress();634 644 635 645 // Menus for logged in user … … 637 647 638 648 // Setup the logged in user variables 639 $user_domain = bp_loggedin_user_domain(); 640 $groups_link = trailingslashit( $user_domain . $this->slug ); 649 $groups_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ); 641 650 642 651 // Pending group invites … … 645 654 $pending = _x( 'No Pending Invites', 'My Account Groups sub nav', 'buddypress' ); 646 655 647 if ( ! empty( $count['total'] ) ) {648 $title = sprintf( _x( 'Groups <span class="count">%s</span>', 'My Account Groups nav', 'buddypress' ), $count);649 $pending = sprintf( _x( 'Pending Invites <span class="count">%s</span>', 'My Account Groups sub nav', 'buddypress' ), $count);656 if ( ! empty( $count['total'] ) ) { 657 $title = sprintf( _x( 'Groups <span class="count">%s</span>', 'My Account Groups nav', 'buddypress' ), bp_core_number_format( $count ) ); 658 $pending = sprintf( _x( 'Pending Invites <span class="count">%s</span>', 'My Account Groups sub nav', 'buddypress' ), bp_core_number_format( $count ) ); 650 659 } 651 660 652 661 // Add the "My Account" sub menus 653 662 $wp_admin_nav[] = array( 654 'parent' => $bp->my_account_menu_id,663 'parent' => buddypress()->my_account_menu_id, 655 664 'id' => 'my-account-' . $this->id, 656 665 'title' => $title, 657 'href' => trailingslashit( $groups_link )666 'href' => $groups_link 658 667 ); 659 668 … … 663 672 'id' => 'my-account-' . $this->id . '-memberships', 664 673 'title' => _x( 'Memberships', 'My Account Groups sub nav', 'buddypress' ), 665 'href' => trailingslashit( $groups_link )674 'href' => $groups_link 666 675 ); 667 676 … … 692 701 */ 693 702 public function setup_title() { 694 $bp = buddypress();695 703 696 704 if ( bp_is_groups_component() ) { 705 $bp = buddypress(); 697 706 698 707 if ( bp_is_my_profile() && !bp_is_single_item() ) {
Note: See TracChangeset
for help on using the changeset viewer.