<!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] [2054] branches/1.1/bp-blogs.php: Fixes #1226</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>2054</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2009-10-23 16:23:17 +0000 (Fri, 23 Oct 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>Fixes #1226</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branches11bpblogsphp">branches/1.1/bp-blogs.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branches11bpblogsphp"></a>
<div class="modfile"><h4>Modified: branches/1.1/bp-blogs.php (2053 => 2054)</h4>
<pre class="diff"><span>
<span class="info">--- branches/1.1/bp-blogs.php        2009-10-23 16:08:52 UTC (rev 2053)
+++ branches/1.1/bp-blogs.php        2009-10-23 16:23:17 UTC (rev 2054)
</span><span class="lines">@@ -308,7 +308,7 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) {
</del><ins>+function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = true ) {
</ins><span class="cx">         global $bp;
</span><span class="cx">         
</span><span class="cx">         if ( !$user_id )
</span><span class="lines">@@ -328,7 +328,7 @@
</span><span class="cx">         bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'last_activity', time() );
</span><span class="cx">         
</span><span class="cx">         /* Only record this activity if the blog is public */
</span><del>-        if ( (int)$_POST['blog_public'] && !$no_activity ) {        
</del><ins>+        if ( (int)$_POST['blog_public'] || !$no_activity ) {
</ins><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><span class="lines">@@ -351,10 +351,9 @@
</span><span class="cx">         
</span><span class="cx">         if ( !$user_id )
</span><span class="cx">                 $user_id = (int)$post->post_author;
</span><del>-
</del><span class="cx">         
</span><span class="cx">         /* This is to stop infinate loops with Donncha's sitewide tags plugin */
</span><del>-        if ( (int)get_site_option('tags_blog_id') == (int)$blog_id )
</del><ins>+        if ( (int)get_site_option( 'tags_blog_id' ) == (int)$blog_id )
</ins><span class="cx">                 return false;
</span><span class="cx">         
</span><span class="cx">         /* Don't record this if it's not a post */
</span><span class="lines">@@ -374,20 +373,22 @@
</span><span class="cx">                         
</span><span class="cx">                         bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', time() );
</span><span class="cx">
</span><del>-                        $post_permalink = bp_post_get_permalink( $post, $blog_id );
</del><ins>+                        if ( (int)get_blog_option( $blog_id, 'blog_public' ) ) {
+                                /* Record this in activity streams */
+                                $post_permalink = bp_post_get_permalink( $post, $blog_id );
</ins><span class="cx">
</span><del>-                        $activity_content = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
-                        $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>";
</del><ins>+                                $activity_content = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
+                                $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>";
</ins><span class="cx">                         
</span><del>-                        /* Record this in activity streams */
-                        bp_blogs_record_activity( array(
-                                'user_id' => (int)$post->post_author,
-                                '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 ),
-                                'component_action' => 'new_blog_post',
-                                'item_id' => $recorded_post_id,
-                                'recorded_time' => strtotime( $post->post_date )
-                        ) );
</del><ins>+                                bp_blogs_record_activity( array(
+                                        'user_id' => (int)$post->post_author,
+                                        '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 ),
+                                        'component_action' => 'new_blog_post',
+                                        'item_id' => $recorded_post_id,
+                                        'recorded_time' => strtotime( $post->post_date )
+                                ));
+                        }
</ins><span class="cx">                 }
</span><span class="cx">         } else {
</span><span class="cx">                 $existing_post = new BP_Blogs_Post( null, $blog_id, $post_id );
</span><span class="lines">@@ -407,23 +408,24 @@
</span><span class="cx">                         // Re-record the post with the new author.
</span><span class="cx">                         bp_blogs_record_post( $post_id );                                
</span><span class="cx">                 }
</span><del>-                
-                /* Now re-record the post in the activity streams */                
-                $post_permalink = bp_post_get_permalink( $post, $blog_id );
-                
</del><span class="cx">
</span><del>-                $activity_content = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
-                $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>";
</del><ins>+                if ( (int)get_blog_option( $blog_id, 'blog_public' ) ) {
+                        /* Now re-record the post in the activity streams */                
+                        $post_permalink = bp_post_get_permalink( $post, $blog_id );
+
+                        $activity_content = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
+                        $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>";
</ins><span class="cx">                 
</span><del>-                /* Record this in activity streams */
-                bp_blogs_record_activity( array(
-                        'user_id' => (int)$post->post_author,
-                        '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 ),
-                        'component_action' => 'new_blog_post',
-                        'item_id' => $existing_post->id,
-                        'recorded_time' => strtotime( $post->post_date )
-                ) );
</del><ins>+                        /* Record this in activity streams */
+                        bp_blogs_record_activity( array(
+                                'user_id' => (int)$post->post_author,
+                                '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 ),
+                                'component_action' => 'new_blog_post',
+                                'item_id' => $existing_post->id,
+                                'recorded_time' => strtotime( $post->post_date )
+                        ) );
+                }
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         do_action( 'bp_blogs_new_blog_post', $existing_post, $is_private, $is_recorded );
</span><span class="lines">@@ -457,21 +459,24 @@
</span><span class="cx">         
</span><span class="cx">         bp_blogs_update_blogmeta( $recorded_comment->blog_id, 'last_activity', time() );
</span><span class="cx">
</span><del>-        $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id );
-        $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );                        
-        $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
</del><ins>+        if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' ) ) {
+                /* Record in activity streams */
+                $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id );
+                $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );                        
+                $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
</ins><span class="cx">
</span><del>-        /* Record this in activity streams */
-        bp_blogs_record_activity( array(
-                'user_id' => $recorded_comment->user_id,
-                '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 ),
-                'component_action' => 'new_blog_comment',
-                'item_id' => $comment_id,
-                'secondary_item_id' => $recorded_comment->blog_id,
-                'recorded_time' => $recorded_comment->date_created
-        ) );
-        
</del><ins>+                /* Record this in activity streams */
+                bp_blogs_record_activity( array(
+                        'user_id' => $recorded_comment->user_id,
+                        '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 ),
+                        'component_action' => 'new_blog_comment',
+                        'item_id' => $comment_id,
+                        'secondary_item_id' => $recorded_comment->blog_id,
+                        'recorded_time' => $recorded_comment->date_created
+                ) );
+        }
+
</ins><span class="cx">         return $recorded_comment;
</span><span class="cx"> }
</span><span class="cx"> add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
</span><span class="lines">@@ -488,20 +493,23 @@
</span><span class="cx">         
</span><span class="cx">         bp_blogs_delete_activity( array( 'item_id' => $comment_id, 'secondary_item_id' => $recorded_comment->blog_id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_comment' ) );
</span><span class="cx">
</span><del>-        $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id );
-        $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $recorded_comment->user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );                        
-        $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
</del><ins>+        if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' ) ) {
+                /* Record in activity streams */
+                $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id );
+                $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $recorded_comment->user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );                        
+                $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
</ins><span class="cx">
</span><del>-        /* Record this in activity streams */
-        bp_blogs_record_activity( array(
-                'user_id' => $recorded_comment->user_id,
-                '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 ),
-                'component_action' => 'new_blog_comment',
-                'item_id' => $comment_id,
-                'secondary_item_id' => $recorded_comment->blog_id,
-                'recorded_time' => $recorded_comment->date_created
-        ) );
</del><ins>+                /* Record this in activity streams */
+                bp_blogs_record_activity( array(
+                        'user_id' => $recorded_comment->user_id,
+                        '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 ),
+                        'component_action' => 'new_blog_comment',
+                        'item_id' => $comment_id,
+                        'secondary_item_id' => $recorded_comment->blog_id,
+                        'recorded_time' => $recorded_comment->date_created
+                ) );
+        }
</ins><span class="cx"> }
</span><span class="cx"> add_action( 'wp_set_comment_status', 'bp_blogs_approve_comment', 10, 2 );
</span><span class="cx">
</span><span class="lines">@@ -513,7 +521,7 @@
</span><span class="cx">
</span><span class="cx"> function bp_blogs_add_user_to_blog( $user_id, $role, $blog_id ) {
</span><span class="cx">         if ( $role != 'subscriber' ) {
</span><del>-                bp_blogs_record_blog( $blog_id, $user_id, $no_activity = true );
</del><ins>+                bp_blogs_record_blog( $blog_id, $user_id );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> add_action( 'add_user_to_blog', 'bp_blogs_add_user_to_blog', 10, 3 );
</span></span></pre>
</div>
</div>
</body>
</html>