Skip to:
Content

BuddyPress.org

Ticket #1793: move_theme_cookies.diff

File move_theme_cookies.diff, 23.6 KB (added by MrMaz, 16 years ago)

diffed this directly with svn

  • bp-themes/bp-default/groups/groups-loop.php

     
    22
    33<?php do_action( 'bp_before_groups_loop' ) ?>
    44
    5 <?php if ( bp_has_groups( bp_ajax_querystring() ) ) : ?>
     5<?php if ( bp_has_groups( bp_dtheme_ajax_querystring( 'groups' ) ) ) : ?>
    66
    77        <div class="pagination">
    88
  • bp-themes/bp-default/members/members-loop.php

     
    22
    33<?php do_action( 'bp_before_members_loop' ) ?>
    44
    5 <?php if ( bp_has_members( bp_ajax_querystring() ) ) : ?>
     5<?php if ( bp_has_members( bp_dtheme_ajax_querystring( 'members' ) ) ) : ?>
    66
    77        <div class="pagination">
    88
  • bp-themes/bp-default/activity/activity-loop.php

     
    22
    33<?php do_action( 'bp_before_activity_loop' ) ?>
    44
    5 <?php if ( bp_has_activities( bp_ajax_querystring() ) ) : ?>
     5<?php if ( bp_has_activities( bp_dtheme_ajax_querystring( 'activity' ) ) ) : ?>
    66
    77        <?php /* Show pagination if JS is not enabled, since the "Load More" link will do nothing */ ?>
    88        <noscript>
  • bp-themes/bp-default/blogs/blogs-loop.php

     
    22
    33<?php do_action( 'bp_before_blogs_loop' ) ?>
    44
    5 <?php if ( bp_has_blogs( bp_ajax_querystring() ) ) : ?>
     5<?php if ( bp_has_blogs( bp_dtheme_ajax_querystring( 'blogs' ) ) ) : ?>
    66
    77        <div class="pagination">
    88
  • bp-themes/bp-default/_inc/ajax.php

     
    99 * your own _inc/ajax.php file and add/remove AJAX functionality as you see fit.
    1010 */
    1111
     12function bp_dtheme_ajax_querystring( $object = null ) {
     13        global $bp;
     14
     15        /* Backwards and forwards compatibility */
     16        if ( empty( $object ) ) {
     17                // no object? just return it
     18                return apply_filters( 'bp_dtheme_ajax_querystring', bp_ajax_querystring() );
     19        }
     20
     21        /* Handle content filtering for the THEME */
     22        $c_scope = 'bp-' . $object . '-scope';
     23        $c_filter = 'bp-' . $object . '-filter';
     24
     25        $scope = ( !empty( $_COOKIE[$c_scope] ) ) ? $_COOKIE[$c_scope] : null;
     26        $filter = ( !empty( $_COOKIE[$c_filter] ) && '-1' != $_COOKIE[$c_filter] ) ? $_COOKIE[$c_filter] : null;
     27
     28        $defaults = array(
     29                'object' => $object,
     30                'scope' => $scope,
     31                'type' => $filter
     32        );
     33
     34        // Do pre-filtering
     35        $r = wp_parse_args( bp_ajax_querystring(), $defaults );
     36        $pre_filtered_querystring = apply_filters( 'bp_dtheme_ajax_querystring_' . $object . '_filter', http_build_query($r) );
     37
     38        // Return after global filter applied
     39        return apply_filters( 'bp_dtheme_ajax_querystring', $pre_filtered_querystring );
     40}
     41
     42/* Personal filtering */
     43function bp_dtheme_ajax_querystring_filter_personal( $query_string ) {
     44        global $bp;
     45
     46        $r = wp_parse_args( $query_string );
     47        extract($r);
     48
     49        if ( !empty( $bp->displayed_user->id ) || 'personal' == $scope ) {
     50                $r['user_id'] = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
     51                return http_build_query($r);
     52        } else {
     53                return $query_string;
     54        }
     55}
     56add_filter( 'bp_dtheme_ajax_querystring_groups_filter', 'bp_dtheme_ajax_querystring_filter_personal', 1 );
     57add_filter( 'bp_dtheme_ajax_querystring_forums_filter', 'bp_dtheme_ajax_querystring_filter_personal', 1 );
     58add_filter( 'bp_dtheme_ajax_querystring_members_filter', 'bp_dtheme_ajax_querystring_filter_personal', 1 );
     59add_filter( 'bp_dtheme_ajax_querystring_blogs_filter', 'bp_dtheme_ajax_querystring_filter_personal', 1 );
     60
     61/* Activity filtering */
     62function bp_dtheme_ajax_querystring_activity_filter_scope( $query_string ) {
     63        global $bp;
     64
     65        $r = wp_parse_args( $query_string );
     66        extract($r);
     67
     68        /* User filtering */
     69        if ( !empty( $bp->displayed_user->id ) )
     70                $user_id = $bp->displayed_user->id;
     71
     72        /* Action filtering */
     73        if ( !empty( $filter ) && '-1' != $filter )
     74                $r['action'] = $filter;
     75
     76        /* User activity scope filtering */
     77        if ( !empty( $user_id ) || !empty( $scope ) ) {
     78
     79                $current_user_id = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
     80
     81                if ( empty( $scope ) || 'just-me' == $scope )
     82                        $r['display_comments'] = 'stream';
     83
     84                switch ( $scope ) {
     85                        case BP_FRIENDS_SLUG:
     86                                if ( function_exists( 'friends_get_friend_user_ids' ) )
     87                                        $r['user_id'] = implode( ',', (array)friends_get_friend_user_ids( $current_user_id ) );
     88                                break;
     89                        case BP_GROUPS_SLUG:
     90                                if ( function_exists( 'groups_get_user_groups' ) ) {
     91                                        $groups = groups_get_user_groups( $current_user_id );
     92                                        $r['object'] = $bp->groups->id;
     93                                        $r['primary_id'] = implode( ',', (array)$groups['groups'] );
     94                                        $r['show_hidden'] = ( $current_user_id == $bp->loggedin_user->id ) ? 1 : 0;
     95                                        $r['user_id'] = false;
     96                                }
     97                                break;
     98                        case 'favorites':
     99                                $favs = bp_activity_get_user_favorites( $current_user_id );
     100                                $r['include'] = implode( ',', (array)$favs );
     101                                $r['show_hidden'] = ( $current_user_id == $bp->loggedin_user->id ) ? 1 : 0;
     102                                break;
     103                        case 'mentions':
     104                                $user_nicename = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->userdata->user_nicename : $bp->loggedin_user->userdata->user_nicename;
     105                                $user_login = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->userdata->user_login : $bp->loggedin_user->userdata->user_login;
     106                                $r['search_terms'] = '@' . bp_core_get_username( $current_user_id, $user_nicename, $user_login );
     107                                $r['show_hidden'] = ( $current_user_id == $bp->loggedin_user->id ) ? 1 : 0;
     108                                $r['display_comments'] = 'stream';
     109                                $r['user_id'] = false;
     110                                break;
     111                }
     112        }
     113
     114        /* Group filtering */
     115        if ( !empty( $bp->groups->current_group ) ) {
     116
     117                $r['object'] = $bp->groups->id;
     118                $r['primary_id'] = $bp->groups->current_group->id;
     119
     120                /* If we're viewing a non-private group and the user is a member, show the hidden activity for the group */
     121                if ( 'public' != $bp->groups->current_group->status && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
     122                        $r['show_hidden'] = 1;
     123        }
     124
     125        /* Support for permalinks on single item pages: /groups/my-group/activity/124/ */
     126        if ( $bp->current_action == $bp->activity->slug )
     127                $r['include'] = $bp->action_variables[0];
     128
     129        return http_build_query($r);
     130}
     131add_filter( 'bp_dtheme_ajax_querystring_activity_filter', 'bp_dtheme_ajax_querystring_activity_filter_scope', 1 );
     132
    12133function bp_dtheme_object_filter() {
    13134        global $bp;
    14135
     
    30151                $search_terms = false;
    31152
    32153        /* Build the querystring */
    33         if ( empty( $filter ) )
    34                 $filter = 'active';
     154        $querystring_args =
     155                array(
     156                        'object' => $object,
     157                        'scope' => $scope,
     158                        'filter' => empty( $filter ) ? 'active' : $filter,
     159                        'page' => empty( $page ) ? 1 : $page
     160                );
    35161
    36         $bp->ajax_querystring = 'type=' . $filter . '&page=' . $page;
    37 
    38162        if ( !empty( $search_terms ) )
    39                 $bp->ajax_querystring .= '&search_terms=' . $search_terms;
     163                $querystring_args['search_terms'] = $search_terms;
    40164
    41         if ( $scope == 'personal' || $bp->displayed_user->id ) {
    42                 $user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
    43                 $bp->ajax_querystring .= '&user_id=' . $user_id;
    44         }
     165        bp_set_ajax_querystring( apply_filters( 'bp_dtheme_ajax_querystring_content_filter', http_build_query($querystring_args), $extras ) );
    45166
    46         $bp->ajax_querystring = apply_filters( 'bp_dtheme_ajax_querystring_content_filter', $bp->ajax_querystring, $extras );
    47 
    48167        locate_template( array( "$object/$object-loop.php" ), true );
    49168}
    50169add_action( 'wp_ajax_members_filter', 'bp_dtheme_object_filter' );
     
    180299function bp_dtheme_activity_loop( $scope = false, $filter = false, $per_page = 20, $page = 1 ) {
    181300        global $bp;
    182301
    183         /* If we are on a profile page we only want to show that users activity */
    184         if ( $bp->displayed_user->id ) {
    185                 $query_string = 'user_id=' . $bp->displayed_user->id;
    186         } else {
     302        /* Build the querystring */
     303        $querystring_args =
     304                array(
     305                        'object' => 'activity',
     306                        'scope' => $scope,
     307                        'filter' => $filter,
     308                        'per_page' => $per_page,
     309                        'page' => $page,
     310                );
     311
     312        /* If we are NOT on a profile page we need to determine the feed url */
     313        if ( !$bp->displayed_user->id ) {
     314
    187315                if ( !empty( $bp->groups->current_group ) )
    188316                        $scope = 'all';
    189317
     
    191319
    192320                switch ( $scope ) {
    193321                        case BP_FRIENDS_SLUG:
    194                                 $friend_ids = implode( ',', friends_get_friend_user_ids( $bp->loggedin_user->id ) );
    195                                 $query_string = 'user_id=' . $friend_ids;
    196322                                $feed_url = $bp->loggedin_user->domain . BP_ACTIVITY_SLUG . '/' . BP_FRIENDS_SLUG . '/feed/';
    197323                                break;
    198324                        case BP_GROUPS_SLUG:
    199                                 $groups = groups_get_user_groups( $bp->loggedin_user->id );
    200                                 $group_ids = implode( ',', $groups['groups'] );
    201                                 $query_string = 'object=groups&primary_id=' . $group_ids . '&show_hidden=1';
    202325                                $feed_url = $bp->loggedin_user->domain . BP_ACTIVITY_SLUG . '/' . BP_GROUPS_SLUG . '/feed/';
    203326                                break;
    204327                        case 'favorites':
    205                                 $favs = bp_activity_get_user_favorites( $bp->loggedin_user->id );
    206 
    207                                 if ( empty( $favs ) )
    208                                         $favorite_ids = false;
    209 
    210                                 $favorite_ids = implode( ',', (array)$favs );
    211                                 $query_string = 'include=' . $favorite_ids;
    212328                                $feed_url = $bp->loggedin_user->domain  . BP_ACTIVITY_SLUG . '/favorites/feed/';
    213329                                break;
    214330                        case 'mentions':
    215                                 $query_string = 'show_hidden=1&search_terms=@' . bp_core_get_username( $bp->loggedin_user->id, $bp->loggedin_user->userdata->user_nicename, $bp->loggedin_user->userdata->user_login );
    216331                                $feed_url = $bp->loggedin_user->domain . BP_ACTIVITY_SLUG . '/mentions/feed/';
    217 
    218332                                /* Reset the number of new @ mentions for the user */
    219333                                delete_usermeta( $bp->loggedin_user->id, 'bp_new_mention_count' );
    220334                                break;
    221335                }
    222336        }
    223337
    224         /* Build the filter */
    225         if ( $filter && $filter != '-1' )
    226                 $query_string .= '&action=' . $filter;
    227 
    228         /* If we are viewing a group then filter the activity just for this group */
    229         if ( !empty( $bp->groups->current_group ) ) {
    230                 $query_string .= '&object=' . $bp->groups->id . '&primary_id=' . $bp->groups->current_group->id;
    231 
    232                 /* If we're viewing a non-private group and the user is a member, show the hidden activity for the group */
    233                 if ( 'public' != $bp->groups->current_group->status && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
    234                         $query_string .= '&show_hidden=1';
    235         }
    236 
    237         /* Add the per_page param */
    238         $query_string .= '&per_page=' . $per_page;
    239 
    240         /* Add the comments param */
    241         if ( $bp->displayed_user->id || 'mentions' == $scope )
    242                 $query_string .= '&display_comments=stream';
    243         else
    244                 $query_string .= '&display_comments=threaded';
    245 
    246         /* Add the new page param */
    247         $args = explode( '&', trim( $query_string ) );
    248         foreach( (array)$args as $arg ) {
    249                 if ( false === strpos( $arg, 'page' ) )
    250                         $new_args[] = $arg;
    251         }
    252         $query_string = implode( '&', $new_args ) . '&page=' . $page;
    253 
    254         $bp->ajax_querystring = apply_filters( 'bp_dtheme_ajax_querystring_activity_filter', $query_string, $scope );
    255         $result['query_string'] = $bp->ajax_querystring;
     338        bp_set_ajax_querystring( apply_filters( 'bp_dtheme_ajax_querystring_activity_filter', http_build_query($querystring_args), $scope ) );
     339        $result['query_string'] = bp_ajax_querystring();
    256340        $result['feed_url'] = apply_filters( 'bp_dtheme_ajax_feed_url', $feed_url );
    257341
    258342        /* Buffer the loop in the template to a var for JS to spit out. */
  • bp-themes/bp-default/forums/forums-loop.php

     
    1 <?php if ( bp_has_forum_topics( bp_ajax_querystring() ) ) : ?>
     1<?php if ( bp_has_forum_topics( bp_dtheme_ajax_querystring( 'forums' ) ) ) : ?>
    22
    33        <div class="pagination">
    44
  • bp-core/bp-core-templatetags.php

     
    117117function bp_has_members( $args = '' ) {
    118118        global $bp, $members_template;
    119119
    120         /***
    121          * Set the defaults based on the current page. Any of these will be overridden
    122          * if arguments are directly passed into the loop. Custom plugins should always
    123          * pass their parameters directly to the loop.
    124          */
    125         $type = 'active';
    126         $user_id = false;
    127         $page = 1;
    128 
    129         /* User filtering */
    130         if ( !empty( $bp->displayed_user->id ) || 'personal' == $_COOKIE['bp-members-scope'] )
    131                 $user_id = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
    132 
    133         /* Action filtering */
    134         if ( !empty( $_COOKIE['bp-members-filter'] ) && '-1' != $_COOKIE['bp-members-filter'] )
    135                 $type = $_COOKIE['bp-members-filter'];
    136 
    137         if ( !empty( $_COOKIE['bp-members-page'] ) && '-1' != $_COOKIE['bp-members-page'] )
    138                 $page = $_COOKIE['bp-members-page'];
    139 
    140120        // type: active ( default ) | random | newest | popular | online | alphabetical
    141121        $defaults = array(
    142                 'type' => $type,
    143                 'page' => $page,
     122                'type' => 'active',
     123                'page' => 1,
    144124                'per_page' => 20,
    145125                'max' => false,
    146126
    147127                'include' => false, // Pass a user_id or comma separated list of user_ids to only show these users
    148128
    149                 'user_id' => $user_id, // Pass a user_id to only show friends of this user
     129                'user_id' => false, // Pass a user_id to only show friends of this user
    150130                'search_terms' => false, // Pass search_terms to filter users by their profile data
    151131
    152132                'populate_extras' => true // Fetch usermeta? Friend count, last active etc.
     
    13991379        return apply_filters( 'bp_ajax_querystring', $bp->ajax_querystring );
    14001380}
    14011381
     1382function bp_set_ajax_querystring( $string ) {
     1383        global $bp;
     1384
     1385        $bp->ajax_querystring = apply_filters( 'bp_set_ajax_querystring', $string );
     1386}
     1387
    14021388/* Template is_() functions to determine the current page */
    14031389
    14041390function bp_is_active( $component ) {
  • bp-activity/bp-activity-templatetags.php

     
    116116function bp_has_activities( $args = '' ) {
    117117        global $bp, $activities_template;
    118118
    119         /***
    120          * Set the defaults based on the current page. Any of these will be overridden
    121          * if arguments are directly passed into the loop. Custom plugins should always
    122          * pass their parameters directly to the loop.
    123          */
    124         $user_id = false;
    125         $include = false;
    126         $show_hidden = false;
    127         $search_terms = false;
    128         $object = false;
    129         $action = false;
    130         $primary_id = false;
    131         $display_comments = 'threaded';
    132 
    133         /* User filtering */
    134         if ( !empty( $bp->displayed_user->id ) )
    135                 $user_id = $bp->displayed_user->id;
    136 
    137         /* Action filtering */
    138         if ( !empty( $_COOKIE['bp-activity-filter'] ) && '-1' != $_COOKIE['bp-activity-filter'] )
    139                 $action = $_COOKIE['bp-activity-filter'];
    140 
    141         /* User activity scope filtering */
    142         if ( !empty( $user_id ) || !empty( $_COOKIE['bp-activity-scope'] ) ) {
    143                 $scope = ( !empty( $bp->current_action ) ) ? $bp->current_action : $_COOKIE['bp-activity-scope'];
    144                 $current_user_id = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
    145 
    146                 if ( empty( $scope ) || 'just-me' == $scope )
    147                         $display_comments = 'stream';
    148 
    149                 switch ( $scope ) {
    150                         case 'friends':
    151                                 if ( function_exists( 'friends_get_friend_user_ids' ) )
    152                                         $user_id = implode( ',', (array)friends_get_friend_user_ids( $current_user_id ) );
    153                                 break;
    154                         case 'groups':
    155                                 if ( function_exists( 'groups_get_user_groups' ) ) {
    156                                         $groups = groups_get_user_groups( $current_user_id );
    157                                         $object = $bp->groups->id;
    158                                         $primary_id = implode( ',', (array)$groups['groups'] );
    159                                         $show_hidden = ( $current_user_id == $bp->loggedin_user->id ) ? 1 : 0;
    160                                         $user_id = false;
    161                                 }
    162                                 break;
    163                         case 'favorites':
    164                                 $favs = bp_activity_get_user_favorites( $current_user_id );
    165                                 $include = implode( ',', (array)$favs );
    166                                 $show_hidden = ( $current_user_id == $bp->loggedin_user->id ) ? 1 : 0;
    167                                 break;
    168                         case 'mentions':
    169                                 $user_nicename = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->userdata->user_nicename : $bp->loggedin_user->userdata->user_nicename;
    170                                 $user_login = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->userdata->user_login : $bp->loggedin_user->userdata->user_login;
    171                                 $search_terms = '@' . bp_core_get_username( $current_user_id, $user_nicename, $user_login );
    172                                 $show_hidden = ( $current_user_id == $bp->loggedin_user->id ) ? 1 : 0;
    173                                 $display_comments = 'stream';
    174                                 $user_id = false;
    175                                 break;
    176                 }
    177         }
    178 
    179         /* Group filtering */
    180         if ( !empty( $bp->groups->current_group ) ) {
    181                 $object = $bp->groups->id;
    182                 $primary_id = $bp->groups->current_group->id;
    183 
    184                 if ( 'public' != $bp->groups->current_group->status && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
    185                         $show_hidden = true;
    186         }
    187 
    188         /* Support for permalinks on single item pages: /groups/my-group/activity/124/ */
    189         if ( $bp->current_action == $bp->activity->slug )
    190                 $include = $bp->action_variables[0];
    191 
    192119        /* Note: any params used for filtering can be a single value, or multiple values comma separated. */
    193120        $defaults = array(
    194                 'display_comments' => $display_comments, // false for none, stream/threaded - show comments in the stream or threaded under items
    195                 'include' => $include, // pass an activity_id or string of ID's comma separated
     121                'display_comments' => 'threaded', // false for none, stream/threaded - show comments in the stream or threaded under items
     122                'include' => false, // pass an activity_id or string of ID's comma separated
    196123                'sort' => 'DESC', // sort DESC or ASC
    197124                'page' => 1, // which page to load
    198125                'per_page' => 25, // number of items per page
    199126                'max' => false, // max number to return
    200                 'show_hidden' => $show_hidden, // Show activity items that are hidden site-wide?
     127                'show_hidden' => false, // Show activity items that are hidden site-wide?
    201128
    202129                /* Filtering */
    203                 'user_id' => $user_id, // user_id to filter on
    204                 'object' => $object, // object to filter on e.g. groups, profile, status, friends
    205                 'action' => $action, // action to filter on e.g. activity_update, new_forum_post, profile_updated
    206                 'primary_id' => $primary_id, // object ID to filter on e.g. a group_id or forum_id or blog_id etc.
     130                'user_id' => false, // user_id to filter on
     131                'object' => false, // object to filter on e.g. groups, profile, status, friends
     132                'action' => false, // action to filter on e.g. activity_update, new_forum_post, profile_updated
     133                'primary_id' => false, // object ID to filter on e.g. a group_id or forum_id or blog_id etc.
    207134                'secondary_id' => false, // secondary object ID to filter on e.g. a post_id
    208135
    209136                /* Searching */
    210                 'search_terms' => $search_terms // specify terms to search on
     137                'search_terms' => false // specify terms to search on
    211138        );
    212139
    213140        $r = wp_parse_args( $args, $defaults );
  • bp-blogs/bp-blogs-templatetags.php

     
    109109function bp_has_blogs( $args = '' ) {
    110110        global $bp, $blogs_template;
    111111
    112         /***
    113          * Set the defaults based on the current page. Any of these will be overridden
    114          * if arguments are directly passed into the loop. Custom plugins should always
    115          * pass their parameters directly to the loop.
    116          */
    117         $type = 'active';
    118         $user_id = false;
    119         $page = 1;
    120 
    121         /* User filtering */
    122         if ( !empty( $bp->displayed_user->id ) || 'personal' == $_COOKIE['bp-blogs-scope'] )
    123                 $user_id = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
    124 
    125         /* Action filtering */
    126         if ( !empty( $_COOKIE['bp-blogs-filter'] ) && '-1' != $_COOKIE['bp-blogs-filter'] )
    127                 $type = $_COOKIE['bp-blogs-filter'];
    128 
    129         if ( !empty( $_COOKIE['bp-blogs-page'] ) && '-1' != $_COOKIE['bp-blogs-page'] )
    130                 $page = $_COOKIE['bp-blogs-page'];
    131 
    132112        $defaults = array(
    133                 'type' => $type,
    134                 'page' => $page,
     113                'type' => 'active',
     114                'page' => 1,
    135115                'per_page' => 20,
    136116                'max' => false,
    137117
    138                 'user_id' => $user_id, // Pass a user_id to limit to only blogs this user has higher than subscriber access to
     118                'user_id' => false, // Pass a user_id to limit to only blogs this user has higher than subscriber access to
    139119                'search_terms' => false // Pass search terms to filter on the blog title or description.
    140120        );
    141121
  • bp-forums/bp-forums-templatetags.php

     
    155155function bp_has_forum_topics( $args = '' ) {
    156156        global $forum_template, $bp;
    157157
    158         /***
    159          * Set the defaults based on the current page. Any of these will be overridden
    160          * if arguments are directly passed into the loop. Custom plugins should always
    161          * pass their parameters directly to the loop.
    162          */
    163         $type = 'newest';
    164         $user_id = false;
    165         $page = 1;
    166 
    167         /* User filtering */
    168         if ( !empty( $bp->displayed_user->id ) || 'personal' == $_COOKIE['bp-forums-scope'] )
    169                 $user_id = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
    170 
    171         /* Action filtering */
    172         if ( !empty( $_COOKIE['bp-forums-filter'] ) && '-1' != $_COOKIE['bp-forums-filter'] )
    173                 $type = $_COOKIE['bp-forums-filter'];
    174 
    175         if ( !empty( $_COOKIE['bp-forums-page'] ) && '-1' != $_COOKIE['bp-forums-page'] )
    176                 $page = $_COOKIE['bp-forums-page'];
    177 
    178158        $defaults = array(
    179                 'type' => $type,
     159                'type' => 'newest',
    180160                'forum_id' => false,
    181                 'user_id' => $user_id,
    182                 'page' => $page,
     161                'user_id' => false,
     162                'page' => 1,
    183163                'per_page' => 20,
    184164                'max' => false,
    185165                'no_stickies' => false,
  • bp-groups/bp-groups-templatetags.php

     
    170170function bp_has_groups( $args = '' ) {
    171171        global $groups_template, $bp;
    172172
    173         /***
    174          * Set the defaults based on the current page. Any of these will be overridden
    175          * if arguments are directly passed into the loop. Custom plugins should always
    176          * pass their parameters directly to the loop.
    177          */
    178         $type = 'active';
    179         $user_id = false;
    180         $page = 1;
    181 
    182         /* User filtering */
    183         if ( !empty( $bp->displayed_user->id ) || 'personal' == $_COOKIE['bp-groups-scope'] )
    184                 $user_id = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
    185 
    186         /* Action filtering */
    187         if ( !empty( $_COOKIE['bp-groups-filter'] ) && '-1' != $_COOKIE['bp-groups-filter'] )
    188                 $type = $_COOKIE['bp-groups-filter'];
    189 
    190         if ( !empty( $_COOKIE['bp-groups-page'] ) && '-1' != $_COOKIE['bp-groups-page'] )
    191                 $page = $_COOKIE['bp-groups-page'];
    192 
    193173        $defaults = array(
    194                 'type' => $type,
    195                 'page' => $page,
     174                'type' => 'active',
     175                'page' => 1,
    196176                'per_page' => 20,
    197177                'max' => false,
    198178
    199                 'user_id' => $user_id, // Pass a user ID to limit to groups this user has joined
     179                'user_id' => false, // Pass a user ID to limit to groups this user has joined
    200180                'slug' => false, // Pass a group slug to only return that group
    201181                'search_terms' => false // Pass search terms to return only matching groups
    202182        );