From e667fb14e0f746ab4907760f4090cd5299bd7036 Mon Sep 17 00:00:00 2001 From: wpmuguru Date: Thu, 25 Feb 2010 22:11:54 +0000 Subject: [PATCH] move super admin list maintenance from ms-options to ms-users, See #11644 git-svn-id: http://svn.automattic.com/wordpress/trunk@13419 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/ms-edit.php | 46 ++++++++++++++++++++++++++++------------- wp-admin/ms-options.php | 12 ----------- wp-admin/ms-users.php | 14 ++++++++++++- 3 files changed, 45 insertions(+), 27 deletions(-) diff --git a/wp-admin/ms-edit.php b/wp-admin/ms-edit.php index 8a5a9a159e..0cbdb67f74 100644 --- a/wp-admin/ms-edit.php +++ b/wp-admin/ms-edit.php @@ -114,20 +114,6 @@ switch ( $_GET['action'] ) { update_site_option( $option_name, $value ); } - $site_admins = explode( ' ', str_replace( ",", " ", $_POST['site_admins'] ) ); - if ( is_array( $site_admins ) ) { - $mainblog_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->blogs} WHERE domain='{$current_site->domain}' AND path='{$current_site->path}'" ); - if ( $mainblog_id ) { - reset( $site_admins ); - foreach ( (array) $site_admins as $site_admin ) { - $uid = get_user_by('login', $site_admin); - if ( $uid ) - add_user_to_blog( $mainblog_id, $uid->ID, 'administrator' ); - } - } - update_site_option( 'site_admins' , $site_admins ); - } - // Update more options here do_action( 'update_wpmu_options' ); @@ -492,6 +478,38 @@ switch ( $_GET['action'] ) { wpmu_delete_user( $id ); wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'all_delete'), 'ms-users.php' ) ); + } elseif ( isset( $_POST[ 'add_superadmin' ] ) ) { + $super_admins = get_site_option( 'site_admins', array( 'admin' ) ); + $mainblog_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->blogs} WHERE domain='{$current_site->domain}' AND path='{$current_site->path}'" ); + foreach ( (array) $_POST['allusers'] as $key => $val ) { + if ( $val == '' || $val == '0' ) + continue; + $user = new WP_User( $val ); + if ( in_array( $user->user_login, $super_admins ) ) + continue; + if ( $mainblog_id ) + add_user_to_blog( $mainblog_id, $user->ID, 'administrator' ); + $super_admins[] = $user->user_login; + } + update_site_option( 'site_admins' , $super_admins ); + + wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'add_superadmin' ), $_SERVER['HTTP_REFERER'] ) ); + } elseif ( isset( $_POST[ 'remove_superadmin' ] ) ) { + $super_admins = get_site_option( 'site_admins', array( 'admin' ) ); + foreach ( (array) $_POST['allusers'] as $key => $val ) { + if ( $val == '' || $val == '0' ) + continue; + $user = new WP_User( $val ); + foreach ( $super_admins as $key => $username ) { + if ( $username == $user->user_login ) { + unset( $super_admins[ $key ] ); + break; + } + } + } + update_site_option( 'site_admins' , $super_admins ); + + wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'remove_superadmin' ), $_SERVER['HTTP_REFERER'] ) ); } else { foreach ( (array) $_POST['allusers'] as $key => $val ) { if ( $val == '' || $val == '0' ) diff --git a/wp-admin/ms-options.php b/wp-admin/ms-options.php index f95206058a..7e17e6111f 100644 --- a/wp-admin/ms-options.php +++ b/wp-admin/ms-options.php @@ -237,18 +237,6 @@ if (isset($_GET['updated'])) { -

- - - - - -
- -
- -
-

(These settings may be overridden by site owners)') ?>

@@ -119,6 +125,8 @@ if ( isset($_GET['updated']) && $_GET['updated'] == 'true' ) { + +
@@ -157,6 +165,7 @@ if ( isset($_GET['updated']) && $_GET['updated'] == 'true' ) {
- +