Changeset 12796
- Timestamp:
- 01/22/2010 05:27:28 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/ms-edit.php
r12774 r12796 223 223 // get blog prefix 224 224 $blog_prefix = $wpdb->get_blog_prefix( $id ); 225 225 226 // user roles 226 227 if ( is_array( $_POST[ 'role' ] ) == true ) { … … 231 232 if ( ! $user ) 232 233 continue; 233 // Hack. Init user caps for given blog. 234 $user->_init_caps($blog_prefix . 'capabilities'); 234 $user->for_blog($id); 235 235 $user->set_role($role); 236 236 } -
trunk/wp-includes/capabilities.php
r12778 r12796 756 756 } 757 757 758 /** 759 * Set the blog to operate on. Defaults to the current blog. 760 * 761 * @since 3.0 762 * 763 * @param int $blog_id Optional Blog ID, defaults to current blog. 764 */ 765 function for_blog( $blog_id = '' ) { 766 global $wpdb; 767 if ( !empty($blog_id) ) { 768 $cap_key = $wpdb->get_blog_prefix( $blog_id ); 769 $cap_key. 'capabilities'; 770 } else { 771 $cap_key = ''; 772 } 773 $this->_init_caps($cap_key); 774 } 758 775 } 759 776 … … 1019 1036 1020 1037 /** 1038 * Whether current user has a capability or role for a given blog. 1039 * 1040 * @since 2.0.0 1041 * 1042 * @param int $blog_id Blog ID 1043 * @param string $capability Capability or role name. 1044 * @return bool 1045 */ 1046 function current_user_can_for_blog( $blog_id, $capability ) { 1047 $current_user = wp_get_current_user(); 1048 1049 if ( is_multisite() && is_super_admin() ) 1050 return true; 1051 1052 if ( empty( $current_user ) ) 1053 return false; 1054 1055 // Create new object to avoid stomping the global current_user. 1056 $user = new WP_User( $current_user->id) ; 1057 1058 // Set the blog id. @todo add blog id arg to WP_User constructor? 1059 $user->for_blog( $blog_id ); 1060 1061 $args = array_slice( func_get_args(), 2 ); 1062 $args = array_merge( array( $capability ), $args ); 1063 1064 return call_user_func_array( array( &$user, 'has_cap' ), $args ); 1065 } 1066 1067 /** 1021 1068 * Whether author of supplied post has capability or role. 1022 1069 * -
trunk/wp-includes/ms-functions.php
r12778 r12796 307 307 308 308 if ( is_object( $current_user ) ) 309 $current_user-> _init_caps();309 $current_user->for_blog( $blog_id ); 310 310 311 311 if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) … … 360 360 361 361 if ( is_object( $current_user ) ) 362 $current_user-> _init_caps();362 $current_user->for_blog( $blog_id ); 363 363 364 364 if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
Note: See TracChangeset
for help on using the changeset viewer.