Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/29/2016 07:38:58 PM (8 years ago)
Author:
boonebgorges
Message:

Discard activity filter values that are invalid for the current context.

Activity filters are stored in a cookie that persists across
activity pages. But some filter values are not valid in all contexts,
such as new_member (valid in the sitewide feed, but not in a group).
This changeset ensures that filter values sent via AJAX are discarded
if they aren't valid in the current context.

Props lakrisgubben.
Fixes #4062.

File:
1 edited

Legend:

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

    r11351 r11356  
    38013801     */
    38023802    function bp_get_activity_show_filters( $context = '' ) {
    3803         // Set default context based on current page.
    3804         if ( empty( $context ) ) {
    3805 
    3806             // On member pages, default to 'member', unless this
    3807             // is a user's Groups activity.
    3808             if ( bp_is_user() ) {
    3809                 if ( bp_is_active( 'groups' ) && bp_is_current_action( bp_get_groups_slug() ) ) {
    3810                     $context = 'member_groups';
    3811                 } else {
    3812                     $context = 'member';
    3813                 }
    3814 
    3815             // On individual group pages, default to 'group'.
    3816             } elseif ( bp_is_active( 'groups' ) && bp_is_group() ) {
    3817                 $context = 'group';
    3818 
    3819             // 'activity' everywhere else.
    3820             } else {
    3821                 $context = 'activity';
     3803        $filters = array();
     3804        $actions = bp_activity_get_actions_for_context( $context );
     3805        foreach ( $actions as $action ) {
     3806            // Friends activity collapses two filters into one.
     3807            if ( in_array( $action['key'], array( 'friendship_accepted', 'friendship_created' ) ) ) {
     3808                $action['key'] = 'friendship_accepted,friendship_created';
    38223809            }
    3823         }
    3824 
    3825         $filters = array();
    3826 
    3827         // Walk through the registered actions, and prepare an the
    3828         // select box options.
    3829         foreach ( bp_activity_get_actions() as $actions ) {
    3830             foreach ( $actions as $action ) {
    3831                 if ( ! in_array( $context, (array) $action['context'] ) ) {
    3832                     continue;
    3833                 }
    3834 
    3835                 // Friends activity collapses two filters into one.
    3836                 if ( in_array( $action['key'], array( 'friendship_accepted', 'friendship_created' ) ) ) {
    3837                     $action['key'] = 'friendship_accepted,friendship_created';
    3838                 }
    3839 
    3840                 $filters[ $action['key'] ] = $action['label'];
    3841             }
     3810
     3811            $filters[ $action['key'] ] = $action['label'];
    38423812        }
    38433813
Note: See TracChangeset for help on using the changeset viewer.