2010-01-06 05:02:57 +01:00
< ? php
2010-04-04 15:29:35 +02:00
/**
* Multisite users administration panel .
*
* @ package WordPress
* @ subpackage Multisite
* @ since 3.0 . 0
*/
2010-04-01 23:21:27 +02:00
require_once ( './admin.php' );
2010-01-06 05:02:57 +01:00
2010-01-06 21:19:35 +01:00
if ( ! is_multisite () )
2010-04-01 23:21:27 +02:00
wp_die ( __ ( 'Multisite support is not enabled.' ) );
2010-01-06 21:19:35 +01:00
2010-04-03 02:10:44 +02:00
if ( ! current_user_can ( 'manage_network_users' ) )
wp_die ( __ ( 'You do not have permission to access this page.' ) );
2010-04-01 23:21:27 +02:00
$title = __ ( 'Users' );
2010-01-07 01:30:53 +01:00
$parent_file = 'ms-admin.php' ;
2010-01-06 05:02:57 +01:00
2010-06-02 22:04:07 +02:00
add_contextual_help ( $current_screen ,
2010-05-27 23:20:23 +02:00
'<p>' . __ ( 'This table shows all users across the network and the sites to which they are assigned.' ) . '</p>' .
'<p>' . __ ( 'Hover over any user on the list to make the edit links appear. The Edit link on the left will take you to his or her Edit User profile page; the Edit link on the right by any site name goes to an Edit Site screen for that site.' ) . '</p>' .
2010-06-02 07:53:24 +02:00
'<p>' . __ ( 'You can also go to the user’s profile page by clicking on the individual username.' ) . '</p>' .
2010-05-27 23:20:23 +02:00
'<p>' . __ ( 'You can sort the table by clicking on any of the bold headings and switch between list and excerpt views by using the icons in the upper right.' ) . '</p>' .
2010-06-02 07:53:24 +02:00
'<p>' . __ ( 'The bulk action will permanently delete selected users, or mark/unmark those selected as spam. Spam users will have posts removed and will be unable to sign up again with the same email addresses.' ) . '</p>' .
2010-05-27 23:20:23 +02:00
'<p>' . __ ( 'Add User will add that person to this table and send them an email.' ) . '</p>' .
'<p>' . __ ( 'Users who are signed up to the network without a site are added as subscribers to the main or primary dashboard site, giving them profile pages to manage their accounts. These users will only see Dashboard and My Sites in the main navigation until a site is created for them.' ) . '</p>' .
'<p>' . __ ( 'You can make an existing user an additional super admin by going to the Edit User profile page and checking the box to grant that privilege.' ) . '</p>' .
'<p><strong>' . __ ( 'For more information:' ) . '</strong></p>' .
2010-06-03 23:00:39 +02:00
'<p>' . __ ( '<a href="http://codex.wordpress.org/Super_Admin_Users_SubPanel" target="_blank">Network Users Documentation</a>' ) . '</p>' .
'<p>' . __ ( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
2010-05-27 23:20:23 +02:00
);
2010-01-06 05:02:57 +01:00
wp_enqueue_script ( 'admin-forms' );
2010-04-01 23:21:27 +02:00
require_once ( './admin-header.php' );
2010-01-06 05:02:57 +01:00
2010-04-01 23:21:27 +02:00
if ( isset ( $_GET [ 'updated' ] ) && $_GET [ 'updated' ] == 'true' && ! empty ( $_GET [ 'action' ] ) ) {
2010-01-06 05:02:57 +01:00
?>
2010-04-08 05:36:52 +02:00
< div id = " message " class = " updated " >< p >
2010-01-06 05:02:57 +01:00
< ? php
2010-04-01 23:21:27 +02:00
switch ( $_GET [ 'action' ] ) {
2010-01-06 05:02:57 +01:00
case 'delete' :
2010-04-01 23:21:27 +02:00
_e ( 'User deleted.' );
2010-01-06 05:02:57 +01:00
break ;
case 'all_spam' :
2010-04-01 23:21:27 +02:00
_e ( 'Users marked as spam.' );
2010-01-06 05:02:57 +01:00
break ;
2010-01-07 05:27:46 +01:00
case 'all_notspam' :
2010-04-03 02:10:44 +02:00
_e ( 'Users removed from spam.' );
2010-01-07 05:27:46 +01:00
break ;
2010-01-06 05:02:57 +01:00
case 'all_delete' :
2010-04-01 23:21:27 +02:00
_e ( 'Users deleted.' );
2010-01-06 05:02:57 +01:00
break ;
case 'add' :
2010-04-01 23:21:27 +02:00
_e ( 'User added.' );
2010-01-06 05:02:57 +01:00
break ;
}
?>
</ p ></ div >
< ? php
}
2010-04-01 23:21:27 +02:00
$pagenum = isset ( $_GET [ 'paged' ] ) ? absint ( $_GET [ 'paged' ] ) : 0 ;
if ( empty ( $pagenum ) )
$pagenum = 1 ;
$per_page = ( int ) get_user_option ( 'ms_users_per_page' );
if ( empty ( $per_page ) || $per_page < 1 )
$per_page = 15 ;
$per_page = apply_filters ( 'ms_users_per_page' , $per_page );
$s = isset ( $_GET [ 's' ] ) ? stripslashes ( trim ( $_GET [ 's' ] ) ) : '' ;
$like_s = esc_sql ( like_escape ( $s ) );
2010-01-06 05:02:57 +01:00
$query = " SELECT * FROM { $wpdb -> users } " ;
2010-04-01 23:21:27 +02:00
if ( ! empty ( $like_s ) ) {
$query .= " WHERE user_login LIKE '% $like_s %' OR user_email LIKE '% $like_s %' " ;
2010-01-06 05:02:57 +01:00
}
2010-01-22 23:27:26 +01:00
$order_by = isset ( $_GET [ 'sortby' ] ) ? $_GET [ 'sortby' ] : 'id' ;
if ( $order_by == 'email' ) {
2010-01-06 05:02:57 +01:00
$query .= ' ORDER BY user_email ' ;
2010-01-22 23:27:26 +01:00
} elseif ( $order_by == 'login' ) {
2010-01-06 05:02:57 +01:00
$query .= ' ORDER BY user_login ' ;
2010-01-22 23:27:26 +01:00
} elseif ( $order_by == 'name' ) {
2010-01-06 05:02:57 +01:00
$query .= ' ORDER BY display_name ' ;
2010-01-22 23:27:26 +01:00
} elseif ( $order_by == 'registered' ) {
2010-01-06 05:02:57 +01:00
$query .= ' ORDER BY user_registered ' ;
2010-01-22 23:27:26 +01:00
} else {
$order_by = 'id' ;
$query .= ' ORDER BY ID ' ;
}
2010-01-06 05:02:57 +01:00
2010-04-01 23:21:27 +02:00
$order = ( isset ( $_GET [ 'order' ] ) && 'DESC' == $_GET [ 'order' ] ) ? 'DESC' : 'ASC' ;
2010-01-22 23:27:26 +01:00
$query .= $order ;
2010-01-06 05:02:57 +01:00
2010-04-01 23:21:27 +02:00
$total = $wpdb -> get_var ( str_replace ( 'SELECT *' , 'SELECT COUNT(ID)' , $query ) );
2010-01-06 05:02:57 +01:00
2010-04-01 23:21:27 +02:00
$query .= " LIMIT " . intval ( ( $pagenum - 1 ) * $per_page ) . " , " . intval ( $per_page );
2010-01-06 05:02:57 +01:00
$user_list = $wpdb -> get_results ( $query , ARRAY_A );
2010-04-01 23:21:27 +02:00
$num_pages = ceil ( $total / $per_page );
$page_links = paginate_links ( array (
'base' => add_query_arg ( 'paged' , '%#%' ),
'format' => '' ,
'prev_text' => __ ( '«' ),
'next_text' => __ ( '»' ),
'total' => $num_pages ,
'current' => $pagenum
2010-01-06 05:02:57 +01:00
));
2010-01-07 05:27:46 +01:00
2010-04-01 23:21:27 +02:00
if ( empty ( $_GET [ 'mode' ] ) )
$mode = 'list' ;
else
$mode = esc_attr ( $_GET [ 'mode' ] );
2010-01-07 05:27:46 +01:00
2010-01-06 05:02:57 +01:00
?>
< div class = " wrap " >
2010-01-20 23:35:21 +01:00
< ? php screen_icon (); ?>
2010-04-01 23:21:27 +02:00
< h2 >< ? php esc_html_e ( 'Users' ); ?>
< a href = " #form-add-user " class = " button add-new-h2 " >< ? php echo esc_html_x ( 'Add New' , 'users' ); ?> </a>
< ? php
if ( isset ( $_GET [ 's' ] ) && $_GET [ 's' ] )
printf ( '<span class="subtitle">' . __ ( 'Search results for “%s”' ) . '</span>' , esc_html ( $s ) );
?>
</ h2 >
2010-01-07 01:30:53 +01:00
< form action = " ms-users.php " method = " get " class = " search-form " >
2010-01-06 05:02:57 +01:00
< p class = " search-box " >
2010-04-01 23:21:27 +02:00
< input type = " text " name = " s " value = " <?php echo esc_attr( $s ); ?> " class = " search-input " id = " user-search-input " />
< input type = " submit " id = " post-query-submit " value = " <?php esc_attr_e( 'Search Users' ) ?> " class = " button " />
2010-01-06 05:02:57 +01:00
</ p >
</ form >
2010-01-07 01:24:03 +01:00
< form id = " form-user-list " action = 'ms-edit.php?action=allusers' method = 'post' >
2010-04-01 23:21:27 +02:00
< input type = " hidden " name = " mode " value = " <?php echo esc_attr( $mode ); ?> " />
2010-01-06 05:02:57 +01:00
< div class = " tablenav " >
< div class = " alignleft actions " >
2010-04-01 23:21:27 +02:00
< select name = " action " >
< option value = " -1 " selected = " selected " >< ? php _e ( 'Bulk Actions' ); ?> </option>
< option value = " delete " >< ? php _e ( 'Delete' ); ?> </option>
2010-05-14 23:46:25 +02:00
< option value = " spam " >< ? php _ex ( 'Mark as Spam' , 'user' ); ?> </option>
< option value = " notspam " >< ? php _ex ( 'Not Spam' , 'user' ); ?> </option>
2010-04-01 23:21:27 +02:00
</ select >
< input type = " submit " value = " <?php esc_attr_e( 'Apply' ); ?> " name = " doaction " id = " doaction " class = " button-secondary action " />
2010-05-19 07:32:39 +02:00
< ? php wp_nonce_field ( 'bulk-ms-users' , '_wpnonce_bulk-ms-users' ); ?>
2010-01-06 05:02:57 +01:00
</ div >
2010-04-01 23:21:27 +02:00
< ? php if ( $page_links ) { ?>
< div class = " tablenav-pages " >
< ? php $page_links_text = sprintf ( '<span class="displaying-num">' . __ ( 'Displaying %s–%s of %s' ) . '</span>%s' ,
number_format_i18n ( ( $pagenum - 1 ) * $per_page + 1 ),
2010-04-22 19:59:21 +02:00
number_format_i18n ( min ( $pagenum * $per_page , $total ) ),
number_format_i18n ( $total ),
2010-04-01 23:21:27 +02:00
$page_links
); echo $page_links_text ; ?>
</ div >
< ? php } ?>
< div class = " view-switch " >
2010-05-03 20:16:22 +02:00
< a href = " <?php echo esc_url( add_query_arg( 'mode', 'list', $_SERVER['REQUEST_URI'] ) ) ?> " >< img < ? php if ( 'list' == $mode ) echo 'class="current"' ; ?> id="view-switch-list" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'List View' ) ?>" alt="<?php _e( 'List View' ) ?>" /></a>
< a href = " <?php echo esc_url( add_query_arg( 'mode', 'excerpt', $_SERVER['REQUEST_URI'] ) ) ?> " >< img < ? php if ( 'excerpt' == $mode ) echo 'class="current"' ; ?> id="view-switch-excerpt" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'Excerpt View' ) ?>" alt="<?php _e( 'Excerpt View' ) ?>" /></a>
2010-04-01 23:21:27 +02:00
</ div >
</ div >
< div class = " clear " ></ div >
2010-01-06 05:02:57 +01:00
< ? php
// define the columns to display, the syntax is 'internal name' => 'display name'
2010-04-01 23:21:27 +02:00
$users_columns = array (
'id' => __ ( 'ID' ),
'login' => __ ( 'Username' ),
'name' => __ ( 'Name' ),
'email' => __ ( 'E-mail' ),
2010-05-03 22:37:07 +02:00
'registered' => _x ( 'Registered' , 'user' ),
2010-04-01 23:21:27 +02:00
'blogs' => __ ( 'Sites' )
2010-01-06 05:02:57 +01:00
);
2010-04-01 23:21:27 +02:00
$users_columns = apply_filters ( 'wpmu_users_columns' , $users_columns );
2010-01-06 05:02:57 +01:00
?>
2010-04-01 23:21:27 +02:00
< table class = " widefat " >
2010-01-06 05:02:57 +01:00
< thead >
< tr >
2010-05-14 17:03:23 +02:00
< th class = " manage-column column-cb check-column " scope = " col " >
2010-04-01 23:21:27 +02:00
< input type = " checkbox " />
</ th >
< ? php
$col_url = '' ;
foreach ( $users_columns as $column_id => $column_display_name ) {
$column_link = " <a href=' " ;
$order2 = '' ;
if ( $order_by == $column_id )
$order2 = ( $order == 'DESC' ) ? 'ASC' : 'DESC' ;
$column_link .= esc_url ( add_query_arg ( array ( 'order' => $order2 , 'paged' => $pagenum , 'sortby' => $column_id ), remove_query_arg ( array ( 'action' , 'updated' ), $_SERVER [ 'REQUEST_URI' ] ) ) );
$column_link .= " '> { $column_display_name } </a> " ;
$col_url .= '<th scope="col">' . ( $column_id == 'blogs' ? $column_display_name : $column_link ) . '</th>' ;
}
echo $col_url ; ?>
2010-01-06 05:02:57 +01:00
</ tr >
</ thead >
2010-04-01 23:21:27 +02:00
< tfoot >
< tr >
2010-05-14 17:03:23 +02:00
< th class = " manage-column column-cb check-column " scope = " col " >
2010-04-01 23:21:27 +02:00
< input type = " checkbox " />
</ th >
< ? php echo $col_url ; ?>
</ tr >
</ tfoot >
< tbody id = " the-user-list " class = " list:user " >
< ? php if ( $user_list ) {
2010-01-22 23:27:26 +01:00
$class = '' ;
2010-04-23 22:34:03 +02:00
$super_admins = get_super_admins ();
2010-04-01 23:21:27 +02:00
foreach ( ( array ) $user_list as $user ) {
$class = ( 'alternate' == $class ) ? '' : 'alternate' ;
2010-01-07 05:27:46 +01:00
2010-04-01 23:21:27 +02:00
$status_list = array ( 'spam' => 'site-spammed' , 'deleted' => 'site-deleted' );
2010-01-07 05:27:46 +01:00
2010-01-06 05:02:57 +01:00
foreach ( $status_list as $status => $col ) {
2010-02-04 20:03:08 +01:00
if ( $user [ $status ] )
$class = $col ;
2010-01-06 05:02:57 +01:00
}
?>
2010-02-04 20:03:08 +01:00
< tr class = " <?php echo $class ; ?> " >
2010-01-06 05:02:57 +01:00
< ? php
2010-04-01 23:21:27 +02:00
foreach ( ( array ) $users_columns as $column_name => $column_display_name ) :
switch ( $column_name ) {
case 'id' : ?>
< th scope = " row " class = " check-column " >
< input type = " checkbox " id = " blog_<?php echo $user['ID'] ?> " name = " allusers[] " value = " <?php echo esc_attr( $user['ID'] ) ?> " />
</ th >
< th valign = " top " scope = " row " >
< ? php echo $user [ 'ID' ] ?>
</ th >
2010-01-07 05:27:46 +01:00
< ? php
2010-01-06 05:02:57 +01:00
break ;
case 'login' :
$avatar = get_avatar ( $user [ 'user_email' ], 32 );
2010-04-02 08:46:07 +02:00
$edit_link = ( $current_user -> ID == $user [ 'ID' ] ) ? 'profile.php' : 'user-edit.php?user_id=' . $user [ 'ID' ];
2010-01-06 05:02:57 +01:00
?>
< td class = " username column-username " >
2010-05-03 20:16:22 +02:00
< ? php echo $avatar ; ?> <strong><a href="<?php echo esc_url( admin_url( $edit_link ) ); ?>" class="edit"><?php echo stripslashes( $user['user_login'] ); ?></a><?php
2010-04-01 23:21:27 +02:00
if ( in_array ( $user [ 'user_login' ], $super_admins ) )
echo ' - ' . __ ( 'Super admin' );
?> </strong>
2010-01-06 05:02:57 +01:00
< br />
< div class = " row-actions " >
2010-05-03 20:16:22 +02:00
< span class = " edit " >< a href = " <?php echo esc_url( admin_url( $edit_link ) ); ?> " >< ? php _e ( 'Edit' ); ?> </a></span>
2010-04-01 23:21:27 +02:00
< ? php if ( ! in_array ( $user [ 'user_login' ], $super_admins ) ) { ?>
2010-05-03 20:16:22 +02:00
| < span class = " delete " >< a href = " <?php echo $delete = esc_url( admin_url( add_query_arg( '_wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'ms-edit.php', 'deleteuser' ) . '&action=deleteuser&id=' . $user['ID'] ) ) ); ?> " class = " delete " >< ? php _e ( 'Delete' ); ?> </a></span>
2010-04-01 23:21:27 +02:00
< ? php } ?>
2010-01-06 05:02:57 +01:00
</ div >
</ td >
< ? php
break ;
case 'name' : ?>
< td class = " name column-name " >< ? php echo $user [ 'display_name' ] ?> </td>
< ? php
break ;
case 'email' : ?>
< td class = " email column-email " >< a href = " mailto:<?php echo $user['user_email'] ?> " >< ? php echo $user [ 'user_email' ] ?> </a></td>
< ? php
break ;
2010-05-03 22:26:11 +02:00
case 'registered' :
2010-04-01 23:21:27 +02:00
if ( 'list' == $mode )
$date = 'Y/m/d' ;
else
$date = 'Y/m/d \<\b\r \/\> g:i:s a' ;
?>
< td >< ? php echo mysql2date ( __ ( $date ), $user [ 'user_registered' ] ); ?> </td>
2010-01-06 05:02:57 +01:00
< ? php
break ;
2010-01-07 05:27:46 +01:00
case 'blogs' :
2010-01-06 05:02:57 +01:00
$blogs = get_blogs_of_user ( $user [ 'ID' ], true );
?>
< td >
< ? php
2010-01-18 21:34:48 +01:00
if ( is_array ( $blogs ) ) {
2010-01-06 05:02:57 +01:00
foreach ( ( array ) $blogs as $key => $val ) {
2010-04-01 23:21:27 +02:00
$path = ( $val -> path == '/' ) ? '' : $val -> path ;
2010-05-03 20:16:22 +02:00
echo '<a href="' . esc_url ( admin_url ( 'ms-sites.php?action=editblog&id=' . $val -> userblog_id ) ) . '">' . str_replace ( '.' . $current_site -> domain , '' , $val -> domain . $path ) . '</a>' ;
2010-01-06 05:02:57 +01:00
echo ' <small class="row-actions">' ;
2010-01-07 05:27:46 +01:00
2010-01-06 05:02:57 +01:00
// Edit
2010-05-03 20:16:22 +02:00
echo '<a href="' . esc_url ( admin_url ( 'ms-sites.php?action=editblog&id=' . $val -> userblog_id ) ) . '">' . __ ( 'Edit' ) . '</a> | ' ;
2010-01-07 05:27:46 +01:00
2010-01-06 05:02:57 +01:00
// View
2010-01-07 05:27:46 +01:00
echo '<a ' ;
2010-01-18 21:34:48 +01:00
if ( get_blog_status ( $val -> userblog_id , 'spam' ) == 1 )
2010-04-01 23:21:27 +02:00
echo 'style="background-color: #faa" ' ;
2010-05-03 20:16:22 +02:00
echo 'href="' . esc_url ( get_home_url ( $val -> userblog_id ) ) . '">' . __ ( 'View' ) . '</a>' ;
2010-05-03 22:26:11 +02:00
2010-01-07 05:27:46 +01:00
echo '</small><br />' ;
2010-01-06 05:02:57 +01:00
}
}
?>
</ td >
< ? php
break ;
default : ?>
2010-04-01 23:21:27 +02:00
< td >< ? php do_action ( 'manage_users_custom_column' , $column_name , $user [ 'ID' ] ); ?> </td>
2010-01-06 05:02:57 +01:00
< ? php
break ;
}
endforeach
?>
2010-01-07 05:27:46 +01:00
</ tr >
2010-01-06 05:02:57 +01:00
< ? php
}
} else {
?>
2010-04-01 23:21:27 +02:00
< tr >
< td colspan = " <?php echo (int) count( $users_columns ); ?> " >< ? php _e ( 'No users found.' ) ?> </td>
2010-01-07 05:27:46 +01:00
</ tr >
2010-01-06 05:02:57 +01:00
< ? php
} // end if ($users)
2010-01-07 05:27:46 +01:00
?>
2010-01-06 05:02:57 +01:00
</ tbody >
</ table >
2010-01-07 05:27:46 +01:00
2010-01-06 05:02:57 +01:00
< div class = " tablenav " >
2010-04-01 23:21:27 +02:00
< ? php
if ( $page_links )
echo " <div class='tablenav-pages'> $page_links_text </div> " ;
?>
< div class = " alignleft actions " >
< select name = " action2 " >
< option value = " -1 " selected = " selected " >< ? php _e ( 'Bulk Actions' ); ?> </option>
< option value = " delete " >< ? php _e ( 'Delete' ); ?> </option>
2010-05-14 23:46:25 +02:00
< option value = " spam " >< ? php _ex ( 'Mark as Spam' , 'user' ); ?> </option>
< option value = " notspam " >< ? php _ex ( 'Not Spam' , 'user' ); ?> </option>
2010-04-01 23:21:27 +02:00
</ select >
< input type = " submit " value = " <?php esc_attr_e( 'Apply' ); ?> " name = " doaction2 " id = " doaction2 " class = " button-secondary action " />
2010-01-06 05:02:57 +01:00
</ div >
2010-04-01 23:21:27 +02:00
< br class = " clear " />
</ div >
</ form >
2010-01-06 05:02:57 +01:00
</ div >
< ? php
2010-04-01 23:21:27 +02:00
if ( apply_filters ( 'show_adduser_fields' , true ) ) :
2010-01-06 05:02:57 +01:00
?>
2010-04-03 13:15:51 +02:00
< div class = " wrap " id = " form-add-user " >
< h3 >< ? php _e ( 'Add User' ) ?> </h3>
< form action = " ms-edit.php?action=adduser " method = " post " >
2010-01-06 05:02:57 +01:00
< table class = " form-table " >
< tr class = " form-field form-required " >
2010-04-01 23:21:27 +02:00
< th scope = " row " >< ? php _e ( 'Username' ) ?> </th>
< td >< input type = " text " class = " regular-text " name = " user[username] " /></ td >
2010-01-06 05:02:57 +01:00
</ tr >
< tr class = " form-field form-required " >
2010-04-01 23:21:27 +02:00
< th scope = " row " >< ? php _e ( 'Email' ) ?> </th>
< td >< input type = " text " class = " regular-text " name = " user[email] " /></ td >
2010-01-06 05:02:57 +01:00
</ tr >
< tr class = " form-field " >
2010-04-01 23:21:27 +02:00
< td colspan = " 2 " >< ? php _e ( 'Username and password will be mailed to the above email address.' ) ?> </td>
2010-01-06 05:02:57 +01:00
</ tr >
</ table >
< p class = " submit " >
2010-05-19 07:32:39 +02:00
< ? php wp_nonce_field ( 'add-user' , '_wpnonce_add-user' ) ?>
2010-04-01 23:21:27 +02:00
< input class = " button " type = " submit " value = " <?php esc_attr_e( 'Add user' ) ?> " /></ p >
2010-01-06 05:02:57 +01:00
</ form >
</ div >
< ? php endif ; ?>
2010-04-01 23:21:27 +02:00
< ? php include ( './admin-footer.php' ); ?>