Ticket #5275: 5275.02.patch
File 5275.02.patch, 4.2 KB (added by , 10 years ago) |
---|
-
src/bp-members/bp-members-functions.php
diff --git src/bp-members/bp-members-functions.php src/bp-members/bp-members-functions.php index a1e3cad..1daf5f6 100644
function bp_core_get_userid( $username = '' ) { 218 218 219 219 $user = get_user_by( 'login', $username ); 220 220 221 // On non multisite config, prevents a signup account to be displayed as a member 222 if ( ! empty( $user->user_status ) && 2 == $user->user_status ) { 223 return false; 224 } 225 221 226 return apply_filters( 'bp_core_get_userid', ! empty( $user->ID ) ? $user->ID : NULL, $username ); 222 227 } 223 228 … … function bp_core_get_userid_from_nicename( $user_nicename = '' ) { 236 241 237 242 $user = get_user_by( 'slug', $user_nicename ); 238 243 244 // On non multisite config, prevents a signup account to be displayed as a member 245 if ( ! empty( $user->user_status ) && 2 == $user->user_status ) { 246 return false; 247 } 248 239 249 return apply_filters( 'bp_core_get_userid_from_nicename', ! empty( $user->ID ) ? $user->ID : NULL, $user_nicename ); 240 250 } 241 251 … … function bp_core_process_spammer_status( $user_id, $status, $do_wp_cleanup = tru 705 715 update_user_status( $user_id, 'spam', $is_spam ); 706 716 } 707 717 708 // Always set single site status709 $wpdb->update( $wpdb->users, array( 'user_status' => $is_spam ), array( 'ID' => $user_id ) );710 711 718 // Call multisite actions in single site mode for good measure 712 if ( ! is_multisite()) {719 if ( ! is_multisite() && ! $is_admin ) { 713 720 $wp_action = ( true === $is_spam ) ? 'make_spam_user' : 'make_ham_user'; 714 721 do_action( $wp_action, bp_displayed_user_id() ); 715 722 } 716 723 } 717 724 725 // Always set user status 726 $wpdb->update( $wpdb->users, array( 'user_status' => $is_spam ), array( 'ID' => $user_id ) ); 727 718 728 // Hide this user's activity 719 729 if ( ( true === $is_spam ) && bp_is_active( 'activity' ) ) { 720 730 bp_activity_hide_user_activity( $user_id ); -
tests/phpunit/testcases/core/functions.php
diff --git tests/phpunit/testcases/core/functions.php tests/phpunit/testcases/core/functions.php index a749eb3..1693e2b 100644
class BP_Tests_Core_Functions extends BP_UnitTestCase { 614 614 date_default_timezone_set( $tz_backup ); 615 615 } 616 616 } 617 618 /** 619 * @group bp_core_process_spammer_status 620 */ 621 public function test_bp_core_process_spammer_status() { 622 if ( is_multisite() ) { 623 return; 624 } 625 626 $bp = buddypress(); 627 $displayed_user = $bp->displayed_user; 628 629 $u1 = $this->factory->user->create(); 630 $bp->displayed_user->id = $u1; 631 632 // Spam the user 633 bp_core_process_spammer_status( $u1, 'spam' ); 634 635 $this->assertTrue( bp_is_user_spammer( $u1 ) ); 636 637 // Unspam the user 638 bp_core_process_spammer_status( $u1, 'ham' ); 639 640 clean_user_cache( $u1 ); 641 642 $this->assertFalse( bp_is_user_spammer( $u1 ) ); 643 644 // Reset displayed user 645 $bp->displayed_user = $displayed_user; 646 } 647 648 /** 649 * @group bp_core_process_spammer_status 650 */ 651 public function test_bp_core_process_spammer_status_ms_bulk_spam() { 652 if ( ! is_multisite() ) { 653 return; 654 } 655 656 $bp = buddypress(); 657 $displayed_user = $bp->displayed_user; 658 659 $u1 = $this->factory->user->create(); 660 $bp->displayed_user->id = $u1; 661 662 // Bulk spam in network admin uses update_user_status 663 update_user_status( $u1, 'spam', '1' ); 664 665 $this->assertTrue( bp_is_user_spammer( $u1 ) ); 666 667 // Unspam the user 668 bp_core_process_spammer_status( $u1, 'ham' ); 669 670 clean_user_cache( $u1 ); 671 672 $this->assertFalse( bp_is_user_spammer( $u1 ) ); 673 674 // Reset displayed user 675 $bp->displayed_user = $displayed_user; 676 } 677 678 /** 679 * @group bp_core_process_spammer_status 680 */ 681 public function test_bp_core_process_spammer_status_ms_bulk_ham() { 682 if ( ! is_multisite() ) { 683 return; 684 } 685 686 $bp = buddypress(); 687 $displayed_user = $bp->displayed_user; 688 689 $u1 = $this->factory->user->create(); 690 $bp->displayed_user->id = $u1; 691 692 // Spam the user 693 bp_core_process_spammer_status( $u1, 'spam' ); 694 695 $this->assertTrue( bp_is_user_spammer( $u1 ) ); 696 697 // Bulk unspam in network admin uses update_user_status 698 update_user_status( $u1, 'spam', '0' ); 699 700 clean_user_cache( $u1 ); 701 702 $this->assertFalse( bp_is_user_spammer( $u1 ) ); 703 704 // Reset displayed user 705 $bp->displayed_user = $displayed_user; 706 } 617 707 }