2010-01-06 05:02:57 +01:00
|
|
|
<?php
|
|
|
|
require_once('admin.php');
|
|
|
|
|
2010-01-06 21:19:35 +01:00
|
|
|
if ( !is_multisite() )
|
|
|
|
wp_die( __('Multisite support is not enabled.') );
|
|
|
|
|
2010-01-07 04:24:24 +01:00
|
|
|
$title = __('Users');
|
2010-01-07 01:30:53 +01:00
|
|
|
$parent_file = 'ms-admin.php';
|
2010-01-06 05:02:57 +01:00
|
|
|
|
|
|
|
wp_enqueue_script( 'admin-forms' );
|
|
|
|
|
|
|
|
require_once('admin-header.php');
|
|
|
|
|
2010-01-07 16:52:22 +01:00
|
|
|
if ( !is_super_admin() )
|
2010-01-06 05:02:57 +01:00
|
|
|
wp_die( __('You do not have permission to access this page.') );
|
|
|
|
|
2010-01-22 23:27:26 +01:00
|
|
|
if ( isset($_GET['updated']) && $_GET['updated'] == 'true' ) {
|
2010-01-06 05:02:57 +01:00
|
|
|
?>
|
|
|
|
<div id="message" class="updated fade"><p>
|
|
|
|
<?php
|
|
|
|
switch ($_GET['action']) {
|
|
|
|
case 'delete':
|
|
|
|
_e('User deleted !');
|
|
|
|
break;
|
|
|
|
case 'all_spam':
|
|
|
|
_e('Users marked as spam !');
|
|
|
|
break;
|
2010-01-07 05:27:46 +01:00
|
|
|
case 'all_notspam':
|
|
|
|
_e('Users marked as not spam !');
|
|
|
|
break;
|
2010-01-06 05:02:57 +01:00
|
|
|
case 'all_delete':
|
|
|
|
_e('Users deleted !');
|
|
|
|
break;
|
|
|
|
case 'add':
|
|
|
|
_e('User added !');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</p></div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|
|
<div class="wrap" style="position:relative;">
|
|
|
|
<?php
|
|
|
|
$apage = isset( $_GET['apage'] ) ? intval( $_GET['apage'] ) : 1;
|
|
|
|
$num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : 15;
|
2010-01-22 23:27:26 +01:00
|
|
|
$s = isset($_GET[ 's' ]) ? esc_attr( trim( $_GET[ 's' ] ) ) : '';
|
2010-01-06 05:02:57 +01:00
|
|
|
|
|
|
|
$query = "SELECT * FROM {$wpdb->users}";
|
|
|
|
|
2010-01-18 21:34:48 +01:00
|
|
|
if ( !empty( $s ) ) {
|
2010-01-06 05:02:57 +01:00
|
|
|
$search = '%' . trim( $s ) . '%';
|
|
|
|
$query .= " WHERE user_login LIKE '$search' OR user_email LIKE '$search'";
|
|
|
|
}
|
|
|
|
|
2010-01-22 23:27:26 +01:00
|
|
|
$order_by = isset( $_GET['sortby'] ) ? $_GET['sortby'] : 'id';
|
2010-01-06 05:02:57 +01:00
|
|
|
|
2010-01-22 23:27:26 +01:00
|
|
|
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-01-22 23:27:26 +01:00
|
|
|
$order = isset($_GET['order']) ? $_GET['order'] : 'ASC';
|
|
|
|
$order = ( 'DESC' == $order ) ? 'DESC' : 'ASC';
|
|
|
|
$query .= $order;
|
2010-01-06 05:02:57 +01:00
|
|
|
|
2010-01-20 23:35:21 +01:00
|
|
|
if ( !empty( $s ) )
|
2010-01-06 05:02:57 +01:00
|
|
|
$total = $wpdb->get_var( str_replace('SELECT *', 'SELECT COUNT(ID)', $query) );
|
2010-01-20 23:35:21 +01:00
|
|
|
else
|
2010-01-06 05:02:57 +01:00
|
|
|
$total = $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->users}");
|
|
|
|
|
|
|
|
$query .= " LIMIT " . intval( ( $apage - 1 ) * $num) . ", " . intval( $num );
|
|
|
|
|
|
|
|
$user_list = $wpdb->get_results( $query, ARRAY_A );
|
|
|
|
|
|
|
|
// Pagination
|
|
|
|
$user_navigation = paginate_links( array(
|
2010-01-07 05:27:46 +01:00
|
|
|
'total' => ceil($total / $num),
|
2010-01-06 05:02:57 +01:00
|
|
|
'current' => $apage,
|
|
|
|
'base' => add_query_arg( 'apage', '%#%' ),
|
|
|
|
'format' => ''
|
|
|
|
));
|
2010-01-07 05:27:46 +01:00
|
|
|
|
2010-01-06 05:02:57 +01:00
|
|
|
if ( $user_navigation ) {
|
|
|
|
$user_navigation = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
|
|
|
|
number_format_i18n( ( $apage - 1 ) * $num + 1 ),
|
|
|
|
number_format_i18n( min( $apage * $num, $total ) ),
|
|
|
|
number_format_i18n( $total ),
|
|
|
|
$user_navigation
|
|
|
|
);
|
|
|
|
}
|
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(); ?>
|
|
|
|
<h2><?php esc_html_e("Users"); ?></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-01-19 18:01:39 +01:00
|
|
|
<input type="text" name="s" value="<?php if ( isset($_GET['s']) ) esc_attr( stripslashes( $s ) ); ?>" class="search-input" id="user-search-input" />
|
2010-01-07 01:25:02 +01:00
|
|
|
<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>
|
|
|
|
</div>
|
|
|
|
|
2010-01-07 01:24:03 +01:00
|
|
|
<form id="form-user-list" action='ms-edit.php?action=allusers' method='post'>
|
2010-01-06 05:02:57 +01:00
|
|
|
<div class="tablenav">
|
|
|
|
<?php if ( $user_navigation ) echo "<div class='tablenav-pages'>$user_navigation</div>"; ?>
|
|
|
|
|
|
|
|
<div class="alignleft actions">
|
2010-01-07 01:25:02 +01:00
|
|
|
<input type="submit" value="<?php esc_attr_e('Delete') ?>" name="alluser_delete" class="button-secondary delete" />
|
|
|
|
<input type="submit" value="<?php esc_attr_e('Mark as Spammers') ?>" name="alluser_spam" class="button-secondary" />
|
|
|
|
<input type="submit" value="<?php esc_attr_e('Not Spam') ?>" name="alluser_notspam" class="button-secondary" />
|
2010-01-06 05:02:57 +01:00
|
|
|
<?php wp_nonce_field( 'allusers' ); ?>
|
|
|
|
<br class="clear" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2010-01-18 21:34:48 +01:00
|
|
|
<?php if ( isset($_GET['s']) && $_GET['s'] != '' ) : ?>
|
2010-01-14 20:42:55 +01:00
|
|
|
<p><a href="ms-sites.php?action=blogs&s=<?php echo urlencode( stripslashes( $s ) ); ?>&blog_name=Search+blogs+by+name"><?php _e('Search Blogs for') ?> <strong><?php echo stripslashes( $s ) ?></strong></a></p>
|
2010-01-06 05:02:57 +01:00
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
// define the columns to display, the syntax is 'internal name' => 'display name'
|
|
|
|
$posts_columns = array(
|
|
|
|
'checkbox' => '',
|
|
|
|
'login' => __('Username'),
|
|
|
|
'name' => __('Name'),
|
|
|
|
'email' => __('E-mail'),
|
|
|
|
'registered' => __('Registered'),
|
|
|
|
'blogs' => ''
|
|
|
|
);
|
|
|
|
$posts_columns = apply_filters('wpmu_users_columns', $posts_columns);
|
|
|
|
?>
|
|
|
|
<table class="widefat" cellspacing="0">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<?php foreach( (array) $posts_columns as $column_id => $column_display_name) {
|
2010-01-18 21:34:48 +01:00
|
|
|
if ( $column_id == 'blogs' ) {
|
2010-01-06 05:02:57 +01:00
|
|
|
echo '<th scope="col">'.__('Blogs').'</th>';
|
2010-01-18 21:34:48 +01:00
|
|
|
} elseif ( $column_id == 'checkbox') {
|
2010-01-06 05:02:57 +01:00
|
|
|
echo '<th scope="col" class="check-column"><input type="checkbox" /></th>';
|
|
|
|
} else { ?>
|
2010-01-22 23:27:26 +01:00
|
|
|
<th scope="col"><a href="ms-users.php?sortby=<?php echo $column_id ?>&<?php if ( $order_by == $column_id ) { if ( $order == 'DESC' ) { echo "order=ASC&" ; } else { echo "order=DESC&"; } } ?>apage=<?php echo $apage ?>"><?php echo $column_display_name; ?></a></th>
|
2010-01-06 05:02:57 +01:00
|
|
|
<?php } ?>
|
|
|
|
<?php } ?>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody id="users" class="list:user user-list">
|
|
|
|
<?php if ($user_list) {
|
2010-01-22 23:27:26 +01:00
|
|
|
$class = '';
|
2010-01-07 05:27:46 +01:00
|
|
|
foreach ( (array) $user_list as $user) {
|
2010-01-06 05:02:57 +01:00
|
|
|
$class = ('alternate' == $class) ? '' : 'alternate';
|
2010-01-07 05:27:46 +01:00
|
|
|
|
2010-02-04 20:03:08 +01: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
|
|
|
|
foreach( (array) $posts_columns as $column_name=>$column_display_name) :
|
|
|
|
switch($column_name) {
|
|
|
|
case 'checkbox': ?>
|
2010-01-07 01:25:02 +01:00
|
|
|
<th scope="row" class="check-column"><input type='checkbox' id='user_<?php echo $user['ID'] ?>' name='allusers[]' value='<?php echo esc_attr($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-02-22 19:15:10 +01:00
|
|
|
$edit = esc_url( add_query_arg( 'wp_http_referer', urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=".$user['ID'] ) );
|
2010-01-07 01:24:03 +01:00
|
|
|
// @todo Make delete link work like delete button with transfering users (in ms-edit.php)
|
2010-02-22 19:15:10 +01:00
|
|
|
//$delete = esc_url( add_query_arg( 'wp_http_referer', urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), wp_nonce_url( 'ms-edit.php', 'deleteuser' ) . '&action=deleteuser&id=' . $user['ID'] ) );
|
2010-01-06 05:02:57 +01:00
|
|
|
?>
|
|
|
|
<td class="username column-username">
|
|
|
|
<?php echo $avatar; ?><strong><a href="<?php echo $edit; ?>" class="edit"><?php echo stripslashes($user['user_login']); ?></a></strong>
|
|
|
|
<br/>
|
|
|
|
<div class="row-actions">
|
|
|
|
<span class="edit"><a href="<?php echo $edit; ?>">Edit</a></span>
|
|
|
|
<?php /*<span class="delete"><a href="<?php echo $delete; ?>" class="delete">Delete</a></span> */ ?>
|
|
|
|
</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;
|
|
|
|
|
|
|
|
case 'registered': ?>
|
|
|
|
<td><?php echo mysql2date(__('Y-m-d \<\b\r \/\> g:i a'), $user['user_registered']); ?></td>
|
|
|
|
<?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 ) {
|
|
|
|
$path = ($val->path == '/') ? '' : $val->path;
|
2010-01-14 20:42:55 +01:00
|
|
|
echo '<a href="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-01-14 20:42:55 +01:00
|
|
|
echo '<a href="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-01-06 05:02:57 +01:00
|
|
|
echo 'style="background-color: #f66" ';
|
|
|
|
echo 'target="_new" href="http://'.$val->domain . $val->path.'">' . __('View') . '</a>';
|
2010-01-07 05:27:46 +01:00
|
|
|
|
|
|
|
echo '</small><br />';
|
2010-01-06 05:02:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</td>
|
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: ?>
|
|
|
|
<td><?php do_action('manage_users_custom_column', $column_name, $user['ID']); ?></td>
|
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
endforeach
|
|
|
|
?>
|
2010-01-07 05:27:46 +01:00
|
|
|
</tr>
|
2010-01-06 05:02:57 +01:00
|
|
|
<?php
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
?>
|
2010-01-07 05:27:46 +01:00
|
|
|
<tr style='background-color: <?php echo $bgcolor; ?>'>
|
|
|
|
<td colspan="<?php echo (int) count($posts_columns); ?>"><?php _e('No users found.') ?></td>
|
|
|
|
</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">
|
|
|
|
<?php if ( $user_navigation ) echo "<div class='tablenav-pages'>$user_navigation</div>"; ?>
|
|
|
|
|
|
|
|
<div class="alignleft">
|
2010-01-07 01:25:02 +01:00
|
|
|
<input type="submit" value="<?php esc_attr_e('Delete') ?>" name="alluser_delete" class="button-secondary delete" />
|
|
|
|
<input type="submit" value="<?php esc_attr_e('Mark as Spammers') ?>" name="alluser_spam" class="button-secondary" />
|
|
|
|
<input type="submit" value="<?php esc_attr_e('Not Spam') ?>" name="alluser_notspam" class="button-secondary" />
|
2010-01-06 05:02:57 +01:00
|
|
|
<?php wp_nonce_field( 'allusers' ); ?>
|
|
|
|
<br class="clear" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<?php
|
2010-01-18 21:34:48 +01:00
|
|
|
if ( apply_filters('show_adduser_fields', true) ) :
|
2010-01-06 05:02:57 +01:00
|
|
|
?>
|
|
|
|
<div class="wrap">
|
|
|
|
<h2><?php _e('Add user') ?></h2>
|
2010-01-07 01:24:03 +01:00
|
|
|
<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">
|
|
|
|
<th scope='row'><?php _e('Username') ?></th>
|
|
|
|
<td><input type="text" name="user[username]" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr class="form-field form-required">
|
|
|
|
<th scope='row'><?php _e('Email') ?></th>
|
|
|
|
<td><input type="text" name="user[email]" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr class="form-field">
|
|
|
|
<td colspan='2'><?php _e('Username and password will be mailed to the above email address.') ?></td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<p class="submit">
|
|
|
|
<?php wp_nonce_field('add-user') ?>
|
2010-01-07 01:25:02 +01:00
|
|
|
<input class="button" type="submit" name="Add user" value="<?php esc_attr_e('Add user') ?>" /></p>
|
2010-01-06 05:02:57 +01:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
<?php include('admin-footer.php'); ?>
|