Skip to:
Content

BuddyPress.org

Ticket #6388: 6388.02.patch

File 6388.02.patch, 9.4 KB (added by imath, 10 years ago)
  • src/bp-core/bp-core-template.php

    diff --git src/bp-core/bp-core-template.php src/bp-core/bp-core-template.php
    index 52bae24..3f60f17 100644
    function bp_is_group_forum() { 
    25342534 * @return True if the current page is a group's activity page.
    25352535 */
    25362536function bp_is_group_activity() {
    2537         return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) );
     2537        $retval = false;
     2538
     2539        if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) ) {
     2540                $retval = true;
     2541        }
     2542
     2543        if ( bp_is_group_home() && bp_is_active( 'activity' ) && ! bp_is_group_custom_front() ) {
     2544                $retval = true;
     2545        }
     2546
     2547        return $retval;
    25382548}
    25392549
    25402550/**
    function bp_is_group_forum_topic_edit() { 
    25672577 * @return bool True if the current page is part of a group's Members page.
    25682578 */
    25692579function bp_is_group_members() {
    2570         return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) );
     2580        $retval = false;
     2581
     2582        if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) ) {
     2583                $retval = true;
     2584        }
     2585
     2586        if ( bp_is_group_home() && ! bp_is_active( 'activity' ) && ! bp_is_group_custom_front() ) {
     2587                $retval = true;
     2588        }
     2589
     2590        return $retval;
    25712591}
    25722592
    25732593/**
    function bp_is_group_single() { 
    26152635}
    26162636
    26172637/**
     2638 * Is the current group page a custom front?
     2639 *
     2640 * @since 2.4.0
     2641 *
     2642 * @return bool True if the current group page is a custom front.
     2643 */
     2644function bp_is_group_custom_front() {
     2645        $bp = buddypress();
     2646        return (bool) bp_is_group_home() && ! empty( $bp->groups->current_group->front_template );
     2647}
     2648
     2649/**
    26182650 * Is the current page the Create a Blog page?
    26192651 *
    26202652 * Eg http://example.com/sites/create/.
  • src/bp-groups/bp-groups-loader.php

    diff --git src/bp-groups/bp-groups-loader.php src/bp-groups/bp-groups-loader.php
    index c5f6f05..02337d1 100644
    class BP_Groups_Component extends BP_Component { 
    251251                                $this->current_group->user_has_access = true;
    252252                        }
    253253
     254                        // Check once if the current group has a custom front template
     255                        $this->current_group->front_template = bp_groups_get_group_front_template( $this->current_group );
     256
    254257                // Set current_group to 0 to prevent debug errors
    255258                } else {
    256259                        $this->current_group = 0;
    class BP_Groups_Component extends BP_Component { 
    364367
    365368                $bp = buddypress();
    366369
     370                // If the activity component is not active and the current group has no custom front, members are displayed in the home nav
     371                if ( 'members' === $this->default_extension && ! bp_is_active( 'activity' ) && ! $this->current_group->front_template ) {
     372                        $this->default_extension = 'home';
     373                }
     374
    367375                if ( ! bp_current_action() ) {
    368376                        $bp->current_action = $this->default_extension;
    369377                }
    class BP_Groups_Component extends BP_Component { 
    520528                                );
    521529                        }
    522530
    523                         $sub_nav[] = array(
    524                                 'name'            => sprintf( _x( 'Members <span>%s</span>', 'My Group screen nav', 'buddypress' ), number_format( $this->current_group->total_member_count ) ),
    525                                 'slug'            => 'members',
    526                                 'parent_url'      => $group_link,
    527                                 'parent_slug'     => $this->current_group->slug,
    528                                 'screen_function' => 'groups_screen_group_members',
    529                                 'position'        => 60,
    530                                 'user_has_access' => $this->current_group->user_has_access,
    531                                 'item_css_id'     => 'members',
    532                                 'no_access_url'   => $group_link,
    533                         );
     531                        if ( $this->current_group->front_template || bp_is_active( 'activity' ) ) {
     532                                /**
     533                                 * Only add the members subnav if it's not the home's nav
     534                                 */
     535                                $sub_nav[] = array(
     536                                        'name'            => sprintf( _x( 'Members <span>%s</span>', 'My Group screen nav', 'buddypress' ), number_format( $this->current_group->total_member_count ) ),
     537                                        'slug'            => 'members',
     538                                        'parent_url'      => $group_link,
     539                                        'parent_slug'     => $this->current_group->slug,
     540                                        'screen_function' => 'groups_screen_group_members',
     541                                        'position'        => 60,
     542                                        'user_has_access' => $this->current_group->user_has_access,
     543                                        'item_css_id'     => 'members',
     544                                        'no_access_url'   => $group_link,
     545                                );
     546
     547                                /**
     548                                 * If the theme is using a custom front, create
     549                                 * an activity nav
     550                                 */
     551                                if ( $this->current_group->front_template && bp_is_active( 'activity' ) ) {
     552                                        $sub_nav[] = array(
     553                                                'name'            => _x( 'Activity', 'My Group screen nav', 'buddypress' ),
     554                                                'slug'            => 'activity',
     555                                                'parent_url'      => $group_link,
     556                                                'parent_slug'     => $this->current_group->slug,
     557                                                'screen_function' => 'groups_screen_group_activity',
     558                                                'position'        => 50,
     559                                                'user_has_access' => $this->current_group->user_has_access,
     560                                                'item_css_id'     => 'activity',
     561                                                'no_access_url'   => $group_link,
     562                                        );
     563                                }
     564                        }
    534565
    535566                        if ( bp_is_active( 'friends' ) && bp_groups_user_can_send_invites() ) {
    536567                                $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 1477c00..ae309cb 100644
    function groups_screen_group_request_membership() { 
    742742}
    743743
    744744/**
     745 * Handle the loading of a single group's activity.
     746 *
     747 * @since 2.4.0
     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 2.4.0
     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 2.4.0
     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 0e3ec0a..4dbbb33 100644
    function bp_group_member_admin_pagination() { 
    43234323        }
    43244324
    43254325/**
     4326 * Load the appropriate current group's home page
     4327 *
     4328 * @since 2.4.0
     4329 */
     4330function bp_groups_load_group_front_template( $require_once = false, $group = null ) {
     4331        $located = bp_groups_get_group_front_template( $group );
     4332
     4333        if ( false !== $located ) {
     4334                $slug = str_replace( '.php', '', $located );
     4335
     4336                /**
     4337                 * Let plugins adding an action to bp_get_template_part get it from here
     4338                 *
     4339                 * @param string $slug Template part slug requested.
     4340                 * @param string $name Template part name requested.
     4341                 */
     4342                do_action( 'get_template_part_' . $slug, $slug, false );
     4343
     4344                load_template( $located, $require_once );
     4345
     4346        } else if ( bp_is_active( 'activity' ) ) {
     4347                bp_get_template_part( 'groups/single/activity' );
     4348
     4349        } else if ( bp_is_active( 'members'  ) ) {
     4350                bp_groups_members_template_part();
     4351        }
     4352
     4353        return $located;
     4354}
     4355
     4356/**
     4357 * Locate a custom group front template if it exsists
     4358 *
     4359 * @since 2.4.0
     4360 */
     4361function bp_groups_get_group_front_template( $group = null ) {
     4362        if ( ! is_a( $group, 'BP_Groups_Group' ) ) {
     4363                $group = groups_get_current_group();
     4364        }
     4365
     4366        if ( ! isset( $group->id ) ) {
     4367                return false;
     4368        }
     4369
     4370        if ( isset( $group->front_template ) ) {
     4371                return $group->front_template;
     4372        }
     4373
     4374        $template_names = apply_filters( 'bp_groups_get_front_template', array(
     4375                'groups/single/front-id-'     . sanitize_file_name( $group->id )     . '.php',
     4376                'groups/single/front-slug-'   . sanitize_file_name( $group->slug )   . '.php',
     4377                'groups/single/front-status-' . sanitize_file_name( $group->status ) . '.php',
     4378                'groups/single/front.php'
     4379        ) );
     4380
     4381        return bp_locate_template( $template_names, false, true );
     4382}
     4383
     4384/**
    43264385 * Output the Group members template
    43274386 *
    43284387 * @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 9a2da4c..5993eaf 100644
     
    6767                                </div>
    6868                                <input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" />
    6969
    70                         <?php elseif ( bp_is_group_home() ) : ?>
     70                        <?php elseif ( bp_is_group_activity() ) : ?>
    7171
    7272                                <input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" />
    7373                                <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 6e2727c..67a8be9 100644
     
    5959
    6060                                if ( bp_group_is_visible() ) {
    6161
    62                                         // Use custom front if one exists
    63                                         $custom_front = bp_locate_template( array( 'groups/single/front.php' ), false, true );
    64                                         if     ( ! empty( $custom_front   ) ) : load_template( $custom_front, true );
    65 
    66                                         // Default to activity
    67                                         elseif ( bp_is_active( 'activity' ) ) : bp_get_template_part( 'groups/single/activity' );
    68 
    69                                         // Otherwise show members
    70                                         elseif ( bp_is_active( 'members'  ) ) : bp_groups_members_template_part();
    71 
    72                                         endif;
     62                                        // Load appropriate front template
     63                                        bp_groups_load_group_front_template();
    7364
    7465                                } else {
    7566