Changeset 394 for trunk/bp-blogs.php
- Timestamp:
- 10/23/2008 12:56:37 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-blogs.php
r391 r394 250 250 251 251 252 function bp_blogs_record_blog( $blog_id = '', $user_id = '') {252 function bp_blogs_record_blog( $blog_id, $user_id ) { 253 253 global $bp; 254 254 … … 261 261 $user_id = $bp['loggedin_userid']; 262 262 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 } 271 add_action( 'wpmu_new_blog', 'bp_blogs_record_blog', 10, 2 ); 272 273 274 function bp_blogs_record_post($post_id) { 279 275 global $bp, $current_blog; 280 276 … … 325 321 add_action( 'publish_post', 'bp_blogs_record_post' ); 326 322 327 function bp_blogs_record_comment( $comment_id = '', $from_ajax = false ) {323 function bp_blogs_record_comment( $comment_id, $from_ajax = false ) { 328 324 global $bp, $current_blog, $current_user; 329 325 … … 376 372 } 377 373 } 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 = '') {374 add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 ); 375 add_action( 'edit_comment', 'bp_blogs_record_comment', 10, 2 ); 376 377 378 function bp_blogs_modify_comment( $comment_id, $comment_status ) { 383 379 global $bp; 384 380 … … 397 393 } 398 394 } 399 add_action( 'wp_set_comment_status', 'bp_blogs_modify_comment' );400 401 function bp_blogs_remove_blog( $blog_id = '') {395 add_action( 'wp_set_comment_status', 'bp_blogs_modify_comment', 10, 2 ); 396 397 function bp_blogs_remove_blog( $blog_id ) { 402 398 $blog_id = (int)$blog_id; 403 399 … … 406 402 add_action( 'delete_blog', 'bp_blogs_remove_blog' ); 407 403 408 function bp_blogs_remove_blog_for_user( $user_id = '', $blog_id = '') {404 function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) { 409 405 $blog_id = (int)$blog_id; 410 406 $user_id = (int)$user_id; … … 412 408 BP_Blogs_Blog::delete_blog_for_user( $blog_id, $user_id ); 413 409 } 414 add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog' );415 416 function bp_blogs_remove_post( $post_id = '') {410 add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog', 10, 2 ); 411 412 function bp_blogs_remove_post( $post_id ) { 417 413 global $current_blog, $bp; 418 414 … … 429 425 add_action( 'delete_post', 'bp_blogs_remove_post' ); 430 426 431 function bp_blogs_remove_comment( $comment_id = '') {427 function bp_blogs_remove_comment( $comment_id ) { 432 428 global $current_blog, $bp; 433 429 … … 445 441 446 442 function 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 ); 460 447 } 461 448 add_action( 'delete_blog', 'bp_blogs_remove_data', 1 ); … … 474 461 if ( is_array($blogs) ) { 475 462 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] ); 485 470 } 486 471 }
Note: See TracChangeset
for help on using the changeset viewer.