diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-08-31 14:55:29 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-08-31 14:55:29 +0000 |
commit | b764f60728be1d4e026f9d7ae618ab47e23322f8 (patch) | |
tree | 1f1b45c4f1c1cf027b3240f605346e56209be8ff /wp-includes/capabilities.php | |
parent | dad010666b767a1d06588d1d09c771c62f67c387 (diff) | |
download | wordpress-mu-b764f60728be1d4e026f9d7ae618ab47e23322f8.tar.gz wordpress-mu-b764f60728be1d4e026f9d7ae618ab47e23322f8.tar.xz wordpress-mu-b764f60728be1d4e026f9d7ae618ab47e23322f8.zip |
WP Merge to rev #4147
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@729 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/capabilities.php')
-rw-r--r-- | wp-includes/capabilities.php | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index 3e85e4f..b2d2662 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -6,6 +6,7 @@ class WP_Roles { var $role_objects = array(); var $role_names = array(); var $role_key; + var $use_db = true; function WP_Roles() { $this->_init(); @@ -13,9 +14,14 @@ class WP_Roles { function _init () { global $wpdb; + global $wp_user_roles; $this->role_key = $wpdb->prefix . 'user_roles'; - - $this->roles = get_option($this->role_key); + if ( ! empty($wp_user_roles) ) { + $this->roles = $wp_user_roles; + $this->use_db = false; + } else { + $this->roles = get_option($this->role_key); + } if ( empty($this->roles) ) return; @@ -35,7 +41,8 @@ class WP_Roles { $this->roles[$role] = array( 'name' => $display_name, 'capabilities' => $capabilities); - update_option($this->role_key, $this->roles); + if ( $this->use_db ) + update_option($this->role_key, $this->roles); $this->role_objects[$role] = new WP_Role($role, $capabilities); $this->role_names[$role] = $display_name; return $this->role_objects[$role]; @@ -48,18 +55,21 @@ class WP_Roles { unset($this->role_objects[$role]); unset($this->role_names[$role]); unset($this->roles[$role]); - - update_option($this->role_key, $this->roles); + + if ( $this->use_db ) + update_option($this->role_key, $this->roles); } function add_cap($role, $cap, $grant = true) { $this->roles[$role]['capabilities'][$cap] = $grant; - update_option($this->role_key, $this->roles); + if ( $this->use_db ) + update_option($this->role_key, $this->roles); } function remove_cap($role, $cap) { unset($this->roles[$role]['capabilities'][$cap]); - update_option($this->role_key, $this->roles); + if ( $this->use_db ) + update_option($this->role_key, $this->roles); } function &get_role($role) { |