Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/28/2015 10:50:33 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Move $user_id abstraction out of bp_get_activities() and into their respective scope filters.

This fixes a regression from Activity Query scope improvements causing private and hidden group activity queries to intersect with user ID's, resulting in unexpected activity stream items being displayed.

Tests included in r9405.

Props r-a-y. Fixes #6169.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-activity.php

    r9372 r9406  
    243243 * @return array
    244244 */
    245 function bp_groups_filter_activity_scope( $retval, $filter ) {
    246     $groups = groups_get_user_groups( $filter['user_id'] );
    247 
     245function bp_groups_filter_activity_scope( $retval = array(), $filter = array() ) {
     246
     247    // Determine the user_id
     248    if ( ! empty( $filter['user_id'] ) ) {
     249        $user_id = $filter['user_id'];
     250    } else {
     251        $user_id = bp_displayed_user_id()
     252            ? bp_displayed_user_id()
     253            : bp_loggedin_user_id();
     254    }
     255
     256    // Determine groups of user
     257    $groups = groups_get_user_groups( $user_id );
    248258    if ( empty( $groups['groups'] ) ) {
    249259        $groups = array( 'groups' => 0 );
    250260    }
    251261
    252     $retval= array(
     262    // Should we show all items regardless of sitewide visibility?
     263    $show_hidden = array();
     264    if ( ! empty( $user_id ) && ( $user_id !== bp_loggedin_user_id() ) ) {
     265        $show_hidden = array(
     266            'column' => 'hide_sitewide',
     267            'value'  => 0
     268        );
     269    }
     270
     271    $retval = array(
    253272        'relation' => 'AND',
    254273        array(
    255             'column' => 'component',
    256             'value'  => buddypress()->groups->id
     274            'relation' => 'AND',
     275            array(
     276                'column' => 'component',
     277                'value'  => buddypress()->groups->id
     278            ),
     279            array(
     280                'column'  => 'item_id',
     281                'compare' => 'IN',
     282                'value'   => (array) $groups['groups']
     283            ),
    257284        ),
    258         array(
    259             'column'  => 'item_id',
    260             'compare' => 'IN',
    261             'value'   => (array) $groups['groups']
     285        $show_hidden,
     286
     287        // overrides
     288        'override' => array(
     289            'filter'      => array( 'user_id' => 0 ),
     290            'show_hidden' => true
    262291        ),
    263292    );
    264 
    265     // wipe out the user ID
    266     $retval['override']['filter']['user_id'] = 0;
    267293
    268294    return $retval;
Note: See TracChangeset for help on using the changeset viewer.