Changeset 6875
- Timestamp:
- 02/16/2008 09:44:50 PM (17 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/template.php
r6865 r6875 512 512 513 513 function user_row( $user_object, $style = '', $role = '' ) { 514 global $wp_roles; 515 514 516 if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) ) 515 517 $user_object = new WP_User( (int) $user_object ); … … 534 536 <td>$user_object->first_name $user_object->last_name</td> 535 537 <td><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td> 536 <td> <a href='$url' title='website: $url'>$short_url</a></td>";538 <td>{$wp_roles->role_names[$role]}</td>"; 537 539 $r .= "\n\t\t<td>"; 538 540 if ( $numposts > 0 ) { -
trunk/wp-admin/includes/user.php
r6615 r6875 290 290 var $search_term; 291 291 var $page; 292 var $role; 292 293 var $raw_page; 293 294 var $users_per_page = 50; … … 300 301 var $search_errors; 301 302 302 function WP_User_Search ($search_term = '', $page = '' ) { // constructor303 function WP_User_Search ($search_term = '', $page = '', $role = '') { // constructor 303 304 $this->search_term = $search_term; 304 305 $this->raw_page = ( '' == $page ) ? false : (int) $page; 305 306 $this->page = (int) ( '' == $page ) ? 1 : $page; 307 $this->role = $role; 306 308 307 309 $this->prepare_query(); … … 315 317 $this->first_user = ($this->page - 1) * $this->users_per_page; 316 318 $this->query_limit = 'LIMIT ' . $this->first_user . ',' . $this->users_per_page; 319 $search_sql = ''; 317 320 if ( $this->search_term ) { 318 321 $searches = array(); … … 323 326 $search_sql .= ')'; 324 327 } 325 $this->query_from_where = "FROM $wpdb->users WHERE 1=1 $search_sql"; 328 329 $this->query_from_where = "FROM $wpdb->users"; 330 if ( $this->role ) 331 $this->query_from_where .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE '%$this->role%'"; 332 else 333 $this->query_from_where .= " WHERE 1=1"; 334 $this->query_from_where .= " $search_sql"; 326 335 327 336 } … … 346 355 'total' => ceil($this->total_users_for_query / $this->users_per_page), 347 356 'current' => $this->page, 348 'prev_text' => __('« Previous Page'),349 'next_text' => __('Next Page »'),350 357 'base' => 'users.php?%_%', 351 358 'format' => 'userspage=%#%', -
trunk/wp-admin/users.php
r6852 r6875 12 12 $update = ''; 13 13 14 if ( empty($_POST) ) { 14 if ( empty($action) && isset($_GET['deleteit']) ) 15 $action = 'delete'; 16 17 if ( empty($_REQUEST) ) { 15 18 $referer = '<input type="hidden" name="wp_http_referer" value="'. attribute_escape(stripslashes($_SERVER['REQUEST_URI'])) . '" />'; 16 } elseif ( isset($_ POST['wp_http_referer']) ) {17 $redirect = remove_query_arg(array('wp_http_referer', 'updated', 'delete_count'), stripslashes($_ POST['wp_http_referer']));19 } elseif ( isset($_REQUEST['wp_http_referer']) ) { 20 $redirect = remove_query_arg(array('wp_http_referer', 'updated', 'delete_count'), stripslashes($_REQUEST['wp_http_referer'])); 18 21 $referer = '<input type="hidden" name="wp_http_referer" value="' . attribute_escape($redirect) . '" />'; 19 22 } else { … … 26 29 check_admin_referer('bulk-users'); 27 30 28 if (empty($_ POST['users'])) {31 if (empty($_REQUEST['users'])) { 29 32 wp_redirect($redirect); 30 33 exit(); … … 34 37 wp_die(__('You can’t edit users.')); 35 38 36 $userids = $_ POST['users'];39 $userids = $_REQUEST['users']; 37 40 $update = 'promote'; 38 41 foreach($userids as $id) { … … 40 43 wp_die(__('You can’t edit that user.')); 41 44 // The new role of the current user must also have edit_users caps 42 if($id == $current_user->ID && !$wp_roles->role_objects[$_ POST['new_role']]->has_cap('edit_users')) {45 if($id == $current_user->ID && !$wp_roles->role_objects[$_REQUEST['new_role']]->has_cap('edit_users')) { 43 46 $update = 'err_admin_role'; 44 47 continue; … … 46 49 47 50 $user = new WP_User($id); 48 $user->set_role($_ POST['new_role']);51 $user->set_role($_REQUEST['new_role']); 49 52 } 50 53 … … 58 61 check_admin_referer('delete-users'); 59 62 60 if ( empty($_ POST['users']) ) {63 if ( empty($_REQUEST['users']) ) { 61 64 wp_redirect($redirect); 62 65 exit(); … … 66 69 wp_die(__('You can’t delete users.')); 67 70 68 $userids = $_ POST['users'];71 $userids = $_REQUEST['users']; 69 72 $update = 'del'; 70 73 $delete_count = 0; … … 78 81 continue; 79 82 } 80 switch($_ POST['delete_option']) {83 switch($_REQUEST['delete_option']) { 81 84 case 'delete': 82 85 wp_delete_user($id); 83 86 break; 84 87 case 'reassign': 85 wp_delete_user($id, $_ POST['reassign_user']);88 wp_delete_user($id, $_REQUEST['reassign_user']); 86 89 break; 87 90 } … … 99 102 check_admin_referer('bulk-users'); 100 103 101 if ( empty($_ POST['users']) ) {104 if ( empty($_REQUEST['users']) ) { 102 105 wp_redirect($redirect); 103 106 exit(); … … 107 110 $errors = new WP_Error('edit_users', __('You can’t delete users.')); 108 111 109 $userids = $_ POST['users'];112 $userids = $_REQUEST['users']; 110 113 111 114 include ('admin-header.php'); … … 168 171 $add_user_errors = $user_id; 169 172 else { 170 $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_ POST['user_login']), true));173 $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_REQUEST['user_login']), true)); 171 174 $redirect = add_query_arg( array('usersearch' => urlencode($new_user_login), 'update' => $update), $redirect ); 172 175 wp_redirect( $redirect . '#user-' . $user_id ); … … 181 184 182 185 // Query the users 183 $wp_user_search = new WP_User_Search($_GET['usersearch'], $_GET['userspage'] );186 $wp_user_search = new WP_User_Search($_GET['usersearch'], $_GET['userspage'], $_GET['role']); 184 187 185 188 // Make the user objects … … 237 240 238 241 <div class="wrap"> 239 242 <form id="posts-filter" action="" method="get"> 240 243 <?php if ( $wp_user_search->is_search() ) : ?> 241 <h2><?php printf(__('Users Matching "%s" by Role'), wp_specialchars($wp_user_search->search_term)); ?></h2>244 <h2><?php printf(__('Users Matching "%s"'), wp_specialchars($wp_user_search->search_term)); ?></h2> 242 245 <?php else : ?> 243 <h2><?php _e(' User List by Role'); ?></h2>246 <h2><?php _e('Manage Users'); ?></h2> 244 247 <?php endif; ?> 245 248 246 <form action="" method="get" name="search" id="search"> 247 <p><input type="text" name="usersearch" id="usersearch" value="<?php echo attribute_escape($wp_user_search->search_term); ?>" /> <input type="submit" value="<?php _e('Search Users »'); ?>" class="button" /></p> 248 </form> 249 <ul class="subsubsub"> 250 <?php 251 $role_links = array(); 252 foreach ( $wp_roles->get_names() as $role => $name ) { 253 $class = ''; 254 255 if ( $role == $_GET['role'] ) 256 $class = ' class="current"'; 257 258 $role_links[] = "<li><a href=\"users.php?role=$role\"$class>" . $name . '</a>'; 259 } 260 $class = empty($_GET['role']) ? ' class="current"' : ''; 261 $role_links[] = "<li><a href=\"users.php\"$class>" . __('All Users') . "</a>"; 262 echo implode(' |</li>', $role_links) . '</li>'; 263 unset($role_links); 264 ?> 265 </ul> 266 <p id="post-search"> 267 <input type="text" id="post-search-input" name="usersearch" value="<?php echo attribute_escape($wp_user_search->search_term); ?>" /> 268 <input type="submit" value="<?php _e( 'Search Users' ); ?>" /> 269 </p> 270 271 <br style="clear:both;" /> 272 273 <div class="tablenav"> 274 275 <?php if ( $wp_user_search->results_are_paged() ) : ?> 276 <div class="tablenav-pages"><?php $wp_user_search->page_links(); ?></div> 277 <?php endif; ?> 278 279 <div style="float: left"> 280 <input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" /> 281 <?php wp_nonce_field('bulk-users'); ?> 282 </div> 283 284 <br style="clear:both;" /> 285 </div> 286 287 <br style="clear:both;" /> 249 288 250 289 <?php if ( is_wp_error( $wp_user_search->search_errors ) ) : ?> … … 272 311 printf(__('%1$s – %2$s of %3$s shown below'), $wp_user_search->first_user + 1, min($wp_user_search->first_user + $wp_user_search->users_per_page, $wp_user_search->total_users_for_query), $wp_user_search->total_users_for_query); ?></h3> 273 312 274 <?php if ( $wp_user_search->results_are_paged() ) : ?>275 <div class="user-paging-text"><p><?php $wp_user_search->page_links(); ?></p></div>276 <?php endif; ?>277 278 313 <form action="" method="post" name="updateusers" id="updateusers"> 279 314 <?php wp_nonce_field('bulk-users') ?> 280 315 <table class="widefat"> 281 <?php282 foreach($roleclasses as $role => $roleclass) {283 uksort($roleclass, "strnatcasecmp");284 ?>285 316 <tbody> 286 <tr>287 <?php if ( !empty($role) ) : ?>288 <th colspan="7"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th>289 <?php else : ?>290 <th colspan="7"><h3><em><?php _e('No role for this blog'); ?></em></h3></th>291 <?php endif; ?>292 </tr>293 317 <tr class="thead"> 294 318 <th><input type="checkbox" onclick="checkAllUsers('<?php echo $role; ?>')"/> </th> … … 296 320 <th><?php _e('Name') ?></th> 297 321 <th><?php _e('E-mail') ?></th> 298 <th><?php _e(' Website') ?></th>322 <th><?php _e('Role') ?></th> 299 323 <th><?php _e('Posts') ?></th> 300 324 </tr> 301 325 </tbody> 326 <?php 327 foreach ($roleclasses as $role => $roleclass) { 328 uksort($roleclass, "strnatcasecmp"); 329 ?> 302 330 <tbody id="role-<?php echo $role; ?>" class="list:user user-list"><?php 303 331 $style = ''; … … 312 340 </table> 313 341 342 <br style="clear:both;" /> 343 344 <div class="tablenav"> 345 314 346 <?php if ( $wp_user_search->results_are_paged() ) : ?> 315 <div class="user-paging-text"><p><?php $wp_user_search->page_links(); ?></p></div> 316 <?php endif; ?> 317 318 <h3><?php _e('Update Selected'); ?></h3> 319 <ul style="list-style:none;"> 320 <li><input type="radio" name="action" id="action0" value="delete" /> <label for="action0"><?php _e('Delete checked users.'); ?></label></li> 321 <li> 322 <input type="radio" name="action" id="action1" value="promote" /> <label for="action1"><?php _e('Set the Role of checked users to:'); ?></label> 323 <select name="new_role" onchange="getElementById('action1').checked = 'true'"><?php wp_dropdown_roles(); ?></select> 324 </li> 325 </ul> 326 <p class="submit" style="width: 420px"> 327 <?php echo $referer; ?> 328 <input type="submit" value="<?php _e('Bulk Update »'); ?>" /> 329 </p> 347 <div class="tablenav-pages"><?php $wp_user_search->page_links(); ?></div> 348 <?php endif; ?> 349 350 <br style="clear:both;" /> 351 </div> 352 330 353 </form> 331 354 <?php endif; ?> 355 332 356 </div> 333 357 … … 336 360 foreach ( array('user_login' => 'user_login', 'first_name' => 'user_firstname', 'last_name' => 'user_lastname', 'email' => 'user_email', 'url' => 'user_uri', 'role' => 'user_role') as $formpost => $var ) { 337 361 $var = 'new_' . $var; 338 $$var = attribute_escape(stripslashes($_ POST[$formpost]));362 $$var = attribute_escape(stripslashes($_REQUEST[$formpost])); 339 363 } 340 364 unset($name); 341 365 } 342 366 ?> 367 368 <br style="clear:both;" /> 343 369 344 370 <div class="wrap">
Note: See TracChangeset
for help on using the changeset viewer.