Make WordPress Core

Changeset 13419


Ignore:
Timestamp:
02/25/2010 10:11:54 PM (15 years ago)
Author:
wpmuguru
Message:

move super admin list maintenance from ms-options to ms-users, See #11644

Location:
trunk/wp-admin
Files:
3 edited

Legend:

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

    r13379 r13419  
    115115        }
    116116
    117         $site_admins = explode( ' ', str_replace( ",", " ", $_POST['site_admins'] ) );
    118         if ( is_array( $site_admins ) ) {
    119             $mainblog_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->blogs} WHERE domain='{$current_site->domain}' AND path='{$current_site->path}'" );
    120             if ( $mainblog_id ) {
    121                 reset( $site_admins );
    122                 foreach ( (array) $site_admins as $site_admin ) {
    123                     $uid = get_user_by('login', $site_admin);
    124                     if ( $uid )
    125                         add_user_to_blog( $mainblog_id, $uid->ID, 'administrator' );
    126                 }
    127             }
    128             update_site_option( 'site_admins' , $site_admins );
    129         }
    130 
    131117        // Update more options here
    132118        do_action( 'update_wpmu_options' );
     
    493479
    494480            wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'all_delete'), 'ms-users.php' ) );
     481        } elseif ( isset( $_POST[ 'add_superadmin' ] ) ) {
     482            $super_admins = get_site_option( 'site_admins', array( 'admin' ) );
     483            $mainblog_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->blogs} WHERE domain='{$current_site->domain}' AND path='{$current_site->path}'" );
     484            foreach ( (array) $_POST['allusers'] as $key => $val ) {
     485                if ( $val == '' || $val == '0' )
     486                    continue;
     487                $user = new WP_User( $val );
     488                if ( in_array( $user->user_login, $super_admins ) )
     489                    continue;
     490                if ( $mainblog_id )
     491                    add_user_to_blog( $mainblog_id, $user->ID, 'administrator' );
     492                $super_admins[] = $user->user_login;
     493            }
     494            update_site_option( 'site_admins' , $super_admins );
     495
     496            wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'add_superadmin' ), $_SERVER['HTTP_REFERER'] ) );
     497        } elseif ( isset( $_POST[ 'remove_superadmin' ] ) ) {
     498            $super_admins = get_site_option( 'site_admins', array( 'admin' ) );
     499            foreach ( (array) $_POST['allusers'] as $key => $val ) {
     500                if ( $val == '' || $val == '0' )
     501                    continue;
     502                $user = new WP_User( $val );
     503                foreach ( $super_admins as $key => $username ) {
     504                    if ( $username == $user->user_login ) {
     505                        unset( $super_admins[ $key ] );
     506                        break;
     507                    }
     508                }
     509            }
     510            update_site_option( 'site_admins' , $super_admins );
     511
     512            wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'remove_superadmin' ), $_SERVER['HTTP_REFERER'] ) );
    495513        } else {
    496514            foreach ( (array) $_POST['allusers'] as $key => $val ) {
  • trunk/wp-admin/ms-options.php

    r13380 r13419  
    235235                <?php if ( get_site_option( 'admin_notice_feed' ) != 'http://' . $current_site->domain . $current_site->path . 'feed/' )
    236236                    echo __( "A good one to use would be the feed from your main site: " ) . 'http://' . $current_site->domain . $current_site->path . 'feed/'; ?></td>
    237             </tr>
    238         </table>
    239 
    240         <h3><?php _e('Administration Settings') ?></h3>
    241         <table class="form-table">
    242             <tr valign="top">
    243                 <th scope="row"><?php _e('Network Admins') ?></th>
    244                 <td>
    245                     <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" />
    246                     <br />
    247                     <?php _e('These users may login to the main site and administer the network. Space separated list of usernames.') ?>
    248                 </td>
    249237            </tr>
    250238        </table>
  • trunk/wp-admin/ms-users.php

    r13379 r13419  
    3434            case 'add':
    3535                _e('User added !');
     36            break;
     37            case 'add_superadmin':
     38                _e('Super admin added !');
     39            break;
     40            case 'remove_superadmin':
     41                _e('Super admin removed !');
    3642            break;
    3743        }
     
    120126                <input type="submit" value="<?php esc_attr_e('Mark as Spammers') ?>" name="alluser_spam" class="button-secondary" />
    121127                <input type="submit" value="<?php esc_attr_e('Not Spam') ?>" name="alluser_notspam" class="button-secondary" />
     128                <input type="submit" value="<?php esc_attr_e('Add to Super Admin list') ?>" name="add_superadmin" class="button-secondary" />
     129                <input type="submit" value="<?php esc_attr_e('Remove from Super Admin list') ?>" name="remove_superadmin" class="button-secondary" />
    122130                <?php wp_nonce_field( 'allusers' ); ?>
    123131                <br class="clear" />
     
    158166            <?php if ($user_list) {
    159167                $class = '';
     168                $super_admins = get_site_option( 'site_admins' );
    160169                foreach ( (array) $user_list as $user) {
    161170                    $class = ('alternate' == $class) ? '' : 'alternate';
     
    186195                                ?>
    187196                                <td class="username column-username">
    188                                     <?php echo $avatar; ?><strong><a href="<?php echo $edit; ?>" class="edit"><?php echo stripslashes($user['user_login']); ?></a></strong>
     197                                    <?php echo $avatar; ?><strong><a href="<?php echo $edit; ?>" class="edit"><?php echo stripslashes($user['user_login']); ?></a><?php
     198                                if ( in_array( $user[ 'user_login' ], $super_admins ) )
     199                                    echo ' - ' . __( 'Super admin' );
     200?></strong>
    189201                                    <br/>
    190202                                    <div class="row-actions">
Note: See TracChangeset for help on using the changeset viewer.