Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/22/2015 04:58:34 AM (9 years ago)
Author:
tw2113
Message:

More docs cleanup for BP-Groups component.

See #6401.

File:
1 edited

Legend:

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

    r10262 r10373  
    1414defined( 'ABSPATH' ) || exit;
    1515
     16/**
     17 * Creates our Groups component.
     18 */
    1619class BP_Groups_Component extends BP_Component {
    1720
     
    3740     * @since 1.6.0
    3841     * @todo Is this used anywhere? Is this a duplicate of $default_extension?
     42     * @var string
    3943     */
    4044    var $default_component;
     
    136140        $bp = buddypress();
    137141
    138         // Define a slug, if necessary
     142        // Define a slug, if necessary.
    139143        if ( ! defined( 'BP_GROUPS_SLUG' ) ) {
    140144            define( 'BP_GROUPS_SLUG', $this->id );
    141145        }
    142146
    143         // Global tables for groups component
     147        // Global tables for groups component.
    144148        $global_tables = array(
    145149            'table_name'           => $bp->table_prefix . 'bp_groups',
     
    148152        );
    149153
    150         // Metadata tables for groups component
     154        // Metadata tables for groups component.
    151155        $meta_tables = array(
    152156            'group' => $bp->table_prefix . 'bp_groups_groupmeta',
     
    168172        parent::setup_globals( $args );
    169173
    170         /** Single Group Globals **********************************************/
     174        /* Single Group Globals **********************************************/
    171175
    172176        // Are we viewing a single group?
     
    215219            }
    216220
    217             // If the user is not an admin, check if they are a moderator
     221            // If the user is not an admin, check if they are a moderator.
    218222            if ( ! bp_is_item_admin() ) {
    219223                bp_update_is_item_mod  ( groups_is_user_mod  ( bp_loggedin_user_id(), $this->current_group->id ), 'groups' );
     
    245249            }
    246250
    247             // Check once if the current group has a custom front template
     251            // Check once if the current group has a custom front template.
    248252            $this->current_group->front_template = bp_groups_get_front_template( $this->current_group );
    249253
    250         // Set current_group to 0 to prevent debug errors
     254        // Set current_group to 0 to prevent debug errors.
    251255        } else {
    252256            $this->current_group = 0;
     
    277281        ) );
    278282
    279         // If the user was attempting to access a group, but no group by that name was found, 404
     283        // If the user was attempting to access a group, but no group by that name was found, 404.
    280284        if ( bp_is_groups_component() && empty( $this->current_group ) && bp_current_action() && !in_array( bp_current_action(), $this->forbidden_names ) ) {
    281285            bp_do_404();
     
    301305        ) );
    302306
    303         // If avatar uploads are not disabled, add avatar option
     307        // If avatar uploads are not disabled, add avatar option.
    304308        $disabled_avatar_uploads = (int) bp_disable_group_avatar_uploads();
    305309        if ( ! $disabled_avatar_uploads && $bp->avatar->show_avatars ) {
     
    317321        }
    318322
    319         // If friends component is active, add invitations
     323        // If friends component is active, add invitations.
    320324        if ( bp_is_active( 'friends' ) ) {
    321325            $this->group_creation_steps['group-invites'] = array(
     
    338342        ) );
    339343
    340         // Auto join group when non group member performs group activity
     344        // Auto join group when non group member performs group activity.
    341345        $this->auto_join = defined( 'BP_DISABLE_AUTO_GROUP_JOIN' ) && BP_DISABLE_AUTO_GROUP_JOIN ? false : true;
    342346    }
     
    368372        $bp = buddypress();
    369373
    370         // If the activity component is not active and the current group has no custom front, members are displayed in the home nav
     374        // If the activity component is not active and the current group has no custom front, members are displayed in the home nav.
    371375        if ( 'members' === $this->default_extension && ! bp_is_active( 'activity' ) && ! $this->current_group->front_template ) {
    372376            $this->default_extension = 'home';
     
    377381        }
    378382
    379         // Prepare for a redirect to the canonical URL
     383        // Prepare for a redirect to the canonical URL.
    380384        $bp->canonical_stack['base_url'] = bp_get_group_permalink( $this->current_group );
    381385
     
    401405        // When viewing the default extension, the canonical URL should not have
    402406        // that extension's slug, unless more has been tacked onto the URL via
    403         // action variables
     407        // action variables.
    404408        if ( bp_is_current_action( $this->default_extension ) && empty( $bp->action_variables ) )  {
    405409            unset( $bp->canonical_stack['action'] );
     
    419423    public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
    420424
    421         // Determine user to use
     425        // Determine user to use.
    422426        if ( bp_displayed_user_domain() ) {
    423427            $user_domain = bp_displayed_user_domain();
     
    428432        }
    429433
    430         // Only grab count if we're on a user page
     434        // Only grab count if we're on a user page.
    431435        if ( bp_is_user() ) {
    432436            $count    = bp_get_total_group_count_for_user();
     
    439443        $slug = bp_get_groups_slug();
    440444
    441         // Add 'Groups' to the main navigation
     445        // Add 'Groups' to the main navigation.
    442446        $main_nav = array(
    443447            'name'                => $nav_name,
     
    453457            $groups_link = trailingslashit( $user_domain . $slug );
    454458
    455             // Add the My Groups nav item
     459            // Add the My Groups nav item.
    456460            $sub_nav[] = array(
    457461                'name'            => __( 'Memberships', 'buddypress' ),
     
    464468            );
    465469
    466             // Add the Group Invites nav item
     470            // Add the Group Invites nav item.
    467471            $sub_nav[] = array(
    468472                'name'            => __( 'Invitations', 'buddypress' ),
     
    480484        if ( bp_is_groups_component() && bp_is_single_item() ) {
    481485
    482             // Reset sub nav
     486            // Reset sub nav.
    483487            $sub_nav = array();
    484488
    485             // Add 'Groups' to the main navigation
     489            // Add 'Groups' to the main navigation.
    486490            $main_nav = array(
    487491                'name'                => __( 'Memberships', 'buddypress' ),
    488492                'slug'                => $this->current_group->slug,
    489                 'position'            => -1, // Do not show in BuddyBar
     493                'position'            => -1, // Do not show in BuddyBar.
    490494                'screen_function'     => 'groups_screen_group_home',
    491495                'default_subnav_slug' => $this->default_extension,
     
    495499            $group_link = bp_get_group_permalink( $this->current_group );
    496500
    497             // Add the "Home" subnav item, as this will always be present
     501            // Add the "Home" subnav item, as this will always be present.
    498502            $sub_nav[] = array(
    499503                'name'            =>  _x( 'Home', 'Group screen navigation title', 'buddypress' ),
     
    526530            }
    527531
    528             // Forums are enabled and turned on
     532            // Forums are enabled and turned on.
    529533            if ( $this->current_group->enable_forum && bp_is_active( 'forums' ) ) {
    530534                $sub_nav[] = array(
     
    559563
    560564                /**
    561                  * Only add the members subnav if it's not the home's nav
     565                 * Only add the members subnav if it's not the home's nav.
    562566                 */
    563567                $sub_nav[] = array(
     
    588592            }
    589593
    590             // If the user is a group admin, then show the group admin nav item
     594            // If the user is a group admin, then show the group admin nav item.
    591595            if ( bp_is_item_admin() ) {
    592596                $sub_nav[] = array(
     
    604608                $admin_link = trailingslashit( $group_link . 'admin' );
    605609
    606                 // Common params to all nav items
     610                // Common params to all nav items.
    607611                $default_params = array(
    608612                    'parent_url'        => $admin_link,
     
    692696    public function setup_admin_bar( $wp_admin_nav = array() ) {
    693697
    694         // Menus for logged in user
     698        // Menus for logged in user.
    695699        if ( is_user_logged_in() ) {
    696700
    697             // Setup the logged in user variables
     701            // Setup the logged in user variables.
    698702            $groups_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() );
    699703
    700             // Pending group invites
     704            // Pending group invites.
    701705            $count   = groups_get_invite_count_for_user();
    702706            $title   = _x( 'Groups', 'My Account Groups', 'buddypress' );
     
    708712            }
    709713
    710             // Add the "My Account" sub menus
     714            // Add the "My Account" sub menus.
    711715            $wp_admin_nav[] = array(
    712716                'parent' => buddypress()->my_account_menu_id,
     
    716720            );
    717721
    718             // My Groups
     722            // My Groups.
    719723            $wp_admin_nav[] = array(
    720724                'parent' => 'my-account-' . $this->id,
     
    724728            );
    725729
    726             // Invitations
     730            // Invitations.
    727731            $wp_admin_nav[] = array(
    728732                'parent' => 'my-account-' . $this->id,
     
    732736            );
    733737
    734             // Create a Group
     738            // Create a Group.
    735739            if ( bp_user_can_create_groups() ) {
    736740                $wp_admin_nav[] = array(
     
    793797    public function setup_cache_groups() {
    794798
    795         // Global groups
     799        // Global groups.
    796800        wp_cache_add_global_groups( array(
    797801            'bp_groups',
Note: See TracChangeset for help on using the changeset viewer.