Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/19/2013 08:37:02 PM (9 years ago)
Author:
boonebgorges
Message:

In bp_has_activities(), allow 'favorites' to be filtered by 'Show' dropdown

Switching the 'favorites' logic to interpret the favorite ids as part of the
'in' parameter rather than the 'include' paramater allows other filter params,
including those in the 'Show' dropdown on activity directories (the 'action'
parameter of bp_has_activities()) to work.

Fixes #4872

Props chroniko

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/testcases/activity/template.php

    r6907 r6926  
    5757    }
    5858
     59
     60    /**
     61     * Make sure that action filters ('activity_update', etc) work when
     62     * limiting query to user favorites
     63     *
     64     * @ticket BP4872
     65     */
     66    public function test_bp_has_activities_favorites_action_filter() {
     67        $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) );
     68
     69        $a1 = $this->factory->activity->create( array(
     70            'type' => 'activity_update',
     71        ) );
     72
     73        $a2 = $this->factory->activity->create( array(
     74            'type' => 'joined_group',
     75        ) );
     76
     77        bp_activity_add_user_favorite( $a1->id, $user_id );
     78        bp_activity_add_user_favorite( $a2->id, $user_id );
     79
     80        // groan. It sucks that you have to invoke the global
     81        global $activities_template;
     82
     83        // Case 1: no action filter
     84        bp_has_activities( array(
     85            'user_id' => $user_id,
     86            'scope' => 'favorites',
     87        ) );
     88
     89        // The formatting of $activities_template->activities is messed
     90        // up, so we're just going to look at the IDs. This should be
     91        // fixed in BP at some point
     92        $ids = wp_list_pluck( $activities_template->activities, 'id' );
     93
     94        $this->assertEquals( $ids, array( $a1->id, $a2->id ) );
     95
     96        $activities_template = null;
     97
     98        // Case 2: action filter
     99        bp_has_activities( array(
     100            'user_id' => $user_id,
     101            'scope' => 'favorites',
     102            'action' => 'activity_update',
     103        ) );
     104
     105        global $wpdb, $bp;
     106
     107        $ids = wp_list_pluck( $activities_template->activities, 'id' );
     108
     109        $this->assertEquals( $ids, array( $a1->id ) );
     110
     111        $activities_template = null;
     112    }
    59113}
Note: See TracChangeset for help on using the changeset viewer.