WordPress.org

Plugin Directory

Changeset 617779


Ignore:
Timestamp:
10/26/12 16:36:36 (18 months ago)
Author:
boonebgorges
Message:

Merge branch 'master' into svn

Location:
bp-mpo-activity-filter/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • bp-mpo-activity-filter/trunk/bp-mpo-activity-filter-bp-functions.php

    r460828 r617779  
    11<?php 
    22 
     3/** 
     4 * Reaches into the activity global and filters out items the user doesn't have access to 
     5 * 
     6 * Uses privacy settings from More Privacy Options 
     7 */ 
    38function bp_mpo_activity_filter( $a, $activities ) { 
    49    global $bp; 
     
    813 
    914    foreach ( $activities->activities as $key => $activity ) { 
    10         if ( $activity->component == 'blogs' ) { 
    11             $blog_id = $activity->item_id; 
     15        if ( $activity->type == 'new_blog_post' || $activity->type == 'new_blog_comment' ) { 
     16 
    1217            $current_user = $bp->loggedin_user->id; 
     18 
     19            // Account for bp-groupblog 
     20            if ( $activity->component == 'groups' ) { 
     21                $group_id = $activity->item_id; 
     22                $blog_id = groups_get_groupmeta( $group_id, 'groupblog_blog_id' ); 
     23            } else { 
     24                $blog_id = $activity->item_id; 
     25            } 
     26 
    1327            $privacy = get_blog_option( $blog_id, 'blog_public' ); 
    1428 
     
    3953 
    4054                case '-2': 
    41                     if ( is_user_logged_in() ) {                         
    42                         switch_to_blog( $blog_id ); 
    43      
    44                         $user = new WP_User( $current_user ); 
    45      
    46                         if ( !empty( $user->caps ) ) 
     55                    if ( is_user_logged_in() ) { 
     56                        $meta_key = 'wp_' . $blog_id . '_capabilities'; 
     57                        $caps = get_user_meta( $current_user, $meta_key, true ); 
     58 
     59                        if ( !empty( $caps ) ) { 
    4760                            continue; 
    48                         else { 
     61                        } else { 
    4962                            $remove_from_stream = true; 
    5063                        } 
    51                         restore_current_blog(); 
    5264                    } else { 
    5365                        $remove_from_stream = true; 
     
    5870                    if ( is_user_logged_in() ) { 
    5971                        switch_to_blog( $blog_id ); 
    60      
     72 
    6173                        $user = new WP_User( $current_user ); 
    62      
     74 
    6375                        if ( in_array( 'administrator', $user->roles ) ) 
    6476                            continue; 
     
    7385 
    7486            } 
    75              
     87 
    7688            if ( $remove_from_stream ) { 
    7789                $activities->activity_count = $activities->activity_count - 1; 
    7890                unset( $activities->activities[$key] ); 
     91 
    7992            } 
    8093        } 
    8194    } 
    82     /* Renumber the array keys to account for missing items */ 
     95 
    8396    $activities_new = array_values( $activities->activities ); 
     97    $activities->activities = $activities_new; 
    8498 
    85     $activities->activities = $activities_new; 
    86     //print "<pre>"; print_r($activities); 
    8799    return $activities; 
    88100} 
     
    95107} 
    96108add_action( 'bp_get_activity_count', 'bp_mpo_activity_count' ); 
    97 ?> 
  • bp-mpo-activity-filter/trunk/bp-mpo-activity-filter.php

    r460828 r617779  
    22/* 
    33Plugin Name: BP MPO Activity Filter 
    4 Plugin URI: http://qwriting.org 
     4Plugin URI: http://github.com/boonebgorges/bp-mpo-activity-filter 
    55Description: When using More Privacy Options, this plugin removes items from BP activity streams according to user roles 
    6 Version: 1.1.1 
     6Version: 1.2 
    77Author: Boone Gorges 
    8 Author URI: http://teleogistic.net 
     8Author URI: http://boone.gorg.es 
    99*/ 
    1010 
     
    1313    require( dirname( __FILE__ ) . '/bp-mpo-activity-filter-bp-functions.php' ); 
    1414} 
    15 add_action( 'bp_init', 'bp_mpo_activity_filter_init' ); 
    16  
    17 ?> 
     15add_action( 'bp_include', 'bp_mpo_activity_filter_init' ); 
  • bp-mpo-activity-filter/trunk/readme.txt

    r460828 r617779  
    33Tags: buddypress, activity, privacy, more privacy options, filter 
    44Requires at least: WP 2.8, BuddyPress 1.2 
    5 Tested up to: WP 3.2.1, BuddyPress 1.5.1 
     5Tested up to: WP 3.4.2, BuddyPress 1.6.1 
    66Donate link: http://teleogistic.net/donate/ 
    7 Stable tag: 1.1.1 
     7Stable tag: 1.2 
    88 
    99When using More Privacy Options, this plugin removes items from BP activity streams according to user roles. 
     
    2525== Changelog == 
    2626 
     27= 1.2 = 
     28* Refactored some queries to avoid unnecessary switch_to_blog() usage 
     29 
    2730= 1.1.1 = 
    2831* Oops 
Note: See TracChangeset for help on using the changeset viewer.