From bf77b5c189c8a4fa1921403b962b3dc292966dd3 Mon Sep 17 00:00:00 2001 From: nacin Date: Fri, 9 Apr 2010 08:26:16 +0000 Subject: [PATCH] More grant/revoke super admin improvements. fixes #12933. git-svn-id: http://svn.automattic.com/wordpress/trunk@14043 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/ms.php | 19 +++++++++---------- wp-admin/user-edit.php | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/wp-admin/includes/ms.php b/wp-admin/includes/ms.php index 32ccc45e54..26a4b3a015 100644 --- a/wp-admin/includes/ms.php +++ b/wp-admin/includes/ms.php @@ -818,7 +818,9 @@ function grant_super_admin( $user_id ) { $super_admins[] = $user->user_login; update_site_option( 'site_admins' , $super_admins ); do_action( 'granted_super_admin', $user_id ); + return true; } + return false; } /** @@ -830,19 +832,16 @@ function grant_super_admin( $user_id ) { function revoke_super_admin( $user_id ) { do_action( 'revoke_super_admin', $user_id ); - $admin_email = get_site_option( 'admin_email' ); $super_admins = get_site_option( 'site_admins', array( 'admin' ) ); - $user = new WP_User( $user_id ); - if ( $user->user_email != $admin_email ) { - foreach ( $super_admins as $key => $username ) { - if ( $username == $user->user_login ) { - unset( $super_admins[$key] ); - update_site_option( 'site_admins' , $super_admins ); - do_action( 'revoked_super_admin', $user_id ); - break; - } + if ( $user->user_email != get_site_option( 'admin_email' ) ) { + if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) { + unset( $super_admins[$key] ); + update_site_option( 'site_admins', $super_admins ); + do_action( 'revoked_super_admin', $user_id ); + return true; } } + return false; } ?> diff --git a/wp-admin/user-edit.php b/wp-admin/user-edit.php index 1c72aaefa4..d0d42c7d86 100644 --- a/wp-admin/user-edit.php +++ b/wp-admin/user-edit.php @@ -121,7 +121,7 @@ if ( !is_multisite() ) { if ( $delete_role ) // stops users being added to current blog when they are edited delete_user_meta( $user_id, $blog_prefix . 'capabilities' ); - if ( is_multisite() && !IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) ) + if ( is_multisite() && !IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && empty( $_POST['super_admin'] ) == is_super_admin( $user_id ) ) empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id ); }