Index: users.php
===================================================================
--- users.php	(revision 3850)
+++ users.php	(working copy)
@@ -84,7 +84,7 @@
 	}
 
 	if ( !current_user_can('delete_users') )
-		$error = new WP_Error('edit_users', __('You can&#8217;t delete users.'));
+		$errors = new WP_Error('edit_users', __('You can&#8217;t delete users.'));
 
 	$userids = $_POST['users'];
 
@@ -155,9 +155,58 @@
 
 	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 ) {
+		$search = 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 .= ')';
+	}
+
+	if ( !$search_term && $page == 1 && $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 .= '<p class="alignleft"><a href="' . add_query_arg('userspage', $page - 1) . '">&laquo; Previous Page</a></p>';
+		if ( $next_page )
+			$paging_text .= '<p class="alignright"><a href="' . add_query_arg('userspage', $page + 1) . '">Next Page &raquo;</a></p>';
+		if ( $prev_page || $next_page )
+			$paging_text .= '<br style="clear:both" />';
+	}
+
+	// DONE WITH PAGING AND SEARCH
+
+	foreach ( (array) $userids as $userid ) {
 		$tmp_user = new WP_User($userid);
 		$roles = $tmp_user->roles;
 		$role = array_shift($roles);
@@ -211,10 +260,34 @@
 	endif;
 	?>
 
+<div class="wrap">
+	<h2><?php _e('Search For Users'); ?></h2>
+	<form action="" method="get" name="search" id="search">
+		<p><input type="text" name="usersearch" id="usersearch" value="<?php echo wp_specialchars($_GET['usersearch']); ?>" /> <input type="submit" value="Search &raquo;" /></p>
+	</form>
+</div>
+
+<?php if ( $too_many_users ) : ?>
+<div id="message" class="updated">
+	<p><?php echo $too_many_users; ?></p>
+</div>
+<?php endif; ?>
+
+<?php if ( $userids ) : ?>
+
 <form action="" method="post" name="updateusers" id="updateusers">
 <?php wp_nonce_field('bulk-users') ?>
 <div class="wrap">
-	<h2><?php _e('User List by Role'); ?></h2>
+	<?php if ( $search_term ) : ?>
+		<h2><?php printf(__('Users Matching "%s" by Role'), $search_term); ?></h2>
+		<h3><?php printf(__('Results %s - %s of %s shown below'), $starton + 1, min($starton + $users_per_page, $total_users_for_this_query), $total_users_for_this_query); ?></h3>
+		<div class="user-paging-text"><?php echo $paging_text; ?></div>
+	<?php else : ?>
+		<h2><?php _e('User List by Role'); ?></h2>
+		<?php if ( $paging_text ) : ?>
+			<div class="user-paging-text"><?php echo $paging_text; ?></p></div>
+		<?php endif; ?>
+	<?php endif; ?>
 <table class="widefat">
 <?php
 foreach($roleclasses as $role => $roleclass) {
@@ -222,10 +295,9 @@
 ?>
 
 <tr>
-	<th colspan="8" align="left"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th>
+	<th colspan="7" align="left"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th>
 </tr>
-<thead>
-<tr>
+<tr class="thead">
 	<th style="text-align: left"><?php _e('ID') ?></th>
 	<th style="text-align: left"><?php _e('Username') ?></th>
 	<th style="text-align: left"><?php _e('Name') ?></th>
@@ -250,6 +322,7 @@
 ?>
 </table>
 
+<div class="user-paging-text"><?php echo $paging_text; ?></div>
 
 	<h2><?php _e('Update Users'); ?></h2>
   <ul style="list-style:none;">
@@ -263,6 +336,8 @@
 </div>
 </form>
 
+<?php endif; // if users were returned ?>
+
 <div class="wrap">
 <h2><?php _e('Add New User') ?></h2>
 <?php echo '<p>'.sprintf(__('Users can <a href="%1$s">register themselves</a> or you can manually create users here.'), get_settings('siteurl').'/wp-register.php').'</p>'; ?>
Index: wp-admin.css
===================================================================
--- wp-admin.css	(revision 3850)
+++ wp-admin.css	(working copy)
@@ -52,7 +52,7 @@
 	font-size: 16px;
 }
 
-thead {
+thead, .thead {
 	background: #dfdfdf
 }
 
