Changeset 6668
- Timestamp:
- 08/25/2017 06:21:26 AM (8 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/admin/tools/repair.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/admin/tools/repair.php
r6644 r6668 723 723 } 724 724 725 // Get non-forum roles 726 $blog_roles = array_keys( bbp_get_blog_roles() ); 727 725 728 // Iterate through each role... 726 foreach ( array_keys( bbp_get_blog_roles() )as $role ) {729 foreach ( $blog_roles as $role ) { 727 730 728 731 // Reset the offset … … 730 733 731 734 // If no role map exists, give the default forum role (bbp-participant) 732 $new_role = isset( $role_map[ $role ] ) ? $role_map[ $role ] : $default_role; 735 $new_role = isset( $role_map[ $role ] ) 736 ? $role_map[ $role ] 737 : $default_role; 733 738 734 739 // Get users of this site, limited to 1000 … … 743 748 foreach ( (array) $users as $user_id ) { 744 749 if ( bbp_set_user_role( $user_id, $new_role ) ) { 750 ++$changed; // Keep a count to display at the end 751 } 752 } 753 754 // Bump the offset for the next query iteration 755 $offset = $offset + 1000; 756 } 757 } 758 759 // Reset the offset 760 $offset = 0; 761 $bbp_db = bbp_db(); 762 $cap_key = $bbp_db->get_blog_prefix() . 'capabilities'; 763 764 // Users without roles should be granted the default role, but not on multi- 765 // site installations where not all users get a role by default. 766 if ( ! is_multisite() ) { 767 768 // Get users with missing capabilities on this site, limited to 1000 769 while ( $users = get_users( array( 770 'meta_key' => $cap_key, 771 'meta_compare' => 'NOT EXISTS', 772 'fields' => 'ID', 773 'number' => 1000, 774 'offset' => $offset 775 ) ) ) { 776 777 // Iterate through each user of $role and try to set it 778 foreach ( (array) $users as $user_id ) { 779 if ( bbp_set_user_role( $user_id, $default_role ) ) { 780 ++$changed; // Keep a count to display at the end 781 } 782 } 783 784 // Bump the offset for the next query iteration 785 $offset = $offset + 1000; 786 } 787 788 // On multisite, we'll look for users with an empty capabilities array. 789 // These are users who basically have malformed caps, and we can fix that. 790 } else { 791 792 // Get users with empty capabilities on this site, limited to 1000 793 while ( $users = get_users( array( 794 'meta_key' => $cap_key, 795 'meta_value' => 'a:0:{}', 796 'fields' => 'ID', 797 'number' => 1000, 798 'offset' => $offset 799 ) ) ) { 800 801 // Iterate through each user of $role and try to set it 802 foreach ( (array) $users as $user_id ) { 803 if ( bbp_set_user_role( $user_id, $default_role ) ) { 745 804 ++$changed; // Keep a count to display at the end 746 805 }
Note: See TracChangeset
for help on using the changeset viewer.