Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/23/2009 04:23:17 PM (14 years ago)
Author:
apeatling
Message:

Fixes #1226

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.1/bp-blogs.php

    r1995 r2054  
    309309}
    310310
    311 function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) {
     311function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = true ) {
    312312    global $bp;
    313313   
     
    329329   
    330330    /* Only record this activity if the blog is public */
    331     if ( (int)$_POST['blog_public'] && !$no_activity ) {   
     331    if ( (int)$_POST['blog_public'] || !$no_activity ) {
    332332        /* Record this in activity streams */
    333333        bp_blogs_record_activity( array(
     
    352352    if ( !$user_id )
    353353        $user_id = (int)$post->post_author;
    354 
    355354   
    356355    /* This is to stop infinate loops with Donncha's sitewide tags plugin */
    357     if ( (int)get_site_option('tags_blog_id') == (int)$blog_id )
     356    if ( (int)get_site_option( 'tags_blog_id' ) == (int)$blog_id )
    358357        return false;
    359358   
     
    375374            bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', time() );
    376375
    377             $post_permalink = bp_post_get_permalink( $post, $blog_id );
    378 
    379             $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>' );
    380             $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>";
     376            if ( (int)get_blog_option( $blog_id, 'blog_public' ) ) {
     377                /* Record this in activity streams */
     378                $post_permalink = bp_post_get_permalink( $post, $blog_id );
     379
     380                $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>' );
     381                $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>";
    381382           
    382             /* Record this in activity streams */
    383             bp_blogs_record_activity( array(
    384                 'user_id' => (int)$post->post_author,
    385                 'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ),
    386                 'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
    387                 'component_action' => 'new_blog_post',
    388                 'item_id' => $recorded_post_id,
    389                 'recorded_time' => strtotime( $post->post_date )
    390             ) );
     383                bp_blogs_record_activity( array(
     384                    'user_id' => (int)$post->post_author,
     385                    'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ),
     386                    'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
     387                    'component_action' => 'new_blog_post',
     388                    'item_id' => $recorded_post_id,
     389                    'recorded_time' => strtotime( $post->post_date )
     390                ));
     391            }
    391392        }
    392393    } else {
     
    408409            bp_blogs_record_post( $post_id );               
    409410        }
    410        
    411         /* Now re-record the post in the activity streams */       
    412         $post_permalink = bp_post_get_permalink( $post, $blog_id );
    413        
    414 
    415         $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>' );
    416         $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>";
    417        
    418         /* Record this in activity streams */
    419         bp_blogs_record_activity( array(
    420             'user_id' => (int)$post->post_author,
    421             'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ),
    422             'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
    423             'component_action' => 'new_blog_post',
    424             'item_id' => $existing_post->id,
    425             'recorded_time' => strtotime( $post->post_date )
    426         ) );
     411
     412        if ( (int)get_blog_option( $blog_id, 'blog_public' ) ) {
     413            /* Now re-record the post in the activity streams */       
     414            $post_permalink = bp_post_get_permalink( $post, $blog_id );
     415
     416            $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>' );
     417            $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>";
     418       
     419            /* Record this in activity streams */
     420            bp_blogs_record_activity( array(
     421                'user_id' => (int)$post->post_author,
     422                'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ),
     423                'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
     424                'component_action' => 'new_blog_post',
     425                'item_id' => $existing_post->id,
     426                'recorded_time' => strtotime( $post->post_date )
     427            ) );
     428        }
    427429    }
    428430
     
    458460    bp_blogs_update_blogmeta( $recorded_comment->blog_id, 'last_activity', time() );
    459461
    460     $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id );
    461     $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>' );         
    462     $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
    463 
    464     /* Record this in activity streams */
    465     bp_blogs_record_activity( array(
    466         'user_id' => $recorded_comment->user_id,
    467         'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ),
    468         'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),
    469         'component_action' => 'new_blog_comment',
    470         'item_id' => $comment_id,
    471         'secondary_item_id' => $recorded_comment->blog_id,
    472         'recorded_time' =>  $recorded_comment->date_created
    473     ) );
    474    
     462    if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' ) ) {
     463        /* Record in activity streams */
     464        $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id );
     465        $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>' );         
     466        $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
     467
     468        /* Record this in activity streams */
     469        bp_blogs_record_activity( array(
     470            'user_id' => $recorded_comment->user_id,
     471            'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ),
     472            'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),
     473            'component_action' => 'new_blog_comment',
     474            'item_id' => $comment_id,
     475            'secondary_item_id' => $recorded_comment->blog_id,
     476            'recorded_time' =>  $recorded_comment->date_created
     477        ) );
     478    }
     479
    475480    return $recorded_comment;
    476481}
     
    489494    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' ) );
    490495
    491     $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id );
    492     $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>' );           
    493     $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
    494 
    495     /* Record this in activity streams */
    496     bp_blogs_record_activity( array(
    497         'user_id' => $recorded_comment->user_id,
    498         'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ),
    499         'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),
    500         'component_action' => 'new_blog_comment',
    501         'item_id' => $comment_id,
    502         'secondary_item_id' => $recorded_comment->blog_id,
    503         'recorded_time' =>  $recorded_comment->date_created
    504     ) );
     496    if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' ) ) {
     497        /* Record in activity streams */
     498        $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id );
     499        $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>' );           
     500        $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
     501
     502        /* Record this in activity streams */
     503        bp_blogs_record_activity( array(
     504            'user_id' => $recorded_comment->user_id,
     505            'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ),
     506            'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),
     507            'component_action' => 'new_blog_comment',
     508            'item_id' => $comment_id,
     509            'secondary_item_id' => $recorded_comment->blog_id,
     510            'recorded_time' =>  $recorded_comment->date_created
     511        ) );
     512    }
    505513}
    506514add_action( 'wp_set_comment_status', 'bp_blogs_approve_comment', 10, 2 );
     
    514522function bp_blogs_add_user_to_blog( $user_id, $role, $blog_id ) {
    515523    if ( $role != 'subscriber' ) {
    516         bp_blogs_record_blog( $blog_id, $user_id, $no_activity = true );
     524        bp_blogs_record_blog( $blog_id, $user_id );
    517525    }
    518526}
Note: See TracChangeset for help on using the changeset viewer.