<!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( &quot;,&quot;, &quot; &quot;, $_POST['site_admins'] ) );
-                if ( is_array( $site_admins ) ) {
-                        $mainblog_id = $wpdb-&gt;get_var( &quot;SELECT blog_id FROM {$wpdb-&gt;blogs} WHERE domain='{$current_site-&gt;domain}' AND path='{$current_site-&gt;path}'&quot; );
-                        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-&gt;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' =&gt; 'true', 'action' =&gt; 'all_delete'), 'ms-users.php' ) );
</span><ins>+                } elseif ( isset( $_POST[ 'add_superadmin' ] ) ) {
+                        $super_admins = get_site_option( 'site_admins', array( 'admin' ) );
+                        $mainblog_id = $wpdb-&gt;get_var( &quot;SELECT blog_id FROM {$wpdb-&gt;blogs} WHERE domain='{$current_site-&gt;domain}' AND path='{$current_site-&gt;path}'&quot; );
+                        foreach ( (array) $_POST['allusers'] as $key =&gt; $val ) {
+                                if ( $val == '' || $val == '0' )
+                                        continue;
+                                $user = new WP_User( $val );
+                                if ( in_array( $user-&gt;user_login, $super_admins ) )
+                                        continue;
+                                if ( $mainblog_id )
+                                        add_user_to_blog( $mainblog_id, $user-&gt;ID, 'administrator' );
+                                $super_admins[] = $user-&gt;user_login;
+                        }
+                        update_site_option( 'site_admins' , $super_admins );
+
+                        wp_redirect( add_query_arg( array( 'updated' =&gt; 'true', 'action' =&gt; '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 =&gt; $val ) {
+                                if ( $val == '' || $val == '0' )
+                                        continue;
+                                $user = new WP_User( $val );
+                                foreach ( $super_admins as $key =&gt; $username ) {
+                                        if ( $username == $user-&gt;user_login ) {
+                                                unset( $super_admins[ $key ] );
+                                                break;
+                                        }
+                                }
+                        }
+                        update_site_option( 'site_admins' , $super_admins );
+
+                        wp_redirect( add_query_arg( array( 'updated' =&gt; 'true', 'action' =&gt; 'remove_superadmin' ), $_SERVER['HTTP_REFERER'] ) );
</ins><span class="cx">                 } else {
</span><span class="cx">                         foreach ( (array) $_POST['allusers'] as $key =&gt; $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">                         &lt;/tr&gt;
</span><span class="cx">                 &lt;/table&gt;
</span><span class="cx"> 
</span><del>-                &lt;h3&gt;&lt;?php _e('Administration Settings') ?&gt;&lt;/h3&gt;
-                &lt;table class=&quot;form-table&quot;&gt;
-                        &lt;tr valign=&quot;top&quot;&gt;
-                                &lt;th scope=&quot;row&quot;&gt;&lt;?php _e('Network Admins') ?&gt;&lt;/th&gt;
-                                &lt;td&gt;
-                                        &lt;input name=&quot;site_admins&quot; type=&quot;text&quot; id=&quot;site_admins&quot; style=&quot;width: 95%&quot; value=&quot;&lt;?php echo esc_attr( implode(' ', get_site_option( 'site_admins', array( 'admin' ) ) ) ) ?&gt;&quot; size=&quot;45&quot; /&gt;
-                                        &lt;br /&gt;
-                                        &lt;?php _e('These users may login to the main site and administer the network. Space separated list of usernames.') ?&gt;
-                                &lt;/td&gt;
-                        &lt;/tr&gt;
-                &lt;/table&gt;
-
</del><span class="cx">                 &lt;h3&gt;&lt;?php _e('Network Wide Settings &lt;em&gt;(These settings may be overridden by site owners)&lt;/em&gt;') ?&gt;&lt;/h3&gt;
</span><span class="cx">                 &lt;table class=&quot;form-table&quot;&gt;
</span><span class="cx">                         &lt;?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">                 ?&gt;
</span><span class="cx">         &lt;/p&gt;&lt;/div&gt;
</span><span class="lines">@@ -119,6 +125,8 @@
</span><span class="cx">                                 &lt;input type=&quot;submit&quot; value=&quot;&lt;?php esc_attr_e('Delete') ?&gt;&quot; name=&quot;alluser_delete&quot; class=&quot;button-secondary delete&quot; /&gt;
</span><span class="cx">                                 &lt;input type=&quot;submit&quot; value=&quot;&lt;?php esc_attr_e('Mark as Spammers') ?&gt;&quot; name=&quot;alluser_spam&quot; class=&quot;button-secondary&quot; /&gt;
</span><span class="cx">                                 &lt;input type=&quot;submit&quot; value=&quot;&lt;?php esc_attr_e('Not Spam') ?&gt;&quot; name=&quot;alluser_notspam&quot; class=&quot;button-secondary&quot; /&gt;
</span><ins>+                                &lt;input type=&quot;submit&quot; value=&quot;&lt;?php esc_attr_e('Add to Super Admin list') ?&gt;&quot; name=&quot;add_superadmin&quot; class=&quot;button-secondary&quot; /&gt;
+                                &lt;input type=&quot;submit&quot; value=&quot;&lt;?php esc_attr_e('Remove from Super Admin list') ?&gt;&quot; name=&quot;remove_superadmin&quot; class=&quot;button-secondary&quot; /&gt;
</ins><span class="cx">                                 &lt;?php wp_nonce_field( 'allusers' ); ?&gt;
</span><span class="cx">                                 &lt;br class=&quot;clear&quot; /&gt;
</span><span class="cx">                         &lt;/div&gt;
</span><span class="lines">@@ -157,6 +165,7 @@
</span><span class="cx">                         &lt;tbody id=&quot;users&quot; class=&quot;list:user user-list&quot;&gt;
</span><span class="cx">                         &lt;?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;amp;action=deleteuser&amp;amp;id=' . $user['ID'] ) );
</span><span class="cx">                                                                 ?&gt;
</span><span class="cx">                                                                 &lt;td class=&quot;username column-username&quot;&gt;
</span><del>-                                                                        &lt;?php echo $avatar; ?&gt;&lt;strong&gt;&lt;a href=&quot;&lt;?php echo $edit; ?&gt;&quot; class=&quot;edit&quot;&gt;&lt;?php echo stripslashes($user['user_login']); ?&gt;&lt;/a&gt;&lt;/strong&gt;
</del><ins>+                                                                        &lt;?php echo $avatar; ?&gt;&lt;strong&gt;&lt;a href=&quot;&lt;?php echo $edit; ?&gt;&quot; class=&quot;edit&quot;&gt;&lt;?php echo stripslashes($user['user_login']); ?&gt;&lt;/a&gt;&lt;?php
+                                                                if ( in_array( $user[ 'user_login' ], $super_admins ) ) 
+                                                                        echo ' - ' . __( 'Super admin' );
+?&gt;&lt;/strong&gt;
</ins><span class="cx">                                                                         &lt;br/&gt;
</span><span class="cx">                                                                         &lt;div class=&quot;row-actions&quot;&gt;
</span><span class="cx">                                                                                 &lt;span class=&quot;edit&quot;&gt;&lt;a href=&quot;&lt;?php echo $edit; ?&gt;&quot;&gt;Edit&lt;/a&gt;&lt;/span&gt;
</span></span></pre>
</div>
</div>

</body>
</html>