Ticket #20152: user-roles-option.diff
File user-roles-option.diff, 7.0 KB (added by , 12 years ago) |
---|
-
wp-includes/user.php
865 865 foreach ( $avail_roles as $this_role => $name ) { 866 866 $select_count[] = "COUNT(NULLIF(`meta_value` LIKE '%\"" . like_escape( $this_role ) . "\"%', false))"; 867 867 } 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 870 874 // 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 ); 872 876 873 877 // Run the previous loop again to associate results with role names. 874 878 $col = 0; -
wp-includes/capabilities.php
61 61 * @access public 62 62 * @var string 63 63 */ 64 var $role_key ;64 var $role_key = 'user_roles'; 65 65 66 66 /** 67 67 * Whether to use the database for retrieval and storage. … … 84 84 /** 85 85 * Set up the object properties. 86 86 * 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 89 88 * be used and the role option will not be updated or used. 90 89 * 91 90 * @since 2.1.0 … … 94 93 * @global array $wp_user_roles Used to set the 'roles' property value. 95 94 */ 96 95 function _init () { 97 global $wp db, $wp_user_roles;98 $this->role_key = $wpdb->prefix . 'user_roles'; 96 global $wp_user_roles; 97 99 98 if ( ! empty( $wp_user_roles ) ) { 100 99 $this->roles = $wp_user_roles; 101 100 $this->use_db = false; … … 128 127 if ( ! $this->use_db ) 129 128 return; 130 129 131 global $wpdb, $wp_user_roles;132 133 130 // Duplicated from _init() to avoid an extra function call. 134 $this->role_key = $wpdb->prefix . 'user_roles';135 131 $this->roles = get_option( $this->role_key ); 136 132 if ( empty( $this->roles ) ) 137 133 return; -
wp-admin/includes/schema.php
593 593 add_role('subscriber', 'Subscriber'); 594 594 595 595 // Add caps for Administrator role 596 $role = &get_role('administrator');596 $role = get_role('administrator'); 597 597 $role->add_cap('switch_themes'); 598 598 $role->add_cap('edit_themes'); 599 599 $role->add_cap('activate_plugins'); … … 626 626 $role->add_cap('level_0'); 627 627 628 628 // Add caps for Editor role 629 $role = &get_role('editor');629 $role = get_role('editor'); 630 630 $role->add_cap('moderate_comments'); 631 631 $role->add_cap('manage_categories'); 632 632 $role->add_cap('manage_links'); … … 648 648 $role->add_cap('level_0'); 649 649 650 650 // Add caps for Author role 651 $role = &get_role('author');651 $role = get_role('author'); 652 652 $role->add_cap('upload_files'); 653 653 $role->add_cap('edit_posts'); 654 654 $role->add_cap('edit_published_posts'); … … 659 659 $role->add_cap('level_0'); 660 660 661 661 // Add caps for Contributor role 662 $role = &get_role('contributor');662 $role = get_role('contributor'); 663 663 $role->add_cap('edit_posts'); 664 664 $role->add_cap('read'); 665 665 $role->add_cap('level_1'); 666 666 $role->add_cap('level_0'); 667 667 668 668 // Add caps for Subscriber role 669 $role = &get_role('subscriber');669 $role = get_role('subscriber'); 670 670 $role->add_cap('read'); 671 671 $role->add_cap('level_0'); 672 672 } … … 679 679 function populate_roles_210() { 680 680 $roles = array('administrator', 'editor'); 681 681 foreach ($roles as $role) { 682 $role = &get_role($role);682 $role = get_role($role); 683 683 if ( empty($role) ) 684 684 continue; 685 685 … … 700 700 $role->add_cap('read_private_pages'); 701 701 } 702 702 703 $role = &get_role('administrator');703 $role = get_role('administrator'); 704 704 if ( ! empty($role) ) { 705 705 $role->add_cap('delete_users'); 706 706 $role->add_cap('create_users'); 707 707 } 708 708 709 $role = &get_role('author');709 $role = get_role('author'); 710 710 if ( ! empty($role) ) { 711 711 $role->add_cap('delete_posts'); 712 712 $role->add_cap('delete_published_posts'); 713 713 } 714 714 715 $role = &get_role('contributor');715 $role = get_role('contributor'); 716 716 if ( ! empty($role) ) { 717 717 $role->add_cap('delete_posts'); 718 718 } … … 724 724 * @since 2.3.0 725 725 */ 726 726 function populate_roles_230() { 727 $role = &get_role( 'administrator' );727 $role = get_role( 'administrator' ); 728 728 729 729 if ( !empty( $role ) ) { 730 730 $role->add_cap( 'unfiltered_upload' ); … … 737 737 * @since 2.5.0 738 738 */ 739 739 function populate_roles_250() { 740 $role = &get_role( 'administrator' );740 $role = get_role( 'administrator' ); 741 741 742 742 if ( !empty( $role ) ) { 743 743 $role->add_cap( 'edit_dashboard' ); … … 750 750 * @since 2.6.0 751 751 */ 752 752 function populate_roles_260() { 753 $role = &get_role( 'administrator' );753 $role = get_role( 'administrator' ); 754 754 755 755 if ( !empty( $role ) ) { 756 756 $role->add_cap( 'update_plugins' ); … … 764 764 * @since 2.7.0 765 765 */ 766 766 function populate_roles_270() { 767 $role = &get_role( 'administrator' );767 $role = get_role( 'administrator' ); 768 768 769 769 if ( !empty( $role ) ) { 770 770 $role->add_cap( 'install_plugins' ); … … 778 778 * @since 2.8.0 779 779 */ 780 780 function populate_roles_280() { 781 $role = &get_role( 'administrator' );781 $role = get_role( 'administrator' ); 782 782 783 783 if ( !empty( $role ) ) { 784 784 $role->add_cap( 'install_themes' ); … … 791 791 * @since 3.0.0 792 792 */ 793 793 function populate_roles_300() { 794 $role = &get_role( 'administrator' );794 $role = get_role( 'administrator' ); 795 795 796 796 if ( !empty( $role ) ) { 797 797 $role->add_cap( 'update_core' ); -
wp-admin/includes/template.php
759 759 760 760 $editable_roles = get_editable_roles(); 761 761 762 if ( empty( $editable_roles ) ) 763 return; 764 762 765 foreach ( $editable_roles as $role => $details ) { 763 766 $name = translate_user_role($details['name'] ); 764 767 if ( $selected == $role ) // preselect specified role -
wp-admin/network/site-settings.php
113 113 <table class="form-table"> 114 114 <?php 115 115 $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'" ); 117 117 foreach ( $options as $option ) { 118 118 if ( $option->option_name == 'default_role' ) 119 119 $editblog_default_role = $option->option_value;