Ticket #2793: users_paging_search_bugfixes_TRUNK.diff
File users_paging_search_bugfixes_TRUNK.diff, 5.0 KB (added by , 17 years ago) |
---|
-
users.php
84 84 } 85 85 86 86 if ( !current_user_can('delete_users') ) 87 $error = new WP_Error('edit_users', __('You can’t delete users.'));87 $errors = new WP_Error('edit_users', __('You can’t delete users.')); 88 88 89 89 $userids = $_POST['users']; 90 90 … … 155 155 156 156 include ('admin-header.php'); 157 157 158 $userids = $wpdb->get_col("SELECT ID FROM $wpdb->users;"); 158 // 159 // Paging and Search by Mark Jaquith, June 6th, 2006 160 // 159 161 160 foreach($userids as $userid) { 162 $users_per_page = 50; 163 164 $page = (int) $_GET['userspage']; 165 if ( !$page ) 166 $page = 1; 167 168 $starton = ($page - 1) * $users_per_page; 169 170 $limit = 'LIMIT ' . $starton . ',' . $users_per_page; 171 172 $search_term = $_GET['usersearch']; 173 if ( $search_term ) { 174 $search = array(); 175 $search_sql = 'AND ('; 176 foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col ) 177 $searches[] = $col . " LIKE '%$search_term%'"; 178 $search_sql .= implode(' OR ', $searches); 179 $search_sql .= ')'; 180 } 181 182 if ( !$search_term && $page == 1 && $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users") > $users_per_page ) 183 $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); 184 185 $from_where = "FROM $wpdb->users WHERE 1=1 $search_sql"; 186 $userids = $wpdb->get_col('SELECT ID ' . $from_where . $limit); 187 188 if ( $userids ) { 189 $total_users_for_this_query = $wpdb->get_var('SELECT COUNT(ID) ' . $from_where); // no limit 190 } else { 191 $errors = new WP_Error('no_matching_users_found', __('No matching users were found!')); 192 } 193 194 // Now for the paging 195 if ( $total_users_for_this_query > $users_per_page ) { // have to page the results 196 $prev_page = ( $page > 1) ? true : false; 197 $next_page = ( ($page * $users_per_page) < $total_users_for_this_query ) ? true : false; 198 $paging_text = ''; 199 if ( $prev_page ) 200 $paging_text .= '<p class="alignleft"><a href="' . add_query_arg('userspage', $page - 1) . '">« Previous Page</a></p>'; 201 if ( $next_page ) 202 $paging_text .= '<p class="alignright"><a href="' . add_query_arg('userspage', $page + 1) . '">Next Page »</a></p>'; 203 if ( $prev_page || $next_page ) 204 $paging_text .= '<br style="clear:both" />'; 205 } 206 207 // DONE WITH PAGING AND SEARCH 208 209 foreach ( (array) $userids as $userid ) { 161 210 $tmp_user = new WP_User($userid); 162 211 $roles = $tmp_user->roles; 163 212 $role = array_shift($roles); … … 211 260 endif; 212 261 ?> 213 262 263 <div class="wrap"> 264 <h2><?php _e('Search For Users'); ?></h2> 265 <form action="" method="get" name="search" id="search"> 266 <p><input type="text" name="usersearch" id="usersearch" value="<?php echo wp_specialchars($_GET['usersearch']); ?>" /> <input type="submit" value="Search »" /></p> 267 </form> 268 </div> 269 270 <?php if ( $too_many_users ) : ?> 271 <div id="message" class="updated"> 272 <p><?php echo $too_many_users; ?></p> 273 </div> 274 <?php endif; ?> 275 276 <?php if ( $userids ) : ?> 277 214 278 <form action="" method="post" name="updateusers" id="updateusers"> 215 279 <?php wp_nonce_field('bulk-users') ?> 216 280 <div class="wrap"> 217 <h2><?php _e('User List by Role'); ?></h2> 281 <?php if ( $search_term ) : ?> 282 <h2><?php printf(__('Users Matching "%s" by Role'), $search_term); ?></h2> 283 <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> 284 <div class="user-paging-text"><?php echo $paging_text; ?></div> 285 <?php else : ?> 286 <h2><?php _e('User List by Role'); ?></h2> 287 <?php if ( $paging_text ) : ?> 288 <div class="user-paging-text"><?php echo $paging_text; ?></p></div> 289 <?php endif; ?> 290 <?php endif; ?> 218 291 <table class="widefat"> 219 292 <?php 220 293 foreach($roleclasses as $role => $roleclass) { … … 222 295 ?> 223 296 224 297 <tr> 225 <th colspan=" 8" align="left"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th>298 <th colspan="7" align="left"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th> 226 299 </tr> 227 <thead> 228 <tr> 300 <tr class="thead"> 229 301 <th style="text-align: left"><?php _e('ID') ?></th> 230 302 <th style="text-align: left"><?php _e('Username') ?></th> 231 303 <th style="text-align: left"><?php _e('Name') ?></th> … … 250 322 ?> 251 323 </table> 252 324 325 <div class="user-paging-text"><?php echo $paging_text; ?></div> 253 326 254 327 <h2><?php _e('Update Users'); ?></h2> 255 328 <ul style="list-style:none;"> … … 263 336 </div> 264 337 </form> 265 338 339 <?php endif; // if users were returned ?> 340 266 341 <div class="wrap"> 267 342 <h2><?php _e('Add New User') ?></h2> 268 343 <?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>'; ?> -
wp-admin.css
52 52 font-size: 16px; 53 53 } 54 54 55 thead {55 thead, .thead { 56 56 background: #dfdfdf 57 57 } 58 58