Skip to:
Content

BuddyPress.org

Changeset 2252


Ignore:
Timestamp:
01/04/2010 09:36:09 AM (15 years ago)
Author:
apeatling
Message:

Fixes #1539 - missing primary blog activity.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-blogs.php

    r2231 r2252  
    361361        if ( 'publish' == $post->post_status && '' == $post->post_password ) {
    362362
    363             $recorded_post = new BP_Blogs_Post;
    364             $recorded_post->user_id = $user_id;
    365             $recorded_post->blog_id = $blog_id;
    366             $recorded_post->post_id = $post_id;
    367             $recorded_post->date_created = strtotime( $post->post_date );
    368 
    369             $recorded_post_id = $recorded_post->save();
    370 
    371             bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', time() );
     363            /* If we're on a multiblog install, record this post */
     364            if ( bp_core_is_multiblog_install() ) {
     365                $recorded_post = new BP_Blogs_Post;
     366                $recorded_post->user_id = $user_id;
     367                $recorded_post->blog_id = $blog_id;
     368                $recorded_post->post_id = $post_id;
     369                $recorded_post->date_created = strtotime( $post->post_date );
     370
     371                $recorded_post_id = $recorded_post->save();
     372
     373                bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', time() );
     374            }
    372375
    373376            if ( (int)get_blog_option( $blog_id, 'blog_public' ) || !bp_core_is_multiblog_install() ) {
     
    383386                    'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
    384387                    'component_action' => 'new_blog_post',
    385                     'item_id' => $recorded_post_id,
     388                    'item_id' => $blog_id,
     389                    'secondary_item_id' => $post_id,
    386390                    'recorded_time' => strtotime( $post->post_date )
    387391                ));
     
    450454        return false;
    451455
    452     $recorded_comment = new BP_Blogs_Comment;
    453     $recorded_comment->user_id = $user_id;
    454     $recorded_comment->blog_id = $wpdb->blogid;
    455     $recorded_comment->comment_id = $comment_id;
    456     $recorded_comment->comment_post_id = $comment->comment_post_ID;
    457     $recorded_comment->date_created = strtotime( $comment->comment_date );
    458 
    459     $recorded_commment_id = $recorded_comment->save();
    460 
    461     bp_blogs_update_blogmeta( $recorded_comment->blog_id, 'last_activity', time() );
     456    /* If we're on a multiblog install, record this post */
     457    if ( bp_core_is_multiblog_install() ) {
     458        $recorded_comment = new BP_Blogs_Comment;
     459        $recorded_comment->user_id = $user_id;
     460        $recorded_comment->blog_id = $wpdb->blogid;
     461        $recorded_comment->comment_id = $comment_id;
     462        $recorded_comment->comment_post_id = $comment->comment_post_ID;
     463        $recorded_comment->date_created = strtotime( $comment->comment_date );
     464
     465        $recorded_commment_id = $recorded_comment->save();
     466
     467        bp_blogs_update_blogmeta( $recorded_comment->blog_id, 'last_activity', time() );
     468    }
     469
     470    if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' ) || !bp_core_is_multiblog_install() ) {
     471        /* Record in activity streams */
     472        $comment_link = bp_post_get_permalink( $comment->post, $wpdb->blogid ) . '#comment-' . $comment_id;
     473        $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>' );
     474        $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
     475
     476        /* Record this in activity streams */
     477        bp_blogs_record_activity( array(
     478            'user_id' => $user_id,
     479            'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ),
     480            'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),
     481            'component_action' => 'new_blog_comment',
     482            'item_id' => $wpdb->blogid,
     483            'secondary_item_id' => $comment_id,
     484            'recorded_time' => strtotime( $comment->comment_date )
     485        ) );
     486    }
     487
     488    return $recorded_comment;
     489}
     490add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
     491
     492function bp_blogs_approve_comment( $comment_id, $comment_status ) {
     493    global $bp, $wpdb;
     494
     495    if ( 'approve' != $comment_status )
     496        return false;
     497
     498    $recorded_comment = bp_blogs_record_comment( $comment_id, true );
     499    $comment = get_comment($comment_id);
     500    $comment->post = get_post( $comment->comment_post_ID );
     501
     502    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' ) );
    462503
    463504    if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' ) || !bp_core_is_multiblog_install() ) {
    464505        /* Record in activity streams */
    465506        $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id );
    466         $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>' );
     507        $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>' );
    467508        $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
    468509
     
    478519        ) );
    479520    }
    480 
    481     return $recorded_comment;
    482 }
    483 add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
    484 
    485 function bp_blogs_approve_comment( $comment_id, $comment_status ) {
    486     global $bp, $wpdb;
    487 
    488     if ( 'approve' != $comment_status )
    489         return false;
    490 
    491     $recorded_comment = bp_blogs_record_comment( $comment_id, true );
    492     $comment = get_comment($comment_id);
    493     $comment->post = get_post( $comment->comment_post_ID );
    494 
    495     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' ) );
    496 
    497     if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' ) || !bp_core_is_multiblog_install() ) {
    498         /* Record in activity streams */
    499         $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id );
    500         $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>' );
    501         $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
    502 
    503         /* Record this in activity streams */
    504         bp_blogs_record_activity( array(
    505             'user_id' => $recorded_comment->user_id,
    506             'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ),
    507             'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),
    508             'component_action' => 'new_blog_comment',
    509             'item_id' => $comment_id,
    510             'secondary_item_id' => $recorded_comment->blog_id,
    511             'recorded_time' =>  $recorded_comment->date_created
    512         ) );
    513     }
    514521}
    515522add_action( 'wp_set_comment_status', 'bp_blogs_approve_comment', 10, 2 );
Note: See TracChangeset for help on using the changeset viewer.