WordPress.org

Make WordPress Core

Changeset 14206


Ignore:
Timestamp:
04/23/2010 08:34:03 PM (11 years ago)
Author:
ryan
Message:

Introduce get_super_admins(). Allow hard-coding a global super_admins array and bypassing site options. fixes #12815

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/ms.php

    r14177 r14206  
    188188    <?php
    189189    wp_nonce_field( 'ms-users-delete' );
    190     $site_admins = get_site_option( 'site_admins', array( 'admin' ) );
     190    $site_admins = get_super_admins();
    191191    $admin_out = "<option value='$current_user->ID'>$current_user->user_login</option>";
    192192
     
    812812 */
    813813function grant_super_admin( $user_id ) {
     814    global $super_admins;
     815
     816    // If global super_admins override is defined, there is nothing to do here.
     817    if ( isset($super_admins) )
     818        return false;
     819
    814820    do_action( 'grant_super_admin', $user_id );
    815821
     822    // Directly fetch site_admins instead of using get_super_admins()
    816823    $super_admins = get_site_option( 'site_admins', array( 'admin' ) );
    817824
     
    833840 */
    834841function revoke_super_admin( $user_id ) {
     842    global $super_admins;
     843
     844    // If global super_admins override is defined, there is nothing to do here.
     845    if ( isset($super_admins) )
     846        return false;
     847
    835848    do_action( 'revoke_super_admin', $user_id );
    836849
     850    // Directly fetch site_admins instead of using get_super_admins()
    837851    $super_admins = get_site_option( 'site_admins', array( 'admin' ) );
     852
    838853    $user = new WP_User( $user_id );
    839854    if ( $user->user_email != get_site_option( 'admin_email' ) ) {
  • trunk/wp-admin/ms-edit.php

    r14102 r14206  
    532532                        case 'spam':
    533533                            $user = new WP_User( $val );
    534                             if ( in_array( $user->user_login, get_site_option( 'site_admins', array( 'admin' ) ) ) )
     534                            if ( in_array( $user->user_login, get_super_admins() ) )
    535535                                wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network admnistrator.' ), esc_html( $user->user_login ) ) );
    536536
  • trunk/wp-admin/ms-users.php

    r14188 r14206  
    200200            <?php if ( $user_list ) {
    201201                $class = '';
    202                 $super_admins = get_site_option( 'site_admins' );
     202                $super_admins = get_super_admins();
    203203                foreach ( (array) $user_list as $user ) {
    204204                    $class = ( 'alternate' == $class ) ? '' : 'alternate';
  • trunk/wp-admin/user-edit.php

    r14171 r14206  
    122122        delete_user_meta( $user_id, $blog_prefix . 'capabilities' );
    123123
    124     if ( is_multisite() && !IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && empty( $_POST['super_admin'] ) == is_super_admin( $user_id ) )
     124    if ( is_multisite() && !IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) && empty( $_POST['super_admin'] ) == is_super_admin( $user_id ) )
    125125        empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id );
    126126}
     
    236236?>
    237237</select>
    238 <?php if ( is_multisite() && current_user_can( 'manage_network_options' ) ) { ?>
     238<?php if ( is_multisite() && current_user_can( 'manage_network_options' ) && !isset($super_admins) ) { ?>
    239239<p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profileuser->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.'); ?></label></p>
    240240<?php } ?>
  • trunk/wp-includes/capabilities.php

    r14189 r14206  
    11721172
    11731173/**
     1174 * Retrieve a list of super admins.
     1175 *
     1176 * @since 3.0.0
     1177 *
     1178 * @uses $super_admins Super admins global variable, if set.
     1179 *
     1180 * @return array List of super admin logins
     1181 */
     1182function get_super_admins() {
     1183    global $super_admins;
     1184
     1185    if ( isset($super_admins) )
     1186        return $super_admins;
     1187    else
     1188        return get_site_option( 'site_admins', array('admin') );
     1189}
     1190
     1191/**
    11741192 * Determine if user is a site admin.
    11751193 *
     
    11911209
    11921210    if ( is_multisite() ) {
    1193         $site_admins = get_site_option( 'site_admins', array('admin') );
    1194         if ( is_array( $site_admins ) && in_array( $user->user_login, $site_admins ) )
     1211        $super_admins = get_super_admins();
     1212        if ( is_array( $super_admins ) && in_array( $user->user_login, $super_admins ) )
    11951213            return true;
    11961214    } else {
Note: See TracChangeset for help on using the changeset viewer.