Skip to:
Content

BuddyPress.org

Changeset 2381 for trunk/bp-blogs.php


Ignore:
Timestamp:
01/20/2010 04:21:20 PM (16 years ago)
Author:
apeatling
Message:

Standardizing activity stream fields and splitting the action from the content for better manageability.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-blogs.php

    r2328 r2381  
    246246        $defaults = array(
    247247                'user_id' => $bp->loggedin_user->id,
    248                 'content' => false,
    249                 'primary_link' => false,
    250                 'component_name' => $bp->blogs->id,
    251                 'component_action' => false,
     248                'action' => '',
     249                'content' => '',
     250                'primary_link' => '',
     251                'component' => $bp->blogs->id,
     252                'type' => false,
    252253                'item_id' => false,
    253254                'secondary_item_id' => false,
     
    259260        extract( $r, EXTR_SKIP );
    260261
    261         return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
     262        return bp_activity_add( array( 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
    262263}
    263264
     
    268269                $defaults = array(
    269270                        'item_id' => false,
    270                         'component_name' => $bp->blogs->id,
    271                         'component_action' => false,
     271                        'component' => $bp->blogs->id,
     272                        'type' => false,
    272273                        'user_id' => false,
    273274                        'secondary_item_id' => false
     
    279280                bp_activity_delete_by_item_id( array(
    280281                        'item_id' => $item_id,
    281                         'component_name' => $component_name,
    282                         'component_action' => $component_action,
     282                        'component' => $component,
     283                        'type' => $type,
    283284                        'user_id' => $user_id,
    284285                        'secondary_item_id' => $secondary_item_id
     
    341342                bp_blogs_record_activity( array(
    342343                        'user_id' => $recorded_blog->user_id,
    343                         '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 ),
     344                        'action' => apply_filters( 'bp_blogs_activity_created_blog_action', 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 ),
    344345                        'primary_link' => apply_filters( 'bp_blogs_activity_created_blog_primary_link', get_blog_option( $recorded_blog->blog_id, 'siteurl' ), $recorded_blog->blog_id ),
    345                         'component_action' => 'new_blog',
     346                        'type' => 'new_blog',
    346347                        'item_id' => $recorded_blog->blog_id
    347348                ) );
     
    389390                                $post_permalink = bp_post_get_permalink( $post, $blog_id );
    390391
    391                                 $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>' );
    392                                 $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>";
     392                                $activity_action = 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>' );
     393                                $activity_content = "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>";
    393394
    394395                                bp_blogs_record_activity( array(
    395396                                        'user_id' => (int)$post->post_author,
    396                                         'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ),
     397                                        'action' => apply_filters( 'bp_blogs_activity_new_post_action', $activity_action, &$post, $post_permalink ),
     398                                        'content' => apply_filters( 'bp_blogs_activity_new_post_content', $activity_content, &$post, $post_permalink ),
    397399                                        'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
    398                                         'component_action' => 'new_blog_post',
     400                                        'type' => 'new_blog_post',
    399401                                        'item_id' => $blog_id,
    400402                                        'secondary_item_id' => $post_id,
     
    407409
    408410                /* Delete and the activity stream item as we are probably going to re-add it later with new info. */
    409                 bp_blogs_delete_activity( array( 'item_id' => $existing_post->id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_post' ) );
     411                bp_blogs_delete_activity( array( 'item_id' => $existing_post->id, 'component' => $bp->blogs->slug, 'type' => 'new_blog_post' ) );
    410412
    411413                /* Delete the recorded post if the status is not published or it is password protected */
     
    426428                        $post_permalink = bp_post_get_permalink( $post, $blog_id );
    427429
    428                         $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>' );
    429                         $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>";
     430                        $activity_action = 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>' );
     431                        $activity_content = "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>";
    430432
    431433                        /* Record this in activity streams */
    432434                        bp_blogs_record_activity( array(
    433435                                'user_id' => (int)$post->post_author,
    434                                 'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ),
     436                                'action' => apply_filters( 'bp_blogs_activity_new_post_action', $activity_action, &$post, $post_permalink ),
     437                                'content' => apply_filters( 'bp_blogs_activity_new_post_content', $activity_content, &$post, $post_permalink ),
    435438                                'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
    436                                 'component_action' => 'new_blog_post',
     439                                'type' => 'new_blog_post',
    437440                                'item_id' => $blog_id,
    438441                                'secondary_item_id' => $existing_post->id,
     
    483486                /* Record in activity streams */
    484487                $comment_link = bp_post_get_permalink( $comment->post, $wpdb->blogid ) . '#comment-' . $comment_id;
    485                 $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>' );
    486                 $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
     488                $activity_action = 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>' );
     489                $activity_content = '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
    487490
    488491                /* Record this in activity streams */
    489492                bp_blogs_record_activity( array(
    490493                        'user_id' => $user_id,
    491                         'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ),
     494                        'action' => apply_filters( 'bp_blogs_activity_new_comment_action', $activity_action, &$comment, &$recorded_comment, $comment_link ),
     495                        'content' => apply_filters( 'bp_blogs_activity_new_comment_content', $activity_content, &$comment, &$recorded_comment, $comment_link ),
    492496                        'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),
    493                         'component_action' => 'new_blog_comment',
     497                        'type' => 'new_blog_comment',
    494498                        'item_id' => $wpdb->blogid,
    495499                        'secondary_item_id' => $comment_id,
     
    530534
    531535        // Delete activity stream item
    532         bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog' ) );
     536        bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component' => $bp->blogs->slug, 'type' => 'new_blog' ) );
    533537
    534538        do_action( 'bp_blogs_remove_blog', $blog_id );
     
    545549
    546550        // Delete activity stream item
    547         bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog' ) );
     551        bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component' => $bp->blogs->slug, 'type' => 'new_blog' ) );
    548552
    549553        do_action( 'bp_blogs_remove_blog_for_user', $blog_id, $user_id );
     
    566570
    567571        // Delete activity stream item
    568         bp_blogs_delete_activity( array( 'item_id' => $wpdb->blogid, 'component_name' => $existing_post->id, 'component_action' => 'new_blog_post' ) );
     572        bp_blogs_delete_activity( array( 'item_id' => $wpdb->blogid, 'component' => $existing_post->id, 'type' => 'new_blog_post' ) );
    569573
    570574        do_action( 'bp_blogs_remove_post', $blog_id, $post_id, $post->user_id );
     
    579583
    580584        // Delete activity stream item
    581         bp_blogs_delete_activity( array( 'item_id' => $wpdb->blogid, 'secondary_item_id' => $comment_id, 'component_action' => 'new_blog_comment' ) );
     585        bp_blogs_delete_activity( array( 'item_id' => $wpdb->blogid, 'secondary_item_id' => $comment_id, 'type' => 'new_blog_comment' ) );
    582586
    583587        do_action( 'bp_blogs_remove_comment', $blog_id, $comment_id, $bp->loggedin_user->id );
     
    608612
    609613        // Delete activity stream item
    610         bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component_name' => $bp->blogs->slug, 'component_action' => false ) );
     614        bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component' => $bp->blogs->slug, 'type' => false ) );
    611615
    612616        do_action( 'bp_blogs_remove_data_for_blog', $blog_id );
Note: See TracChangeset for help on using the changeset viewer.