<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[13419] trunk/wp-admin:
move super admin list maintenance from ms-options to ms-users, See #11644</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13419">13419</a></dd>
<dt>Author</dt> <dd>wpmuguru</dd>
<dt>Date</dt> <dd>2010-02-25 22:11:54 +0000 (Thu, 25 Feb 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>move super admin list maintenance from ms-options to ms-users, See <a href="http://trac.wordpress.org/ticket/11644">#11644</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminmseditphp">trunk/wp-admin/ms-edit.php</a></li>
<li><a href="#trunkwpadminmsoptionsphp">trunk/wp-admin/ms-options.php</a></li>
<li><a href="#trunkwpadminmsusersphp">trunk/wp-admin/ms-users.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminmseditphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/ms-edit.php (13418 => 13419)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/ms-edit.php        2010-02-25 22:06:10 UTC (rev 13418)
+++ trunk/wp-admin/ms-edit.php        2010-02-25 22:11:54 UTC (rev 13419)
</span><span class="lines">@@ -114,20 +114,6 @@
</span><span class="cx">                         update_site_option( $option_name, $value );
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                $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 );
-                }
-
</del><span class="cx">                 // Update more options here
</span><span class="cx">                 do_action( 'update_wpmu_options' );
</span><span class="cx">
</span><span class="lines">@@ -492,6 +478,38 @@
</span><span class="cx">                                         wpmu_delete_user( $id );
</span><span class="cx">
</span><span class="cx">                         wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'all_delete'), 'ms-users.php' ) );
</span><ins>+                } 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'] ) );
</ins><span class="cx">                 } else {
</span><span class="cx">                         foreach ( (array) $_POST['allusers'] as $key => $val ) {
</span><span class="cx">                                 if ( $val == '' || $val == '0' )
</span></span></pre></div>
<a id="trunkwpadminmsoptionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/ms-options.php (13418 => 13419)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/ms-options.php        2010-02-25 22:06:10 UTC (rev 13418)
+++ trunk/wp-admin/ms-options.php        2010-02-25 22:11:54 UTC (rev 13419)
</span><span class="lines">@@ -237,18 +237,6 @@
</span><span class="cx">                         </tr>
</span><span class="cx">                 </table>
</span><span class="cx">
</span><del>-                <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>
-
</del><span class="cx">                 <h3><?php _e('Network Wide Settings <em>(These settings may be overridden by site owners)</em>') ?></h3>
</span><span class="cx">                 <table class="form-table">
</span><span class="cx">                         <?php
</span></span></pre></div>
<a id="trunkwpadminmsusersphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/ms-users.php (13418 => 13419)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/ms-users.php        2010-02-25 22:06:10 UTC (rev 13418)
+++ trunk/wp-admin/ms-users.php        2010-02-25 22:11:54 UTC (rev 13419)
</span><span class="lines">@@ -34,6 +34,12 @@
</span><span class="cx">                         case 'add':
</span><span class="cx">                                 _e('User added !');
</span><span class="cx">                         break;
</span><ins>+                        case 'add_superadmin':
+                                _e('Super admin added !');
+                        break;
+                        case 'remove_superadmin':
+                                _e('Super admin removed !');
+                        break;
</ins><span class="cx">                 }
</span><span class="cx">                 ?>
</span><span class="cx">         </p></div>
</span><span class="lines">@@ -119,6 +125,8 @@
</span><span class="cx">                                 <input type="submit" value="<?php esc_attr_e('Delete') ?>" name="alluser_delete" class="button-secondary delete" />
</span><span class="cx">                                 <input type="submit" value="<?php esc_attr_e('Mark as Spammers') ?>" name="alluser_spam" class="button-secondary" />
</span><span class="cx">                                 <input type="submit" value="<?php esc_attr_e('Not Spam') ?>" name="alluser_notspam" class="button-secondary" />
</span><ins>+                                <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" />
</ins><span class="cx">                                 <?php wp_nonce_field( 'allusers' ); ?>
</span><span class="cx">                                 <br class="clear" />
</span><span class="cx">                         </div>
</span><span class="lines">@@ -157,6 +165,7 @@
</span><span class="cx">                         <tbody id="users" class="list:user user-list">
</span><span class="cx">                         <?php if ($user_list) {
</span><span class="cx">                                 $class = '';
</span><ins>+                                $super_admins = get_site_option( 'site_admins' );
</ins><span class="cx">                                 foreach ( (array) $user_list as $user) {
</span><span class="cx">                                         $class = ('alternate' == $class) ? '' : 'alternate';
</span><span class="cx">
</span><span class="lines">@@ -185,7 +194,10 @@
</span><span class="cx">                                                                 //$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'] ) );
</span><span class="cx">                                                                 ?>
</span><span class="cx">                                                                 <td class="username column-username">
</span><del>-                                                                        <?php echo $avatar; ?><strong><a href="<?php echo $edit; ?>" class="edit"><?php echo stripslashes($user['user_login']); ?></a></strong>
</del><ins>+                                                                        <?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>
</ins><span class="cx">                                                                         <br/>
</span><span class="cx">                                                                         <div class="row-actions">
</span><span class="cx">                                                                                 <span class="edit"><a href="<?php echo $edit; ?>">Edit</a></span>
</span></span></pre>
</div>
</div>
</body>
</html>