Skip to:
Content

BuddyPress.org

Ticket #6388: 6388.patch

File 6388.patch, 8.3 KB (added by imath, 11 years ago)
  • src/bp-groups/bp-groups-loader.php

    diff --git src/bp-groups/bp-groups-loader.php src/bp-groups/bp-groups-loader.php
    index 58addca..21348fb 100644
    class BP_Groups_Component extends BP_Component { 
    244244                                $this->current_group->user_has_access = true;
    245245                        }
    246246
     247                        // Check once if the current group has a custom front template
     248                        $this->current_group->front_template = bp_groups_get_group_front_template( $this->current_group );
     249
    247250                // Set current_group to 0 to prevent debug errors
    248251                } else {
    249252                        $this->current_group = 0;
    class BP_Groups_Component extends BP_Component { 
    356359                 */
    357360                $this->default_extension = apply_filters( 'bp_groups_default_extension', defined( 'BP_GROUPS_DEFAULT_EXTENSION' ) ? BP_GROUPS_DEFAULT_EXTENSION : 'home' );
    358361
     362                // If the activity component is not active and the current group has no custom front, members are displayed in the home nav
     363                if ( 'members' === $this->default_extension && ! bp_is_active( 'activity' ) && ! $this->current_group->front_template ) {
     364                        $this->default_extension = 'home';
     365                }
     366
    359367                if ( !bp_current_action() ) {
    360368                        buddypress()->current_action = $this->default_extension;
    361369                }
    class BP_Groups_Component extends BP_Component { 
    511519                                );
    512520                        }
    513521
    514                         $sub_nav[] = array(
    515                                 'name'            => sprintf( _x( 'Members <span>%s</span>', 'My Group screen nav', 'buddypress' ), number_format( $this->current_group->total_member_count ) ),
    516                                 'slug'            => 'members',
    517                                 'parent_url'      => $group_link,
    518                                 'parent_slug'     => $this->current_group->slug,
    519                                 'screen_function' => 'groups_screen_group_members',
    520                                 'position'        => 60,
    521                                 'user_has_access' => $this->current_group->user_has_access,
    522                                 'item_css_id'     => 'members',
    523                                 'no_access_url'   => $group_link,
    524                         );
     522                        if ( $this->current_group->front_template || bp_is_active( 'activity' ) ) {
     523                                /**
     524                                 * Only add the members subnav if it's not the home's nav
     525                                 */
     526                                $sub_nav[] = array(
     527                                        'name'            => sprintf( _x( 'Members <span>%s</span>', 'My Group screen nav', 'buddypress' ), number_format( $this->current_group->total_member_count ) ),
     528                                        'slug'            => 'members',
     529                                        'parent_url'      => $group_link,
     530                                        'parent_slug'     => $this->current_group->slug,
     531                                        'screen_function' => 'groups_screen_group_members',
     532                                        'position'        => 60,
     533                                        'user_has_access' => $this->current_group->user_has_access,
     534                                        'item_css_id'     => 'members',
     535                                        'no_access_url'   => $group_link,
     536                                );
     537
     538                                /**
     539                                 * If the theme is using a custom front, create
     540                                 * an activity nav
     541                                 */
     542                                if ( $this->current_group->front_template && bp_is_active( 'activity' ) ) {
     543                                        $sub_nav[] = array(
     544                                                'name'            => _x( 'Activity', 'My Group screen nav', 'buddypress' ),
     545                                                'slug'            => 'activity',
     546                                                'parent_url'      => $group_link,
     547                                                'parent_slug'     => $this->current_group->slug,
     548                                                'screen_function' => 'groups_screen_group_activity',
     549                                                'position'        => 50,
     550                                                'user_has_access' => $this->current_group->user_has_access,
     551                                                'item_css_id'     => 'activity',
     552                                                'no_access_url'   => $group_link,
     553                                        );
     554                                }
     555                        }
    525556
    526557                        if ( bp_is_active( 'friends' ) && bp_groups_user_can_send_invites() ) {
    527558                                $sub_nav[] = array(
  • src/bp-groups/bp-groups-screens.php

    diff --git src/bp-groups/bp-groups-screens.php src/bp-groups/bp-groups-screens.php
    index a21fcb5..82c6ad6 100644
    function groups_screen_group_request_membership() { 
    742742}
    743743
    744744/**
     745 * Handle the loading of a single group's activity.
     746 *
     747 * @since BuddyPress (?)
     748 */
     749function groups_screen_group_activity() {
     750
     751        if ( ! bp_is_single_item() ) {
     752                return false;
     753        }
     754
     755        /**
     756         * Fires before the loading of a single group's activity page.
     757         *
     758         * @since BuddyPress (?)
     759         */
     760        do_action( 'groups_screen_group_activity' );
     761
     762        /**
     763         * Filters the template to load for a single group's activity page.
     764         *
     765         * @since BuddyPress (?)
     766         *
     767         * @param string $value Path to a single group's template to load.
     768         */
     769        bp_core_load_template( apply_filters( 'groups_screen_group_activity', 'groups/single/activity' ) );
     770}
     771
     772/**
    745773 * Handle the display of a single group activity item.
    746774 */
    747775function groups_screen_group_activity_permalink() {
  • src/bp-groups/bp-groups-template.php

    diff --git src/bp-groups/bp-groups-template.php src/bp-groups/bp-groups-template.php
    index e6921a0..a238e6c 100644
    function bp_group_has_members( $args = '' ) { 
    37523752        global $members_template;
    37533753
    37543754        $exclude_admins_mods = 1;
     3755        $current_group = groups_get_current_group();
    37553756
    3756         if ( bp_is_group_members() ) {
     3757        if ( bp_is_group_members() || ( empty( $current_group->front_template ) && ! bp_is_active( 'activity' ) && bp_is_group_home() ) ) {
    37573758                $exclude_admins_mods = 0;
    37583759        }
    37593760
    function bp_group_member_admin_pagination() { 
    41514152        }
    41524153
    41534154/**
     4155 * Load the appropriate current group's home page
     4156 *
     4157 * @since BuddyPress (?)
     4158 */
     4159function bp_groups_load_group_front_template( $require_once = false, $group = null ) {
     4160        $located = bp_groups_get_group_front_template( $group );
     4161
     4162        if ( false !== $located ) {
     4163                $slug = str_replace( '.php', '', $located );
     4164
     4165                /**
     4166                 * Let plugins adding an action to bp_get_template_part get it from here
     4167                 *
     4168                 * @param string $slug Template part slug requested.
     4169                 * @param string $name Template part name requested.
     4170                 */
     4171                do_action( 'get_template_part_' . $slug, $slug, false );
     4172
     4173                load_template( $located, $require_once );
     4174
     4175        } else if ( bp_is_active( 'activity' ) ) {
     4176                bp_get_template_part( 'groups/single/activity' );
     4177
     4178        } else if ( bp_is_active( 'members'  ) ) {
     4179                bp_groups_members_template_part();
     4180        }
     4181
     4182        return $located;
     4183}
     4184
     4185/**
     4186 * Locate a custom group front template if it exsists
     4187 *
     4188 * @since BuddyPress (?)
     4189 */
     4190function bp_groups_get_group_front_template( $group = null ) {
     4191        if ( ! is_a( $group, 'BP_Groups_Group' ) ) {
     4192                $group = groups_get_current_group();
     4193        }
     4194
     4195        if ( ! isset( $group->id ) ) {
     4196                return false;
     4197        }
     4198
     4199        if ( isset( $group->front_template ) ) {
     4200                return $group->front_template;
     4201        }
     4202
     4203        $template_names = apply_filters( 'bp_groups_get_front_template', array(
     4204                'groups/single/front-id-'     . sanitize_file_name( $group->id )     . '.php',
     4205                'groups/single/front-slug-'   . sanitize_file_name( $group->slug )   . '.php',
     4206                'groups/single/front-status-' . sanitize_file_name( $group->status ) . '.php',
     4207                'groups/single/front.php'
     4208        ) );
     4209
     4210        return bp_locate_template( $template_names, false, true );
     4211}
     4212
     4213/**
    41544214 * Output the Group members template
    41554215 *
    41564216 * @since BuddyPress (2.0.0)
  • src/bp-templates/bp-legacy/buddypress/activity/post-form.php

    diff --git src/bp-templates/bp-legacy/buddypress/activity/post-form.php src/bp-templates/bp-legacy/buddypress/activity/post-form.php
    index 12023a8..4ea132c 100644
     
    6565                                </div>
    6666                                <input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" />
    6767
    68                         <?php elseif ( bp_is_group_home() ) : ?>
     68                        <?php elseif ( bp_is_group_home() || bp_is_group_activity() ) : ?>
    6969
    7070                                <input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" />
    7171                                <input type="hidden" id="whats-new-post-in" name="whats-new-post-in" value="<?php bp_group_id(); ?>" />
  • src/bp-templates/bp-legacy/buddypress/groups/single/home.php

    diff --git src/bp-templates/bp-legacy/buddypress/groups/single/home.php src/bp-templates/bp-legacy/buddypress/groups/single/home.php
    index f22e339..7139418 100644
     
    3838
    3939                                if ( bp_group_is_visible() ) {
    4040
    41                                         // Use custom front if one exists
    42                                         $custom_front = bp_locate_template( array( 'groups/single/front.php' ), false, true );
    43                                         if     ( ! empty( $custom_front   ) ) : load_template( $custom_front, true );
    44 
    45                                         // Default to activity
    46                                         elseif ( bp_is_active( 'activity' ) ) : bp_get_template_part( 'groups/single/activity' );
    47 
    48                                         // Otherwise show members
    49                                         elseif ( bp_is_active( 'members'  ) ) : bp_groups_members_template_part();
    50 
    51                                         endif;
     41                                        // Load appropriate front template
     42                                        bp_groups_load_group_front_template();
    5243
    5344                                } else {
    5445