| 1 | Index: users.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- users.php (revision 3850) |
|---|
| 4 | +++ users.php (working copy) |
|---|
| 5 | @@ -84,7 +84,7 @@ |
|---|
| 6 | } |
|---|
| 7 | |
|---|
| 8 | if ( !current_user_can('delete_users') ) |
|---|
| 9 | - $error = new WP_Error('edit_users', __('You can’t delete users.')); |
|---|
| 10 | + $errors = new WP_Error('edit_users', __('You can’t delete users.')); |
|---|
| 11 | |
|---|
| 12 | $userids = $_POST['users']; |
|---|
| 13 | |
|---|
| 14 | @@ -155,9 +155,58 @@ |
|---|
| 15 | |
|---|
| 16 | include ('admin-header.php'); |
|---|
| 17 | |
|---|
| 18 | - $userids = $wpdb->get_col("SELECT ID FROM $wpdb->users;"); |
|---|
| 19 | + // |
|---|
| 20 | + // Paging and Search by Mark Jaquith, June 6th, 2006 |
|---|
| 21 | + // |
|---|
| 22 | |
|---|
| 23 | - foreach($userids as $userid) { |
|---|
| 24 | + $users_per_page = 50; |
|---|
| 25 | + |
|---|
| 26 | + $page = (int) $_GET['userspage']; |
|---|
| 27 | + if ( !$page ) |
|---|
| 28 | + $page = 1; |
|---|
| 29 | + |
|---|
| 30 | + $starton = ($page - 1) * $users_per_page; |
|---|
| 31 | + |
|---|
| 32 | + $limit = 'LIMIT ' . $starton . ',' . $users_per_page; |
|---|
| 33 | + |
|---|
| 34 | + $search_term = $_GET['usersearch']; |
|---|
| 35 | + if ( $search_term ) { |
|---|
| 36 | + $search = array(); |
|---|
| 37 | + $search_sql = 'AND ('; |
|---|
| 38 | + foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col ) |
|---|
| 39 | + $searches[] = $col . " LIKE '%$search_term%'"; |
|---|
| 40 | + $search_sql .= implode(' OR ', $searches); |
|---|
| 41 | + $search_sql .= ')'; |
|---|
| 42 | + } |
|---|
| 43 | + |
|---|
| 44 | + if ( !$search_term && $page == 1 && $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users") > $users_per_page ) |
|---|
| 45 | + $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); |
|---|
| 46 | + |
|---|
| 47 | + $from_where = "FROM $wpdb->users WHERE 1=1 $search_sql"; |
|---|
| 48 | + $userids = $wpdb->get_col('SELECT ID ' . $from_where . $limit); |
|---|
| 49 | + |
|---|
| 50 | + if ( $userids ) { |
|---|
| 51 | + $total_users_for_this_query = $wpdb->get_var('SELECT COUNT(ID) ' . $from_where); // no limit |
|---|
| 52 | + } else { |
|---|
| 53 | + $errors = new WP_Error('no_matching_users_found', __('No matching users were found!')); |
|---|
| 54 | + } |
|---|
| 55 | + |
|---|
| 56 | + // Now for the paging |
|---|
| 57 | + if ( $total_users_for_this_query > $users_per_page ) { // have to page the results |
|---|
| 58 | + $prev_page = ( $page > 1) ? true : false; |
|---|
| 59 | + $next_page = ( ($page * $users_per_page) < $total_users_for_this_query ) ? true : false; |
|---|
| 60 | + $paging_text = ''; |
|---|
| 61 | + if ( $prev_page ) |
|---|
| 62 | + $paging_text .= '<p class="alignleft"><a href="' . add_query_arg('userspage', $page - 1) . '">« Previous Page</a></p>'; |
|---|
| 63 | + if ( $next_page ) |
|---|
| 64 | + $paging_text .= '<p class="alignright"><a href="' . add_query_arg('userspage', $page + 1) . '">Next Page »</a></p>'; |
|---|
| 65 | + if ( $prev_page || $next_page ) |
|---|
| 66 | + $paging_text .= '<br style="clear:both" />'; |
|---|
| 67 | + } |
|---|
| 68 | + |
|---|
| 69 | + // DONE WITH PAGING AND SEARCH |
|---|
| 70 | + |
|---|
| 71 | + foreach ( (array) $userids as $userid ) { |
|---|
| 72 | $tmp_user = new WP_User($userid); |
|---|
| 73 | $roles = $tmp_user->roles; |
|---|
| 74 | $role = array_shift($roles); |
|---|
| 75 | @@ -211,10 +260,34 @@ |
|---|
| 76 | endif; |
|---|
| 77 | ?> |
|---|
| 78 | |
|---|
| 79 | +<div class="wrap"> |
|---|
| 80 | + <h2><?php _e('Search For Users'); ?></h2> |
|---|
| 81 | + <form action="" method="get" name="search" id="search"> |
|---|
| 82 | + <p><input type="text" name="usersearch" id="usersearch" value="<?php echo wp_specialchars($_GET['usersearch']); ?>" /> <input type="submit" value="Search »" /></p> |
|---|
| 83 | + </form> |
|---|
| 84 | +</div> |
|---|
| 85 | + |
|---|
| 86 | +<?php if ( $too_many_users ) : ?> |
|---|
| 87 | +<div id="message" class="updated"> |
|---|
| 88 | + <p><?php echo $too_many_users; ?></p> |
|---|
| 89 | +</div> |
|---|
| 90 | +<?php endif; ?> |
|---|
| 91 | + |
|---|
| 92 | +<?php if ( $userids ) : ?> |
|---|
| 93 | + |
|---|
| 94 | <form action="" method="post" name="updateusers" id="updateusers"> |
|---|
| 95 | <?php wp_nonce_field('bulk-users') ?> |
|---|
| 96 | <div class="wrap"> |
|---|
| 97 | - <h2><?php _e('User List by Role'); ?></h2> |
|---|
| 98 | + <?php if ( $search_term ) : ?> |
|---|
| 99 | + <h2><?php printf(__('Users Matching "%s" by Role'), $search_term); ?></h2> |
|---|
| 100 | + <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> |
|---|
| 101 | + <div class="user-paging-text"><?php echo $paging_text; ?></div> |
|---|
| 102 | + <?php else : ?> |
|---|
| 103 | + <h2><?php _e('User List by Role'); ?></h2> |
|---|
| 104 | + <?php if ( $paging_text ) : ?> |
|---|
| 105 | + <div class="user-paging-text"><?php echo $paging_text; ?></p></div> |
|---|
| 106 | + <?php endif; ?> |
|---|
| 107 | + <?php endif; ?> |
|---|
| 108 | <table class="widefat"> |
|---|
| 109 | <?php |
|---|
| 110 | foreach($roleclasses as $role => $roleclass) { |
|---|
| 111 | @@ -222,10 +295,9 @@ |
|---|
| 112 | ?> |
|---|
| 113 | |
|---|
| 114 | <tr> |
|---|
| 115 | - <th colspan="8" align="left"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th> |
|---|
| 116 | + <th colspan="7" align="left"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th> |
|---|
| 117 | </tr> |
|---|
| 118 | -<thead> |
|---|
| 119 | -<tr> |
|---|
| 120 | +<tr class="thead"> |
|---|
| 121 | <th style="text-align: left"><?php _e('ID') ?></th> |
|---|
| 122 | <th style="text-align: left"><?php _e('Username') ?></th> |
|---|
| 123 | <th style="text-align: left"><?php _e('Name') ?></th> |
|---|
| 124 | @@ -250,6 +322,7 @@ |
|---|
| 125 | ?> |
|---|
| 126 | </table> |
|---|
| 127 | |
|---|
| 128 | +<div class="user-paging-text"><?php echo $paging_text; ?></div> |
|---|
| 129 | |
|---|
| 130 | <h2><?php _e('Update Users'); ?></h2> |
|---|
| 131 | <ul style="list-style:none;"> |
|---|
| 132 | @@ -263,6 +336,8 @@ |
|---|
| 133 | </div> |
|---|
| 134 | </form> |
|---|
| 135 | |
|---|
| 136 | +<?php endif; // if users were returned ?> |
|---|
| 137 | + |
|---|
| 138 | <div class="wrap"> |
|---|
| 139 | <h2><?php _e('Add New User') ?></h2> |
|---|
| 140 | <?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>'; ?> |
|---|
| 141 | Index: wp-admin.css |
|---|
| 142 | =================================================================== |
|---|
| 143 | --- wp-admin.css (revision 3850) |
|---|
| 144 | +++ wp-admin.css (working copy) |
|---|
| 145 | @@ -52,7 +52,7 @@ |
|---|
| 146 | font-size: 16px; |
|---|
| 147 | } |
|---|
| 148 | |
|---|
| 149 | -thead { |
|---|
| 150 | +thead, .thead { |
|---|
| 151 | background: #dfdfdf |
|---|
| 152 | } |
|---|
| 153 | |
|---|