Changeset 3232
- Timestamp:
- 09/06/2010 04:24:57 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 41 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-classes.php
r2951 r3232 35 35 $this->component = $row->component; 36 36 $this->type = $row->type; 37 $this->action = $row-> action;37 $this->action = $row->type; 38 38 $this->content = $row->content; 39 39 $this->date_recorded = $row->date_recorded; -
trunk/bp-activity/bp-activity-notifications.php
r2941 r3232 13 13 14 14 foreach( (array)$usernames as $username ) { 15 if ( !$receiver_user_id = bp_core_get_userid( $username) )15 if ( !$receiver_user_id = bp_core_get_userid($username) ) 16 16 continue; 17 17 -
trunk/bp-activity/bp-activity-templatetags.php
r2944 r3232 275 275 $total = bp_core_number_format( $activities_template->total_activity_count ); 276 276 277 return sprintf( __( 'Viewing item % 1$s to %2$s (of %3$s items)', 'buddypress' ), $from_num, $to_num, $total ) . ' <span class="ajax-loader"></span>';277 return sprintf( __( 'Viewing item %s to %s (of %s items)', 'buddypress' ), $from_num, $to_num, $total ) . ' <span class="ajax-loader"></span>'; 278 278 } 279 279 -
trunk/bp-blogs.php
r2946 r3232 10 10 global $bp, $wpdb; 11 11 12 if ( !defined( 'BP_BLOGS_SLUG' ) )13 define ( 'BP_BLOGS_SLUG', $bp->pages->blogs->slug );14 15 12 /* For internal identification */ 16 13 $bp->blogs->id = 'blogs'; 17 $bp->blogs->name = $bp->pages->blogs->name; 14 18 15 $bp->blogs->slug = BP_BLOGS_SLUG; 19 16 20 $bp->blogs->table_name = $wpdb->base_prefix . 'bp_user_blogs'; 21 $bp->blogs->table_name_blogmeta = $wpdb->base_prefix . 'bp_user_blogs_blogmeta'; 17 $bp->blogs->table_name = $bp->table_prefix . 'bp_user_blogs'; 18 $bp->blogs->table_name_blogmeta = $bp->table_prefix . 'bp_user_blogs_blogmeta'; 19 22 20 $bp->blogs->format_notification_function = 'bp_blogs_format_notifications'; 23 21 … … 97 95 do_action( 'bp_blogs_screen_my_blogs' ); 98 96 bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'members/single/home' ) ); 97 } 98 99 function bp_blogs_screen_recent_posts() { 100 do_action( 'bp_blogs_screen_recent_posts' ); 101 bp_core_load_template( apply_filters( 'bp_blogs_template_recent_posts', 'members/single/home' ) ); 102 } 103 104 function bp_blogs_screen_recent_comments() { 105 do_action( 'bp_blogs_screen_recent_comments' ); 106 bp_core_load_template( apply_filters( 'bp_blogs_template_recent_comments', 'members/single/home' ) ); 99 107 } 100 108 … … 237 245 } 238 246 247 239 248 function bp_blogs_record_existing_blogs() { 240 249 global $bp, $wpdb; … … 308 317 $user_id = (int)$post->post_author; 309 318 310 /* This is to stop infin ite loops with Donncha's sitewide tags plugin */319 /* This is to stop infinate loops with Donncha's sitewide tags plugin */ 311 320 if ( (int)$bp->site_options['tags_blog_id'] == (int)$blog_id ) 312 321 return false; … … 316 325 return false; 317 326 318 if ( 'publish' == $post->post_status && '' == $post->post_password ) { 327 if ( !$is_recorded = BP_Blogs_Post::is_recorded( $post_id, $blog_id, $user_id ) ) { 328 if ( 'publish' == $post->post_status && '' == $post->post_password ) { 329 330 /* If we're on a multiblog install, record this post */ 331 if ( bp_core_is_multisite() ) { 332 $recorded_post = new BP_Blogs_Post; 333 $recorded_post->user_id = $user_id; 334 $recorded_post->blog_id = $blog_id; 335 $recorded_post->post_id = $post_id; 336 $recorded_post->date_created = strtotime( $post->post_date ); 337 338 $recorded_post_id = $recorded_post->save(); 339 340 bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) ); 341 } 342 343 if ( (int)get_blog_option( $blog_id, 'blog_public' ) || !bp_core_is_multisite() ) { 344 /* Record this in activity streams */ 345 $post_permalink = get_permalink( $post_id ); 346 347 $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>' ); 348 $activity_content = $post->post_content; 349 350 bp_blogs_record_activity( array( 351 'user_id' => (int)$post->post_author, 352 'action' => apply_filters( 'bp_blogs_activity_new_post_action', $activity_action, &$post, $post_permalink ), 353 'content' => apply_filters( 'bp_blogs_activity_new_post_content', $activity_content, &$post, $post_permalink ), 354 'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ), 355 'type' => 'new_blog_post', 356 'item_id' => $blog_id, 357 'secondary_item_id' => $post_id, 358 'recorded_time' => $post->post_date_gmt 359 )); 360 } 361 } 362 } else { 363 $existing_post = new BP_Blogs_Post( null, $blog_id, $post_id ); 364 365 /* Delete the recorded post if the status is not published or it is password protected */ 366 if ( 'publish' != $post->post_status || '' != $post->post_password ) { 367 return bp_blogs_remove_post( $post_id, $blog_id, $existing_post ); 368 369 /* If the post author has changed, delete the post and re-add it. */ 370 } else if ( (int)$existing_post->user_id != (int)$post->post_author ) { 371 // Delete the existing recorded post 372 bp_blogs_remove_post( $post_id, $blog_id, $existing_post ); 373 374 // Re-record the post with the new author. 375 bp_blogs_record_post( $post_id ); 376 } 377 319 378 bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) ); 320 379 321 380 if ( (int)get_blog_option( $blog_id, 'blog_public' ) || !bp_core_is_multisite() ) { 322 /* Record this inactivity streams */381 /* Now re-record the post in the activity streams */ 323 382 $post_permalink = get_permalink( $post_id ); 324 383 … … 335 394 'secondary_item_id' => $post_id, 336 395 'recorded_time' => $post->post_date_gmt 337 ) );396 ) ); 338 397 } 339 } else 340 bp_blogs_remove_post( $post_id, $blog_id ); 398 } 341 399 342 400 bp_blogs_update_blogmeta( $blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) ); 343 401 344 do_action( 'bp_blogs_new_blog_post', $ post_id, $post, $user_id );402 do_action( 'bp_blogs_new_blog_post', $existing_post, $is_private, $is_recorded ); 345 403 } 346 404 add_action( 'save_post', 'bp_blogs_record_post', 10, 2 ); … … 349 407 global $wpdb, $bp; 350 408 351 $comment = get_comment($comment_id); 352 353 if ( !$is_approved ) 354 return false; 355 356 $comment->post = get_post( $comment->comment_post_ID ); 357 358 /* Get the user_id from the author email. */ 359 $user = get_user_by_email( $comment->comment_author_email ); 409 // Get the users comment 410 $recorded_comment = get_comment( $comment_id ); 411 412 // Don't record activity if the comment hasn't been approved 413 if ( !$is_approved || !$recorded_comment->comment_approved ) 414 return false; 415 416 // Don't record activity if no email address has been included 417 if ( empty( $recorded_comment->comment_author_email ) ) 418 return false; 419 420 // Get the user_id from the comment author email. 421 $user = get_user_by_email( $recorded_comment->comment_author_email ); 360 422 $user_id = (int)$user->ID; 361 423 362 if ( !$user_id ) 363 return false; 364 365 /* If this is a password protected post, don't record the comment */ 366 if ( !empty( $post->post_password ) ) 367 return false; 368 369 if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' ) || !bp_core_is_multisite() ) { 370 /* Record in activity streams */ 371 $comment_link = get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment_id; 372 $activity_action = sprintf( __( '%1$s commented on the blog post %2$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' ); 373 $activity_content = $comment->comment_content; 374 375 /* Record this in activity streams */ 424 // If there's no registered user id, don't record activity 425 if ( empty( $user_id ) ) 426 return false; 427 428 // Get blog and post data 429 $blog_id = (int)$wpdb->blogid; 430 $recorded_comment->post = get_post( $recorded_comment->comment_post_ID ); 431 432 // If this is a password protected post, don't record the comment 433 if ( !empty( $recorded_comment->post->post_password ) ) 434 return false; 435 436 // If blog is public allow activity to be posted 437 if ( get_blog_option( $blog_id, 'blog_public' ) ) { 438 // Get activity related links 439 $post_permalink = get_permalink( $recorded_comment->comment_post_ID ); 440 $comment_link = htmlspecialchars( get_comment_link( $recorded_comment->comment_ID ) ); 441 442 // Prepare to record in activity streams 443 $activity_action = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>' ); 444 $activity_content = $recorded_comment->comment_content; 445 446 // Record in activity streams 376 447 bp_blogs_record_activity( array( 377 'user_id' => $user_id,378 'action' => apply_filters( 'bp_blogs_activity_new_comment_action', $activity_action, &$comment, &$recorded_comment, $comment_link ),379 'content' => apply_filters( 'bp_blogs_activity_new_comment_content', $activity_content, &$comment, &$recorded_comment, $comment_link ),380 'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),381 'type' => 'new_blog_comment',382 'item_id' => $wpdb->blogid,448 'user_id' => $user_id, 449 'action' => apply_filters( 'bp_blogs_activity_new_comment_action', $activity_action, &$recorded_comment, $comment_link ), 450 'content' => apply_filters( 'bp_blogs_activity_new_comment_content', $activity_content, &$recorded_comment, $comment_link ), 451 'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$recorded_comment ), 452 'type' => 'new_blog_comment', 453 'item_id' => $blog_id, 383 454 'secondary_item_id' => $comment_id, 384 'recorded_time' => $comment->comment_date_gmt455 'recorded_time' => $recorded_comment->comment_date_gmt 385 456 ) ); 386 } 387 388 bp_blogs_update_blogmeta( $blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) ); 457 458 // Update the blogs last active date 459 bp_blogs_update_blogmeta( $blog_id, 'last_activity', bp_core_current_time() ); 460 } 389 461 390 462 return $recorded_comment; … … 451 523 add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog_for_user', 10, 2 ); 452 524 453 function bp_blogs_remove_post( $post_id, $blog_id = false ) {525 function bp_blogs_remove_post( $post_id, $blog_id = false, $existing_post = false ) { 454 526 global $current_blog, $bp; 455 527 … … 459 531 $blog_id = (int)$current_blog->blog_id; 460 532 533 if ( !$existing_post ) 534 $existing_post = new BP_Blogs_Post( null, $blog_id, $post_id ); 535 536 // Delete post from the bp_blogs table 537 BP_Blogs_Post::delete( $post_id, $blog_id ); 538 461 539 // Delete activity stream item 462 540 bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'secondary_item_id' => $post_id, 'component' => $bp->blogs->slug, 'type' => 'new_blog_post' ) ); … … 468 546 function bp_blogs_remove_comment( $comment_id ) { 469 547 global $wpdb, $bp; 548 549 $recorded_comment = new BP_Blogs_Comment( false, $wpdb->blogid, $comment_id ); 550 BP_Blogs_Comment::delete( $comment_id, $wpdb->blogid ); 470 551 471 552 // Delete activity stream item … … 504 585 /* If this is regular blog, delete all data for that blog. */ 505 586 BP_Blogs_Blog::delete_blog_for_all( $blog_id ); 587 BP_Blogs_Post::delete_posts_for_blog( $blog_id ); 588 BP_Blogs_Comment::delete_comments_for_blog( $blog_id ); 506 589 507 590 // Delete activity stream item … … 516 599 } 517 600 601 /* DEPRECATED - scheduled for removal. Please use the activity stream with a 'new_blog_post' filter. */ 602 function bp_blogs_get_posts_for_user( $user_id ) { 603 return BP_Blogs_Post::get_posts_for_user( $user_id ); 604 } 605 606 /* DEPRECATED - scheduled for removal. Please use the activity stream with a 'new_blog_comment' filter. */ 607 function bp_blogs_get_comments_for_user( $user_id ) { 608 return BP_Blogs_Comment::get_comments_for_user( $user_id ); 609 } 610 611 function bp_blogs_get_latest_posts( $blog_id = null, $limit = 5 ) { 612 global $bp; 613 614 if ( !is_numeric( $limit ) ) 615 $limit = 5; 616 617 return BP_Blogs_Post::get_latest_posts( $blog_id, $limit ); 618 } 619 518 620 function bp_blogs_get_all_blogs( $limit = null, $page = null ) { 519 621 return BP_Blogs_Blog::get_all( $limit, $page ); … … 522 624 function bp_blogs_get_random_blogs( $limit = null, $page = null ) { 523 625 return BP_Blogs_Blog::get( 'random', $limit, $page ); 626 } 627 628 function bp_blogs_get_all_posts( $limit = null, $page = null ) { 629 return BP_Blogs_Post::get_all( $limit, $page ); 630 } 631 632 function bp_blogs_total_post_count( $blog_id ) { 633 return BP_Blogs_Post::total_post_count( $blog_id ); 634 } 635 636 function bp_blogs_total_comment_count( $blog_id, $post_id = false ) { 637 return BP_Blogs_Post::total_comment_count( $blog_id, $post_id ); 524 638 } 525 639 … … 640 754 641 755 function bp_blogs_remove_data( $user_id ) { 642 if ( !bp_core_is_multisite() )643 return false;644 645 756 /* If this is regular blog, delete all data for that blog. */ 646 757 BP_Blogs_Blog::delete_blogs_for_user( $user_id ); 758 BP_Blogs_Post::delete_posts_for_user( $user_id ); 759 BP_Blogs_Comment::delete_comments_for_user( $user_id ); 647 760 648 761 do_action( 'bp_blogs_remove_data', $user_id ); 649 762 } 650 add_action( 'wpmu_delete_user', 'bp_blogs_remove_data' ); 651 add_action( 'delete_user', 'bp_blogs_remove_data' ); 652 add_action( 'make_spam_user', 'bp_blogs_remove_data' ); 763 add_action( 'wpmu_delete_user', 'bp_blogs_remove_data', 1 ); 764 add_action( 'delete_user', 'bp_blogs_remove_data', 1 ); 653 765 654 766 … … 677 789 } 678 790 791 function bp_blogs_clear_post_object_cache( $blog_id, $post_id, $user_id ) { 792 wp_cache_delete( 'bp_user_posts_' . $user_id, 'bp' ); 793 } 794 795 function bp_blogs_format_clear_post_cache( $recorded_post_obj ) { 796 bp_blogs_clear_post_object_cache( false, false, $recorded_post_obj->user_id ); 797 798 /* Clear the sitewide activity cache */ 799 wp_cache_delete( 'sitewide_activity', 'bp' ); 800 } 801 802 function bp_blogs_clear_comment_object_cache( $blog_id, $comment_id, $user_id ) { 803 wp_cache_delete( 'bp_user_comments_' . $user_id, 'bp' ); 804 } 805 806 function bp_blogs_format_clear_comment_cache( $recorded_comment_obj ) { 807 bp_blogs_clear_comment_object_cache( false, false, $recorded_comment_obj->user_id ); 808 809 /* Clear the sitewide activity cache */ 810 wp_cache_delete( 'sitewide_activity', 'bp' ); 811 } 812 679 813 // List actions to clear object caches on 680 814 add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_clear_blog_object_cache', 10, 2 ); 815 add_action( 'bp_blogs_remove_post', 'bp_blogs_clear_post_object_cache', 10, 3 ); 816 add_action( 'bp_blogs_remove_comment', 'bp_blogs_clear_comment_object_cache', 10, 3 ); 817 681 818 add_action( 'bp_blogs_new_blog', 'bp_blogs_format_clear_blog_cache', 10, 2 ); 819 add_action( 'bp_blogs_new_blog_post', 'bp_blogs_format_clear_post_cache', 10, 2 ); 820 add_action( 'bp_blogs_new_blog_comment', 'bp_blogs_format_clear_comment_cache', 10, 2 ); 682 821 683 822 // List actions to clear super cached pages on, if super cache is installed -
trunk/bp-blogs/bp-blogs-classes.php
r2842 r3232 279 279 return $paged_blogs; 280 280 281 for ( $i = 0; $i < count( $paged_blogs ); $i++ ) 282 $paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT post_title, guid FROM {$wpdb->base_prefix}" . $paged_blogs[$i]->blog_id . "_posts WHERE post_status = 'publish' AND post_type = 'post' AND id != 1 ORDER BY id DESC LIMIT 1" ); 281 /* Fetch lastest post for each blog. */ 282 $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.blog_id IN ( {$blog_ids} ) GROUP BY p.blog_id ORDER BY p.date_created DESC" ) ); 283 284 for ( $i = 0; $i < count( $paged_blogs ); $i++ ) { 285 foreach ( (array)$post_ids as $post ) { 286 if ( $post->blog_id == $paged_blogs[$i]->blog_id ) { 287 $paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT post_title, guid FROM {$wpdb->base_prefix}" . $post->blog_id . "_posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY id DESC LIMIT 1" ); 288 } 289 } 290 } 283 291 284 292 /* Fetch the blog description for each blog (as it may be empty we can't fetch it in the main query). */ … … 308 316 } 309 317 318 /* DEPRECATED - Post DB recording is scheduled for removal. Please use the activity stream to fetch a user's posts. */ 319 Class BP_Blogs_Post { 320 var $id; 321 var $user_id; 322 var $blog_id; 323 var $post_id; 324 var $date_created; 325 326 function bp_blogs_post( $id = null, $blog_id = null, $post_id = null ) { 327 global $bp, $wpdb; 328 329 if ( $id || ( !$id && $blog_id && $post_id ) ) { 330 $this->id = $id; 331 $this->blog_id = $blog_id; 332 $this->post_id = $post_id; 333 $this->populate(); 334 } 335 } 336 337 function populate() { 338 global $wpdb, $bp; 339 340 if ( $this->id ) 341 $post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_posts} WHERE id = %d", $this->id ) ); 342 else 343 $post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d AND post_id = %d", $this->blog_id, $this->post_id ) ); 344 345 $this->id = $post->id; 346 $this->user_id = $post->user_id; 347 $this->blog_id = $post->blog_id; 348 $this->post_id = $post->post_id; 349 $this->date_created = $post->date_created; 350 } 351 352 function save() { 353 global $wpdb, $bp; 354 355 $this->post_id = apply_filters( 'bp_blogs_post_id_before_save', $this->post_id, $this->id ); 356 $this->blog_id = apply_filters( 'bp_blogs_post_blog_id_before_save', $this->blog_id, $this->id ); 357 $this->user_id = apply_filters( 'bp_blogs_post_user_id_before_save', $this->user_id, $this->id ); 358 $this->date_created = apply_filters( 'bp_blogs_post_date_created_before_save', $this->date_created, $this->id ); 359 360 do_action( 'bp_blogs_post_before_save', $this ); 361 362 if ( $this->id ) { 363 // Update 364 $sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name_blog_posts} SET post_id = %d, blog_id = %d, user_id = %d, date_created = FROM_UNIXTIME(%d) WHERE id = %d", $this->post_id, $this->blog_id, $this->user_id, $this->date_created, $this->id ); 365 } else { 366 // Save 367 $sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blog_posts} ( post_id, blog_id, user_id, date_created ) VALUES ( %d, %d, %d, FROM_UNIXTIME(%d) )", $this->post_id, $this->blog_id, $this->user_id, $this->date_created ); 368 } 369 370 if ( !$wpdb->query($sql) ) 371 return false; 372 373 do_action( 'bp_blogs_post_after_save', $this ); 374 375 if ( $this->id ) 376 return $this->id; 377 else 378 return $wpdb->insert_id; 379 } 380 381 /* Static Functions */ 382 383 function delete( $post_id, $blog_id ) { 384 global $wpdb, $bp, $current_user; 385 386 if ( !$bp->blogs ) 387 bp_blogs_setup_globals(); 388 389 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d AND post_id = %d", $blog_id, $post_id ) ); 390 } 391 392 function delete_oldest( $user_id = null ) { 393 global $wpdb, $bp; 394 395 if ( !$bp->blogs ) 396 bp_blogs_setup_globals(); 397 398 if ( !$user_id ) 399 $user_id = $current_user->ID; 400 401 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d ORDER BY date_created ASC LIMIT 1", $user_id ) ); 402 } 403 404 function delete_posts_for_user( $user_id = null ) { 405 global $wpdb, $bp; 406 407 if ( !$bp->blogs ) 408 bp_blogs_setup_globals(); 409 410 if ( !$user_id ) 411 $user_id = $bp->loggedin_user->id; 412 413 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d", $user_id ) ); 414 } 415 416 function delete_posts_for_blog( $blog_id ) { 417 global $wpdb, $bp; 418 419 if ( !$bp->blogs ) 420 bp_blogs_setup_globals(); 421 422 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d", $blog_id ) ); 423 } 424 425 function get_latest_posts( $blog_id = null, $limit = 5 ) { 426 global $wpdb, $bp; 427 428 if ( !$bp->blogs ) 429 bp_blogs_setup_globals(); 430 431 if ( $blog_id ) 432 $blog_sql = $wpdb->prepare( " AND p.blog_id = %d", $blog_id ); 433 434 $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 $blog_sql ORDER BY p.date_created DESC LIMIT $limit" ) ); 435 436 for ( $i = 0; $i < count($post_ids); $i++ ) { 437 $posts[$i] = BP_Blogs_Post::fetch_post_content($post_ids[$i]); 438 } 439 440 return $posts; 441 } 442 443 function get_posts_for_user( $user_id = null ) { 444 global $bp, $wpdb; 445 446 if ( !$bp->blogs ) 447 bp_blogs_setup_globals(); 448 449 if ( !$user_id ) 450 $user_id = $bp->displayed_user->id; 451 452 // Show a logged in user their posts on private blogs, but not anyone else. 453 if ( !bp_is_my_profile() ) { 454 $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d ORDER BY p.date_created DESC", $user_id) ); 455 $total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(p.post_id) FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d", $user_id) ); 456 } else { 457 $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d ORDER BY p.date_created DESC", $user_id) ); 458 459 $total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(p.post_id) FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d", $user_id) ); 460 } 461 462 for ( $i = 0; $i < count($post_ids); $i++ ) { 463 $posts[$i] = BP_Blogs_Post::fetch_post_content($post_ids[$i]); 464 } 465 466 return array( 'posts' => $posts, 'count' => $total_post_count ); 467 } 468 469 function fetch_post_content( $post_object ) { 470 // TODO: switch_to_blog() calls are expensive and this needs to be changed. 471 switch_to_blog( $post_object->blog_id ); 472 $post = get_post($post_object->post_id); 473 $post->blog_id = $post_object->blog_id; 474 restore_current_blog(); 475 476 return $post; 477 } 478 479 function get_total_recorded_for_user( $user_id = null ) { 480 global $bp, $wpdb; 481 482 if ( !$bp->blogs ) 483 bp_blogs_setup_globals(); 484 485 if ( !$user_id ) 486 $user_id = $current_user->ID; 487 488 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(post_id) FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d", $user_id ) ); 489 } 490 491 function is_recorded( $post_id, $blog_id, $user_id = null ) { 492 global $bp, $wpdb, $current_user; 493 494 if ( !$bp->blogs ) 495 bp_blogs_setup_globals(); 496 497 if ( !$user_id ) 498 $user_id = $current_user->ID; 499 500 return $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$bp->blogs->table_name_blog_posts} WHERE post_id = %d AND blog_id = %d AND user_id = %d", $post_id, $blog_id, $user_id ) ); 501 } 502 503 function total_post_count( $blog_id ) { 504 global $bp, $wpdb; 505 506 if ( !$bp->blogs ) 507 bp_blogs_setup_globals(); 508 509 if ( !$blog_id ) 510 return false; 511 512 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(post_id) FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d", $blog_id ) ); 513 } 514 515 function get_all() { 516 global $bp, $wpdb; 517 518 if ( !$bp->blogs ) 519 bp_blogs_setup_globals(); 520 521 return $wpdb->get_col( $wpdb->prepare( "SELECT post_id, blog_id FROM " . $bp->blogs->table_name_blog_posts ) ); 522 } 523 524 } 525 526 /* DEPRECATED - Comment DB recording is scheduled for removal. Please use the activity stream to fetch a user's comments. */ 527 Class BP_Blogs_Comment { 528 var $id; 529 var $user_id; 530 var $blog_id; 531 var $comment_id; 532 var $comment_post_id; 533 var $date_created; 534 535 function bp_blogs_comment( $id = false, $blog_id = false, $comment_id = false ) { 536 global $bp, $wpdb; 537 538 if ( !$user_id ) 539 $user_id = $bp->displayed_user->id; 540 541 if ( $id || ( !$id && $blog_id && $comment_id ) ) { 542 $this->id = $id; 543 $this->blog_id = $blog_id; 544 $this->comment_id = $comment_id; 545 $this->populate(); 546 } 547 } 548 549 function populate() { 550 global $wpdb, $bp; 551 552 if ( $this->id ) 553 $comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_comments} WHERE id = %d", $this->id ) ); 554 else 555 $comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_comments} WHERE blog_id = %d AND comment_id = %d", (int)$this->blog_id, (int)$this->comment_id ) ); 556 557 $this->comment_id = $comment->comment_id; 558 $this->user_id = $comment->user_id; 559 $this->blog_id = $comment->blog_id; 560 $this->comment_post_id = $comment->comment_post_id; 561 $this->date_created = $comment->date_created; 562 } 563 564 function save() { 565 global $wpdb, $bp; 566 567 $this->comment_id = apply_filters( 'bp_blogs_comment_id_before_save', $this->comment_id, $this->id ); 568 $this->comment_post_id = apply_filters( 'bp_blogs_comment_post_id_before_save', $this->comment_post_id, $this->id ); 569 $this->blog_id = apply_filters( 'bp_blogs_comment_blog_id_before_save', $this->blog_id, $this->id ); 570 $this->user_id = apply_filters( 'bp_blogs_comment_user_id_before_save', $this->user_id, $this->id ); 571 $this->date_created = apply_filters( 'bp_blogs_comment_date_created_before_save', $this->date_created, $this->id ); 572 573 do_action( 'bp_blogs_comment_before_save', $this ); 574 575 if ( $this->id ) { 576 // Update 577 $sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name_blog_comments} SET comment_id = %d, comment_post_id = %d, blog_id = %d, user_id = %d, date_created = FROM_UNIXTIME(%d) WHERE id = %d", $this->comment_id, $this->comment_post_id, $this->blog_id, $this->user_id, $this->date_created, $this->id ); 578 } else { 579 // Save 580 $sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blog_comments} ( comment_id, comment_post_id, blog_id, user_id, date_created ) VALUES ( %d, %d, %d, %d, FROM_UNIXTIME(%d) )", $this->comment_id, $this->comment_post_id, $this->blog_id, $this->user_id, $this->date_created ); 581 } 582 583 if ( !$wpdb->query($sql) ) 584 return false; 585 586 do_action( 'bp_blogs_comment_after_save', $this ); 587 588 if ( $this->id ) 589 return $this->id; 590 else 591 return $wpdb->insert_id; 592 } 593 594 /* Static Functions */ 595 596 function delete( $comment_id, $blog_id ) { 597 global $wpdb, $bp, $current_user; 598 599 if ( !$bp->blogs ) 600 bp_blogs_setup_globals(); 601 602 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE comment_id = %d AND blog_id = %d", $comment_id, $blog_id ) ); 603 } 604 605 function delete_oldest( $user_id = null ) { 606 global $wpdb, $bp, $current_user; 607 608 if ( !$bp->blogs ) 609 bp_blogs_setup_globals(); 610 611 if ( !$user_id ) 612 $user_id = $current_user->ID; 613 614 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d ORDER BY date_created ASC LIMIT 1", $user_id ) ); 615 } 616 617 function delete_comments_for_user( $user_id = null ) { 618 global $wpdb, $bp; 619 620 if ( !$bp->blogs ) 621 bp_blogs_setup_globals(); 622 623 if ( !$user_id ) 624 $user_id = $bp->loggedin_user->id; 625 626 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d", $user_id ) ); 627 } 628 629 function delete_comments_for_blog( $blog_id ) { 630 global $wpdb, $bp; 631 632 if ( !$bp->blogs ) 633 bp_blogs_setup_globals(); 634 635 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE blog_id = %d", $blog_id ) ); 636 } 637 638 function get_comments_for_user( $user_id = null ) { 639 global $bp, $wpdb; 640 641 if ( !$bp->blogs ) 642 bp_blogs_setup_globals(); 643 644 if ( !$user_id ) 645 $user_id = $bp->displayed_user->id; 646 647 // Show the logged in user their comments on hidden blogs, but not to anyone else. 648 if ( !bp_is_my_profile() ) { 649 $comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id) ); 650 $total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id) ); 651 } else { 652 $comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id) ); 653 654 $total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id) ); 655 } 656 657 for ( $i = 0; $i < count($comment_ids); $i++ ) 658 $comments[$i] = BP_Blogs_Comment::fetch_comment_content($comment_ids[$i]); 659 660 return array( 'comments' => $comments, 'count' => $total_comment_count ); 661 } 662 663 function fetch_comment_content( $comment_object ) { 664 switch_to_blog($comment_object->blog_id); 665 $comment = get_comment($comment_object->comment_id); 666 $comment->blog_id = $comment_object->blog_id; 667 $comment->post = &get_post( $comment->comment_post_ID ); 668 restore_current_blog(); 669 670 return $comment; 671 } 672 673 function get_total_recorded_for_user( $user_id = null ) { 674 global $bp, $wpdb, $current_user; 675 676 if ( !$bp->blogs ) 677 bp_blogs_setup_globals(); 678 679 if ( !$user_id ) 680 $user_id = $current_user->ID; 681 682 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_id) FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d", $user_id ) ); 683 } 684 685 function total_comment_count( $blog_id, $post_id ) { 686 global $bp, $wpdb; 687 688 if ( !$bp->blogs ) 689 bp_blogs_setup_globals(); 690 691 if ( $post_id ) 692 $post_sql = $wpdb->prepare( " AND comment_post_id = %d", $post_id ); 693 694 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_id) WHERE blog_id = %d{$post_sql}", $blog_id ) ); 695 } 696 697 698 function is_recorded( $comment_id, $comment_post_id, $blog_id, $user_id = null ) { 699 global $bp, $wpdb, $current_user; 700 701 if ( !$bp->blogs ) 702 bp_blogs_setup_globals(); 703 704 if ( !$user_id ) 705 $user_id = $current_user->ID; 706 707 return $wpdb->get_var( $wpdb->prepare( "SELECT comment_id FROM {$bp->blogs->table_name_blog_comments} WHERE comment_id = %d AND blog_id = %d AND comment_post_id = %d AND user_id = %d", $comment_id, $blog_id, $comment_post_id, $user_id ) ); 708 } 709 710 } 711 310 712 ?> -
trunk/bp-blogs/bp-blogs-templatetags.php
r2944 r3232 145 145 146 146 $blogs_template = new BP_Blogs_Template( $type, $page, $per_page, $max, $user_id, $search_terms ); 147 return apply_filters( 'bp_has_blogs', $blogs_template->has_blogs(), &$blogs_template);147 return $blogs_template->has_blogs(); 148 148 } 149 149 … … 167 167 $total = bp_core_number_format( $blogs_template->total_blog_count ); 168 168 169 echo sprintf( __( 'Viewing blog % 1$s to %2$s (of %3$s blogs)', 'buddypress' ), $from_num, $to_num, $total ); ?> 169 echo sprintf( __( 'Viewing blog %s to %s (of %s blogs)', 'buddypress' ), $from_num, $to_num, $total ); ?> 170 170 <span class="ajax-loader"></span><?php 171 171 } -
trunk/bp-core.php
r2978 r3232 30 30 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php' ); 31 31 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php' ); 32 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-filters.php' );33 32 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php' ); 34 33 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-avatars.php' ); … … 38 37 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-notifications.php' ); 39 38 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-signup.php' ); 39 40 /* Multisite includes built in account activation support. */ 41 if ( bp_core_is_multisite() ) 42 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-activation.php' ); 40 43 41 44 /* If BP_DISABLE_ADMIN_BAR is defined, do not load the global admin bar. */ … … 229 232 } 230 233 231 232 234 return apply_filters( 'bp_core_get_page_names', $pages ); 233 235 } 236 234 237 235 238 /** … … 463 466 } 464 467 465 do_action( 'bp_core_action_ delete_user', $errors );468 do_action( 'bp_core_action_set_spammer_status', $errors ); 466 469 467 470 if ( $errors ) … … 497 500 'search_terms' => false, // Limit to users that match these search terms 498 501 499 'include' => false, // Pass comma separated list of user_ids to limit to only these users500 502 'per_page' => 20, // The number of results to return per page 501 503 'page' => 1, // The page to return if limiting per page … … 506 508 extract( $params, EXTR_SKIP ); 507 509 508 return apply_filters( 'bp_core_get_users', BP_Core_User::get_users( $type, $per_page, $page, $user_id, $ include, $search_terms, $populate_extras ), &$params );510 return apply_filters( 'bp_core_get_users', BP_Core_User::get_users( $type, $per_page, $page, $user_id, $search_terms, $populate_extras ), &$params ); 509 511 } 510 512 … … 898 900 } 899 901 900 901 902 /** 902 903 * bp_core_get_random_member() … … 934 935 global $wpdb; 935 936 936 if ( empty( $username ) ) 937 return false; 938 939 return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) ); 937 if ( !empty( $username ) ) 938 return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) ); 940 939 } 941 940 … … 1290 1289 add_action( 'bp_init', 'bp_core_setup_message' ); 1291 1290 1291 1292 1292 /** 1293 1293 * bp_core_render_message() … … 1331 1331 function bp_core_time_since( $older_date, $newer_date = false ) { 1332 1332 // array of time period chunks 1333 1334 1333 $chunks = array( 1335 1334 array( 60 * 60 * 24 * 365 , __( 'year', 'buddypress' ), __( 'years', 'buddypress' ) ), … … 1451 1450 return $number; 1452 1451 1453 return apply_filters( 'bp_core_ number_format', number_format( $number, $decimals ), $number, $decimals );1452 return apply_filters( 'bp_core_bp_core_number_format', number_format( $number, $decimals ), $number, $decimals ); 1454 1453 } 1455 1454 … … 1498 1497 unset( $site_path[2] ); 1499 1498 1500 if ( !count( $site_path ) ) 1501 $site_path = '/'; 1502 else 1503 $site_path = '/' . implode( '/', $site_path ) . '/'; 1499 $site_path = '/' . implode( '/', $site_path ) . '/'; 1504 1500 } 1505 1501 } … … 1507 1503 return apply_filters( 'bp_core_get_site_path', $site_path ); 1508 1504 } 1505 1509 1506 /** 1510 1507 * bp_core_get_site_options() … … 1623 1620 1624 1621 /** 1622 * bp_core_email_from_name_filter() 1623 * 1624 * Sets the "From" name in emails sent to the name of the site and not "WordPress" 1625 * 1626 * @package BuddyPress Core 1627 * @uses get_blog_option() fetches the value for a meta_key in the wp_X_options table 1628 * @return The blog name for the root blog 1629 */ 1630 function bp_core_email_from_name_filter() { 1631 return apply_filters( 'bp_core_email_from_name_filter', get_blog_option( BP_ROOT_BLOG, 'blogname' ) ); 1632 } 1633 add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' ); 1634 1635 1636 /** 1637 * bp_core_email_from_name_filter() 1638 * 1639 * Sets the "From" address in emails sent 1640 * 1641 * @package BuddyPress Core 1642 * @global $current_site Object containing current site metadata 1643 * @return noreply@sitedomain email address 1644 */ 1645 function bp_core_email_from_address_filter() { 1646 $domain = (array) explode( '/', site_url() ); 1647 1648 return apply_filters( 'bp_core_email_from_address_filter', __( 'noreply', 'buddypress' ) . '@' . $domain[2] ); 1649 } 1650 add_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' ); 1651 1652 /** 1625 1653 * bp_core_delete_account() 1626 1654 * … … 1635 1663 */ 1636 1664 function bp_core_delete_account( $user_id = false ) { 1637 global $bp, $wp db;1665 global $bp, $wp_version; 1638 1666 1639 1667 if ( !$user_id ) … … 1644 1672 return false; 1645 1673 1674 /* Site admins cannot be deleted */ 1675 if ( is_super_admin( bp_core_get_username( $user_id ) ) ) 1676 return false; 1677 1646 1678 /* Specifically handle multi-site environment */ 1647 1679 if ( bp_core_is_multisite() ) { 1648 /* Site admins cannot be deleted */1649 if ( is_site_admin( bp_core_get_username( $user_id ) ) )1650 return false;1651 1652 require_once( ABSPATH . '/wp-admin/includes/mu.php' ); 1680 if ( $wp_version >= '3.0' ) 1681 require_once( ABSPATH . '/wp-admin/includes/ms.php' ); 1682 else 1683 require_once( ABSPATH . '/wp-admin/includes/mu.php' ); 1684 1653 1685 require_once( ABSPATH . '/wp-admin/includes/user.php' ); 1654 1686 1655 1687 return wpmu_delete_user( $user_id ); 1656 }1657 1688 1658 1689 /* Single site user deletion */ 1659 require_once( ABSPATH . '/wp-admin/includes/user.php' ); 1660 return wp_delete_user( $user_id ); 1661 } 1662 1690 } else { 1691 require_once( ABSPATH . '/wp-admin/includes/user.php' ); 1692 return wp_delete_user( $user_id ); 1693 } 1694 } 1663 1695 1664 1696 /** … … 1767 1799 ?> 1768 1800 1769 <!-- Generated in <?php timer_stop(1); ?> seconds. -->1801 <!-- Generated in <?php timer_stop(1); ?> seconds. (<?php echo get_num_queries(); ?> q) --> 1770 1802 1771 1803 <?php … … 1838 1870 $user = get_userdatabylogin( $username ); 1839 1871 1840 if ( ( bp_core_is_multisite() && (int)$user->spam ) || 1 == (int)$user->user_status)1872 if ( (int)$user->spam ) 1841 1873 bp_core_redirect( $bp->root_domain ); 1842 1874 else … … 1861 1893 wp_cache_flush(); 1862 1894 } 1863 add_action( 'wpmu_delete_user', 'bp_core_remove_data' );1864 add_action( 'delete_user', 'bp_core_remove_data' );1865 add_action( 'make_spam_user', 'bp_core_remove_data' );1895 add_action( 'wpmu_delete_user', 'bp_core_remove_data', 1 ); 1896 add_action( 'delete_user', 'bp_core_remove_data', 1 ); 1897 add_action( 'make_spam_user', 'bp_core_remove_data', 1 ); 1866 1898 1867 1899 /** … … 1899 1931 } 1900 1932 add_action( 'in_plugin_update_message-buddypress/bp-loader.php', 'bp_core_update_message' ); 1933 1934 /** 1935 * bp_core_filter_parent_theme() 1936 * 1937 * Remove social network parent theme from the theme list. 1938 * 1939 * @package BuddyPress Core 1940 */ 1941 function bp_core_filter_parent_theme() { 1942 global $wp_themes, $pagenow; 1943 1944 if ( is_admin() && 'themes.php' == $pagenow ) 1945 $wp_themes = get_themes(); 1946 1947 unset( $wp_themes['BuddyPress Classic Parent'] ); 1948 } 1949 add_filter( 'admin_menu', 'bp_core_filter_parent_theme' ); 1950 1951 /** 1952 * bp_core_allow_default_theme() 1953 * 1954 * On multiblog installations you must first allow themes to be activated and show 1955 * up on the theme selection screen. This function will let the BuddyPress bundled 1956 * themes show up on the root blog selection screen and bypass this step. It also 1957 * means that the themes won't show for selection on other blogs. 1958 * 1959 * @package BuddyPress Core 1960 */ 1961 function bp_core_allow_default_theme( $themes ) { 1962 global $bp, $current_blog; 1963 1964 if ( !is_site_admin() ) 1965 return $themes; 1966 1967 if ( $current_blog->ID == $bp->root_blog ) { 1968 $themes['bp-default'] = 1; 1969 $themes['bp-classic'] = 1; 1970 } 1971 1972 return $themes; 1973 } 1974 add_filter( 'allowed_themes', 'bp_core_allow_default_theme' ); 1901 1975 1902 1976 /** … … 1941 2015 add_action( 'admin_notices', 'bp_core_activation_notice' ); 1942 2016 2017 2018 /** 2019 * bp_core_filter_comments() 2020 * 2021 * Filter the blog post comments array and insert BuddyPress URLs for users. 2022 * 2023 * @package BuddyPress Core 2024 */ 2025 function bp_core_filter_comments( $comments, $post_id ) { 2026 global $wpdb; 2027 2028 foreach( (array)$comments as $comment ) { 2029 if ( $comment->user_id ) 2030 $user_ids[] = $comment->user_id; 2031 } 2032 2033 if ( empty( $user_ids ) ) 2034 return $comments; 2035 2036 $user_ids = implode( ',', $user_ids ); 2037 2038 if ( !$userdata = $wpdb->get_results( $wpdb->prepare( "SELECT ID as user_id, user_login, user_nicename FROM {$wpdb->users} WHERE ID IN ({$user_ids})" ) ) ) 2039 return $comments; 2040 2041 foreach( (array)$userdata as $user ) 2042 $users[$user->user_id] = bp_core_get_user_domain( $user->user_id, $user->user_nicename, $user->user_login ); 2043 2044 foreach( (array)$comments as $i => $comment ) { 2045 if ( !empty( $comment->user_id ) ) { 2046 if ( !empty( $users[$comment->user_id] ) ) 2047 $comments[$i]->comment_author_url = $users[$comment->user_id]; 2048 } 2049 } 2050 2051 return $comments; 2052 } 2053 add_filter( 'comments_array', 'bp_core_filter_comments', 10, 2 ); 2054 2055 2056 /** 2057 * bp_core_login_redirect() 2058 * 2059 * When a user logs in, always redirect them back to the previous page. NOT the admin area. 2060 * 2061 * @package BuddyPress Core 2062 */ 2063 function bp_core_login_redirect( $redirect_to ) { 2064 global $bp, $current_blog; 2065 2066 if ( bp_core_is_multisite() && $current_blog->blog_id != BP_ROOT_BLOG ) 2067 return $redirect_to; 2068 2069 if ( !empty( $_REQUEST['redirect_to'] ) || strpos( $_REQUEST['redirect_to'], 'wp-admin' ) ) 2070 return $redirect_to; 2071 2072 if ( false === strpos( wp_get_referer(), 'wp-login.php' ) && false === strpos( wp_get_referer(), 'activate' ) && empty( $_REQUEST['nr'] ) ) 2073 return wp_get_referer(); 2074 2075 return $bp->root_domain; 2076 } 2077 add_filter( 'login_redirect', 'bp_core_login_redirect' ); 2078 2079 1943 2080 /******************************************************************************** 1944 2081 * Custom Actions … … 1964 2101 do_action( 'bp_setup_nav' ); 1965 2102 } 1966 add_action( 'plugins_loaded', 'bp_setup_nav' ); 1967 add_action( 'admin_menu', 'bp_setup_nav' ); 2103 add_action( 'bp_loaded', 'bp_setup_nav', 8 ); 1968 2104 1969 2105 /* Allow core components and dependent plugins to register widgets */ -
trunk/bp-core/admin/bp-core-upgrade.php
r2881 r3232 236 236 </div> 237 237 238 239 <?php if ( bp_core_is_multisite() ) : ?> 238 240 <div class="component"> 239 241 <h5><?php _e( "Blog Tracking", 'buddypress' ) ?></h5> … … 245 247 246 248 <img src="<?php echo plugins_url( 'buddypress/screenshot-7.gif' ) ?>" alt="Activity Streams" /> 247 <p><?php _e( "Track new blogs, new posts and new comments across your entire blog network.", 'buddypress' ) ?></p>249 <p><?php _e( "Track new blogs, new posts and new comments across your entire blog network.", 'buddypress' ) ?></p> 248 250 </div> 251 <?php endif; ?> 249 252 </div> 250 253 -
trunk/bp-core/bp-core-adminbar.php
r2946 r3232 7 7 return false; 8 8 9 if ( (int) get_site_option( 'hide-loggedout-adminbar' )&& !is_user_logged_in() )9 if ( (int)$bp->site_options['hide-loggedout-adminbar'] && !is_user_logged_in() ) 10 10 return false; 11 11 -
trunk/bp-core/bp-core-avatars.php
r2946 r3232 40 40 41 41 if ( !defined( 'BP_AVATAR_DEFAULT' ) ) 42 define( 'BP_AVATAR_DEFAULT', BP_PLUGIN_URL . '/bp- xprofile/images/none.gif' );42 define( 'BP_AVATAR_DEFAULT', BP_PLUGIN_URL . '/bp-core/images/mystery-man.jpg' ); 43 43 44 44 if ( !defined( 'BP_AVATAR_DEFAULT_THUMB' ) ) 45 define( 'BP_AVATAR_DEFAULT_THUMB', BP_PLUGIN_URL . '/bp-xprofile/images/none-thumbnail.gif' ); 46 } 47 add_action( 'bp_init', 'bp_core_set_avatar_constants' ); 48 45 define( 'BP_AVATAR_DEFAULT_THUMB', BP_PLUGIN_URL . '/bp-core/images/mystery-man-50.jpg' ); 46 } 47 add_action( 'bp_loaded', 'bp_core_set_avatar_constants', 8 ); 48 49 /** 50 * bp_core_fetch_avatar() 51 * 52 * Fetches an avatar from a BuddyPress object. Supports user/group/blog as 53 * default, but can be extended to include your own custom components too. 54 * 55 * @global object $bp 56 * @global object $current_blog 57 * @param array $args Determine the output of this function 58 * @return string Formatted HTML <img> element, or raw avatar URL based on $html arg 59 */ 49 60 function bp_core_fetch_avatar( $args = '' ) { 50 61 global $bp, $current_blog; 51 62 63 // Set a few default variables 64 $def_object = 'user'; 65 $def_type = 'thumb'; 66 $def_class = 'avatar'; 67 $def_alt = __( 'Avatar Image', 'buddypress' ); 68 69 // Set the default variables array 52 70 $defaults = array( 53 'item_id' => false, 54 'object' => 'user', // user OR group OR blog OR custom type (if you use filters) 55 'type' => 'thumb', 56 'avatar_dir' => false, 57 'width' => false, 58 'height' => false, 59 'class' => 'avatar', 60 'css_id' => false, 61 'alt' => __( 'Avatar Image', 'buddypress' ), 62 'email' => false, // Pass the user email (for gravatar) to prevent querying the DB for it 63 'no_grav' => false // If there is no avatar found, return false instead of a grav? 71 'item_id' => false, 72 'object' => $def_object, // user/group/blog/custom type (if you use filters) 73 'type' => $def_type, // thumb or full 74 'avatar_dir' => false, // Specify a custom avatar directory for your object 75 'width' => false, // Custom width (int) 76 'height' => false, // Custom height (int) 77 'class' => $def_class, // Custom <img> class (string) 78 'css_id' => false, // Custom <img> ID (string) 79 'alt' => $def_alt, // Custom <img> alt (string) 80 'email' => false, // Pass the user email (for gravatar) to prevent querying the DB for it 81 'no_grav' => false, // If there is no avatar found, return false instead of a grav? 82 'html' => true // Wrap the return img URL in <img /> 64 83 ); 65 84 85 // Compare defaults to passed and extract 66 86 $params = wp_parse_args( $args, $defaults ); 67 87 extract( $params, EXTR_SKIP ); 68 88 89 // Set item_id if not passed 69 90 if ( !$item_id ) { 70 91 if ( 'user' == $object ) … … 80 101 } 81 102 103 // Set avatar_dir if not passed (uses $object) 82 104 if ( !$avatar_dir ) { 83 105 if ( 'user' == $object ) … … 93 115 } 94 116 95 / * Add an identifying class to each item */117 // Add an identifying class to each item 96 118 $class .= ' ' . $object . '-' . $item_id . '-avatar'; 97 119 98 if ( !empty($css_id) ) 120 // Set CSS ID if passed 121 if ( !empty( $css_id ) ) 99 122 $css_id = " id='{$css_id}'"; 100 123 124 // Set avatar width 101 125 if ( $width ) 102 126 $html_width = " width='{$width}'"; … … 104 128 $html_width = ( 'thumb' == $type ) ? ' width="' . BP_AVATAR_THUMB_WIDTH . '"' : ' width="' . BP_AVATAR_FULL_WIDTH . '"'; 105 129 130 // Set avatar height 106 131 if ( $height ) 107 132 $html_height = " height='{$height}'"; … … 109 134 $html_height = ( 'thumb' == $type ) ? ' height="' . BP_AVATAR_THUMB_HEIGHT . '"' : ' height="' . BP_AVATAR_FULL_HEIGHT . '"'; 110 135 111 $avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', str_replace( WP_CONTENT_DIR, BP_AVATAR_URL, BP_AVATAR_UPLOAD_PATH ) . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir ); 136 // Set avatar URL and DIR based on prepopulated constants 137 $avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', BP_AVATAR_URL . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir ); 112 138 $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', BP_AVATAR_UPLOAD_PATH . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir ); 113 139 … … 117 143 * or thumbnail image. 118 144 */ 119 $avatar_ name = ( 'full' == $type ) ? '-bpfull' : '-bpthumb';145 $avatar_size = ( 'full' == $type ) ? '-bpfull' : '-bpthumb'; 120 146 $legacy_user_avatar_name = ( 'full' == $type ) ? '-avatar2' : '-avatar1'; 121 147 $legacy_group_avatar_name = ( 'full' == $type ) ? '-groupavatar-full' : '-groupavatar-thumb'; 122 148 149 // Check for directory 123 150 if ( file_exists( $avatar_folder_dir ) ) { 151 152 // Open directory 124 153 if ( $av_dir = opendir( $avatar_folder_dir ) ) { 154 155 // Stash files in an array once to check for one that matches 156 $avatar_files = array(); 125 157 while ( false !== ( $avatar_file = readdir($av_dir) ) ) { 126 if ( preg_match( "/{$avatar_name}/", $avatar_file ) || preg_match( "/{$legacy_user_avatar_name}/", $avatar_file ) || preg_match( "/{$legacy_group_avatar_name}/", $avatar_file ) ) 127 $avatar_url = $avatar_folder_url . '/' . $avatar_file; 158 // Only add files to the array (skip directories) 159 if ( 2 < strlen( $avatar_file ) ) 160 $avatar_files[] = $avatar_file; 161 } 162 163 // Check for array 164 if ( 0 < count( $avatar_files ) ) { 165 166 // Check for current avatar 167 foreach( $avatar_files as $key => $value ) { 168 if ( strpos ( $value, $avatar_size )!== false ) 169 $avatar_url = $avatar_folder_url . '/' . $avatar_files[$key]; 170 } 171 172 // Legacy avatar check 173 if ( !isset( $avatar_url ) ) { 174 foreach( $avatar_files as $key => $value ) { 175 if ( strpos ( $value, $legacy_user_avatar_name )!== false ) 176 $avatar_url = $avatar_folder_url . '/' . $avatar_files[$key]; 177 } 178 179 // Legacy group avatar check 180 if ( !isset( $avatar_url ) ) { 181 foreach( $avatar_files as $key => $value ) { 182 if ( strpos ( $value, $legacy_group_avatar_name )!== false ) 183 $avatar_url = $avatar_folder_url . '/' . $avatar_files[$key]; 184 } 185 } 186 } 128 187 } 129 188 } 130 closedir($av_dir); 131 132 if ( $avatar_url ) 133 return apply_filters( 'bp_core_fetch_avatar', "<img src='{$avatar_url}' alt='{$alt}' class='{$class}'{$css_id}{$html_width}{$html_height} />", $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir ); 134 } 135 136 /* If no avatars have been uploaded for this item, display a gravatar */ 189 190 // Close the avatar directory 191 closedir( $av_dir ); 192 193 // If we found a locally uploaded avatar 194 if ( $avatar_url ) { 195 196 // Return it wrapped in an <img> element 197 if ( true === $html ) { 198 return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $avatar_url . '" alt="' . $alt . '" class="' . $class . '"' . $css_id . $html_width . $html_height . ' />', $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir ); 199 200 // ...or only the URL 201 } else { 202 return apply_filters( 'bp_core_fetch_avatar_url', $avatar_url ); 203 } 204 } 205 } 206 207 // If no avatars could be found, try to display a gravatar 208 209 // Skips gravatar check if $no_grav is passed 137 210 if ( !$no_grav ) { 211 212 // Set gravatar size 213 if ( $width ) 214 $grav_size = $width; 215 else if ( 'full' == $type ) 216 $grav_size = BP_AVATAR_FULL_WIDTH; 217 else if ( 'thumb' == $type ) 218 $grav_size = BP_AVATAR_THUMB_WIDTH; 219 220 // Set gravatar type 138 221 if ( empty( $bp->grav_default->{$object} ) ) 139 222 $default_grav = 'wavatar'; 140 223 else if ( 'mystery' == $bp->grav_default->{$object} ) 141 $default_grav = apply_filters( 'bp_core_mysteryman_src', BP_ PLUGIN_URL . '/bp-core/images/mystery-man.jpg');224 $default_grav = apply_filters( 'bp_core_mysteryman_src', BP_AVATAR_DEFAULT, $grav_size ); 142 225 else 143 226 $default_grav = $bp->grav_default->{$object}; 144 227 145 if ( $width ) $grav_size = $width; 146 else if ( 'full' == $type ) $grav_size = BP_AVATAR_FULL_WIDTH; 147 else if ( 'thumb' == $type ) $grav_size = BP_AVATAR_THUMB_WIDTH; 148 228 // Set gravatar object 149 229 if ( empty( $email ) ) { 150 230 if ( 'user' == $object ) { … … 155 235 } 156 236 237 // Set host based on if using ssl 157 238 if ( is_ssl() ) 158 239 $host = 'https://secure.gravatar.com/avatar/'; … … 160 241 $host = 'http://www.gravatar.com/avatar/'; 161 242 162 $email = apply_filters( 'bp_core_gravatar_email', $email, $item_id, $object ); 163 $gravatar = apply_filters( 'bp_gravatar_url', $host ) . md5( $email ) . '?d=' . $default_grav . '&s=' . $grav_size; 164 165 return apply_filters( 'bp_core_fetch_avatar', "<img src='{$gravatar}' alt='{$alt}' class='{$class}'{$css_id}{$html_width}{$html_height} />", $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir ); 243 // Filter gravatar vars 244 $email = apply_filters( 'bp_core_gravatar_email', $email, $item_id, $object ); 245 $gravatar = apply_filters( 'bp_gravatar_url', $host ) . md5( strtolower( $email ) ) . '?d=' . $default_grav . '&s=' . $grav_size; 246 247 // Return gravatar wrapped in <img /> 248 if ( true === $html ) 249 return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $gravatar . '" alt="' . $alt . '" class="' . $class . '"' . $css_id . $html_width . $html_height . ' />', $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir ); 250 251 // ...or only return the gravatar URL 252 else 253 return apply_filters( 'bp_core_fetch_avatar_url', $gravatar ); 254 166 255 } else { 167 256 return apply_filters( 'bp_core_fetch_avatar', false, $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir ); … … 275 364 } 276 365 277 /* Resize the image down to something manageable and then delete the original */ 278 if ( getimagesize( $bp->avatar_admin->original['file'] ) > BP_AVATAR_ORIGINAL_MAX_WIDTH ) 279 $bp->avatar_admin->resized = wp_create_thumbnail( $bp->avatar_admin->original['file'], BP_AVATAR_ORIGINAL_MAX_WIDTH ); 280 281 $bp->avatar_admin->image = new stdClass; 366 /* Get image size */ 367 $size = @getimagesize( $bp->avatar_admin->original['file'] ); 368 369 /* Check image size and shrink if too large */ 370 if ( $size[0] > BP_AVATAR_ORIGINAL_MAX_WIDTH ) { 371 $thumb = wp_create_thumbnail( $bp->avatar_admin->original['file'], BP_AVATAR_ORIGINAL_MAX_WIDTH ); 372 373 /* Check for thumbnail creation errors */ 374 if ( is_wp_error( $thumb ) ) { 375 bp_core_add_message( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $thumb->get_error_message() ), 'error' ); 376 return false; 377 } 378 379 /* Thumbnail is good so proceed */ 380 $bp->avatar_admin->resized = $thumb; 381 } 282 382 283 383 /* We only want to handle one image after resize. */ 284 384 if ( empty( $bp->avatar_admin->resized ) ) 285 $bp->avatar_admin->image->dir = $bp->avatar_admin->original['file'];385 $bp->avatar_admin->image->dir = str_replace( BP_AVATAR_UPLOAD_PATH, '', $bp->avatar_admin->original['file'] ); 286 386 else { 287 $bp->avatar_admin->image->dir = $bp->avatar_admin->resized;387 $bp->avatar_admin->image->dir = str_replace( BP_AVATAR_UPLOAD_PATH, '', $bp->avatar_admin->resized ); 288 388 @unlink( $bp->avatar_admin->original['file'] ); 289 389 } 290 390 291 391 /* Set the url value for the image */ 292 $bp->avatar_admin->image->url = str_replace( WP_CONTENT_DIR, BP_AVATAR_URL, $bp->avatar_admin->image->dir );392 $bp->avatar_admin->image->url = BP_AVATAR_URL . $bp->avatar_admin->image->dir; 293 393 294 394 return true; … … 323 423 return false; 324 424 325 if ( !file_exists( WP_CONTENT_DIR . '/' . $original_file ) ) 425 $original_file = BP_AVATAR_UPLOAD_PATH . $original_file; 426 427 if ( !file_exists( $original_file ) ) 326 428 return false; 327 429 328 430 if ( !$item_id ) 329 $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR .dirname( $original_file ), $item_id, $object, $avatar_dir );431 $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', dirname( $original_file ), $item_id, $object, $avatar_dir ); 330 432 else 331 433 $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', BP_AVATAR_UPLOAD_PATH . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir ); … … 352 454 353 455 /* Crop the image */ 354 $full_cropped = wp_crop_image( WP_CONTENT_DIR .$original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_FULL_WIDTH, BP_AVATAR_FULL_HEIGHT, false, $avatar_folder_dir . '/' . $full_filename );355 $thumb_cropped = wp_crop_image( WP_CONTENT_DIR .$original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_THUMB_WIDTH, BP_AVATAR_THUMB_HEIGHT, false, $avatar_folder_dir . '/' . $thumb_filename );456 $full_cropped = wp_crop_image( $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_FULL_WIDTH, BP_AVATAR_FULL_HEIGHT, false, $avatar_folder_dir . '/' . $full_filename ); 457 $thumb_cropped = wp_crop_image( $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_THUMB_WIDTH, BP_AVATAR_THUMB_HEIGHT, false, $avatar_folder_dir . '/' . $thumb_filename ); 356 458 357 459 /* Remove the original */ 358 @unlink( WP_CONTENT_DIR .$original_file );460 @unlink( $original_file ); 359 461 360 462 return true; 361 463 } 362 464 363 // Override internal "get_avatar()" function to use our own where possible 465 /** 466 * bp_core_fetch_avatar_filter() 467 * 468 * Attempts to filter get_avatar function and let BuddyPress have a go 469 * at finding an avatar that may have been uploaded locally. 470 * 471 * @global array $authordata 472 * @param string $avatar The result of get_avatar from before-filter 473 * @param int|string|object $user A user ID, email address, or comment object 474 * @param int $size Size of the avatar image (thumb/full) 475 * @param string $default URL to a default image to use if no avatar is available 476 * @param string $alt Alternate text to use in image tag. Defaults to blank 477 * @return <type> 478 */ 364 479 function bp_core_fetch_avatar_filter( $avatar, $user, $size, $default, $alt ) { 365 global $authordata; 366 480 global $pagenow; 481 482 // Do not filter if inside WordPress options page 483 if ( 'options-discussion.php' == $pagenow ) 484 return $avatar; 485 486 // If passed an object, assume $user->user_id 367 487 if ( is_object( $user ) ) 368 488 $id = $user->user_id; 489 490 // If passed a number, assume it was a $user_id 369 491 else if ( is_numeric( $user ) ) 370 492 $id = $user; 371 else 372 $id = $authordata->ID; 373 493 494 // If passed a string and that string returns a user, get the $id 495 else if ( is_string( $user ) && ( $user_by_email = get_user_by_email( $user ) ) ) 496 $id = $user_by_email->ID; 497 498 // If somehow $id hasn't been assigned, return the result of get_avatar 374 499 if ( empty( $id ) ) 375 return $avatar; 376 500 return !empty( $avatar ) ? $avatar : $default; 501 502 // Let BuddyPress handle the fetching of the avatar 377 503 $bp_avatar = bp_core_fetch_avatar( array( 'item_id' => $id, 'width' => $size, 'height' => $size, 'alt' => $alt ) ); 378 504 505 // If BuddyPress found an avatar, use it. If not, use the result of get_avatar 379 506 return ( !$bp_avatar ) ? $avatar : $bp_avatar; 380 507 } … … 402 529 } 403 530 531 /** 532 * bp_core_avatar_upload_path() 533 * 534 * Returns the absolute upload path for the WP installation 535 * 536 * @global object $current_blog Current blog information 537 * @uses wp_upload_dir To get upload directory info 538 * @return string Absolute path to WP upload directory 539 */ 404 540 function bp_core_avatar_upload_path() { 405 if ( bp_core_is_multisite() ) 406 $path = ABSPATH . get_blog_option( BP_ROOT_BLOG, 'upload_path' ); 407 else { 408 if ( !$path = get_option( 'upload_path' ) ) 409 $path = WP_CONTENT_DIR . '/uploads'; 410 else 411 $path = ABSPATH . $path; 412 } 413 414 return apply_filters( 'bp_core_avatar_upload_path', $path ); 415 } 416 541 global $current_blog; 542 543 // Get upload directory information from current site 544 $upload_dir = wp_upload_dir(); 545 546 // If multisite, and current blog does not match root blog, make adjustments 547 if ( bp_core_is_multisite() && BP_ROOT_BLOG != $current_blog->blog_id ) 548 $upload_dir['basedir'] = get_blog_option( BP_ROOT_BLOG, 'upload_path' ); 549 550 return apply_filters( 'bp_core_avatar_upload_path', $upload_dir['basedir'] ); 551 } 552 553 /** 554 * bp_core_avatar_url() 555 * 556 * Returns the raw base URL for root site upload location 557 * 558 * @global object $current_blog Current blog information 559 * @uses wp_upload_dir To get upload directory info 560 * @return string Full URL to current upload location 561 */ 417 562 function bp_core_avatar_url() { 418 if ( !bp_core_is_multisite() ) 419 return WP_CONTENT_URL; 420 421 return apply_filters( 'bp_core_avatar_url', get_blog_option( BP_ROOT_BLOG, 'siteurl' ) ); 563 global $current_blog; 564 565 // Get upload directory information from current site 566 $upload_dir = wp_upload_dir(); 567 568 // If multisite, and current blog does not match root blog, make adjustments 569 if ( bp_core_is_multisite() && BP_ROOT_BLOG != $current_blog->blog_id ) 570 $upload_dir['baseurl'] = str_replace( get_blog_option( $current_blog->blog_id, 'home' ) , get_blog_option( BP_ROOT_BLOG, 'home' ), $upload_dir['baseurl'] ); 571 572 return apply_filters( 'bp_core_avatar_url', $upload_dir['baseurl'] ); 422 573 } 423 574 -
trunk/bp-core/bp-core-classes.php
r3023 r3232 107 107 /* Static Functions */ 108 108 109 function get_users( $type, $limit = null, $page = 1, $user_id = false, $ include = false, $search_terms = false, $populate_extras = true ) {109 function get_users( $type, $limit = null, $page = 1, $user_id = false, $search_terms = false, $populate_extras = true ) { 110 110 global $wpdb, $bp; 111 111 … … 134 134 135 135 if ( 'online' == $type ) 136 $sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= UTC_TIMESTAMP()";136 $sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= NOW()"; 137 137 138 138 if ( 'alphabetical' == $type ) 139 139 $sql['where_alpha'] = "AND pd.field_id = 1"; 140 140 141 if ( $include ) { 142 if ( is_array( $include ) ) 143 $uids = $wpdb->escape( implode( ',', (array)$include ) ); 144 else 145 $uids = $wpdb->escape( $include ); 146 147 if ( !empty( $uids ) ) 148 $sql['where_users'] = "AND u.ID IN ({$uids})"; 149 } 150 151 else if ( $user_id && function_exists( 'friends_install' ) ) { 141 if ( $user_id && function_exists( 'friends_install' ) ) { 152 142 $friend_ids = friends_get_friend_user_ids( $user_id ); 153 143 $friend_ids = $wpdb->escape( implode( ',', (array)$friend_ids ) ); … … 261 251 } 262 252 253 function get_specific_users( $user_ids, $limit = null, $page = 1, $populate_extras = true ) { 254 global $wpdb, $bp; 255 256 if ( $limit && $page ) 257 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 258 259 $user_sql = " AND user_id IN ( " . $wpdb->escape( $user_ids ) . " ) "; 260 $status_sql = bp_core_get_status_sql(); 261 262 $total_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', $wpdb->prepare( "SELECT COUNT(DISTINCT ID) FROM " . CUSTOM_USER_TABLE . " WHERE {$status_sql} AND ID IN ( " . $wpdb->escape( $user_ids ) . " ) " ), $wpdb->escape( $user_ids ) ); 263 $paged_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', $wpdb->prepare( "SELECT DISTINCT ID as id, user_registered, user_nicename, user_login, user_email FROM " . CUSTOM_USER_TABLE . " WHERE {$status_sql} AND ID IN ( " . $wpdb->escape( $user_ids ) . " ) {$pag_sql}" ), $wpdb->escape( $user_ids ) ); 264 265 $total_users = $wpdb->get_var( $total_users_sql ); 266 $paged_users = $wpdb->get_results( $paged_users_sql ); 267 268 /*** 269 * Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list. 270 * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join) 271 */ 272 273 /* Add additional data to the returned results */ 274 if ( $populate_extras ) 275 $paged_users = BP_Core_User::get_user_extras( &$paged_users, &$user_ids ); 276 277 278 return array( 'users' => $paged_users, 'total' => $total_users ); 279 } 280 263 281 function search_users( $search_terms, $limit = null, $page = 1, $populate_extras = true ) { 264 282 global $wpdb, $bp; … … 300 318 /* Fetch the user's full name */ 301 319 if ( bp_is_active( 'xprofile' ) && 'alphabetical' != $type ) { 302 /* Ensure xprofile globals are set */303 if ( !defined( 'BP_XPROFILE_FULLNAME_FIELD_NAME' ) )304 xprofile_setup_globals();305 306 320 $names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id as id, pd.value as fullname FROM {$bp->profile->table_name_fields} pf, {$bp->profile->table_name_data} pd WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} )", BP_XPROFILE_FULLNAME_FIELD_NAME ) ); 307 321 for ( $i = 0; $i < count( $paged_users ); $i++ ) { -
trunk/bp-core/bp-core-cssjs.php
r2946 r3232 48 48 global $current_blog; 49 49 50 if ( bp_core_is_multisite() &&$current_blog->blog_id != BP_ROOT_BLOG )50 if ( $current_blog->blog_id != BP_ROOT_BLOG ) 51 51 return false; 52 52 ?> … … 175 175 global $bp; 176 176 177 if ( defined( 'BP_DISABLE_ADMIN_BAR' ) || ( (int)get_site_option( 'hide-loggedout-adminbar' )&& !is_user_logged_in() ) ) {177 if ( defined( 'BP_DISABLE_ADMIN_BAR' ) || ( $bp->site_options['hide-loggedout-adminbar'] && !is_user_logged_in() ) ) { 178 178 ?> 179 179 <style type="text/css">body { padding-top: 0 !important; } #wp-admin-bar { display: none; }</style> -
trunk/bp-core/bp-core-signup.php
r2946 r3232 181 181 182 182 /* Make sure we include the jQuery jCrop file for image cropping */ 183 add_action( 'wp _print_scripts', 'bp_core_add_jquery_cropper' );183 add_action( 'wp', 'bp_core_add_jquery_cropper' ); 184 184 } 185 185 } … … 256 256 */ 257 257 258 /** 259 * bp_core_flush_illegal_names() 260 * 261 * Flush illegal names by getting and setting 'illegal_names' site option 262 */ 263 function bp_core_flush_illegal_names() { 264 $illegal_names = get_site_option( 'illegal_names' ); 265 update_site_option( 'illegal_names', $illegal_names ); 266 } 267 268 /** 269 * bp_core_illegal_names() 270 * 271 * Filter the illegal_names site option and make sure it includes a few 272 * specific BuddyPress and Multi-site slugs 273 * 274 * @param array|string $value Illegal names from field 275 * @param array|string $oldvalue The value as it is currently 276 * @return array Merged and unique array of illegal names 277 */ 278 function bp_core_illegal_names( $value = '', $oldvalue = '' ) { 279 280 // Make sure $value is array 281 if ( empty( $value ) ) 282 $db_illegal_names = array(); 283 if ( is_array( $value ) ) 284 $db_illegal_names = $value; 285 elseif ( is_string( $value ) ) 286 $db_illegal_names = implode( ' ', $names ); 287 288 // Add our slugs to the array and allow them to be filtered 289 $filtered_illegal_names = apply_filters( 'bp_core_illegal_usernames', array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', BP_GROUPS_SLUG, BP_MEMBERS_SLUG, BP_FORUMS_SLUG, BP_BLOGS_SLUG, BP_ACTIVITY_SLUG, BP_XPROFILE_SLUG, BP_FRIENDS_SLUG, BP_SEARCH_SLUG, BP_SETTINGS_SLUG, BP_REGISTER_SLUG, BP_ACTIVATION_SLUG ) ); 290 291 // Merge the arrays together 292 $merged_names = array_merge( (array)$filtered_illegal_names, (array)$db_illegal_names ); 293 294 // Remove duplicates 295 $illegal_names = array_unique( (array)$merged_names ); 296 297 return apply_filters( 'bp_core_illegal_names', $illegal_names ); 298 } 299 add_filter( 'pre_update_site_option_illegal_names', 'bp_core_illegal_names', 10, 2 ); 300 301 /** 302 * bp_core_validate_user_signup() 303 * 304 * Validate a user name and email address when creating a new user. 305 * 306 * @global object $wpdb DB Layer 307 * @param string $user_name Username to validate 308 * @param string $user_email Email address to validate 309 * @return array Results of user validation including errors, if any 310 */ 258 311 function bp_core_validate_user_signup( $user_name, $user_email ) { 259 global $wpdb , $bp;312 global $wpdb; 260 313 261 314 $errors = new WP_Error(); … … 268 321 preg_match( "/[a-z0-9]+/", $user_name, $maybe ); 269 322 270 $db_illegal_names = get_site_option( 'illegal_names' ); 271 $filtered_illegal_names = apply_filters( 'bp_core_illegal_usernames', array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', BP_GROUPS_SLUG, $bp->members->slug, BP_FORUMS_SLUG, BP_BLOGS_SLUG, BP_REGISTER_SLUG, BP_ACTIVATION_SLUG ) ); 272 273 /* Safely merge our illegal names into existing site_option */ 274 $common_names = array_intersect( (array)$db_illegal_names, (array)$filtered_illegal_names ); 275 $diff_names = array_diff( (array)$db_illegal_names, (array)$filtered_illegal_names ); 276 $illegal_names = array_merge( (array)$diff_names, (array)$common_names ); 277 278 update_site_option( 'illegal_names', $illegal_names ); 279 280 if ( in_array( $user_name, (array)$illegal_names ) ) 281 $errors->add( 'user_name', __( 'Sorry, that username is not allowed', 'buddypress' ) ); 282 283 if ( !validate_username( $user_name ) || $user_name != $maybe[0] ) 323 // Make sure illegal names include BuddyPress slugs and values 324 bp_core_flush_illegal_names(); 325 326 if ( !validate_username( $user_name ) || in_array( $user_name, (array)$illegal_names ) || $user_name != $maybe[0] ) 284 327 $errors->add( 'user_name', __( 'Only lowercase letters and numbers allowed', 'buddypress' ) ); 285 328 … … 382 425 if ( !bp_core_is_multisite() ) { 383 426 $activation_key = wp_hash( $user_id ); 384 update_user meta( $user_id, 'activation_key', $activation_key );427 update_user_meta( $user_id, 'activation_key', $activation_key ); 385 428 bp_core_signup_send_validation_email( $user_id, $user_email, $activation_key ); 386 429 } … … 445 488 446 489 /* Remove the activation key meta */ 447 delete_user meta( $user_id, 'activation_key' );490 delete_user_meta( $user_id, 'activation_key' ); 448 491 } 449 492 … … 452 495 453 496 /* Add a last active entry */ 454 update_user meta( $user_id, 'last_activity', gmdate( "Y-m-d H:i:s") );497 update_user_meta( $user_id, 'last_activity', bp_core_current_time() ); 455 498 456 499 /* Set the password on multisite installs */ … … 495 538 496 539 /* Add a last active entry */ 497 update_user meta( $user_id, 'last_activity', gmdate( "Y-m-d H:i:s") );540 update_user_meta( $user_id, 'last_activity', bp_core_current_time() ); 498 541 499 542 /* Add the user's fullname to Xprofile */ 500 543 if ( function_exists( 'xprofile_set_field_data' ) ) { 501 $firstname = get_user meta( $user_id, 'first_name');502 $lastname = ' ' . get_user meta( $user_id, 'last_name');544 $firstname = get_user_meta( $user_id, 'first_name', true ); 545 $lastname = ' ' . get_user_meta( $user_id, 'last_name', true ); 503 546 $name = $firstname . $lastname; 504 547 505 548 if ( empty( $name ) || ' ' == $name ) 506 $name = get_user meta( $user_id, 'nickname');549 $name = get_user_meta( $user_id, 'nickname', true ); 507 550 508 551 xprofile_set_field_data( 1, $user_id, $name ); … … 523 566 @wp_mkdir_p( $path ); 524 567 525 $newurl = str_replace( BP_AVATAR_UPLOAD_PATH, BP_AVATAR_URL, $path );568 $newurl = BP_AVATAR_URL . '/avatars/signups/' . $bp->signup->avatar_dir; 526 569 $newburl = $newurl; 527 570 $newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir; … … 532 575 function bp_core_signup_send_validation_email( $user_id, $user_email, $key ) { 533 576 $activate_url = bp_get_activation_page() ."?key=$key"; 534 $activate_url = clean_url( $activate_url );577 $activate_url = esc_url( $activate_url ); 535 578 $admin_email = get_site_option( "admin_email" ); 536 579 -
trunk/bp-core/bp-core-templatetags.php
r2950 r3232 27 27 if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) { 28 28 $this->members = BP_Core_User::get_users_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page, $populate_extras ); 29 } else { 30 $this->members = bp_core_get_users( array( 'type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'include' => $include, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras ) ); 29 } 30 else if ( false !== $include ) { 31 $this->members = BP_Core_User::get_specific_users( $include, $this->pag_num, $this->pag_page, $populate_extras ); 32 } 33 else { 34 $this->members = bp_core_get_users( array( 'type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras ) ); 31 35 } 32 36 … … 160 164 161 165 $members_template = new BP_Core_Members_Template( $type, $page, $per_page, $max, $user_id, $search_terms, $include, (bool)$populate_extras ); 162 return apply_filters( 'bp_has_members', $members_template->has_members(), &$members_template ); 166 167 return $members_template->has_members(); 163 168 } 164 169 … … 312 317 313 318 // Populate the user if it hasn't been already. 314 if ( empty( $members_template->member->profile_data ) && method_exists( 'BP_XProfile_ProfileData', 'get_all_for_user' ))315 $members_template->member ->profile_data = BP_XProfile_ProfileData::get_all_for_user( $members_template->member->id );319 if ( empty( $members_template->member->profile_data ) ) 320 $members_template->member = new BP_Core_User( $members_template->member->id ); 316 321 317 322 $data = xprofile_format_profile_field( $members_template->member->profile_data[$field]['field_type'], $members_template->member->profile_data[$field]['field_data'] ); … … 676 681 function bp_is_home() { return bp_is_my_profile(); } 677 682 683 function bp_get_loggedin_user_link() { 684 global $bp; 685 686 return $bp->loggedin_user->domain; 687 } 688 689 function bp_get_displayed_user_link() { 690 global $bp; 691 692 return $bp->displayed_user->domain; 693 } 694 678 695 function bp_last_activity( $user_id = false, $echo = true ) { 679 696 global $bp; … … 690 707 } 691 708 692 function bp_user_firstname( $name = false) {693 echo bp_get_user_firstname( $name);709 function bp_user_firstname() { 710 echo bp_get_user_firstname(); 694 711 } 695 712 function bp_get_user_firstname( $name = false ) { … … 708 725 709 726 echo apply_filters( 'bp_the_avatar_thumbnail', $bp->displayed_user->domain ); 710 }711 712 function bp_get_loggedin_user_link() {713 global $bp;714 715 return $bp->loggedin_user->domain;716 }717 718 function bp_get_displayed_user_link() {719 global $bp;720 721 return $bp->displayed_user->domain;722 727 } 723 728 … … 919 924 } else if ( bp_is_activation_page() ) { 920 925 $title = __( 'Activate your Account', 'buddypress' ); 921 922 } else if ( bp_is_group_create() ) {923 $title = __( 'Create a Group', 'buddypress' );924 925 } else if ( bp_is_create_blog() ) {926 $title = __( 'Create a Blog', 'buddypress' );927 926 } 928 927 … … 990 989 991 990 function bp_search_form_type_select() { 992 global $bp;993 994 991 // Eventually this won't be needed and a page will be built to integrate all search results. 995 992 $selection_box = '<select name="search-which" id="search-which" style="width: auto">'; … … 1180 1177 1181 1178 function bp_signup_avatar( $args = '' ) { 1182 echo bp_get_signup_avatar( $args = '');1179 echo bp_get_signup_avatar( $args ); 1183 1180 } 1184 1181 function bp_get_signup_avatar( $args = '' ) { … … 1206 1203 1207 1204 $gravatar_url = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' ); 1208 return apply_filters( 'bp_get_signup_avatar', '<img src="' . $gravatar_url . md5( $_POST['signup_email'] ) . '?d=' . $default_grav . '&s=' . $size ). '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />';1205 $gravatar_img = '<img src="' . $gravatar_url . md5( strtolower( $_POST['signup_email'] ) ) . '?d=' . $default_grav . '&s=' . $size . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />'; 1209 1206 } else { 1210 return apply_filters( 'bp_get_signup_avatar', bp_core_fetch_avatar( array( 'item_id' => $signup_avatar_dir, 'object' => 'signup', 'avatar_dir' => 'avatars/signups', 'type' => 'full', 'width' => $size, 'height' => $size, 'alt' => $alt, 'class' => $class )) );1207 $gravatar_img = bp_core_fetch_avatar( array( 'item_id' => $signup_avatar_dir, 'object' => 'signup', 'avatar_dir' => 'avatars/signups', 'type' => 'full', 'width' => $size, 'height' => $size, 'alt' => $alt, 'class' => $class ) ); 1211 1208 } 1209 1210 return apply_filters( 'bp_get_signup_avatar', $gravatar_img ); 1212 1211 } 1213 1212 … … 1251 1250 1252 1251 function bp_registration_needs_activation() { 1253 return apply_filters( 'bp_registration_needs_activation', true);1252 return apply_filters( 'bp_registration_needs_activation', bp_core_is_multisite() ); 1254 1253 } 1255 1254 -
trunk/bp-core/bp-core-wpabstraction.php
r2925 r3232 90 90 } 91 91 } 92 93 if ( !function_exists( 'wpmu_validate_user_signup' ) ) { 94 function wpmu_validate_user_signup( $user_name, $user_email ) { 95 global $wpdb; 96 97 $errors = new WP_Error(); 98 99 $user_email = sanitize_email( $user_email ); 100 101 if ( empty( $user_name ) ) 102 $errors->add('user_name', __("Please enter a username")); 103 104 $maybe = array(); 105 preg_match( "/[a-z0-9]+/", $user_name, $maybe ); 106 107 $illegal_names = get_site_option( "illegal_names" ); 108 if( is_array( $illegal_names ) == false ) { 109 $illegal_names = array( "www", "web", "root", "admin", "main", "invite", "administrator" ); 110 add_site_option( "illegal_names", $illegal_names ); 111 } 112 113 if ( !validate_username( $user_name ) || in_array( $user_name, $illegal_names ) == true || $user_name != $maybe[0] ) { 114 $errors->add('user_name', __("Only lowercase letters and numbers allowed")); 115 } 116 117 if( strlen( $user_name ) < 4 ) { 118 $errors->add('user_name', __("Username must be at least 4 characters")); 119 } 120 121 if ( strpos( " " . $user_name, "_" ) != false ) 122 $errors->add('user_name', __("Sorry, usernames may not contain the character '_'!")); 123 124 // all numeric? 125 $match = array(); 126 preg_match( '/[0-9]*/', $user_name, $match ); 127 if ( $match[0] == $user_name ) 128 $errors->add('user_name', __("Sorry, usernames must have letters too!")); 129 130 if ( !is_email( $user_email ) ) 131 $errors->add('user_email', __("Please check your email address.")); 132 133 $limited_email_domains = get_site_option( 'limited_email_domains' ); 134 if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) { 135 $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) ); 136 if( in_array( $emaildomain, $limited_email_domains ) == false ) { 137 $errors->add('user_email', __("Sorry, that email address is not allowed!")); 138 } 139 } 140 141 // Check if the username has been used already. 142 if ( username_exists($user_name) ) 143 $errors->add('user_name', __("Sorry, that username already exists!")); 144 145 // Check if the email address has been used already. 146 if ( email_exists($user_email) ) 147 $errors->add('user_email', __("Sorry, that email address is already used!")); 148 149 $result = array('user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors); 150 151 return apply_filters('wpmu_validate_user_signup', $result); 152 } 153 } 154 ?> -
trunk/bp-forums.php
r2925 r3232 441 441 $post_position = $post->post_position; 442 442 443 $post _id= bb_insert_post( array( 'post_id' => $post_id, 'topic_id' => $topic_id, 'post_text' => stripslashes( trim( $post_text ) ), 'post_time' => $post_time, 'poster_id' => $poster_id, 'poster_ip' => $poster_ip, 'post_status' => $post_status, 'post_position' => $post_position ) );444 445 if ( $post _id)443 $post = bb_insert_post( array( 'post_id' => $post_id, 'topic_id' => $topic_id, 'post_text' => stripslashes( trim( $post_text ) ), 'post_time' => $post_time, 'poster_id' => $poster_id, 'poster_ip' => $poster_ip, 'post_status' => $post_status, 'post_position' => $post_position ) ); 444 445 if ( $post ) 446 446 do_action( 'bp_forums_new_post', $post_id ); 447 447 448 return $post _id;448 return $post; 449 449 } 450 450 -
trunk/bp-forums/bp-forums-templatetags.php
r2950 r3232 290 290 global $forum_template; 291 291 292 $poster_id = ( empty( $forum_template->topic->poster_id ) ) ? $forum_template->topic->topic_poster : $forum_template->topic->poster_id; 293 294 if ( !$name = bp_core_get_userlink( $poster_id ) ) 292 if ( !$name = bp_core_get_userlink( $forum_template->topic->poster_id ) ) 295 293 return __( 'Deleted User', 'buddypress' ); 296 294 … … 464 462 global $forum_template; 465 463 466 return apply_filters( 'bp_get_the_topic_total_posts', $forum_template->topic->topic_posts );464 return $forum_template->topic->topic_posts; 467 465 } 468 466 -
trunk/bp-friends.php
r2946 r3232 566 566 do_action( 'friends_remove_data', $user_id ); 567 567 } 568 add_action( 'wpmu_delete_user', 'friends_remove_data' );569 add_action( 'delete_user', 'friends_remove_data' );570 add_action( 'make_spam_user', 'friends_remove_data' );568 add_action( 'wpmu_delete_user', 'friends_remove_data', 1 ); 569 add_action( 'delete_user', 'friends_remove_data', 1 ); 570 add_action( 'make_spam_user', 'friends_remove_data', 1 ); 571 571 572 572 … … 595 595 global $bp; 596 596 597 if ( isset( $_GET['new']) )598 bp_core_delete_notifications_for_user_by_type( $bp-> loggedin_user->id, $bp->friends->id, 'friendship_accepted' );597 if ( isset($_GET['new']) ) 598 bp_core_delete_notifications_for_user_by_type( $bp->displayed_user->id, $bp->friends->id, 'friendship_accepted' ); 599 599 } 600 600 add_action( 'bp_activity_screen_my_activity', 'friends_clear_friend_notifications' ); -
trunk/bp-groups.php
r2946 r3232 492 492 493 493 if ( $bp->is_single_item ) { 494 /* Refresh the group member count meta */495 groups_update_groupmeta( $bp->groups->current_group->id, 'total_member_count', groups_get_total_member_count( $bp->groups->current_group->id ) );496 497 494 do_action( 'groups_screen_group_members', $bp->groups->current_group->id ); 498 495 bp_core_load_template( apply_filters( 'groups_template_group_members', 'groups/single/home' ) ); … … 798 795 799 796 if ( $bp->current_component == $bp->groups->slug && 'membership-requests' == $bp->action_variables[0] ) { 800 801 /* Ask for a login if the user is coming here via an email notification */802 if ( !is_user_logged_in() )803 bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/membership-requests/' ) );804 797 805 798 if ( !$bp->is_item_admin || 'public' == $bp->groups->current_group->status ) … … 1653 1646 } 1654 1647 1655 function groups_get_total_member_count( $group_id ) {1656 return BP_Groups_Group::get_total_member_count( $group_id );1657 }1658 1659 1648 /*** Group Fetching, Filtering & Searching *************************************/ 1660 1649 … … 1814 1803 groups_update_groupmeta( $group_id, 'forum_id', $forum_id ); 1815 1804 1816 do_action( 'groups_new_group_forum', $forum _id, $group_id );1805 do_action( 'groups_new_group_forum', $forum, $group_id ); 1817 1806 } 1818 1807 … … 2417 2406 do_action( 'groups_remove_data_for_user', $user_id ); 2418 2407 } 2419 add_action( 'wpmu_delete_user', 'groups_remove_data_for_user' );2420 add_action( 'delete_user', 'groups_remove_data_for_user' );2421 add_action( 'make_spam_user', 'groups_remove_data_for_user' );2408 add_action( 'wpmu_delete_user', 'groups_remove_data_for_user', 1 ); 2409 add_action( 'delete_user', 'groups_remove_data_for_user', 1 ); 2410 add_action( 'make_spam_user', 'groups_remove_data_for_user', 1 ); 2422 2411 2423 2412 -
trunk/bp-groups/bp-groups-classes.php
r2989 r3232 634 634 groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) - 1 ) ); 635 635 636 $group_count = get_user meta( $this->user_id, 'total_group_count');636 $group_count = get_user_meta( $this->user_id, 'total_group_count', true ); 637 637 if ( !empty( $group_count ) ) 638 update_user meta( $this->user_id, 'total_group_count', (int)$group_count - 1 );638 update_user_meta( $this->user_id, 'total_group_count', (int)$group_count - 1 ); 639 639 640 640 return $this->save(); … … 648 648 649 649 groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) + 1 ) ); 650 update_user meta( $this->user_id, 'total_group_count', (int)get_usermeta( $this->user_id, 'total_group_count') + 1 );650 update_user_meta( $this->user_id, 'total_group_count', (int)get_user_meta( $this->user_id, 'total_group_count', true ) + 1 ); 651 651 652 652 return $this->save(); … … 656 656 $this->inviter_id = 0; 657 657 $this->is_confirmed = 1; 658 $this->date_modified = gmdate( "Y-m-d H:i:s");658 $this->date_modified = bp_core_current_time(); 659 659 } 660 660 661 661 function accept_request() { 662 662 $this->is_confirmed = 1; 663 $this->date_modified = gmdate( "Y-m-d H:i:s" ); 663 $this->date_modified = bp_core_current_time(); 664 } 665 666 function remove( $user_id, $group_id ) { 667 global $wpdb, $bp; 668 669 $sql = $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ); 670 671 if ( !$result = $wpdb->query( $sql ) ) 672 return false; 673 674 groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) - 1 ) ); 675 676 $group_count = get_user_meta( $this->user_id, 'total_group_count', true ); 677 if ( !empty( $group_count ) ) 678 update_user_meta( $this->user_id, 'total_group_count', (int)$group_count - 1 ); 679 680 return $result; 664 681 } 665 682 … … 758 775 $user_id = $bp->displayed_user->id; 759 776 760 if ( $user_id != $bp->loggedin_user->id && !is_s ite_admin() ) {777 if ( $user_id != $bp->loggedin_user->id && !is_super_admin() ) { 761 778 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0", $user_id ) ); 762 779 } else { … … 795 812 } 796 813 814 function delete_request( $user_id, $group_id ) { 815 global $wpdb, $bp; 816 817 if ( !$user_id ) 818 return false; 819 820 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id = 0 AND invite_sent = 0", $user_id, $group_id ) ); 821 } 822 797 823 function check_is_admin( $user_id, $group_id ) { 798 824 global $wpdb, $bp; … … 829 855 830 856 return $wpdb->get_var( $wpdb->prepare( "SELECT is_banned FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) ); 857 } 858 859 /** 860 * Is the specified user the creator of the group? 861 * 862 * @global object $bp BuddyPress global settings 863 * @global wpdb $wpdb WordPress database object 864 * @param int $user_id 865 * @param int $group_id 866 * @since 1.2.6 867 */ 868 function check_is_creator( $user_id, $group_id ) { 869 global $bp, $wpdb; 870 871 if ( !$user_id ) 872 return false; 873 874 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name} WHERE creator_id = %d AND id = %d", $user_id, $group_id ) ); 831 875 } 832 876 … … 888 932 889 933 if ( bp_is_active( 'xprofile' ) ) 890 $members = $wpdb->get_results( apply_filters( 'bp_group_members_user_join_filter', $wpdb->prepare( "SELECT m.user_id, m.date_modified, m.is_banned, u.user_login, u.user_nicename, u.user_email, pd.value as display_name FROM {$bp->groups->table_name_members} m, {$wpdb->users} u, {$bp->profile->table_name_data} pd WHERE u.ID = m.user_id AND u.ID = pd.user_id AND pd.field_id = 1 AND group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_sql} ORDER BY m.date_modified DESC {$pag_sql}", $group_id )) );934 $members = $wpdb->get_results( $wpdb->prepare( "SELECT m.user_id, m.date_modified, m.is_banned, u.user_login, u.user_nicename, u.user_email, pd.value as display_name FROM {$bp->groups->table_name_members} m, {$wpdb->users} u, {$bp->profile->table_name_data} pd WHERE u.ID = m.user_id AND u.ID = pd.user_id AND pd.field_id = 1 AND group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_sql} ORDER BY m.date_modified DESC {$pag_sql}", $group_id ) ); 891 935 else 892 $members = $wpdb->get_results( apply_filters( 'bp_group_members_user_join_filter', $wpdb->prepare( "SELECT m.user_id, m.date_modified, m.is_banned, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$bp->groups->table_name_members} m, {$wpdb->users} u WHERE u.ID = m.user_id AND group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_sql} ORDER BY m.date_modified DESC {$pag_sql}", $group_id )) );936 $members = $wpdb->get_results( $wpdb->prepare( "SELECT m.user_id, m.date_modified, m.is_banned, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$bp->groups->table_name_members} m, {$wpdb->users} u WHERE u.ID = m.user_id AND group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_sql} ORDER BY m.date_modified DESC {$pag_sql}", $group_id ) ); 893 937 894 938 if ( !$members ) … … 898 942 $total_member_count = count($members); 899 943 else 900 $total_member_count = $wpdb->get_var( apply_filters( 'bp_group_members_count_user_join_filter', $wpdb->prepare( "SELECT COUNT(user_id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_sql}", $group_id )) );944 $total_member_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(user_id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_sql}", $group_id ) ); 901 945 902 946 /* Fetch whether or not the user is a friend */ … … 904 948 $user_ids = $wpdb->escape( join( ',', (array)$user_ids ) ); 905 949 906 if ( bp_is_active( 'friends' ) ) {950 if ( function_exists( 'friends_install' ) ) { 907 951 $friend_status = $wpdb->get_results( $wpdb->prepare( "SELECT initiator_user_id, friend_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id IN ( {$user_ids} ) ) OR (initiator_user_id IN ( {$user_ids} ) AND friend_user_id = %d )", $bp->loggedin_user->id, $bp->loggedin_user->id ) ); 908 952 for ( $i = 0; $i < count( $members ); $i++ ) { … … 923 967 } 924 968 969 /** 970 * Delete all group membership information for the specified user 971 * 972 * @global object $bp BuddyPress global settings 973 * @global wpdb $wpdb WordPress database object 974 * @param int $user_id 975 * @since 1.0 976 * @uses BP_Groups_Member 977 */ 925 978 function delete_all_for_user( $user_id ) { 926 global $wpdb, $bp; 979 global $bp, $wpdb; 980 981 // Get all the group ids for the current user's groups and update counts 982 $group_ids = BP_Groups_Member::get_group_ids( $user_id ); 983 foreach ( $group_ids['groups'] as $group_id ) { 984 groups_update_groupmeta( $group_id, 'total_member_count', groups_get_total_member_count( $group_id ) - 1 ); 985 986 // If current user is the creator of a group and is the sole admin, delete that group to avoid counts going out-of-sync 987 if ( groups_is_user_admin( $user_id, $group_id ) && count( groups_get_group_admins( $group_id ) ) < 2 && groups_is_user_creator( $user_id, $group_id ) ) 988 groups_delete_group( $group_id ); 989 } 927 990 928 991 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d", $user_id ) ); … … 994 1057 global $bp; 995 1058 996 /* When we are viewing a single group, add the group extension nav item */997 if ( $this->visbility == 'public' || ( $this->visbility != 'public' && $bp->groups->current_group->user_has_access ) ) {998 if ( $this->enable_nav_item ) {999 if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item )1000 bp_core_new_subnav_item( array( 'name' => ( !$this->nav_item_name ) ? $this->name : $this->nav_item_name, 'slug' => $this->slug, 'parent_slug' => BP_GROUPS_SLUG, 'parent_url' => bp_get_group_permalink( $bp->groups->current_group ), 'position' => $this->nav_item_position, 'item_css_id' => 'nav-' . $this->slug, 'screen_function' => array( &$this, '_display_hook' ), 'user_has_access' => $this->enable_nav_item ) );1001 1002 /* When we are viewing the extension display page, set the title and options title */1003 if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item && $bp->current_action == $this->slug ) {1004 add_action( 'bp_template_content_header', create_function( '', 'echo "' . attribute_escape( $this->name ) . '";' ) );1005 add_action( 'bp_template_title', create_function( '', 'echo "' . attribute_escape( $this->name ) . '";' ) );1006 }1007 }1008 1009 /* Hook the group home widget */1010 if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) )1011 add_action( $this->display_hook, array( &$this, 'widget_display' ) );1012 }1013 1014 1059 if ( $this->enable_create_step ) { 1015 / * Insert the group creation step for the new group extension */1060 // Insert the group creation step for the new group extension 1016 1061 $bp->groups->group_creation_steps[$this->slug] = array( 'name' => $this->name, 'slug' => $this->slug, 'position' => $this->create_step_position ); 1017 1062 1018 / * Attach the group creation step display content action */1063 // Attach the group creation step display content action 1019 1064 add_action( 'groups_custom_create_steps', array( &$this, 'create_screen' ) ); 1020 1065 1021 / * Attach the group creation step save content action */1066 // Attach the group creation step save content action 1022 1067 add_action( 'groups_create_group_step_save_' . $this->slug, array( &$this, 'create_screen_save' ) ); 1023 1068 } 1024 1069 1025 / * Construct the admin edit tab for the new group extension */1070 // Construct the admin edit tab for the new group extension 1026 1071 if ( $this->enable_edit_item ) { 1027 add_action( 'groups_admin_tabs', create_function( '$current, $group_slug', 'if ( "' . attribute_escape( $this->slug ) . '" == $current ) $selected = " class=\"current\""; echo "<li{$selected}><a href=\"' . $bp->root_domain . '/' . $bp->groups->slug . '/{$group_slug}/admin/' . attribute_escape( $this->slug ) . '\">' . attribute_escape( $this->name ) . '</a></li>";' ), 10, 2 ); 1028 1029 /* Catch the edit screen and forward it to the plugin template */ 1072 add_action( 'groups_admin_tabs', create_function( '$current, $group_slug', 'if ( "' . esc_attr( $this->slug ) . '" == $current ) $selected = " class=\"current\""; echo "<li{$selected}><a href=\"' . $bp->root_domain . '/' . $bp->groups->slug . '/{$group_slug}/admin/' . esc_attr( $this->slug ) . '\">' . esc_attr( $this->name ) . '</a></li>";' ), 10, 2 ); 1073 1074 // Make sure user has access 1075 if ( !$bp->is_item_admin ) 1076 return false; 1077 1078 // Catch the edit screen and forward it to the plugin template 1030 1079 if ( $bp->current_component == $bp->groups->slug && 'admin' == $bp->current_action && $this->slug == $bp->action_variables[0] ) { 1031 $this->edit_screen_save();1080 add_action( 'wp', array( &$this, 'edit_screen_save' ) ); 1032 1081 add_action( 'groups_custom_edit_steps', array( &$this, 'edit_screen' ) ); 1033 1082 … … 1041 1090 } 1042 1091 } 1092 1093 // When we are viewing a single group, add the group extension nav item 1094 if ( $this->visibility == 'public' || ( $this->visibility != 'public' && $bp->groups->current_group->user_has_access ) ) { 1095 if ( $this->enable_nav_item ) { 1096 if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item ) 1097 bp_core_new_subnav_item( array( 'name' => ( !$this->nav_item_name ) ? $this->name : $this->nav_item_name, 'slug' => $this->slug, 'parent_slug' => BP_GROUPS_SLUG, 'parent_url' => bp_get_group_permalink( $bp->groups->current_group ), 'position' => $this->nav_item_position, 'item_css_id' => 'nav-' . $this->slug, 'screen_function' => array( &$this, '_display_hook' ), 'user_has_access' => $this->enable_nav_item ) ); 1098 1099 // When we are viewing the extension display page, set the title and options title 1100 if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item && $bp->current_action == $this->slug ) { 1101 add_action( 'bp_template_content_header', create_function( '', 'echo "' . esc_attr( $this->name ) . '";' ) ); 1102 add_action( 'bp_template_title', create_function( '', 'echo "' . esc_attr( $this->name ) . '";' ) ); 1103 } 1104 } 1105 1106 // Hook the group home widget 1107 if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) ) 1108 add_action( $this->display_hook, array( &$this, 'widget_display' ) ); 1109 } 1043 1110 } 1044 1111 … … 1055 1122 return false; 1056 1123 1057 /* Register the group extension on the plugins_loadedaction so we have access to all plugins */1058 add_action( ' init', create_function( '', '$extension = new ' . $group_extension_class . '; add_action( "pre_get_posts", array( &$extension, "_register" ) );' ));1124 /* Register the group extension on the bp_init action so we have access to all plugins */ 1125 add_action( 'bp_init', create_function( '', '$extension = new ' . $group_extension_class . '; add_action( "wp", array( &$extension, "_register" ), 2 );' ), 11 ); 1059 1126 } 1060 1127 -
trunk/bp-groups/bp-groups-templatetags.php
r2950 r3232 1413 1413 $total = bp_core_number_format( $members_template->total_member_count ); 1414 1414 1415 return apply_filters( 'bp_get_group_member_pagination_count', sprintf( __( 'Viewing members % 1$s to %2$s (of %3$s members)', 'buddypress' ), $from_num, $to_num, $total ) );1415 return apply_filters( 'bp_get_group_member_pagination_count', sprintf( __( 'Viewing members %s to %s (of %s members)', 'buddypress' ), $from_num, $to_num, $total ) ); 1416 1416 } 1417 1417 -
trunk/bp-loader.php
r2925 r3232 7 7 Version: 1.3-bleeding 8 8 Author URI: http://buddypress.org/developers/ 9 Network: true10 9 */ 11 10 … … 62 61 include( BP_PLUGIN_DIR . '/bp-xprofile.php' ); 63 62 64 /* Allow dependent plugins to hook into BuddyPress in a safe way */ 63 /** 64 * bp_loaded() 65 * 66 * Allow dependent plugins and core actions to attach themselves in a safe way. 67 * 68 * See bp-core.php for the following core actions: 69 * - bp_init|bp_setup_globals|bp_setup_root_components|bp_setup_nav|bp_register_widgets 70 */ 65 71 function bp_loaded() { 66 do_action( 'bp_ init' );72 do_action( 'bp_loaded' ); 67 73 } 68 add_action( 'plugins_loaded', 'bp_loaded' );74 add_action( 'plugins_loaded', 'bp_loaded', 20 ); 69 75 } 70 76 -
trunk/bp-messages/bp-messages-notifications.php
r2941 r3232 34 34 ', 'buddypress' ), $sender_name, $subject, $content, $message_link ); 35 35 36 $ email_content .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );36 $content .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 37 37 38 38 /* Send the message */ -
trunk/bp-messages/bp-messages-templatetags.php
r2944 r3232 313 313 $total = bp_core_number_format( $messages_template->total_thread_count ); 314 314 315 echo sprintf( __( 'Viewing message % 1$s to %2$s (of %3$s messages)', 'buddypress' ), $from_num, $to_num, $total ); ?> 315 echo sprintf( __( 'Viewing message %s to %s (of %s messages)', 'buddypress' ), $from_num, $to_num, $total ); ?> 316 316 <span class="ajax-loader"></span><?php 317 317 } -
trunk/bp-themes/bp-default/_inc/css/default.css
r2842 r3232 803 803 } 804 804 805 form.standard-form a.clear-value {806 display: block;807 margin-top: 5px;808 outline: none;809 }810 811 805 form.standard-form #basic-details-section, form.standard-form #blog-details-section, 812 806 form.standard-form #profile-details-section { -
trunk/bp-themes/bp-default/_inc/global.js
r2925 r3232 169 169 if ( 'fav' == type ) { 170 170 if ( !jq('div.item-list-tabs li#activity-favorites').length ) 171 jq('div.item-list-tabs ul li#activity-mentions').before( '<li id="activity-favorites"><a href="#">' + bp_terms_my_favs + ' (<span>0</span>)</a></li>');171 jq('div.item-list-tabs ul li#activity-mentions').before( '<li id="activity-favorites"><a href="#">' + BP_DTheme.my_favs + ' (<span>0</span>)</a></li>'); 172 172 173 173 target.removeClass('fav'); … … 229 229 /* Load more updates at the end of the page */ 230 230 if ( target.parent().attr('class') == 'load-more' ) { 231 jq(" li.load-more").addClass('loading');231 jq("#content li.load-more").addClass('loading'); 232 232 233 233 if ( null == jq.cookie('bp-activity-oldestpage') ) … … 243 243 function(response) 244 244 { 245 jq(" li.load-more").removeClass('loading');245 jq("#content li.load-more").removeClass('loading'); 246 246 jq.cookie( 'bp-activity-oldestpage', oldest_page, {path: '/'} ); 247 jq(" ul.activity-list").append(response.contents);247 jq("#content ul.activity-list").append(response.contents); 248 248 249 249 target.parent().hide(); … … 461 461 jq('span.highlight span').click( function() { 462 462 if ( !jq('div.help').length ) { 463 jq(this).parent().after( '<div id="message" class="info help"><p>' + bp_terms_mention_explain + '</p></div>' );463 jq(this).parent().after( '<div id="message" class="info help"><p>' + BP_DTheme.mention_explain + '</p></div>' ); 464 464 jq('div.help').hide().slideDown(200); 465 465 } else { … … 713 713 button.fadeOut( 100, function() { 714 714 if ( jq(this).hasClass('accept') ) { 715 jq(this).html( bp_terms_accepted ).fadeIn(50);715 jq(this).html( BP_DTheme.accepted ).fadeIn(50); 716 716 jq(this).addClass('accepted'); 717 717 } else { 718 jq(this).html( bp_terms_rejected ).fadeIn(50);718 jq(this).html( BP_DTheme.rejected ).fadeIn(50); 719 719 jq(this).addClass('rejected'); 720 720 } … … 820 820 /** Alternate Highlighting ******************************************/ 821 821 822 jq('table tr, div.message-box, ul#topic-post-list li').each( function(i) { 823 if ( i % 2 != 1 ) 822 jq('body#bp-default table.zebra tbody tr').mouseover( function() { 823 jq(this).addClass('over'); 824 }).mouseout( function() { 825 jq(this).removeClass('over'); 826 }); 827 828 jq('body#bp-default table.zebra tbody tr:odd').addClass('alt'); 829 830 jq('div.message-box').each( function(i) { 831 if ( i % 2 == 1 ) 824 832 jq(this).addClass('alt'); 825 833 }); … … 957 965 958 966 /* Bulk delete messages */ 959 jq("a#delete_inbox_messages ").click( function() {967 jq("a#delete_inbox_messages, a#delete_sentbox_messages").click( function() { 960 968 checkboxes_tosend = ''; 961 969 checkboxes = jq("#message-threads tr td input[type='checkbox']"); … … 990 998 991 999 jq('div#message').hide().slideDown(150); 992 jq("a#delete_inbox_messages ").removeClass('loading');1000 jq("a#delete_inbox_messages, a#delete_sentbox_messages").removeClass('loading'); 993 1001 }); 994 1002 return false; … … 1078 1086 return false; 1079 1087 1080 if ( jq.query.get('s') )1088 if ( jq.query.get('s') && !search_terms ) 1081 1089 search_terms = jq.query.get('s'); 1082 1090 … … 1159 1167 jq(this).html(response.contents); 1160 1168 jq(this).fadeIn(100); 1169 1170 /* Selectively hide comments */ 1171 bp_dtheme_hide_comments(); 1161 1172 }); 1162 1173 … … 1166 1177 1167 1178 jq('div.item-list-tabs li.selected').removeClass('loading'); 1168 1169 /* Selectively hide comments */1170 bp_dtheme_hide_comments();1171 1179 1172 1180 }, 'json' ); … … 1198 1206 1199 1207 if ( !i ) 1200 jq(this).before( '<li class="show-all"><a href="#' + parent_li.attr('id') + '/show-all/" title="' + bp_terms_show_all_comments + '">' + bp_terms_show_all + ' ' + comment_count + ' ' + bp_terms_comments + '</a></li>' );1208 jq(this).before( '<li class="show-all"><a href="#' + parent_li.attr('id') + '/show-all/" title="' + BP_DTheme.show_all_comments + '">' + BP_DTheme.show_all + ' ' + comment_count + ' ' + BP_DTheme.comments + '</a></li>' ); 1201 1209 } 1202 1210 }); -
trunk/bp-themes/bp-default/blogs/create.php
r2925 r3232 1 1 <?php get_header() ?> 2 2 3 <?php do_action( 'bp_before_directory_ blogs_content' ) ?>3 <?php do_action( 'bp_before_directory_groups_content' ) ?> 4 4 5 5 <div id="content"> … … 31 31 <?php locate_template( array( 'sidebar.php' ), true ) ?> 32 32 33 <?php do_action( 'bp_after_directory_ blogs_content' ) ?>33 <?php do_action( 'bp_after_directory_groups_content' ) ?> 34 34 35 35 <?php get_footer() ?> -
trunk/bp-themes/bp-default/comments.php
r2946 r3232 20 20 21 21 <span class="title"><?php the_title() ?></span> 22 <h3 id="comments"><?php comments_number( ' ', '', $numComments);?></h3>22 <h3 id="comments"><?php comments_number( 'No Comments', 'One Comment', $numComments . ' Comments' );?></h3> 23 23 24 24 <?php do_action( 'bp_before_blog_comment_list' ) ?> -
trunk/bp-themes/bp-default/forums/forums-loop.php
r2925 r3232 1 <?php /* Querystring is set via AJAX in _inc/ajax.php - bp_dtheme_object_filter() */ ?> 2 3 <?php do_action( 'bp_before_forums_loop' ) ?> 4 1 5 <?php if ( bp_has_forum_topics( bp_ajax_querystring( 'forums' ) ) ) : ?> 2 6 3 <div class="pagination">7 <div id="pag-top" class="pagination"> 4 8 5 <div id="post-count" class="pag-count"> 6 <?php if ( bp_is_group_forum() && is_user_logged_in() ) : ?> 7 <a href="#post-new" class="button"><?php _e( 'New Topic', 'buddypress' ) ?></a> 8 <?php endif; ?> 9 9 <div class="pag-count" id="topic-count-top"> 10 10 <?php bp_forum_pagination_count() ?> 11 11 </div> 12 12 13 <div class="pagination-links" id="topic-pag ">13 <div class="pagination-links" id="topic-pag-top"> 14 14 <?php bp_forum_pagination() ?> 15 15 </div> … … 19 19 <?php do_action( 'bp_before_directory_forums_list' ) ?> 20 20 21 <table class="forum"> 21 <table class="forum zebra"> 22 <thead> 23 <tr> 24 <th id="th-title"><?php _e( 'Topic Title', 'buddypress' ) ?></th> 25 <th id="th-poster"><?php _e( 'Latest Poster', 'buddypress' ) ?></th> 22 26 23 <tr>24 <th id="th-title"><?php _e( 'Topic Title', 'buddypress' ) ?></th>25 <th id="th-poster"><?php _e( 'Latest Poster', 'buddypress' ) ?></th>27 <?php if ( !bp_is_group_forum() ) : ?> 28 <th id="th-group"><?php _e( 'Posted In Group', 'buddypress' ) ?></th> 29 <?php endif; ?> 26 30 27 <?php if ( !bp_is_group_forum() ) : ?> 28 <th id="th-group"><?php _e( 'Posted In Group', 'buddypress' ) ?></th> 29 <?php endif; ?> 31 <th id="th-postcount"><?php _e( 'Posts', 'buddypress' ) ?></th> 32 <th id="th-freshness"><?php _e( 'Freshness', 'buddypress' ) ?></th> 30 33 31 <th id="th-postcount"><?php _e( 'Posts', 'buddypress' ) ?></th> 32 <th id="th-freshness"><?php _e( 'Freshness', 'buddypress' ) ?></th> 34 <?php do_action( 'bp_directory_forums_extra_cell_head' ) ?> 33 35 34 <?php do_action( 'bp_directory_forums_extra_cell_head' ) ?> 36 </tr> 37 </thead> 35 38 36 < /tr>39 <tbody> 37 40 38 <?php while ( bp_forum_topics() ) : bp_the_forum_topic(); ?>41 <?php while ( bp_forum_topics() ) : bp_the_forum_topic(); ?> 39 42 40 <tr class="<?php bp_the_topic_css_class() ?>">41 <td class="td-title">42 <a class="topic-title" href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>">43 <?php bp_the_topic_title() ?>44 </a>45 </td>46 <td class="td-poster">47 <a href="<?php bp_the_topic_permalink() ?>"><?php bp_the_topic_last_poster_avatar( 'type=thumb&width=20&height=20' ) ?></a>48 <div class="poster-name"><?php bp_the_topic_last_poster_name() ?></div>49 </td>43 <tr class="<?php bp_the_topic_css_class() ?>"> 44 <td class="td-title"> 45 <a class="topic-title" href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"> 46 <?php bp_the_topic_title() ?> 47 </a> 48 </td> 49 <td class="td-poster"> 50 <a href="<?php bp_the_topic_permalink() ?>"><?php bp_the_topic_last_poster_avatar( 'type=thumb&width=20&height=20' ) ?></a> 51 <div class="poster-name"><?php bp_the_topic_last_poster_name() ?></div> 52 </td> 50 53 51 <?php if ( !bp_is_group_forum() ) : ?> 52 <td class="td-group"> 53 <a href="<?php bp_the_topic_object_permalink() ?>"><?php bp_the_topic_object_avatar( 'type=thumb&width=20&height=20' ) ?></a> 54 <div class="object-name"><a href="<?php bp_the_topic_object_permalink() ?>" title="<?php bp_the_topic_object_name() ?>"><?php bp_the_topic_object_name() ?></a></div> 54 <?php if ( !bp_is_group_forum() ) : ?> 55 <td class="td-group"> 56 <a href="<?php bp_the_topic_object_permalink() ?>"><?php bp_the_topic_object_avatar( 'type=thumb&width=20&height=20' ) ?></a> 57 <div class="object-name"><a href="<?php bp_the_topic_object_permalink() ?>" title="<?php bp_the_topic_object_name() ?>"><?php bp_the_topic_object_name() ?></a></div> 58 </td> 59 <?php endif; ?> 60 61 <td class="td-postcount"> 62 <?php bp_the_topic_total_posts() ?> 55 63 </td> 56 <?php endif; ?> 64 <td class="td-freshness"> 65 <?php bp_the_topic_time_since_last_post() ?> 66 </td> 57 67 58 <td class="td-postcount"> 59 <?php bp_the_topic_total_posts() ?> 60 </td> 61 <td class="td-freshness"> 62 <?php bp_the_topic_time_since_last_post() ?> 63 </td> 68 <?php do_action( 'bp_directory_forums_extra_cell' ) ?> 69 </tr> 64 70 65 <?php do_action( 'bp_directory_forums_extra_cell' ) ?> 66 </tr> 71 <?php do_action( 'bp_directory_forums_extra_row' ) ?> 67 72 68 <?php do_action( 'bp_directory_forums_extra_row' )?>73 <?php endwhile; ?> 69 74 70 <?php endwhile; ?> 71 75 </tbody> 72 76 </table> 73 77 74 78 <?php do_action( 'bp_after_directory_forums_list' ) ?> 79 80 <div id="pag-bottom" class="pagination"> 81 82 <div class="pag-count" id="topic-count-bottom"> 83 <?php bp_forum_pagination_count() ?> 84 </div> 85 86 <div class="pagination-links" id="topic-pag-bottom"> 87 <?php bp_forum_pagination() ?> 88 </div> 89 90 </div> 75 91 76 92 <?php else: ?> … … 81 97 82 98 <?php endif;?> 99 100 <?php do_action( 'bp_after_forums_loop' ) ?> -
trunk/bp-themes/bp-default/forums/index.php
r2925 r3232 1 1 <?php get_header() ?> 2 3 <?php do_action( 'bp_before_directory_forums_content' ) ?> 2 4 3 5 <div id="content"> … … 5 7 6 8 <form action="" method="post" id="forums-search-form" class="dir-form"> 7 8 9 <h3><?php _e( 'Group Forums Directory', 'buddypress' ) ?><?php if ( is_user_logged_in() ) : ?> <a class="button" href="#new-topic" id="new-topic-button"><?php _e( 'New Topic', 'buddypress' ) ?></a><?php endif; ?></h3> 9 10 <?php do_action( 'bp_before_directory_forums_content' ) ?>11 10 12 11 <div id="forums-dir-search" class="dir-search"> -
trunk/bp-themes/bp-default/functions.php
r2842 r3232 72 72 /* Filter the dropdown for selecting the page to show on front to include "Activity Stream" */ 73 73 function bp_dtheme_wp_pages_filter( $page_html ) { 74 if ( !bp_is_active( 'activity' ) )75 return $page_html;76 77 74 if ( 'page_on_front' != substr( $page_html, 14, 13 ) ) 78 75 return $page_html; -
trunk/bp-themes/bp-default/groups/index.php
r2925 r3232 15 15 <div class="item-list-tabs"> 16 16 <ul> 17 <li class="selected" id="groups-all"><a href="<?php echo bp_get_root_domain() . '/' . BP_GROUPS_SLUG?>"><?php printf( __( 'All Groups (%s)', 'buddypress' ), bp_get_total_group_count() ) ?></a></li>17 <li class="selected" id="groups-all"><a href="<?php bp_root_domain() ?>"><?php printf( __( 'All Groups (%s)', 'buddypress' ), bp_get_total_group_count() ) ?></a></li> 18 18 19 19 <?php if ( is_user_logged_in() && bp_get_total_group_count_for_user( bp_loggedin_user_id() ) ) : ?> -
trunk/bp-themes/bp-default/members/single/home.php
r2925 r3232 15 15 <?php bp_get_displayed_user_nav() ?> 16 16 17 <?php do_action( 'bp_member _options_nav' ) ?>17 <?php do_action( 'bp_members_directory_member_types' ) ?> 18 18 </ul> 19 19 </div> -
trunk/bp-themes/bp-default/members/single/profile/edit.php
r2842 r3232 48 48 <?php bp_the_profile_field_options() ?> 49 49 </select> 50 51 <?php if ( !bp_get_the_profile_field_is_required() ) : ?>52 <a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name() ?>' );"><?php _e( 'Clear', 'buddypress' ) ?></a>53 <?php endif; ?>54 50 55 51 <?php endif; ?> -
trunk/bp-themes/bp-default/sidebar.php
r2925 r3232 38 38 </p> 39 39 40 <form name="login-form" id="sidebar-login-form" class="standard-form" action="<?php echo site_url( 'wp-login.php', 'login _post' ) ?>" method="post">40 <form name="login-form" id="sidebar-login-form" class="standard-form" action="<?php echo site_url( 'wp-login.php', 'login' ) ?>" method="post"> 41 41 <label><?php _e( 'Username', 'buddypress' ) ?><br /> 42 42 <input type="text" name="log" id="sidebar-user-login" class="input" value="<?php echo attribute_escape(stripslashes($user_login)); ?>" /></label> -
trunk/bp-xprofile.php
r2946 r3232 16 16 * @uses site_url() Returns the site URL 17 17 */ 18 18 19 function xprofile_setup_globals() { 19 20 global $bp, $wpdb; … … 136 137 <li><a href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/change-avatar/"><?php printf( __( "Edit %s's Avatar", 'buddypress' ), attribute_escape( $bp->displayed_user->fullname ) ) ?></a></li> 137 138 <?php if ( !bp_core_is_user_spammer( $bp->displayed_user->id ) ) : ?> 138 139 139 <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/mark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Mark as Spammer", 'buddypress' ) ?></a></li> 140 140 <?php else : ?> … … 235 235 } 236 236 237 if ( !empty( $errors ))237 if ( $errors ) 238 238 bp_core_add_message( __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' ), 'error' ); 239 239 else { … … 249 249 } 250 250 251 do_action( 'xprofile_updated_profile', $ bp->displayed_user->id, $posted_field_ids, $errors );251 do_action( 'xprofile_updated_profile', $posted_field_ids, $errors ); 252 252 253 253 /* Set the feedback messages */ … … 642 642 return false; 643 643 644 /* If the value is empty, then delete any field data that exists */645 if ( empty( $value ) ) {646 xprofile_delete_field_data( $field_id, $user_id );647 return true;648 }649 650 644 $field = new BP_XProfile_Field( $field_id ); 651 645 … … 693 687 $field_id = xprofile_get_field_id_from_name( $field ); 694 688 695 if ( empty( $field_id ) || empty( $user_id ))696 return false; 697 698 $field = new BP_XProfile_ProfileData( $field_id , $user_id);689 if ( !$field_id ) 690 return false; 691 692 $field = new BP_XProfile_ProfileData( $field_id ); 699 693 return $field->delete(); 700 694 } … … 882 876 BP_XProfile_ProfileData::delete_data_for_user( $user_id ); 883 877 884 / * delete any avatar files. */885 @unlink( get_user meta( $user_id, 'bp_core_avatar_v1_path') );886 @unlink( get_user meta( $user_id, 'bp_core_avatar_v2_path') );887 888 / * unset the usermeta for avatars from the usermeta table. */889 delete_user meta( $user_id, 'bp_core_avatar_v1' );890 delete_user meta( $user_id, 'bp_core_avatar_v1_path' );891 delete_user meta( $user_id, 'bp_core_avatar_v2' );892 delete_user meta( $user_id, 'bp_core_avatar_v2_path' );878 // delete any avatar files. 879 @unlink( get_user_meta( $user_id, 'bp_core_avatar_v1_path', true ) ); 880 @unlink( get_user_meta( $user_id, 'bp_core_avatar_v2_path', true ) ); 881 882 // unset the usermeta for avatars from the usermeta table. 883 delete_user_meta( $user_id, 'bp_core_avatar_v1' ); 884 delete_user_meta( $user_id, 'bp_core_avatar_v1_path' ); 885 delete_user_meta( $user_id, 'bp_core_avatar_v2' ); 886 delete_user_meta( $user_id, 'bp_core_avatar_v2_path' ); 893 887 } 894 888 add_action( 'wpmu_delete_user', 'xprofile_remove_data' ); -
trunk/bp-xprofile/admin/css/admin.css
r2887 r3232 141 141 margin: 0 0 1em 0; 142 142 } 143 143 144 144 ul.forTab li label { 145 145 display: block; 146 146 } 147 147 148 148 ul.forTab li input { 149 149 font-size: 1.4em; 150 150 } 151 151 152 152 p.success { background: green;} 153 p.err { 153 p.err { 154 154 border-top: 2px solid red; 155 155 border-bottom: 2px solid red; … … 158 158 width: 40%; 159 159 } 160 160 161 161 span.desc, span.signup-description { 162 162 display: block; -
trunk/bp-xprofile/bp-xprofile-admin.php
r2887 r3232 121 121 } /* End For */ ?> 122 122 </div> 123 <?php 123 <?php 124 124 else : 125 125 ?> … … 330 330 function xprofile_admin_field( $admin_field, $admin_group ) { 331 331 global $field; 332 332 333 333 $field = $admin_field; 334 334 ?> -
trunk/bp-xprofile/bp-xprofile-classes.php
r2883 r3232 549 549 <input type="text" name="<?php echo $type; ?>_option[<?php echo $j; ?>]" id="<?php echo $type; ?>_option<?php echo $j; ?>" value="<?php echo attribute_escape( $options[$i]->name ); ?>" /> 550 550 <input type="<?php echo $default_input; ?>" name="isDefault_<?php echo $type; ?>_option<?php echo $default_name; ?>" <?php if ( (int) $options[$i]->is_default_option ) {?> checked="checked"<?php } ?> " value="<?php echo $j; ?>" /> <?php _e( 'Default Value', 'buddypress' ); ?> 551 <?php 551 <?php 552 552 if ( $j != 1 && $options[$i]->id != -1 ) : ?> 553 553 <a href="admin.php?page=bp-profile-setup&mode=delete_option&option_id=<?php echo $options[$i]->id ?>" class="ajax-option-delete" id="delete-<?php echo $options[$i]->id; ?>">[x]</a> -
trunk/bp-xprofile/bp-xprofile-templatetags.php
r2911 r3232 343 343 global $field; 344 344 345 $array_box = false; 346 if ( 'multiselectbox' == $field->type ) 347 $array_box = '[]'; 348 349 return apply_filters( 'bp_get_the_profile_field_input_name', 'field_' . $field->id . $array_box ); 345 return apply_filters( 'bp_get_the_profile_field_input_name', 'field_' . $field->id ); 350 346 } 351 347 … … 375 371 376 372 for ( $k = 0; $k < count($options); $k++ ) { 377 $option_values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $options[$k]->parent_id ) ); 378 $option_values = (array)$option_values; 373 $option_value = BP_XProfile_ProfileData::get_value_byid($options[$k]->parent_id); 379 374 380 375 /* Check for updated posted values, but errors preventing them from being saved first time */ 381 foreach( (array)$option_values as $i => $option_value ) { 382 if ( isset( $_POST['field_' . $field->id] ) && $_POST['field_' . $field->id] != $option_value ) { 383 if ( !empty( $_POST['field_' . $field->id] ) ) 384 $option_values[$i] = $_POST['field_' . $field->id]; 385 } 376 if ( isset( $_POST['field_' . $field->id] ) && $option_value != $_POST['field_' . $field->id] ) { 377 if ( !empty( $_POST['field_' . $field->id] ) ) 378 $option_value = $_POST['field_' . $field->id]; 386 379 } 387 380 -
trunk/readme.txt
r2925 r3232 1 1 === Plugin Name === 2 Contributors: apeatling 2 Contributors: apeatling, johnjamesjacoby, mrmaz 3 3 Tags: buddypress, social networking, activity, profiles, messaging, friends, groups, forums, microblogging, twitter, facebook, mingle, social, community, networks, networking, cms 4 Requires at least: 2.9.15 Tested up to: 2.9.26 Stable tag: 1.2. 34 Requires at least: 3.0 5 Tested up to: 3.0.1 6 Stable tag: 1.2.5.2 7 7 8 8 == Description == … … 124 124 == Upgrade Notice == 125 125 126 = 1.2. 2.1 =127 Fixes a bug where new account activation emails would not be sent correctly. Important upgrade.126 = 1.2.5.1 = 127 Fixes 'Mark user as spam' and 'Delete user' issues. Important upgrade. 128 128 129 129 == Changelog ==
Note: See TracChangeset
for help on using the changeset viewer.