Skip to:
Content

BuddyPress.org

Ticket #6169: 6169.diff

File 6169.diff, 2.7 KB (added by boonebgorges, 11 years ago)
  • src/bp-activity/bp-activity-template.php

    diff --git src/bp-activity/bp-activity-template.php src/bp-activity/bp-activity-template.php
    index b2f8036..12524a3 100644
    function bp_has_activities( $args = '' ) { 
    622622        if ( empty( $search_terms ) && ! empty( $_REQUEST['s'] ) )
    623623                $search_terms = $_REQUEST['s'];
    624624
    625         // Set some default arguments when using a scope
    626         if ( ! empty( $scope ) ) {
     625        // A number of pre-defined scopes require specific values for user_id and show_hidden.
     626        if ( $scope && in_array( $scope, array( 'just-me', 'friends', 'groups', 'favorites', 'mentions' ) ) ) {
    627627                // Determine which user ID applies
    628628                if ( empty( $user_id ) ) {
    629629                        $user_id = bp_displayed_user_id() ? bp_displayed_user_id() : bp_loggedin_user_id();
  • tests/phpunit/testcases/activity/template.php

    diff --git tests/phpunit/testcases/activity/template.php tests/phpunit/testcases/activity/template.php
    index f61a61b..cca9e64 100644
    class BP_Tests_Activity_Template extends BP_UnitTestCase { 
    858858        }
    859859
    860860        /**
     861         * @group BP6169
     862         */
     863        public function test_bp_has_activities_private_group_home_scope() {
     864                global $activities_template;
     865                $bp = buddypress();
     866                $reset_current_group = $bp->groups->current_group;
     867                $reset_current_action = $bp->current_action;
     868
     869                $u1 = $this->factory->user->create();
     870                $u2 = $this->factory->user->create();
     871                $u3 = $this->factory->user->create();
     872
     873                $this->set_current_user( $u1 );
     874
     875                $g = $this->factory->group->create( array(
     876                        'status' => 'private',
     877                ) );
     878
     879                groups_join_group( $g, $u2 );
     880                groups_join_group( $g, $u3 );
     881
     882                $a1 = $this->factory->activity->create( array(
     883                        'component' => $bp->groups->id,
     884                        'item_id'   => $g,
     885                        'type'      => 'activity_update',
     886                        'user_id'   => $u2,
     887                        'content'   => 'foo bar',
     888                ) );
     889
     890                $a2 = $this->factory->activity->create( array(
     891                        'component' => $bp->groups->id,
     892                        'item_id'   => $g,
     893                        'type'      => 'activity_update',
     894                        'user_id'   => $u3,
     895                        'content'   => 'bar foo',
     896                ) );
     897
     898                $bp->groups->current_group = groups_get_group( array(
     899                        'group_id'        => $g,
     900                        'populate_extras' => true,
     901                ) );
     902
     903                // On group's home the scope is set to 'home'
     904                $bp->current_action = 'home';
     905
     906                bp_has_activities( array( 'action' => 'activity_update' ) );
     907
     908                $this->assertEqualSets( array( $a1, $a2 ), wp_list_pluck( $activities_template->activities, 'id' ) );
     909
     910                // clean up!
     911                $activities_template = null;
     912                $bp->groups->current_group = $reset_current_group;
     913                $bp->current_action = $reset_current_action;
     914        }
     915
     916        /**
    861917         * Integration test for 'meta_query' param
    862918         */
    863919        function test_bp_has_activities_with_meta_query() {