Commit 504badae authored by lechuck's avatar lechuck Committed by lechuck

Upgrate BP activity filter to 1.1.1

parent 9c945e64
<?php
function bp_mpo_activity_filter( $a, $activities ) {
global $bp;
if ( is_site_admin() )
return $activities;
global $bp;
if ( is_super_admin() )
return $activities;
foreach ( $activities->activities as $key => $activity ) {
if ( $activity->component == 'blogs' ) {
$blog_id = $activity->item_id;
$current_user = $bp->loggedin_user->id;
$privacy = get_blog_option( $blog_id, 'blog_public' );
$remove_from_stream = false;
switch ( $privacy ) {
case '1':
continue;
break;
case '0':
if ( $current_user != 0 ) {
continue;
}
else
unset( $activities->activities[$key] );
break;
else {
$remove_from_stream = true;
}
break;
case '-1':
if ( $current_user != 0 )
continue;
else
unset( $activities->activities[$key] );
else {
$remove_from_stream = true;
}
break;
case '-2':
switch_to_blog( $blog_id );
$user = new WP_User( $current_user );
if ( !empty( $user->caps ) )
continue;
else
unset( $activities->activities[$key] );
restore_current_blog();
if ( is_user_logged_in() ) {
switch_to_blog( $blog_id );
$user = new WP_User( $current_user );
if ( !empty( $user->caps ) )
continue;
else {
$remove_from_stream = true;
}
restore_current_blog();
} else {
$remove_from_stream = true;
}
break;
case '-3':
switch_to_blog( $blog_id );
$user = new WP_User( $current_user );
if ( in_array( 'administrator', $user->roles ) )
continue;
else
unset( $activities->activities[$key] );
restore_current_blog();
break;
if ( is_user_logged_in() ) {
switch_to_blog( $blog_id );
$user = new WP_User( $current_user );
if ( in_array( 'administrator', $user->roles ) )
continue;
else {
$remove_from_stream = true;
}
restore_current_blog();
} else {
$remove_from_stream = true;
}
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 */
$activities_new = array_values( $activities->activities );
$activities->activities = $activities_new;
//print "<pre>"; print_r($activities);
return $activities;
}
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 @@
Plugin Name: BP MPO Activity Filter
Plugin URI: http://qwriting.org
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 URI: http://teleogistic.net
*/
......@@ -14,4 +14,4 @@ function bp_mpo_activity_filter_init() {
}
add_action( 'bp_init', 'bp_mpo_activity_filter_init' );
?>
\ No newline at end of file
?>
=== Plugin Name ===
Contributors: boonebgorges
Contributors: boonebgorges, cuny-academic-commons
Tags: buddypress, activity, privacy, more privacy options, filter
Requires at least: WPMU 2.8, BuddyPress 1.2
Tested up to: WPMU 2.9.1.1, BuddyPress 1.2.1
Requires at least: WP 2.8, BuddyPress 1.2
Tested up to: WP 3.2.1, BuddyPress 1.5.1
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.
......@@ -24,9 +24,16 @@ I borrowed the idea, and a little bit of the code, from this plugin: http://blog
== Changelog ==
= 1.0 =
* Initial release
= 1.1.1 =
* Oops
= 1.1 =
* Upgraded to reduce unnecessary switch_to_blog()
= 1.0.1 =
* 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
= 1.0 =
* Initial release
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment