Skip to content
Snippets Groups Projects
Commit 504badae authored by lechuck's avatar lechuck Committed by lechuck
Browse files

Upgrate BP activity filter to 1.1.1

parent 9c945e64
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
function bp_mpo_activity_filter( $a, $activities ) { function bp_mpo_activity_filter( $a, $activities ) {
global $bp; global $bp;
if ( is_site_admin() ) if ( is_super_admin() )
return $activities; return $activities;
foreach ( $activities->activities as $key => $activity ) { foreach ( $activities->activities as $key => $activity ) {
...@@ -12,6 +12,8 @@ function bp_mpo_activity_filter( $a, $activities ) { ...@@ -12,6 +12,8 @@ function bp_mpo_activity_filter( $a, $activities ) {
$current_user = $bp->loggedin_user->id; $current_user = $bp->loggedin_user->id;
$privacy = get_blog_option( $blog_id, 'blog_public' ); $privacy = get_blog_option( $blog_id, 'blog_public' );
$remove_from_stream = false;
switch ( $privacy ) { switch ( $privacy ) {
case '1': case '1':
continue; continue;
...@@ -21,53 +23,75 @@ function bp_mpo_activity_filter( $a, $activities ) { ...@@ -21,53 +23,75 @@ function bp_mpo_activity_filter( $a, $activities ) {
if ( $current_user != 0 ) { if ( $current_user != 0 ) {
continue; continue;
} }
else else {
unset( $activities->activities[$key] ); $remove_from_stream = true;
}
break; break;
case '-1': case '-1':
if ( $current_user != 0 ) if ( $current_user != 0 )
continue; continue;
else else {
unset( $activities->activities[$key] ); $remove_from_stream = true;
}
break; break;
case '-2': case '-2':
if ( is_user_logged_in() ) {
switch_to_blog( $blog_id ); switch_to_blog( $blog_id );
$user = new WP_User( $current_user ); $user = new WP_User( $current_user );
if ( !empty( $user->caps ) ) if ( !empty( $user->caps ) )
continue; continue;
else else {
unset( $activities->activities[$key] ); $remove_from_stream = true;
}
restore_current_blog(); restore_current_blog();
} else {
$remove_from_stream = true;
}
break; break;
case '-3': case '-3':
if ( is_user_logged_in() ) {
switch_to_blog( $blog_id ); switch_to_blog( $blog_id );
$user = new WP_User( $current_user ); $user = new WP_User( $current_user );
if ( in_array( 'administrator', $user->roles ) ) if ( in_array( 'administrator', $user->roles ) )
continue; continue;
else else {
unset( $activities->activities[$key] ); $remove_from_stream = true;
}
restore_current_blog(); restore_current_blog();
} else {
$remove_from_stream = true;
}
break; break;
} }
if ( $remove_from_stream ) {
$activities->activity_count = $activities->activity_count - 1;
unset( $activities->activities[$key] );
}
} }
} }
/* Renumber the array keys to account for missing items */ /* Renumber the array keys to account for missing items */
$activities_new = array_values( $activities->activities ); $activities_new = array_values( $activities->activities );
$activities->activities = $activities_new; $activities->activities = $activities_new;
//print "<pre>"; print_r($activities); //print "<pre>"; print_r($activities);
return $activities; return $activities;
} }
add_action( 'bp_has_activities', 'bp_mpo_activity_filter', 10, 2 ); add_action( 'bp_has_activities', 'bp_mpo_activity_filter', 10, 2 );
// Filter the output of 'bp_get_activity_count' to account for the fact that there are fewer items. A total hack.
function bp_mpo_activity_count() {
return '20';
}
add_action( 'bp_get_activity_count', 'bp_mpo_activity_count' );
?> ?>
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Plugin Name: BP MPO Activity Filter Plugin Name: BP MPO Activity Filter
Plugin URI: http://qwriting.org Plugin URI: http://qwriting.org
Description: When using More Privacy Options, this plugin removes items from BP activity streams according to user roles Description: When using More Privacy Options, this plugin removes items from BP activity streams according to user roles
Version: 1.0.1 Version: 1.1.1
Author: Boone Gorges Author: Boone Gorges
Author URI: http://teleogistic.net Author URI: http://teleogistic.net
*/ */
......
=== Plugin Name === === Plugin Name ===
Contributors: boonebgorges Contributors: boonebgorges, cuny-academic-commons
Tags: buddypress, activity, privacy, more privacy options, filter Tags: buddypress, activity, privacy, more privacy options, filter
Requires at least: WPMU 2.8, BuddyPress 1.2 Requires at least: WP 2.8, BuddyPress 1.2
Tested up to: WPMU 2.9.1.1, BuddyPress 1.2.1 Tested up to: WP 3.2.1, BuddyPress 1.5.1
Donate link: http://teleogistic.net/donate/ Donate link: http://teleogistic.net/donate/
Stable tag: trunk Stable tag: 1.1.1
When using More Privacy Options, this plugin removes items from BP activity streams according to user roles. When using More Privacy Options, this plugin removes items from BP activity streams according to user roles.
...@@ -24,9 +24,16 @@ I borrowed the idea, and a little bit of the code, from this plugin: http://blog ...@@ -24,9 +24,16 @@ I borrowed the idea, and a little bit of the code, from this plugin: http://blog
== Changelog == == Changelog ==
= 1.0 = = 1.1.1 =
* Initial release * Oops
= 1.1 =
* Upgraded to reduce unnecessary switch_to_blog()
= 1.0.1 = = 1.0.1 =
* Added code to ensure that plugin is not loaded before BuddyPress is * Added code to ensure that plugin is not loaded before BuddyPress is
* Updated readme file to include more information on compatibility with BP < 1.2 * Updated readme file to include more information on compatibility with BP < 1.2
= 1.0 =
* Initial release
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment