<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[BuddyPress] [1852] trunk:
Adding filters to all activity recording functions.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>1852</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2009-09-10 20:36:48 +0000 (Thu, 10 Sep 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>Adding filters to all activity recording functions.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpblogsphp">trunk/bp-blogs.php</a></li>
<li><a href="#trunkbpfriendsphp">trunk/bp-friends.php</a></li>
<li><a href="#trunkbpgroupsphp">trunk/bp-groups.php</a></li>
<li><a href="#trunkbpstatusphp">trunk/bp-status.php</a></li>
<li><a href="#trunkbpxprofilephp">trunk/bp-xprofile.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpblogsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-blogs.php (1851 => 1852)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-blogs.php        2009-09-10 20:05:55 UTC (rev 1851)
+++ trunk/bp-blogs.php        2009-09-10 20:36:48 UTC (rev 1852)
</span><span class="lines">@@ -330,8 +330,8 @@
</span><span class="cx">                 /* Record this in activity streams */
</span><span class="cx">                 bp_blogs_record_activity( array(
</span><span class="cx">                         'user_id' => $recorded_blog->user_id,
</span><del>-                        'content' => sprintf( __( '%s created the blog %s', 'buddypress'), bp_core_get_userlink( $recorded_blog->user_id ), '<a href="' . get_blog_option( $recorded_blog->blog_id, 'siteurl' ) . '">' . attribute_escape( $name ) . '</a>' ),
-                        'primary_link' => get_blog_option( $recorded_blog->blog_id, 'siteurl' ),
</del><ins>+                        'content' => apply_filters( 'bp_blogs_activity_created_blog', sprintf( __( '%s created the blog %s', 'buddypress'), bp_core_get_userlink( $recorded_blog->user_id ), '<a href="' . get_blog_option( $recorded_blog->blog_id, 'siteurl' ) . '">' . attribute_escape( $name ) . '</a>' ), &$recorded_blog, $name, $description ),
+                        'primary_link' => apply_filters( 'bp_blogs_activity_created_blog_primary_link', get_blog_option( $recorded_blog->blog_id, 'siteurl' ), $recorded_blog->blog_id ),
</ins><span class="cx">                         'component_action' => 'new_blog',
</span><span class="cx">                         'item_id' => $recorded_blog->blog_id
</span><span class="cx">                 ) );
</span><span class="lines">@@ -380,8 +380,8 @@
</span><span class="cx">                         /* Record this in activity streams */
</span><span class="cx">                         bp_blogs_record_activity( array(
</span><span class="cx">                                 'user_id' => (int)$post->post_author,
</span><del>-                                'content' => $activity_content,
-                                'primary_link' => $post_permalink,
</del><ins>+                                'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ),
+                                'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
</ins><span class="cx">                                 'component_action' => 'new_blog_post',
</span><span class="cx">                                 'item_id' => $recorded_post_id,
</span><span class="cx">                                 'recorded_time' => strtotime( $post->post_date )
</span><span class="lines">@@ -416,8 +416,8 @@
</span><span class="cx">                 /* Record this in activity streams */
</span><span class="cx">                 bp_blogs_record_activity( array(
</span><span class="cx">                         'user_id' => (int)$post->post_author,
</span><del>-                        'content' => $activity_content,
-                        'primary_link' => $post_permalink,
</del><ins>+                        'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ),
+                        'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
</ins><span class="cx">                         'component_action' => 'new_blog_post',
</span><span class="cx">                         'item_id' => $existing_post->id,
</span><span class="cx">                         'recorded_time' => strtotime( $post->post_date )
</span><span class="lines">@@ -462,8 +462,8 @@
</span><span class="cx">         /* Record this in activity streams */
</span><span class="cx">         bp_blogs_record_activity( array(
</span><span class="cx">                 'user_id' => $recorded_comment->user_id,
</span><del>-                'content' => $activity_content,
-                'primary_link' => $comment_link,
</del><ins>+                'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ),
+                'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),
</ins><span class="cx">                 'component_action' => 'new_blog_comment',
</span><span class="cx">                 'item_id' => $comment_id,
</span><span class="cx">                 'secondary_item_id' => $recorded_comment->blog_id,
</span><span class="lines">@@ -490,8 +490,8 @@
</span><span class="cx">         /* Record this in activity streams */
</span><span class="cx">         bp_blogs_record_activity( array(
</span><span class="cx">                 'user_id' => $recorded_comment->user_id,
</span><del>-                'content' => $content,
-                'primary_link' => $comment_link,
</del><ins>+                'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ),
+                'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),
</ins><span class="cx">                 'component_action' => 'new_blog_comment',
</span><span class="cx">                 'item_id' => $comment_id,
</span><span class="cx">                 'secondary_item_id' => $recorded_comment->blog_id,
</span></span></pre></div>
<a id="trunkbpfriendsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-friends.php (1851 => 1852)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-friends.php        2009-09-10 20:05:55 UTC (rev 1851)
+++ trunk/bp-friends.php        2009-09-10 20:36:48 UTC (rev 1852)
</span><span class="lines">@@ -627,25 +627,22 @@
</span><span class="cx">                 $initiator_link = bp_core_get_userlink( $friendship->initiator_user_id );
</span><span class="cx">                 $friend_link = bp_core_get_userlink( $friendship->friend_user_id );
</span><span class="cx">                 
</span><del>-                $primary_link = apply_filters( 'bp_friends_friendship_accepted_primary_link', bp_core_get_userlink( $friendship->initiator_user_id ), &$friendship );
-                $activity_content = apply_filters( 'bp_friends_friendship_accepted_activity', sprintf( __( '%s and %s are now friends', 'buddypress' ), $initiator_link, $friend_link ), &$friendship );
-                        
</del><ins>+                $primary_link = apply_filters( 'friends_activity_friendship_accepted_primary_link', bp_core_get_userlink( $friendship->initiator_user_id ), &$friendship );
+                
</ins><span class="cx">                 /* Record in activity streams for the initiator */
</span><span class="cx">                 friends_record_activity( array(
</span><span class="cx">                         'user_id' => $friendship->initiator_user_id,
</span><span class="cx">                         'component_action' => 'friendship_created',
</span><del>-                        'content' => $activity_content,
</del><ins>+                        'content' => apply_filters( 'friends_activity_friendship_accepted', sprintf( __( '%s and %s are now friends', 'buddypress' ), $initiator_link, $friend_link ), &$friendship ),
</ins><span class="cx">                         'primary_link' => $primary_link,
</span><span class="cx">                         'item_id' => $friendship_id
</span><span class="cx">                 ) );
</span><span class="cx">
</span><del>-                $activity_content = apply_filters( 'bp_friends_friendship_accepted_activity', sprintf( __( '%s and %s are now friends', 'buddypress' ), $friend_link, $initiator_link ), &$friendship );
-                
</del><span class="cx">                 /* Record in activity streams for the friend */
</span><span class="cx">                 friends_record_activity( array(
</span><span class="cx">                         'user_id' => $friendship->friend_user_id,
</span><span class="cx">                         'component_action' => 'friendship_created',
</span><del>-                        'content' => $activity_content,
</del><ins>+                        'content' => apply_filters( 'friends_activity_friendship_accepted', sprintf( __( '%s and %s are now friends', 'buddypress' ), $friend_link, $initiator_link ), &$friendship ),
</ins><span class="cx">                         'primary_link' => $primary_link,
</span><span class="cx">                         'item_id' => $friendship_id,
</span><span class="cx">                         'hide_sitewide' => true /* We've already got the first entry site wide */
</span></span></pre></div>
<a id="trunkbpgroupsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups.php (1851 => 1852)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups.php        2009-09-10 20:05:55 UTC (rev 1851)
+++ trunk/bp-groups.php        2009-09-10 20:36:48 UTC (rev 1852)
</span><span class="lines">@@ -346,8 +346,8 @@
</span><span class="cx">                         $group = new BP_Groups_Group( $group_id, false, false );
</span><span class="cx">
</span><span class="cx">                         groups_record_activity( array(
</span><del>-                                'content' => sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ),
-                                'primary_link' => bp_get_group_permalink( $group ),
</del><ins>+                                'content' => apply_filters( 'groups_activity_accepted_invite', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $bp->loggedin_user->id, &$group ),
+                                'primary_link' => apply_filters( 'groups_activity_accepted_invite_primary_link', bp_get_group_permalink( $group ), &$group ),
</ins><span class="cx">                                 'component_action' => 'joined_group',
</span><span class="cx">                                 'item_id' => $group->id
</span><span class="cx">                         ) );
</span><span class="lines">@@ -489,8 +489,8 @@
</span><span class="cx">                         
</span><span class="cx">                         /* Once we compelete all steps, record the group creation in the activity stream. */
</span><span class="cx">                         groups_record_activity( array(
</span><del>-                                'content' => sprintf( __( '%s created the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ),
-                                'primary_link' => bp_get_group_permalink( $bp->groups->current_group ),
</del><ins>+                                'content' => apply_filters( 'groups_activity_created_group', sprintf( __( '%s created the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ) ),
+                                'primary_link' => apply_filters( 'groups_activity_created_group_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
</ins><span class="cx">                                 'component_action' => 'created_group',
</span><span class="cx">                                 'item_id' => $bp->groups->new_group_id
</span><span class="cx">                         ) );
</span><span class="lines">@@ -1780,8 +1780,8 @@
</span><span class="cx">
</span><span class="cx">         /* Record this in activity streams */
</span><span class="cx">         groups_record_activity( array(
</span><del>-                'content' => sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ),
-                'primary_link' => bp_get_group_permalink( $bp->groups->current_group ),
</del><ins>+                'content' => apply_filters( 'groups_activity_joined_group', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ) ),
+                'primary_link' => apply_filters( 'groups_activity_joined_group_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
</ins><span class="cx">                 'component_action' => 'joined_group',
</span><span class="cx">                 'item_id' => $bp->groups->current_group->id
</span><span class="cx">         ) );
</span><span class="lines">@@ -1984,8 +1984,8 @@
</span><span class="cx">                 $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $content ) ) . '</blockquote>';
</span><span class="cx">                 
</span><span class="cx">                 groups_record_activity( array(
</span><del>-                        'content' => $activity_content,
-                        'primary_link' => bp_get_group_permalink( $bp->groups->current_group ),
</del><ins>+                        'content' => apply_filters( 'groups_activity_new_wire_post', $activity_content ),
+                        'primary_link' => apply_filters( 'groups_activity_new_wire_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
</ins><span class="cx">                         'component_action' => 'new_wire_post',
</span><span class="cx">                         'item_id' => $bp->groups->current_group->id,
</span><span class="cx">                         'secondary_item_id' => $wire_post->item_id
</span><span class="lines">@@ -2045,8 +2045,8 @@
</span><span class="cx">                 
</span><span class="cx">                 /* Record this in activity streams */
</span><span class="cx">                 groups_record_activity( array(
</span><del>-                        'content' => $activity_content,
-                        'primary_link' => bp_get_group_permalink( $bp->groups->current_group ),
</del><ins>+                        'content' => apply_filters( 'groups_activity_new_forum_post', $activity_content, $post_text, &$topic, &$forum_post ),
+                        'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
</ins><span class="cx">                         'component_action' => 'new_forum_post',
</span><span class="cx">                         'item_id' => $bp->groups->current_group->id,
</span><span class="cx">                         'secondary_item_id' => $forum_post->id
</span><span class="lines">@@ -2071,8 +2071,8 @@
</span><span class="cx">                 
</span><span class="cx">                 /* Record this in activity streams */
</span><span class="cx">                 groups_record_activity( array(
</span><del>-                        'content' => $activity_content,
-                        'primary_link' => bp_get_group_permalink( $bp->groups->current_group ),
</del><ins>+                        'content' => apply_filters( 'groups_activity_new_forum_topic', $activity_content, $topic_text, &$topic ),
+                        'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
</ins><span class="cx">                         'component_action' => 'new_forum_topic',
</span><span class="cx">                         'item_id' => $bp->groups->current_group->id,
</span><span class="cx">                         'secondary_item_id' => $topic->topic_id
</span><span class="lines">@@ -2098,8 +2098,8 @@
</span><span class="cx">
</span><span class="cx">                 /* Record this in activity streams */
</span><span class="cx">                 groups_record_activity( array(
</span><del>-                        'content' => $activity_content,
-                        'primary_link' => bp_get_group_permalink( $bp->groups->current_group ),
</del><ins>+                        'content' => apply_filters( 'groups_activity_new_forum_topic', $activity_content, $topic_text, &$topic ),
+                        'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
</ins><span class="cx">                         'component_action' => 'new_forum_topic',
</span><span class="cx">                         'item_id' => (int)$bp->groups->current_group->id,
</span><span class="cx">                         'user_id' => (int)$topic->topic_poster,
</span><span class="lines">@@ -2149,8 +2149,8 @@
</span><span class="cx">                 
</span><span class="cx">                 /* Record this in activity streams */
</span><span class="cx">                 groups_record_activity( array(
</span><del>-                        'content' => $activity_content,
-                        'primary_link' => bp_get_group_permalink( $bp->groups->current_group ),
</del><ins>+                        'content' => apply_filters( 'groups_activity_new_forum_post', $activity_content, $post_text, &$topic, &$forum_post ),
+                        'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
</ins><span class="cx">                         'component_action' => 'new_forum_post',
</span><span class="cx">                         'item_id' => $bp->groups->current_group->id,
</span><span class="cx">                         'secondary_item_id' => $post_id,
</span><span class="lines">@@ -2400,8 +2400,8 @@
</span><span class="cx">         $group = new BP_Groups_Group( $group_id, false, false );
</span><span class="cx">
</span><span class="cx">         groups_record_activity( array(
</span><del>-                'content' => sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ),
-                'primary_link' => bp_get_group_permalink( $group ),
</del><ins>+                'content' => apply_filters( 'groups_activity_membership_accepted', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $user_id, &$group ),
+                'primary_link' => apply_filters( 'groups_activity_membership_accepted_primary_link', bp_get_group_permalink( $group ), &$group ),
</ins><span class="cx">                 'component_action' => 'joined_group',
</span><span class="cx">                 'item_id' => $group->id,
</span><span class="cx">                 'user_id' => $user_id
</span></span></pre></div>
<a id="trunkbpstatusphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-status.php (1851 => 1852)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-status.php        2009-09-10 20:05:55 UTC (rev 1851)
+++ trunk/bp-status.php        2009-09-10 20:36:48 UTC (rev 1852)
</span><span class="lines">@@ -126,7 +126,7 @@
</span><span class="cx">         $activity_content = sprintf( __( '%s posted a new status update:', 'buddypress' ), $user_link );
</span><span class="cx">         $activity_content .= "<blockquote>$content</blockquote>";
</span><span class="cx">
</span><del>-        bp_status_record_activity( $user_id, $activity_content, $user_link );
</del><ins>+        bp_status_record_activity( $user_id, apply_filters( 'bp_status_activity_new', $activity_content, $content, $user_link ), apply_filters( 'bp_status_activity_new_primary_link', $user_link, $user_id ) );
</ins><span class="cx">         
</span><span class="cx">         do_action( 'bp_status_add_status', $user_id, $content );
</span><span class="cx">
</span></span></pre></div>
<a id="trunkbpxprofilephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile.php (1851 => 1852)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile.php        2009-09-10 20:05:55 UTC (rev 1851)
+++ trunk/bp-xprofile.php        2009-09-10 20:36:48 UTC (rev 1852)
</span><span class="lines">@@ -552,8 +552,8 @@
</span><span class="cx">                 /* Now write the values */
</span><span class="cx">                 xprofile_record_activity( array(
</span><span class="cx">                         'user_id' => $bp->loggedin_user->id,
</span><del>-                        'content' => $content,
-                        'primary_link' => $primary_link,
</del><ins>+                        'content' => apply_filters( 'xprofile_activity_new_wire_post', $content, &$wire_post ),
+                        'primary_link' => apply_filters( 'xprofile_activity_new_wire_post_primary_link', $primary_link ),
</ins><span class="cx">                         'component_action' => 'new_wire_post',
</span><span class="cx">                         'item_id' => $wire_post->id
</span><span class="cx">                 ) );
</span></span></pre>
</div>
</div>
</body>
</html>