Make WordPress Core

Ticket #20152: user-roles-option.diff

File user-roles-option.diff, 7.0 KB (added by wonderboymusic, 12 years ago)
  • wp-includes/user.php

     
    865865                foreach ( $avail_roles as $this_role => $name ) {
    866866                        $select_count[] = "COUNT(NULLIF(`meta_value` LIKE '%\"" . like_escape( $this_role ) . "\"%', false))";
    867867                }
    868                 $select_count = implode(', ', $select_count);
    869 
     868               
     869                if ( ! empty( $select_count ) )
     870                        $select_count = implode(', ', $select_count) . ',';
     871                else
     872                        $select_count = '';
     873               
    870874                // Add the meta_value index to the selection list, then run the query.
    871                 $row = $wpdb->get_row( "SELECT $select_count, COUNT(*) FROM $wpdb->usermeta WHERE meta_key = '{$blog_prefix}capabilities'", ARRAY_N );
     875                $row = $wpdb->get_row( "SELECT $select_count COUNT(*) FROM $wpdb->usermeta WHERE meta_key = '{$blog_prefix}capabilities'", ARRAY_N );
    872876
    873877                // Run the previous loop again to associate results with role names.
    874878                $col = 0;
  • wp-includes/capabilities.php

     
    6161         * @access public
    6262         * @var string
    6363         */
    64         var $role_key;
     64        var $role_key = 'user_roles';
    6565
    6666        /**
    6767         * Whether to use the database for retrieval and storage.
     
    8484        /**
    8585         * Set up the object properties.
    8686         *
    87          * The role key is set to the current prefix for the $wpdb object with
    88          * 'user_roles' appended. If the $wp_user_roles global is set, then it will
     87         * If the $wp_user_roles global is set, then it will
    8988         * be used and the role option will not be updated or used.
    9089         *
    9190         * @since 2.1.0
     
    9493         * @global array $wp_user_roles Used to set the 'roles' property value.
    9594         */
    9695        function _init () {
    97                 global $wpdb, $wp_user_roles;
    98                 $this->role_key = $wpdb->prefix . 'user_roles';
     96                global $wp_user_roles;
     97
    9998                if ( ! empty( $wp_user_roles ) ) {
    10099                        $this->roles = $wp_user_roles;
    101100                        $this->use_db = false;
     
    128127                if ( ! $this->use_db )
    129128                        return;
    130129
    131                 global $wpdb, $wp_user_roles;
    132 
    133130                // Duplicated from _init() to avoid an extra function call.
    134                 $this->role_key = $wpdb->prefix . 'user_roles';
    135131                $this->roles = get_option( $this->role_key );
    136132                if ( empty( $this->roles ) )
    137133                        return;
  • wp-admin/includes/schema.php

     
    593593        add_role('subscriber', 'Subscriber');
    594594
    595595        // Add caps for Administrator role
    596         $role =& get_role('administrator');
     596        $role = get_role('administrator');
    597597        $role->add_cap('switch_themes');
    598598        $role->add_cap('edit_themes');
    599599        $role->add_cap('activate_plugins');
     
    626626        $role->add_cap('level_0');
    627627
    628628        // Add caps for Editor role
    629         $role =& get_role('editor');
     629        $role = get_role('editor');
    630630        $role->add_cap('moderate_comments');
    631631        $role->add_cap('manage_categories');
    632632        $role->add_cap('manage_links');
     
    648648        $role->add_cap('level_0');
    649649
    650650        // Add caps for Author role
    651         $role =& get_role('author');
     651        $role = get_role('author');
    652652        $role->add_cap('upload_files');
    653653        $role->add_cap('edit_posts');
    654654        $role->add_cap('edit_published_posts');
     
    659659        $role->add_cap('level_0');
    660660
    661661        // Add caps for Contributor role
    662         $role =& get_role('contributor');
     662        $role = get_role('contributor');
    663663        $role->add_cap('edit_posts');
    664664        $role->add_cap('read');
    665665        $role->add_cap('level_1');
    666666        $role->add_cap('level_0');
    667667
    668668        // Add caps for Subscriber role
    669         $role =& get_role('subscriber');
     669        $role = get_role('subscriber');
    670670        $role->add_cap('read');
    671671        $role->add_cap('level_0');
    672672}
     
    679679function populate_roles_210() {
    680680        $roles = array('administrator', 'editor');
    681681        foreach ($roles as $role) {
    682                 $role =& get_role($role);
     682                $role = get_role($role);
    683683                if ( empty($role) )
    684684                        continue;
    685685
     
    700700                $role->add_cap('read_private_pages');
    701701        }
    702702
    703         $role =& get_role('administrator');
     703        $role = get_role('administrator');
    704704        if ( ! empty($role) ) {
    705705                $role->add_cap('delete_users');
    706706                $role->add_cap('create_users');
    707707        }
    708708
    709         $role =& get_role('author');
     709        $role = get_role('author');
    710710        if ( ! empty($role) ) {
    711711                $role->add_cap('delete_posts');
    712712                $role->add_cap('delete_published_posts');
    713713        }
    714714
    715         $role =& get_role('contributor');
     715        $role = get_role('contributor');
    716716        if ( ! empty($role) ) {
    717717                $role->add_cap('delete_posts');
    718718        }
     
    724724 * @since 2.3.0
    725725 */
    726726function populate_roles_230() {
    727         $role =& get_role( 'administrator' );
     727        $role = get_role( 'administrator' );
    728728
    729729        if ( !empty( $role ) ) {
    730730                $role->add_cap( 'unfiltered_upload' );
     
    737737 * @since 2.5.0
    738738 */
    739739function populate_roles_250() {
    740         $role =& get_role( 'administrator' );
     740        $role = get_role( 'administrator' );
    741741
    742742        if ( !empty( $role ) ) {
    743743                $role->add_cap( 'edit_dashboard' );
     
    750750 * @since 2.6.0
    751751 */
    752752function populate_roles_260() {
    753         $role =& get_role( 'administrator' );
     753        $role = get_role( 'administrator' );
    754754
    755755        if ( !empty( $role ) ) {
    756756                $role->add_cap( 'update_plugins' );
     
    764764 * @since 2.7.0
    765765 */
    766766function populate_roles_270() {
    767         $role =& get_role( 'administrator' );
     767        $role = get_role( 'administrator' );
    768768
    769769        if ( !empty( $role ) ) {
    770770                $role->add_cap( 'install_plugins' );
     
    778778 * @since 2.8.0
    779779 */
    780780function populate_roles_280() {
    781         $role =& get_role( 'administrator' );
     781        $role = get_role( 'administrator' );
    782782
    783783        if ( !empty( $role ) ) {
    784784                $role->add_cap( 'install_themes' );
     
    791791 * @since 3.0.0
    792792 */
    793793function populate_roles_300() {
    794         $role =& get_role( 'administrator' );
     794        $role = get_role( 'administrator' );
    795795
    796796        if ( !empty( $role ) ) {
    797797                $role->add_cap( 'update_core' );
  • wp-admin/includes/template.php

     
    759759
    760760        $editable_roles = get_editable_roles();
    761761
     762        if ( empty( $editable_roles ) )
     763                return;
     764               
    762765        foreach ( $editable_roles as $role => $details ) {
    763766                $name = translate_user_role($details['name'] );
    764767                if ( $selected == $role ) // preselect specified role
  • wp-admin/network/site-settings.php

     
    113113        <table class="form-table">
    114114                <?php
    115115                $blog_prefix = $wpdb->get_blog_prefix( $id );
    116                 $options = $wpdb->get_results( "SELECT * FROM {$blog_prefix}options WHERE option_name NOT LIKE '\_%' AND option_name NOT LIKE '%user_roles'" );
     116                $options = $wpdb->get_results( "SELECT * FROM {$blog_prefix}options WHERE option_name NOT LIKE '\_%' AND option_name != 'user_roles'" );
    117117                foreach ( $options as $option ) {
    118118                        if ( $option->option_name == 'default_role' )
    119119                                $editblog_default_role = $option->option_value;