Skip to:
Content

BuddyPress.org

Changeset 394 for trunk/bp-blogs.php


Ignore:
Timestamp:
10/23/2008 12:56:37 PM (18 years ago)
Author:
apeatling
Message:

Removed home base requirement

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-blogs.php

    r391 r394  
    250250
    251251
    252 function bp_blogs_record_blog( $blog_id = '', $user_id = '' ) {
     252function bp_blogs_record_blog( $blog_id, $user_id ) {
    253253        global $bp;
    254254       
    … …  
    261261                $user_id = $bp['loggedin_userid'];
    262262       
    263         if ( !get_usermeta( $user_id, 'home_base' ) )
    264                 return false;
    265                
    266         if ( (int)$blog_id != (int)get_usermeta( $user_id, 'home_base' ) ) {           
    267                 $recorded_blog = new BP_Blogs_Blog;
    268                 $recorded_blog->user_id = $user_id;
    269                 $recorded_blog->blog_id = $blog_id;
    270 
    271                 $recorded_blog_id = $recorded_blog->save();
    272                
    273                 do_action( 'bp_blogs_new_blog', array( 'item_id' => $recorded_blog_id, 'component_name' => 'blogs', 'component_action' => 'new_blog', 'is_private' => 0 ) );
    274         }
    275 }
    276 add_action( 'wpmu_new_blog', 'bp_blogs_record_blog', 10 );
    277 
    278 function bp_blogs_record_post($post_id = '') {
     263        $recorded_blog = new BP_Blogs_Blog;
     264        $recorded_blog->user_id = $user_id;
     265        $recorded_blog->blog_id = $blog_id;
     266       
     267        $recorded_blog_id = $recorded_blog->save();
     268       
     269        do_action( 'bp_blogs_new_blog', array( 'item_id' => $recorded_blog_id, 'component_name' => 'blogs', 'component_action' => 'new_blog', 'is_private' => 0 ) );
     270}
     271add_action( 'wpmu_new_blog', 'bp_blogs_record_blog', 10, 2 );
     272
     273
     274function bp_blogs_record_post($post_id) {
    279275        global $bp, $current_blog;
    280276       
    … …  
    325321add_action( 'publish_post', 'bp_blogs_record_post' );
    326322
    327 function bp_blogs_record_comment( $comment_id = '', $from_ajax = false ) {
     323function bp_blogs_record_comment( $comment_id, $from_ajax = false ) {
    328324        global $bp, $current_blog, $current_user;
    329325
    … …  
    376372        }
    377373}
    378 add_action( 'comment_post', 'bp_blogs_record_comment' );
    379 add_action( 'edit_comment', 'bp_blogs_record_comment' );
    380 
    381 
    382 function bp_blogs_modify_comment( $comment_id = '', $comment_status = '' ) {
     374add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
     375add_action( 'edit_comment', 'bp_blogs_record_comment', 10, 2 );
     376
     377
     378function bp_blogs_modify_comment( $comment_id, $comment_status ) {
    383379        global $bp;
    384380       
    … …  
    397393        }
    398394}
    399 add_action( 'wp_set_comment_status', 'bp_blogs_modify_comment' );
    400 
    401 function bp_blogs_remove_blog( $blog_id = '' ) {
     395add_action( 'wp_set_comment_status', 'bp_blogs_modify_comment', 10, 2 );
     396
     397function bp_blogs_remove_blog( $blog_id ) {
    402398        $blog_id = (int)$blog_id;
    403399
    … …  
    406402add_action( 'delete_blog', 'bp_blogs_remove_blog' );
    407403
    408 function bp_blogs_remove_blog_for_user( $user_id = '', $blog_id = '' ) {
     404function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
    409405        $blog_id = (int)$blog_id;
    410406        $user_id = (int)$user_id;
    … …  
    412408        BP_Blogs_Blog::delete_blog_for_user( $blog_id, $user_id );
    413409}
    414 add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog' );
    415 
    416 function bp_blogs_remove_post( $post_id = '' ) {
     410add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog', 10, 2 );
     411
     412function bp_blogs_remove_post( $post_id ) {
    417413        global $current_blog, $bp;
    418414       
    … …  
    429425add_action( 'delete_post', 'bp_blogs_remove_post' );
    430426
    431 function bp_blogs_remove_comment( $comment_id = '' ) {
     427function bp_blogs_remove_comment( $comment_id ) {
    432428        global $current_blog, $bp;
    433429       
    … …  
    445441
    446442function bp_blogs_remove_data( $blog_id ) {
    447 
    448         if ( $user_id = bp_core_get_homebase_userid( $blog_id ) ) {
    449                 /* If this is a home base, delete everything for that user. */
    450                 BP_Blogs_Blog::delete_blogs_for_user( $user_id );
    451                 BP_Blogs_Post::delete_posts_for_user( $user_id );
    452                 BP_Blogs_Comment::delete_comments_for_user( $user_id );
    453         } else {
    454                 /* If this is regular blog, delete all data for that blog. */
    455                 BP_Blogs_Blog::delete_blog_for_all( $blog_id );
    456                 BP_Blogs_Post::delete_posts_for_blog( $blog_id );               
    457                 BP_Blogs_Comment::delete_comments_for_blog( $blog_id );
    458         }
    459        
     443        /* If this is regular blog, delete all data for that blog. */
     444        BP_Blogs_Blog::delete_blog_for_all( $blog_id );
     445        BP_Blogs_Post::delete_posts_for_blog( $blog_id );               
     446        BP_Blogs_Comment::delete_comments_for_blog( $blog_id );
    460447}
    461448add_action( 'delete_blog', 'bp_blogs_remove_data', 1 );
    … …  
    474461        if ( is_array($blogs) ) {
    475462                foreach ( $blogs as $blog ) {
    476                         if ( (int)$blog->userblog_id != (int)get_usermeta( $user_id, 'home_base' ) ) {
    477                                 bp_blogs_record_blog( (int)$blog->userblog_id, (int)$user_id );
    478 
    479                                 switch_to_blog( $blog->userblog_id );
    480                                 $posts_for_blog = bp_core_get_all_posts_for_user( $user_id );
    481                        
    482                                 for ( $i = 0; $i < count($posts); $i++ ) {
    483                                         bp_blogs_record_post( $posts[$i] );
    484                                 }
     463                        bp_blogs_record_blog( (int)$blog->userblog_id, (int)$user_id );
     464
     465                        switch_to_blog( $blog->userblog_id );
     466                        $posts_for_blog = bp_core_get_all_posts_for_user( $user_id );
     467               
     468                        for ( $i = 0; $i < count($posts); $i++ ) {
     469                                bp_blogs_record_post( $posts[$i] );
    485470                        }
    486471                }
Note: See TracChangeset for help on using the changeset viewer.