# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: \\UBU\www\sandbox2\public_html\wp-content\plugins\buddypress
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: bp-blogs/bp-blogs-templatetags.php
--- bp-blogs/bp-blogs-templatetags.php Base (BASE)
+++ bp-blogs/bp-blogs-templatetags.php Locally Modified (Based On LOCAL)
@@ -109,33 +109,13 @@
 function bp_has_blogs( $args = '' ) {
 	global $bp, $blogs_template;
 
-	/***
-	 * Set the defaults based on the current page. Any of these will be overridden
-	 * if arguments are directly passed into the loop. Custom plugins should always
-	 * pass their parameters directly to the loop.
-	 */
-	$type = 'active';
-	$user_id = false;
-	$page = 1;
-
-	/* User filtering */
-	if ( !empty( $bp->displayed_user->id ) || 'personal' == $_COOKIE['bp-blogs-scope'] )
-		$user_id = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
-
-	/* Action filtering */
-	if ( !empty( $_COOKIE['bp-blogs-filter'] ) && '-1' != $_COOKIE['bp-blogs-filter'] )
-		$type = $_COOKIE['bp-blogs-filter'];
-
-	if ( !empty( $_COOKIE['bp-blogs-page'] ) && '-1' != $_COOKIE['bp-blogs-page'] )
-		$page = $_COOKIE['bp-blogs-page'];
-
 	$defaults = array(
-		'type' => $type,
-		'page' => $page,
+		'type' => 'active',
+		'page' => 1,
 		'per_page' => 20,
 		'max' => false,
 
-		'user_id' => $user_id, // Pass a user_id to limit to only blogs this user has higher than subscriber access to
\ No newline at end of file
+		'user_id' => false, // Pass a user_id to limit to only blogs this user has higher than subscriber access to
\ No newline at end of file
 		'search_terms' => false // Pass search terms to filter on the blog title or description.
 	);
 
Index: bp-core/bp-core-templatetags.php
--- bp-core/bp-core-templatetags.php Base (BASE)
+++ bp-core/bp-core-templatetags.php Locally Modified (Based On LOCAL)
@@ -117,36 +117,16 @@
 function bp_has_members( $args = '' ) {
 	global $bp, $members_template;
 
-	/***
-	 * Set the defaults based on the current page. Any of these will be overridden
-	 * if arguments are directly passed into the loop. Custom plugins should always
-	 * pass their parameters directly to the loop.
-	 */
-	$type = 'active';
-	$user_id = false;
-	$page = 1;
-
-	/* User filtering */
-	if ( !empty( $bp->displayed_user->id ) || 'personal' == $_COOKIE['bp-members-scope'] )
-		$user_id = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
-
-	/* Action filtering */
-	if ( !empty( $_COOKIE['bp-members-filter'] ) && '-1' != $_COOKIE['bp-members-filter'] )
-		$type = $_COOKIE['bp-members-filter'];
-
-	if ( !empty( $_COOKIE['bp-members-page'] ) && '-1' != $_COOKIE['bp-members-page'] )
-		$page = $_COOKIE['bp-members-page'];
-
 	// type: active ( default ) | random | newest | popular | online | alphabetical
 	$defaults = array(
-		'type' => $type,
-		'page' => $page,
+		'type' => 'active',
+		'page' => 1,
 		'per_page' => 20,
 		'max' => false,
 
 		'include' => false, // Pass a user_id or comma separated list of user_ids to only show these users
 
-		'user_id' => $user_id, // Pass a user_id to only show friends of this user
+		'user_id' => false, // Pass a user_id to only show friends of this user
 		'search_terms' => false, // Pass search_terms to filter users by their profile data
 
 		'populate_extras' => true // Fetch usermeta? Friend count, last active etc.
@@ -1399,6 +1379,12 @@
 	return apply_filters( 'bp_ajax_querystring', $bp->ajax_querystring );
 }
 
+function bp_set_ajax_querystring( $string ) {
+	global $bp;
+
+	$bp->ajax_querystring = apply_filters( 'bp_set_ajax_querystring', $string );
+}
+
\ No newline at end of file
 /* Template is_() functions to determine the current page */
 
 function bp_is_active( $component ) {
Index: bp-forums/bp-forums-templatetags.php
--- bp-forums/bp-forums-templatetags.php Base (BASE)
+++ bp-forums/bp-forums-templatetags.php Locally Modified (Based On LOCAL)
@@ -155,31 +155,11 @@
 function bp_has_forum_topics( $args = '' ) {
 	global $forum_template, $bp;
 
-	/***
-	 * Set the defaults based on the current page. Any of these will be overridden
-	 * if arguments are directly passed into the loop. Custom plugins should always
-	 * pass their parameters directly to the loop.
-	 */
-	$type = 'newest';
-	$user_id = false;
-	$page = 1;
-
-	/* User filtering */
-	if ( !empty( $bp->displayed_user->id ) || 'personal' == $_COOKIE['bp-forums-scope'] )
-		$user_id = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
-
-	/* Action filtering */
-	if ( !empty( $_COOKIE['bp-forums-filter'] ) && '-1' != $_COOKIE['bp-forums-filter'] )
-		$type = $_COOKIE['bp-forums-filter'];
-
-	if ( !empty( $_COOKIE['bp-forums-page'] ) && '-1' != $_COOKIE['bp-forums-page'] )
-		$page = $_COOKIE['bp-forums-page'];
-
 	$defaults = array(
-		'type' => $type,
+		'type' => 'newest',
 		'forum_id' => false,
-		'user_id' => $user_id,
-		'page' => $page,
\ No newline at end of file
+		'user_id' => false,
+		'page' => 1,
\ No newline at end of file
 		'per_page' => 20,
 		'max' => false,
 		'no_stickies' => false,
Index: bp-groups/bp-groups-templatetags.php
--- bp-groups/bp-groups-templatetags.php Base (BASE)
+++ bp-groups/bp-groups-templatetags.php Locally Modified (Based On LOCAL)
@@ -170,33 +170,13 @@
 function bp_has_groups( $args = '' ) {
 	global $groups_template, $bp;
 
-	/***
-	 * Set the defaults based on the current page. Any of these will be overridden
-	 * if arguments are directly passed into the loop. Custom plugins should always
-	 * pass their parameters directly to the loop.
-	 */
-	$type = 'active';
-	$user_id = false;
-	$page = 1;
-
-	/* User filtering */
-	if ( !empty( $bp->displayed_user->id ) || 'personal' == $_COOKIE['bp-groups-scope'] )
-		$user_id = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
-
-	/* Action filtering */
-	if ( !empty( $_COOKIE['bp-groups-filter'] ) && '-1' != $_COOKIE['bp-groups-filter'] )
-		$type = $_COOKIE['bp-groups-filter'];
-
-	if ( !empty( $_COOKIE['bp-groups-page'] ) && '-1' != $_COOKIE['bp-groups-page'] )
-		$page = $_COOKIE['bp-groups-page'];
-
 	$defaults = array(
-		'type' => $type,
-		'page' => $page,
+		'type' => 'active',
+		'page' => 1,
 		'per_page' => 20,
 		'max' => false,
 
-		'user_id' => $user_id, // Pass a user ID to limit to groups this user has joined
\ No newline at end of file
+		'user_id' => false, // Pass a user ID to limit to groups this user has joined
\ No newline at end of file
 		'slug' => false, // Pass a group slug to only return that group
 		'search_terms' => false // Pass search terms to return only matching groups
 	);
Index: bp-themes/bp-default/_inc/ajax.php
--- bp-themes/bp-default/_inc/ajax.php Base (BASE)
+++ bp-themes/bp-default/_inc/ajax.php Locally Modified (Based On LOCAL)
@@ -9,6 +9,59 @@
  * your own _inc/ajax.php file and add/remove AJAX functionality as you see fit.
  */
 
+function bp_dtheme_ajax_querystring( $object = null ) {
+	global $bp;
+
+	/* Backwards and forwards compatibility */
+	if ( empty( $object ) ) {
+		// no object? just return it
+		return apply_filters( 'bp_dtheme_ajax_querystring', bp_ajax_querystring() );
+	} elseif ( 'activity' == $object ) {
+		// activity filtering not completed yet, but here is what the filter will be
+		$pre_filtered_querystring = apply_filters( 'bp_dtheme_ajax_querystring_activity_filter', bp_ajax_querystring() );
+		return apply_filters( 'bp_dtheme_ajax_querystring', $pre_filtered_querystring );
+	}
+
+	/* Handle content filtering for the THEME */
+	$c_scope = 'bp-' . $object . '-scope';
+	$c_filter = 'bp-' . $object . '-filter';
+
+	$scope = ( !empty( $_COOKIE[$c_scope] ) ) ? $_COOKIE[$c_scope] : null;
+	$filter = ( !empty( $_COOKIE[$c_filter] ) && '-1' != $_COOKIE[$c_filter] ) ? $_COOKIE[$c_filter] : null;
+
+	$defaults = array(
+		'object' => $object,
+		'scope' => $scope,
+		'type' => $filter
+	);
+
+	// Do pre-filtering
+	$r = wp_parse_args( bp_ajax_querystring(), $defaults );
+	$pre_filtered_querystring = apply_filters( 'bp_dtheme_ajax_querystring_' . $object . '_filter', http_build_query($r) );
+
+	// Return after global filter applied
+	return apply_filters( 'bp_dtheme_ajax_querystring', $pre_filtered_querystring );
+}
+
+/* Personal filtering */
+function bp_dtheme_ajax_querystring_filter_personal( $query_string ) {
+	global $bp;
+
+	$r = wp_parse_args( $query_string );
+	extract($r);
+
+	if ( !empty( $bp->displayed_user->id ) || 'personal' == $scope ) {
+		$r['user_id'] = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
+		return http_build_query($r);
+	} else {
+		return $query_string;
+	}
+}
+add_filter( 'bp_dtheme_ajax_querystring_groups_filter', 'bp_dtheme_ajax_querystring_filter_personal', 1 );
+add_filter( 'bp_dtheme_ajax_querystring_forums_filter', 'bp_dtheme_ajax_querystring_filter_personal', 1 );
+add_filter( 'bp_dtheme_ajax_querystring_members_filter', 'bp_dtheme_ajax_querystring_filter_personal', 1 );
+add_filter( 'bp_dtheme_ajax_querystring_blogs_filter', 'bp_dtheme_ajax_querystring_filter_personal', 1 );
+
 function bp_dtheme_object_filter() {
 	global $bp;
 
@@ -30,21 +83,19 @@
 		$search_terms = false;
 
 	/* Build the querystring */
-	if ( empty( $filter ) )
-		$filter = 'active';
+	$querystring_args =
+		array(
+			'object' => $object,
+			'scope' => $scope,
+			'filter' => empty( $filter ) ? 'active' : $filter,
+			'page' => empty( $page ) ? 1 : $page,
+		);
 
-	$bp->ajax_querystring = 'type=' . $filter . '&page=' . $page;
-
 	if ( !empty( $search_terms ) )
-		$bp->ajax_querystring .= '&search_terms=' . $search_terms;
+		$querystring_args['search_terms'] = $search_terms;
 
-	if ( $scope == 'personal' || $bp->displayed_user->id ) {
-		$user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
-		$bp->ajax_querystring .= '&user_id=' . $user_id;
-	}
+	bp_set_ajax_querystring( apply_filters( 'bp_dtheme_ajax_querystring_content_filter', http_build_query($querystring_args), $extras ) );
 
-	$bp->ajax_querystring = apply_filters( 'bp_dtheme_ajax_querystring_content_filter', $bp->ajax_querystring, $extras );
-
 	locate_template( array( "$object/$object-loop.php" ), true );
 }
 add_action( 'wp_ajax_members_filter', 'bp_dtheme_object_filter' );
@@ -251,8 +302,8 @@
 	}
 	$query_string = implode( '&', $new_args ) . '&page=' . $page;
 
-	$bp->ajax_querystring = apply_filters( 'bp_dtheme_ajax_querystring_activity_filter', $query_string, $scope );
-	$result['query_string'] = $bp->ajax_querystring;
\ No newline at end of file
+	bp_set_ajax_querystring( apply_filters( 'bp_dtheme_ajax_querystring_activity_filter', $query_string, $scope ) );
+	$result['query_string'] = bp_ajax_querystring();
\ No newline at end of file
 	$result['feed_url'] = apply_filters( 'bp_dtheme_ajax_feed_url', $feed_url );
 
 	/* Buffer the loop in the template to a var for JS to spit out. */
Index: bp-themes/bp-default/activity/activity-loop.php
--- bp-themes/bp-default/activity/activity-loop.php Base (BASE)
+++ bp-themes/bp-default/activity/activity-loop.php Locally Modified (Based On LOCAL)
@@ -2,7 +2,7 @@
 
 <?php do_action( 'bp_before_activity_loop' ) ?>
 
-<?php if ( bp_has_activities( bp_ajax_querystring() ) ) : ?>
\ No newline at end of file
+<?php if ( bp_has_activities( bp_dtheme_ajax_querystring( 'activity' ) ) ) : ?>
\ No newline at end of file
 
 	<?php /* Show pagination if JS is not enabled, since the "Load More" link will do nothing */ ?>
 	<noscript>
Index: bp-themes/bp-default/blogs/blogs-loop.php
--- bp-themes/bp-default/blogs/blogs-loop.php Base (BASE)
+++ bp-themes/bp-default/blogs/blogs-loop.php Locally Modified (Based On LOCAL)
@@ -2,7 +2,7 @@
 
 <?php do_action( 'bp_before_blogs_loop' ) ?>
 
-<?php if ( bp_has_blogs( bp_ajax_querystring() ) ) : ?>
+<?php if ( bp_has_blogs( bp_dtheme_ajax_querystring( 'blogs' ) ) ) : ?>
 
 	<div class="pagination">
 
Index: bp-themes/bp-default/forums/forums-loop.php
--- bp-themes/bp-default/forums/forums-loop.php Base (BASE)
+++ bp-themes/bp-default/forums/forums-loop.php Locally Modified (Based On LOCAL)
@@ -1,4 +1,4 @@
-<?php if ( bp_has_forum_topics( bp_ajax_querystring() ) ) : ?>
\ No newline at end of file
+<?php if ( bp_has_forum_topics( bp_dtheme_ajax_querystring( 'forums' ) ) ) : ?>
\ No newline at end of file
 
 	<div class="pagination">
 
Index: bp-themes/bp-default/groups/groups-loop.php
--- bp-themes/bp-default/groups/groups-loop.php Base (BASE)
+++ bp-themes/bp-default/groups/groups-loop.php Locally Modified (Based On LOCAL)
@@ -2,7 +2,7 @@
 
 <?php do_action( 'bp_before_groups_loop' ) ?>
 
-<?php if ( bp_has_groups( bp_ajax_querystring() ) ) : ?>
\ No newline at end of file
+<?php if ( bp_has_groups( bp_dtheme_ajax_querystring( 'groups' ) ) ) : ?>
\ No newline at end of file
 
 	<div class="pagination">
 
Index: bp-themes/bp-default/members/members-loop.php
--- bp-themes/bp-default/members/members-loop.php Base (BASE)
+++ bp-themes/bp-default/members/members-loop.php Locally Modified (Based On LOCAL)
@@ -2,7 +2,7 @@
 
 <?php do_action( 'bp_before_members_loop' ) ?>
 
-<?php if ( bp_has_members( bp_ajax_querystring() ) ) : ?>
\ No newline at end of file
+<?php if ( bp_has_members( bp_dtheme_ajax_querystring( 'members' ) ) ) : ?>
\ No newline at end of file
 
 	<div class="pagination">
 
