Super Admin filter for network/users.php. fixes #15371.

git-svn-id: http://svn.automattic.com/wordpress/trunk@16277 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-11-10 17:05:20 +00:00
parent 8b6cb32160
commit 3b2c4501d1
1 changed files with 28 additions and 2 deletions

View File

@ -23,12 +23,14 @@ class WP_MS_Users_List_Table extends WP_List_Table {
}
function prepare_items() {
global $usersearch;
global $usersearch, $role, $wpdb;
$usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
$users_per_page = $this->get_items_per_page( 'users_network_per_page' );
$role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';
$paged = $this->get_pagenum();
$args = array(
@ -38,6 +40,11 @@ class WP_MS_Users_List_Table extends WP_List_Table {
'blog_id' => 0
);
if ( $role == 'super' ) {
$logins = implode( "', '", get_super_admins() );
$args['include'] = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_login IN ('$logins')" );
}
// If the network is large and a search is not being performed, show only the latest users with no paging in order
// to avoid expensive count queries.
if ( !$usersearch && ( get_blog_count() >= 10000 ) ) {
@ -78,6 +85,25 @@ class WP_MS_Users_List_Table extends WP_List_Table {
_e( 'No users found.' );
}
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;
}
function pagination( $which ) {
global $mode;
@ -155,7 +181,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
<td class="username column-username">
<?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
if ( in_array( $user->user_login, $super_admins ) )
echo ' - ' . __( 'Super admin' );
echo ' - ' . __( 'Super Admin' );
?></strong>
<br/>
<?php