Skip to:
Content

BuddyPress.org

Ticket #6388: 6388.06.patch

File 6388.06.patch, 13.4 KB (added by imath, 10 years ago)
  • src/bp-activity/bp-activity-functions.php

    diff --git src/bp-activity/bp-activity-functions.php src/bp-activity/bp-activity-functions.php
    index 30f4bef..8bcc546 100644
    function bp_embed_activity_save_cache( $cache, $cachekey, $id ) { 
    31043104 * @uses bp_is_activity_heartbeat_active() to check if heartbeat setting is on.
    31053105 * @uses bp_is_activity_directory() to check if the current page is the activity
    31063106 *       directory.
    3107  * @uses bp_is_active() to check if the group component is active.
    31083107 * @uses bp_is_group_activity() to check if on a single group, the current page
    31093108 *       is the group activities.
    3110  * @uses bp_is_group_home() to check if the current page is a single group home
    3111  *       page.
    31123109 *
    31133110 * @return bool True if activity heartbeat is enabled, otherwise false.
    31143111 */
    function bp_activity_do_heartbeat() { 
    31193116                return $retval;
    31203117        }
    31213118
    3122         if ( bp_is_activity_directory() ) {
     3119        if ( bp_is_activity_directory() || bp_is_group_activity() ) {
    31233120                $retval = true;
    31243121        }
    31253122
    3126         if ( bp_is_active( 'groups') ) {
    3127                 // If no custom front, then activities are loaded in group's home
    3128                 $has_custom_front = bp_locate_template( array( 'groups/single/front.php' ), false, true );
    3129 
    3130                 if ( bp_is_group_activity() || ( ! $has_custom_front && bp_is_group_home() ) ) {
    3131                         $retval = true;
    3132                 }
    3133         }
    3134 
    31353123        return $retval;
    31363124}
  • src/bp-core/bp-core-template.php

    diff --git src/bp-core/bp-core-template.php src/bp-core/bp-core-template.php
    index be74901..93e0bb5 100644
    function bp_is_group_forum() { 
    25522552 * @return True if the current page is a group's activity page.
    25532553 */
    25542554function bp_is_group_activity() {
    2555         return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) );
     2555        $retval = false;
     2556
     2557        if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) ) {
     2558                $retval = true;
     2559        }
     2560
     2561        if ( bp_is_group_home() && bp_is_active( 'activity' ) && ! bp_is_group_custom_front() ) {
     2562                $retval = true;
     2563        }
     2564
     2565        return $retval;
    25562566}
    25572567
    25582568/**
    function bp_is_group_forum_topic_edit() { 
    25852595 * @return bool True if the current page is part of a group's Members page.
    25862596 */
    25872597function bp_is_group_members() {
    2588         return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) );
     2598        $retval = false;
     2599
     2600        if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) ) {
     2601                $retval = true;
     2602        }
     2603
     2604        if ( bp_is_group_home() && ! bp_is_active( 'activity' ) && ! bp_is_group_custom_front() ) {
     2605                $retval = true;
     2606        }
     2607
     2608        return $retval;
    25892609}
    25902610
    25912611/**
    function bp_is_group_single() { 
    26332653}
    26342654
    26352655/**
     2656 * Is the current group page a custom front?
     2657 *
     2658 * @since 2.4.0
     2659 *
     2660 * @return bool True if the current group page is a custom front.
     2661 */
     2662function bp_is_group_custom_front() {
     2663        $bp = buddypress();
     2664        return (bool) bp_is_group_home() && ! empty( $bp->groups->current_group->front_template );
     2665}
     2666
     2667/**
    26362668 * Is the current page the Create a Blog page?
    26372669 *
    26382670 * Eg http://example.com/sites/create/.
  • src/bp-groups/bp-groups-filters.php

    diff --git src/bp-groups/bp-groups-filters.php src/bp-groups/bp-groups-filters.php
    index 0e53571..470ce9b 100644
    function bp_groups_maybe_load_mentions_scripts( $load_mentions, $mentions_enable 
    269269                return $load_mentions;
    270270        }
    271271
    272         if ( $load_mentions || ( bp_is_group_activity() || bp_is_group_home() ) ) {
     272        if ( $load_mentions || bp_is_group_activity() ) {
    273273                return true;
    274274        }
    275275
  • src/bp-groups/bp-groups-loader.php

    diff --git src/bp-groups/bp-groups-loader.php src/bp-groups/bp-groups-loader.php
    index 3c5653b..d5b698f 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_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 { 
    371374
    372375                $bp = buddypress();
    373376
     377                // If the activity component is not active and the current group has no custom front, members are displayed in the home nav
     378                if ( 'members' === $this->default_extension && ! bp_is_active( 'activity' ) && ! $this->current_group->front_template ) {
     379                        $this->default_extension = 'home';
     380                }
     381
    374382                if ( ! bp_current_action() ) {
    375383                        $bp->current_action = $this->default_extension;
    376384                }
    class BP_Groups_Component extends BP_Component { 
    527535                                );
    528536                        }
    529537
    530                         $sub_nav[] = array(
    531                                 'name'            => sprintf( _x( 'Members <span>%s</span>', 'My Group screen nav', 'buddypress' ), number_format( $this->current_group->total_member_count ) ),
    532                                 'slug'            => 'members',
    533                                 'parent_url'      => $group_link,
    534                                 'parent_slug'     => $this->current_group->slug,
    535                                 'screen_function' => 'groups_screen_group_members',
    536                                 'position'        => 60,
    537                                 'user_has_access' => $this->current_group->user_has_access,
    538                                 'item_css_id'     => 'members',
    539                                 'no_access_url'   => $group_link,
    540                         );
     538                        if ( $this->current_group->front_template || bp_is_active( 'activity' ) ) {
     539                                /**
     540                                 * If the theme is using a custom front, create activity subnav.
     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'        => 11,
     550                                                'user_has_access' => $this->current_group->user_has_access,
     551                                                'item_css_id'     => 'activity',
     552                                                'no_access_url'   => $group_link,
     553                                        );
     554                                }
     555
     556                                /**
     557                                 * Only add the members subnav if it's not the home's nav
     558                                 */
     559                                $sub_nav[] = array(
     560                                        'name'            => sprintf( _x( 'Members <span>%s</span>', 'My Group screen nav', 'buddypress' ), number_format( $this->current_group->total_member_count ) ),
     561                                        'slug'            => 'members',
     562                                        'parent_url'      => $group_link,
     563                                        'parent_slug'     => $this->current_group->slug,
     564                                        'screen_function' => 'groups_screen_group_members',
     565                                        'position'        => 60,
     566                                        'user_has_access' => $this->current_group->user_has_access,
     567                                        'item_css_id'     => 'members',
     568                                        'no_access_url'   => $group_link,
     569                                );
     570                        }
    541571
    542572                        if ( bp_is_active( 'friends' ) && bp_groups_user_can_send_invites() ) {
    543573                                $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 875527f..5ffcbcb 100644
    function groups_screen_group_request_membership() { 
    741741}
    742742
    743743/**
     744 * Handle the loading of a single group's activity.
     745 *
     746 * @since 2.4.0
     747 */
     748function groups_screen_group_activity() {
     749
     750        if ( ! bp_is_single_item() ) {
     751                return false;
     752        }
     753
     754        /**
     755         * Fires before the loading of a single group's activity page.
     756         *
     757         * @since 2.4.0
     758         */
     759        do_action( 'groups_screen_group_activity' );
     760
     761        /**
     762         * Filters the template to load for a single group's activity page.
     763         *
     764         * @since 2.4.0
     765         *
     766         * @param string $value Path to a single group's template to load.
     767         */
     768        bp_core_load_template( apply_filters( 'groups_screen_group_activity', 'groups/single/activity' ) );
     769}
     770
     771/**
    744772 * Handle the display of a single group activity item.
    745773 */
    746774function 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 9cbdcad..9aa5a2d 100644
    function bp_group_member_admin_pagination() { 
    43434343        }
    43444344
    43454345/**
     4346 * Output the contents of the current group's home page.
     4347 *
     4348 * You should only use this when on a single group page.
     4349 *
     4350 * @since 2.4.0
     4351 */
     4352function bp_groups_front_template_part() {
     4353        $located = bp_groups_get_front_template();
     4354
     4355        if ( false !== $located ) {
     4356                $slug = str_replace( '.php', '', $located );
     4357
     4358                /**
     4359                 * Let plugins adding an action to bp_get_template_part get it from here
     4360                 *
     4361                 * @param string $slug Template part slug requested.
     4362                 * @param string $name Template part name requested.
     4363                 */
     4364                do_action( 'get_template_part_' . $slug, $slug, false );
     4365
     4366                load_template( $located, true );
     4367
     4368        } else if ( bp_is_active( 'activity' ) ) {
     4369                bp_get_template_part( 'groups/single/activity' );
     4370
     4371        } else if ( bp_is_active( 'members'  ) ) {
     4372                bp_groups_members_template_part();
     4373        }
     4374
     4375        return $located;
     4376}
     4377
     4378/**
     4379 * Locate a custom group front template if it exists.
     4380 *
     4381 * @since 2.4.0
     4382 *
     4383 * @param  BP_Groups_Group|null $group Optional. Falls back to current group if not passed.
     4384 * @return string|bool                 Path to front template on success; boolean false on failure.
     4385 */
     4386function bp_groups_get_front_template( $group = null ) {
     4387        if ( ! is_a( $group, 'BP_Groups_Group' ) ) {
     4388                $group = groups_get_current_group();
     4389        }
     4390
     4391        if ( ! isset( $group->id ) ) {
     4392                return false;
     4393        }
     4394
     4395        if ( isset( $group->front_template ) ) {
     4396                return $group->front_template;
     4397        }
     4398
     4399        $template_names = apply_filters( 'bp_groups_get_front_template', array(
     4400                'groups/single/front-id-'     . sanitize_file_name( $group->id )     . '.php',
     4401                'groups/single/front-slug-'   . sanitize_file_name( $group->slug )   . '.php',
     4402                'groups/single/front-status-' . sanitize_file_name( $group->status ) . '.php',
     4403                'groups/single/front.php'
     4404        ) );
     4405
     4406        return bp_locate_template( $template_names, false, true );
     4407}
     4408
     4409/**
    43464410 * Output the Group members template
    43474411 *
    43484412 * @since 2.0.0
  • src/bp-templates/bp-legacy/buddypress-functions.php

    diff --git src/bp-templates/bp-legacy/buddypress-functions.php src/bp-templates/bp-legacy/buddypress-functions.php
    index 2532123..d5c436e 100644
    function bp_legacy_theme_post_update() { 
    925925                exit( '-1<div id="message" class="error bp-ajax-message"><p>' . __( 'Please enter some content to post.', 'buddypress' ) . '</p></div>' );
    926926
    927927        $activity_id = 0;
    928         if ( empty( $_POST['object'] ) && bp_is_active( 'activity' ) ) {
     928        $item_id     = 0;
     929        $object      = '';
     930
     931
     932        // Try to get the item id from posted variables.
     933        if ( ! empty( $_POST['item_id'] ) ) {
     934                $item_id = (int) $_POST['item_id'];
     935        }
     936
     937        // Try to get the object from posted variables.
     938        if ( ! empty( $_POST['object'] ) ) {
     939                $object  = sanitize_key( $_POST['object'] );
     940
     941        // If the object is not set and we're in a group, set the item id and the object
     942        } elseif ( bp_is_group() ) {
     943                $item_id = bp_get_current_group_id();
     944                $object = 'groups';
     945        }
     946
     947        if ( ! $object && bp_is_active( 'activity' ) ) {
    929948                $activity_id = bp_activity_post_update( array( 'content' => $_POST['content'] ) );
    930949
    931         } elseif ( $_POST['object'] == 'groups' ) {
    932                 if ( ! empty( $_POST['item_id'] ) && bp_is_active( 'groups' ) )
    933                         $activity_id = groups_post_update( array( 'content' => $_POST['content'], 'group_id' => $_POST['item_id'] ) );
     950        } elseif ( 'groups' === $object ) {
     951                if ( $item_id && bp_is_active( 'groups' ) )
     952                        $activity_id = groups_post_update( array( 'content' => $_POST['content'], 'group_id' => $item_id ) );
    934953
    935954        } else {
    936955
    937956                /** This filter is documented in bp-activity/bp-activity-actions.php */
    938                 $activity_id = apply_filters( 'bp_activity_custom_update', false, $_POST['object'], $_POST['item_id'], $_POST['content'] );
     957                $activity_id = apply_filters( 'bp_activity_custom_update', false, $object, $item_id, $_POST['content'] );
    939958        }
    940959
    941960        if ( empty( $activity_id ) )
  • 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 fb4f175..5632973 100644
     
    6666                                </div>
    6767                                <input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" />
    6868
    69                         <?php elseif ( bp_is_group_home() ) : ?>
     69                        <?php elseif ( bp_is_group_activity() ) : ?>
    7070
    7171                                <input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" />
    7272                                <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 5097547..94dc19a 100644
     
    6868
    6969                                if ( bp_group_is_visible() ) {
    7070
    71                                         // Use custom front if one exists
    72                                         $custom_front = bp_locate_template( array( 'groups/single/front.php' ), false, true );
    73                                         if     ( ! empty( $custom_front   ) ) : load_template( $custom_front, true );
    74 
    75                                         // Default to activity
    76                                         elseif ( bp_is_active( 'activity' ) ) : bp_get_template_part( 'groups/single/activity' );
    77 
    78                                         // Otherwise show members
    79                                         elseif ( bp_is_active( 'members'  ) ) : bp_groups_members_template_part();
    80 
    81                                         endif;
     71                                        // Load appropriate front template
     72                                        bp_groups_front_template_part();
    8273
    8374                                } else {
    8475