<!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>[16277] trunk/wp-admin/includes/class-wp-ms-users-list-table.php:
Super Admin filter for network/users.php.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/16277">16277</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-11-10 17:05:20 +0000 (Wed, 10 Nov 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Super Admin filter for network/users.php. fixes <a href="http://trac.wordpress.org/ticket/15371">#15371</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesclasswpmsuserslisttablephp">trunk/wp-admin/includes/class-wp-ms-users-list-table.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesclasswpmsuserslisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-ms-users-list-table.php (16276 => 16277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-ms-users-list-table.php        2010-11-10 16:42:59 UTC (rev 16276)
+++ trunk/wp-admin/includes/class-wp-ms-users-list-table.php        2010-11-10 17:05:20 UTC (rev 16277)
</span><span class="lines">@@ -23,12 +23,14 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         function prepare_items() {
</span><del>-                global $usersearch;
</del><ins>+                global $usersearch, $role, $wpdb;
</ins><span class="cx">
</span><span class="cx">                 $usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
</span><span class="cx">
</span><span class="cx">                 $users_per_page = $this->get_items_per_page( 'users_network_per_page' );
</span><span class="cx">
</span><ins>+                $role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';
+
</ins><span class="cx">                 $paged = $this->get_pagenum();
</span><span class="cx">
</span><span class="cx">                 $args = array(
</span><span class="lines">@@ -38,6 +40,11 @@
</span><span class="cx">                         'blog_id' => 0
</span><span class="cx">                 );
</span><span class="cx">
</span><ins>+                if ( $role == 'super' ) {
+                        $logins = implode( "', '", get_super_admins() );
+                        $args['include'] = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_login IN ('$logins')" );
+                }
+
</ins><span class="cx">                 // If the network is large and a search is not being performed, show only the latest users with no paging in order
</span><span class="cx">                 // to avoid expensive count queries.
</span><span class="cx">                 if ( !$usersearch && ( get_blog_count() >= 10000 ) ) {
</span><span class="lines">@@ -78,6 +85,25 @@
</span><span class="cx">                 _e( 'No users found.' );
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        function get_views() {
+                global $wp_roles, $role;
+
+                $users_of_blog = count_users();
+                $total_users = $users_of_blog['total_users'];
+                $super_admins = get_super_admins();
+                $total_admins = count( $super_admins );
+                unset($users_of_blog);
+
+                $current_role = false;
+                $class = $role != 'super' ? ' class="current"' : '';
+                $role_links = array();
+                $role_links['all'] = "<a href='" . network_admin_url('users.php') . "'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>';
+                $class = $role == 'super' ? ' class="current"' : '';
+                $role_links['super'] = "<a href='" . network_admin_url('users.php?role=super') . "'$class>" . sprintf( _n( 'Super Admin <span class="count">(%s)</span>', 'Super Admins <span class="count">(%s)</span>', $total_admins ), number_format_i18n( $total_admins ) ) . '</a>';
+
+                return $role_links;
+        }
+
</ins><span class="cx">         function pagination( $which ) {
</span><span class="cx">                 global $mode;
</span><span class="cx">
</span><span class="lines">@@ -155,7 +181,7 @@
</span><span class="cx">                                                 <td class="username column-username">
</span><span class="cx">                                                         <?php echo $avatar; ?><strong><a href="<?php echo esc_url( self_admin_url( $edit_link ) ); ?>" class="edit"><?php echo stripslashes( $user->user_login ); ?></a><?php
</span><span class="cx">                                                         if ( in_array( $user->user_login, $super_admins ) )
</span><del>-                                                                echo ' - ' . __( 'Super admin' );
</del><ins>+                                                                echo ' - ' . __( 'Super Admin' );
</ins><span class="cx">                                                         ?></strong>
</span><span class="cx">                                                         <br/>
</span><span class="cx">                                                         <?php
</span></span></pre>
</div>
</div>
</body>
</html>