Changes in trunk/wp-admin/users.php [17439:15152]
- File:
-
- 1 edited
-
trunk/wp-admin/users.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/users.php
r17439 r15152 8 8 9 9 /** WordPress Administration Bootstrap */ 10 require_once( './admin.php' ); 11 12 if ( ! current_user_can( 'list_users' ) ) 13 wp_die( __( 'Cheatin’ uh?' ) ); 14 15 $wp_list_table = _get_list_table('WP_Users_List_Table'); 16 $pagenum = $wp_list_table->get_pagenum(); 10 require_once('./admin.php'); 11 12 /** WordPress Registration API */ 13 require_once( ABSPATH . WPINC . '/registration.php'); 14 15 if ( !current_user_can('list_users') ) 16 wp_die(__('Cheatin’ uh?')); 17 17 18 $title = __('Users'); 18 19 $parent_file = 'users.php'; 19 20 20 add_screen_option( 'per_page', array('label' => _x( 'Users', 'users per page (screen options)' )) );21 22 21 // contextual help - choose Help on the top right of admin panel to preview this. 23 22 add_contextual_help($current_screen, 24 '<p>' . __('This screen lists all the existing users for your site. Each user has one of five defined roles as set by the site admin: Site Administrator, Editor, Author, Contributor, or Subscriber. Users with roles other than Administrator will see fewer options in the dashboard navigationwhen they are logged in, based on their role.') . '</p>' .23 '<p>' . __('This screen lists all the existing users for your site. Each user has one of five defined roles as set by the site admin: Site Administrator, Editor, Author, Contributor, or Subscriber. Users with roles other than Administrator will see fewer options when they are logged in, based on their role.') . '</p>' . 25 24 '<p>' . __('You can customize the display of information on this screen as you can on other screens, by using the Screen Options tab and the on-screen filters.') . '</p>' . 26 25 '<p>' . __('To add a new user for your site, click the Add New button at the top of the screen or Add New in the Users menu section.') . '</p>' . 27 26 '<p><strong>' . __('For more information:') . '</strong></p>' . 28 '<p>' . __('<a href="http://codex.wordpress.org/Users_ Users_SubPanel" target="_blank">Documentation on ManagingUsers</a>') . '</p>' .29 '<p>' . __('<a href="http://codex.wordpress.org/Roles_and_Capabilities" target="_blank"> Descriptions of Roles and Capabilities</a>') . '</p>' .27 '<p>' . __('<a href="http://codex.wordpress.org/Users_Authors_and_Users_SubPanel" target="_blank">Documentation on Authors and Users</a>') . '</p>' . 28 '<p>' . __('<a href="http://codex.wordpress.org/Roles_and_Capabilities" target="_blank">Roles and Capabilities Descriptions</a>') . '</p>' . 30 29 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' 31 30 ); 31 32 $update = $doaction = ''; 33 if ( isset($_REQUEST['action']) ) 34 $doaction = $_REQUEST['action'] ? $_REQUEST['action'] : $_REQUEST['action2']; 35 36 if ( empty($doaction) ) { 37 if ( isset($_GET['changeit']) && !empty($_GET['new_role']) ) 38 $doaction = 'promote'; 39 } 32 40 33 41 if ( empty($_REQUEST) ) { … … 41 49 } 42 50 43 $update = ''; 44 45 switch ( $wp_list_table->current_action() ) { 51 switch ($doaction) { 46 52 47 53 /* Bulk Dropdown menu Role changes */ 48 54 case 'promote': 49 55 check_admin_referer('bulk-users'); 50 51 if ( ! current_user_can( 'promote_users' ) )52 wp_die( __( 'You can’t edit that user.' ) );53 56 54 57 if ( empty($_REQUEST['users']) ) { … … 176 179 } 177 180 } 181 // @todo Delete is always for !is_multisite(). Use API. 182 if ( !is_multisite() ) { 183 $all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY user_login"); 184 } else { 185 // WPMU only searches users of current blog 186 $all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users, $wpdb->usermeta WHERE $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '".$wpdb->prefix."capabilities' ORDER BY user_login"); 187 } 188 $user_dropdown = '<select name="reassign_user">'; 189 foreach ( (array) $all_logins as $login ) 190 if ( $login->ID == $current_user->ID || !in_array($login->ID, $userids) ) 191 $user_dropdown .= "<option value=\"" . esc_attr($login->ID) . "\">{$login->user_login}</option>"; 192 $user_dropdown .= '</select>'; 178 193 ?> 179 194 </ul> … … 184 199 <?php _e('Delete all posts and links.'); ?></label></li> 185 200 <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" /> 186 <?php echo '<label for="delete_option1">'.__('Attribute all posts and links to:').'</label>'; 187 wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li> 201 <?php echo '<label for="delete_option1">'.__('Attribute all posts and links to:')."</label> $user_dropdown"; ?></li> 188 202 </ul></fieldset> 189 203 <input type="hidden" name="action" value="dodelete" /> 190 < ?php submit_button( __('Confirm Deletion'), 'secondary' ); ?>204 <p class="submit"><input type="submit" name="submit" value="<?php esc_attr_e('Confirm Deletion'); ?>" class="button-secondary" /></p> 191 205 <?php else : ?> 192 206 <p><?php _e('There are no valid users selected for deletion.'); ?></p> … … 201 215 check_admin_referer('remove-users'); 202 216 203 if ( ! is_multisite() )204 wp_die( __( 'You can’t remove users.' ) );205 206 217 if ( empty($_REQUEST['users']) ) { 207 218 wp_redirect($redirect); … … 209 220 } 210 221 211 if ( ! current_user_can( 'remove_users' ))212 wp_die( __( 'You can’t remove users.' ));222 if ( !current_user_can('remove_users') ) 223 die(__('You can’t remove users.')); 213 224 214 225 $userids = $_REQUEST['users']; … … 237 248 238 249 check_admin_referer('bulk-users'); 239 240 if ( ! is_multisite() )241 wp_die( __( 'You can’t remove users.' ) );242 250 243 251 if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) { … … 282 290 <?php if ( $go_remove ) : ?> 283 291 <input type="hidden" name="action" value="doremove" /> 284 < ?php submit_button( __('Confirm Removal'), 'secondary' ); ?>292 <p class="submit"><input type="submit" name="submit" value="<?php esc_attr_e('Confirm Removal'); ?>" class="button-secondary" /></p> 285 293 <?php else : ?> 286 294 <p><?php _e('There are no valid users selected for removal.'); ?></p> … … 299 307 } 300 308 301 $wp_list_table->prepare_items();302 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );303 if ( $pagenum > $total_pages && $total_pages > 0 ) {304 wp_redirect( add_query_arg( 'paged', $total_pages ) );305 exit;306 }307 309 include('./admin-header.php'); 310 311 $usersearch = isset($_GET['usersearch']) ? $_GET['usersearch'] : null; 312 $userspage = isset($_GET['userspage']) ? $_GET['userspage'] : null; 313 $role = isset($_GET['role']) ? $_GET['role'] : null; 314 315 // Query the user IDs for this page 316 $wp_user_search = new WP_User_Search($usersearch, $userspage, $role); 317 318 // Query the post counts for this page 319 $post_counts = count_many_users_posts($wp_user_search->get_results()); 320 321 // Query the users for this page 322 cache_users($wp_user_search->get_results()); 308 323 309 324 $messages = array(); … … 357 372 <div class="wrap"> 358 373 <?php screen_icon(); ?> 359 <h2> 360 <?php 361 echo esc_html( $title ); 362 if ( current_user_can( 'create_users' ) ) { ?> 363 <a href="user-new.php" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'user' ); ?></a> 364 <?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?> 365 <a href="user-new.php" class="button add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a> 366 <?php } 367 368 if ( $usersearch ) 369 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $usersearch ) ); ?> 374 <h2><?php echo esc_html( $title ); if ( current_user_can( 'create_users' ) ) { ?> <a href="user-new.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'user'); ?></a><?php } 375 if ( isset($_GET['usersearch']) && $_GET['usersearch'] ) 376 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $_GET['usersearch'] ) ); ?> 370 377 </h2> 371 378 372 <?php $wp_list_table->views(); ?> 373 374 <form action="" method="get"> 375 376 <?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?> 377 378 <?php $wp_list_table->display(); ?> 379 <div class="filter"> 380 <form id="list-filter" action="" method="get"> 381 <ul class="subsubsub"> 382 <?php 383 $users_of_blog = count_users(); 384 $total_users = $users_of_blog['total_users']; 385 $avail_roles =& $users_of_blog['avail_roles']; 386 unset($users_of_blog); 387 388 $current_role = false; 389 $class = empty($role) ? ' class="current"' : ''; 390 $role_links = array(); 391 $role_links[] = "<li><a href='users.php'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>'; 392 foreach ( $wp_roles->get_names() as $this_role => $name ) { 393 if ( !isset($avail_roles[$this_role]) ) 394 continue; 395 396 $class = ''; 397 398 if ( $this_role == $role ) { 399 $current_role = $role; 400 $class = ' class="current"'; 401 } 402 403 $name = translate_user_role( $name ); 404 /* translators: User role name with count */ 405 $name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, $avail_roles[$this_role] ); 406 $role_links[] = "<li><a href='users.php?role=$this_role'$class>$name</a>"; 407 } 408 echo implode( " |</li>\n", $role_links) . '</li>'; 409 unset($role_links); 410 ?> 411 </ul> 379 412 </form> 413 </div> 414 415 <form class="search-form" action="" method="get"> 416 <p class="search-box"> 417 <label class="screen-reader-text" for="user-search-input"><?php _e( 'Search Users' ); ?>:</label> 418 <input type="text" id="user-search-input" name="usersearch" value="<?php echo esc_attr($wp_user_search->search_term); ?>" /> 419 <input type="submit" value="<?php esc_attr_e( 'Search Users' ); ?>" class="button" /> 420 </p> 421 </form> 422 423 <form id="posts-filter" action="" method="get"> 424 <div class="tablenav"> 425 426 <?php if ( $wp_user_search->results_are_paged() ) : ?> 427 <div class="tablenav-pages"><?php $wp_user_search->page_links(); ?></div> 428 <?php endif; ?> 429 430 <div class="alignleft actions"> 431 <select name="action"> 432 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option> 433 <?php if ( !is_multisite() && current_user_can('delete_users') ) { ?> 434 <option value="delete"><?php _e('Delete'); ?></option> 435 <?php } else { ?> 436 <option value="remove"><?php _e('Remove'); ?></option> 437 <?php } ?> 438 </select> 439 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" /> 440 <label class="screen-reader-text" for="new_role"><?php _e('Change role to…') ?></label><select name="new_role" id="new_role"><option value=''><?php _e('Change role to…') ?></option><?php wp_dropdown_roles(); ?></select> 441 <input type="submit" value="<?php esc_attr_e('Change'); ?>" name="changeit" class="button-secondary" /> 442 <?php wp_nonce_field('bulk-users'); ?> 443 </div> 444 445 <br class="clear" /> 446 </div> 447 448 <?php if ( is_wp_error( $wp_user_search->search_errors ) ) : ?> 449 <div class="error"> 450 <ul> 451 <?php 452 foreach ( $wp_user_search->search_errors->get_error_messages() as $message ) 453 echo "<li>$message</li>"; 454 ?> 455 </ul> 456 </div> 457 <?php endif; ?> 458 459 460 <?php if ( $wp_user_search->get_results() ) : ?> 461 462 <?php if ( $wp_user_search->is_search() ) : ?> 463 <p><a href="users.php"><?php _e('← Back to All Users'); ?></a></p> 464 <?php endif; ?> 465 466 <table class="widefat fixed" cellspacing="0"> 467 <thead> 468 <tr class="thead"> 469 <?php print_column_headers('users') ?> 470 </tr> 471 </thead> 472 473 <tfoot> 474 <tr class="thead"> 475 <?php print_column_headers('users', false) ?> 476 </tr> 477 </tfoot> 478 479 <tbody id="users" class="list:user user-list"> 480 <?php 481 $style = ''; 482 foreach ( $wp_user_search->get_results() as $userid ) { 483 $user_object = new WP_User($userid); 484 $roles = $user_object->roles; 485 $role = array_shift($roles); 486 487 if ( is_multisite() && empty( $role ) ) 488 continue; 489 490 $style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"'; 491 echo "\n\t", user_row( $user_object, $style, $role, $post_counts[ $userid ] ); 492 } 493 ?> 494 </tbody> 495 </table> 496 497 <div class="tablenav"> 498 499 <?php if ( $wp_user_search->results_are_paged() ) : ?> 500 <div class="tablenav-pages"><?php $wp_user_search->page_links(); ?></div> 501 <?php endif; ?> 502 503 <div class="alignleft actions"> 504 <select name="action2"> 505 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option> 506 <?php if ( !is_multisite() && current_user_can('delete_users') ) { ?> 507 <option value="delete"><?php _e('Delete'); ?></option> 508 <?php } else { ?> 509 <option value="remove"><?php _e('Remove'); ?></option> 510 <?php } ?></select> 511 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 512 </div> 513 514 <br class="clear" /> 515 </div> 516 517 <?php endif; ?> 518 519 </form> 520 </div> 380 521 381 522 <?php … … 390 531 391 532 <br class="clear" /> 392 </div>393 533 <?php 394 534 break; … … 397 537 398 538 include('./admin-footer.php'); 539 ?>
Note: See TracChangeset
for help on using the changeset viewer.