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
This commit is contained in:
wpmuguru 2010-02-25 22:11:54 +00:00
parent 3e4ce6e9a3
commit e667fb14e0
3 changed files with 45 additions and 27 deletions

View File

@ -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' )

View File

@ -237,18 +237,6 @@ if (isset($_GET['updated'])) {
</tr>
</table>
<h3><?php _e('Administration Settings') ?></h3>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Network Admins') ?></th>
<td>
<input name="site_admins" type="text" id="site_admins" style="width: 95%" value="<?php echo esc_attr( implode(' ', get_site_option( 'site_admins', array( 'admin' ) ) ) ) ?>" size="45" />
<br />
<?php _e('These users may login to the main site and administer the network. Space separated list of usernames.') ?>
</td>
</tr>
</table>
<h3><?php _e('Network Wide Settings <em>(These settings may be overridden by site owners)</em>') ?></h3>
<table class="form-table">
<?php

View File

@ -34,6 +34,12 @@ if ( isset($_GET['updated']) && $_GET['updated'] == 'true' ) {
case 'add':
_e('User added !');
break;
case 'add_superadmin':
_e('Super admin added !');
break;
case 'remove_superadmin':
_e('Super admin removed !');
break;
}
?>
</p></div>
@ -119,6 +125,8 @@ if ( isset($_GET['updated']) && $_GET['updated'] == 'true' ) {
<input type="submit" value="<?php esc_attr_e('Delete') ?>" name="alluser_delete" class="button-secondary delete" />
<input type="submit" value="<?php esc_attr_e('Mark as Spammers') ?>" name="alluser_spam" class="button-secondary" />
<input type="submit" value="<?php esc_attr_e('Not Spam') ?>" name="alluser_notspam" class="button-secondary" />
<input type="submit" value="<?php esc_attr_e('Add to Super Admin list') ?>" name="add_superadmin" class="button-secondary" />
<input type="submit" value="<?php esc_attr_e('Remove from Super Admin list') ?>" name="remove_superadmin" class="button-secondary" />
<?php wp_nonce_field( 'allusers' ); ?>
<br class="clear" />
</div>
@ -157,6 +165,7 @@ if ( isset($_GET['updated']) && $_GET['updated'] == 'true' ) {
<tbody id="users" class="list:user user-list">
<?php if ($user_list) {
$class = '';
$super_admins = get_site_option( 'site_admins' );
foreach ( (array) $user_list as $user) {
$class = ('alternate' == $class) ? '' : 'alternate';
@ -185,7 +194,10 @@ if ( isset($_GET['updated']) && $_GET['updated'] == 'true' ) {
//$delete = esc_url( add_query_arg( 'wp_http_referer', urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), wp_nonce_url( 'ms-edit.php', 'deleteuser' ) . '&amp;action=deleteuser&amp;id=' . $user['ID'] ) );
?>
<td class="username column-username">
<?php echo $avatar; ?><strong><a href="<?php echo $edit; ?>" class="edit"><?php echo stripslashes($user['user_login']); ?></a></strong>
<?php echo $avatar; ?><strong><a href="<?php echo $edit; ?>" class="edit"><?php echo stripslashes($user['user_login']); ?></a><?php
if ( in_array( $user[ 'user_login' ], $super_admins ) )
echo ' - ' . __( 'Super admin' );
?></strong>
<br/>
<div class="row-actions">
<span class="edit"><a href="<?php echo $edit; ?>">Edit</a></span>