Make WordPress Core

Changeset 4113


Ignore:
Timestamp:
08/24/2006 11:23:36 PM (20 years ago)
Author:
ryan
Message:

Allow use of global roles array instead of options db. Useful for multi-blog setups.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/capabilities.php

    r3859 r4113  
    77        var $role_names = array();
    88        var $role_key;
     9        var $use_db = true;
    910
    1011        function WP_Roles() {
    … …  
    1415        function _init () {
    1516                global $wpdb;
     17                global $wp_user_roles;
    1618                $this->role_key = $wpdb->prefix . 'user_roles';
    17 
    18                 $this->roles = get_option($this->role_key);
     19                if ( ! empty($wp_user_roles) ) {
     20                        $this->roles = $wp_user_roles;
     21                        $this->use_db = false;
     22                } else {
     23                        $this->roles = get_option($this->role_key);
     24                }
    1925
    2026                if ( empty($this->roles) )
    … …  
    3642                        'name' => $display_name,
    3743                        'capabilities' => $capabilities);
    38                 update_option($this->role_key, $this->roles);
     44                if ( $this->use_db )
     45                        update_option($this->role_key, $this->roles);
    3946                $this->role_objects[$role] = new WP_Role($role, $capabilities);
    4047                $this->role_names[$role] = $display_name;
    … …  
    4956                unset($this->role_names[$role]);
    5057                unset($this->roles[$role]);
    51 
    52                 update_option($this->role_key, $this->roles);
     58               
     59                if ( $this->use_db )
     60                        update_option($this->role_key, $this->roles);
    5361        }
    5462
    5563        function add_cap($role, $cap, $grant = true) {
    5664                $this->roles[$role]['capabilities'][$cap] = $grant;
    57                 update_option($this->role_key, $this->roles);
     65                if ( $this->use_db )
     66                        update_option($this->role_key, $this->roles);
    5867        }
    5968
    6069        function remove_cap($role, $cap) {
    6170                unset($this->roles[$role]['capabilities'][$cap]);
    62                 update_option($this->role_key, $this->roles);
     71                if ( $this->use_db )
     72                        update_option($this->role_key, $this->roles);
    6373        }
    6474
Note: See TracChangeset for help on using the changeset viewer.