[buddypress-trac] [BuddyPress] #3192: replying to a nested activity item, whose root item is yours, results in duplicated activity stream entries

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Fri Oct 7 22:30:28 UTC 2011


#3192: replying to a nested activity item, whose root item is yours, results in
duplicated activity stream entries
-----------------------------+----------------------
 Reporter:  alanchrishughes  |       Owner:
     Type:  enhancement      |      Status:  closed
 Priority:  normal           |   Milestone:
Component:  Activity         |     Version:  1.2
 Severity:  normal           |  Resolution:  invalid
 Keywords:                   |
-----------------------------+----------------------
Changes (by boonebgorges):

 * status:  reopened => closed
 * resolution:   => invalid
 * milestone:  Future Release =>


Comment:

 I would say that this is plugin territory. I don't think it makes sense to
 make this change in BuddyPress itself, since what you perceive as
 redundant in this case would not be redundant if the activity item being
 replied to was a few days old.

 Essentially, this does what you want:

 {{{
 function bbg_remove_self_replies( $has_activities ) {
         global $activities_template;

         foreach( $activities_template->activities as $activity_key =>
 $activity ) {
                 if ( 'activity_comment' == $activity->type ) {
                         // Get the parent item
                         $parent_id = $activity->item_id;

                         if ( empty(
 $activities_template->activity_parents[$parent_id] ) ) {
                                 return $has_activities;
                         } else {
                                 $parent =
 $activities_template->activity_parents[$parent_id];
                         }

                         // Is the activity author the same as the parent
 author? If so, remove
                         if ( $parent->user_id == $activity->user_id ) {
                                 unset(
 $activities_template->activities[$activity_key] );
                         }
                 }
         }

         // Reset indexes
         $activities_template->activities = array_values(
 $activities_template->activities );

         return $has_activities;
 }
 add_filter( 'bp_has_activities', 'bbg_remove_self_replies' );
 }}}

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/3192#comment:10>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list