-
-
+ }
+ $all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY user_login");
+ $user_dropdown = '
';
+ ?>
+
+
+
@@ -143,35 +157,86 @@ case 'adduser':
die(__('You can’t create users.'));
$user_id = add_user();
+ $update = 'add';
if ( is_wp_error( $user_id ) )
- $errors = $user_id;
+ $add_user_errors = $user_id;
else {
- header('Location: users.php?update=add');
+ $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_POST['user_login']), true));
+ $redirect = add_query_arg('usersearch', $new_user_login, $redirect);
+ header('Location: ' . add_query_arg('update', $update, $redirect) . '#user-' . $user_id);
die();
}
default:
- wp_enqueue_script( 'admin-users' );
+ wp_enqueue_script('admin-users');
- include ('admin-header.php');
+ include('admin-header.php');
- $userids = $wpdb->get_col("SELECT ID FROM $wpdb->users;");
+ /* Paging and Search by Mark Jaquith, June 6th, 2006 */
- foreach($userids as $userid) {
+ $users_per_page = 50;
+
+ $page = (int) $_GET['userspage'];
+ if ( !$page )
+ $page = 1;
+
+ $starton = ($page - 1) * $users_per_page;
+
+ $limit = 'LIMIT ' . $starton . ',' . $users_per_page;
+
+ $search_term = $_GET['usersearch'];
+ if ( $search_term ) {
+ $searches = array();
+ $search_sql = 'AND (';
+ foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col )
+ $searches[] = $col . " LIKE '%$search_term%'";
+ $search_sql .= implode(' OR ', $searches);
+ $search_sql .= ')';
+ $search_term = stripslashes($search_term); // done with DB, from now on we want slashes gone
+ }
+
+ if ( !$_GET['update'] && !$search_term && !$_GET['userspage'] && $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users") > $users_per_page )
+ $too_many_users = sprintf(__('Because this blog has more than %s users, they cannot all be shown on one page. Use the paging or search functionality in order to find the user you want to edit.'), $users_per_page);
+
+ $from_where = "FROM $wpdb->users WHERE 1=1 $search_sql";
+ $userids = $wpdb->get_col('SELECT ID ' . $from_where . $limit);
+
+ if ( $userids )
+ $total_users_for_this_query = $wpdb->get_var('SELECT COUNT(ID) ' . $from_where); // no limit
+ else
+ $errors = new WP_Error('no_matching_users_found', __('No matching users were found!'));
+
+ // Now for the paging
+ if ( $total_users_for_this_query > $users_per_page ) { // have to page the results
+ $prev_page = ( $page > 1) ? true : false;
+ $next_page = ( ($page * $users_per_page) < $total_users_for_this_query ) ? true : false;
+ $paging_text = '';
+ if ( $prev_page )
+ $paging_text .= '« Previous Page
';
+ if ( $next_page )
+ $paging_text .= 'Next Page »
';
+ if ( $prev_page || $next_page )
+ $paging_text .= '
';
+ }
+
+ // Clean up, we're done with these variables
+ unset($prev_page, $next_page, $limit, $searches, $search_sql, $col);
+
+ // Make the user objects
+ foreach ( (array) $userids as $userid ) {
$tmp_user = new WP_User($userid);
$roles = $tmp_user->roles;
$role = array_shift($roles);
$roleclasses[$role][$tmp_user->user_login] = $tmp_user;
}
- ?>
-
-
-
+
+
+ endif; ?>
+
+
get_error_messages() as $message )
- echo "- $message
";
+ echo "- $message
";
?>
-
+
+
+
+
+
+
+
+
+
-
-
-'.sprintf(__('Users can
register themselves or you can manually create users here.'), get_settings('siteurl').'/wp-register.php').''; ?>
-
-
+?>
\ No newline at end of file
diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css
index b73b73ec0b..eb7052dd66 100644
--- a/wp-admin/wp-admin.css
+++ b/wp-admin/wp-admin.css
@@ -52,7 +52,7 @@ a.delete:hover {
font-size: 16px;
}
-thead {
+thead, .thead {
background: #dfdfdf
}
diff --git a/wp-includes/functions.php b/wp-includes/functions.php
index 17fcfbd103..e3dae435ff 100644
--- a/wp-includes/functions.php
+++ b/wp-includes/functions.php
@@ -809,17 +809,24 @@ add_query_arg(associative_array, oldquery_or_uri)
function add_query_arg() {
$ret = '';
if ( is_array(func_get_arg(0)) ) {
- if ( @func_num_args() < 2 )
+ if ( @func_num_args() < 2 || '' == @func_get_arg(1) )
$uri = $_SERVER['REQUEST_URI'];
else
$uri = @func_get_arg(1);
} else {
- if ( @func_num_args() < 3 )
+ if ( @func_num_args() < 3 || '' == @func_get_arg(2) )
$uri = $_SERVER['REQUEST_URI'];
else
$uri = @func_get_arg(2);
}
+ if ( preg_match('|^https?://|i', $uri, $matches) ) {
+ $protocol = $matches[0];
+ $uri = substr($uri, strlen($protocol));
+ } else {
+ $protocol = '';
+ }
+
if ( strstr($uri, '?') ) {
$parts = explode('?', $uri, 2);
if ( 1 == count($parts) ) {
@@ -829,8 +836,7 @@ function add_query_arg() {
$base = $parts[0] . '?';
$query = $parts[1];
}
- }
- else if ( strstr($uri, '/') ) {
+ } else if ( strstr($uri, '/') ) {
$base = $uri . '?';
$query = '';
} else {
@@ -853,11 +859,28 @@ function add_query_arg() {
$ret .= "$k=$v";
}
}
- $ret = $base . $ret;
+ $ret = $protocol . $base . $ret;
+ if ( get_magic_quotes_gpc() )
+ $ret = stripslashes($ret); // parse_str() adds slashes if magicquotes is on. See: http://php.net/parse_str
return trim($ret, '?');
}
-function remove_query_arg($key, $query) {
+/*
+remove_query_arg: Returns a modified querystring by removing
+a single key or an array of keys.
+Omitting oldquery_or_uri uses the $_SERVER value.
+
+Parameters:
+remove_query_arg(removekey, [oldquery_or_uri]) or
+remove_query_arg(removekeyarray, [oldquery_or_uri])
+*/
+
+function remove_query_arg($key, $query='') {
+ if ( is_array($key) ) { // removing multiple keys
+ foreach ( (array) $key as $k )
+ $query = add_query_arg($k, '', $query);
+ return $query;
+ }
return add_query_arg($key, '', $query);
}