Make WordPress Core

Changeset 6875


Ignore:
Timestamp:
02/16/2008 09:44:50 PM (16 years ago)
Author:
ryan
Message:

users.php redesign. WIP

Location:
trunk/wp-admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/template.php

    r6865 r6875  
    512512
    513513function user_row( $user_object, $style = '', $role = '' ) {
     514    global $wp_roles;
     515
    514516    if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) )
    515517        $user_object = new WP_User( (int) $user_object );
     
    534536        <td>$user_object->first_name $user_object->last_name</td>
    535537        <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>";
    537539    $r .= "\n\t\t<td>";
    538540    if ( $numposts > 0 ) {
  • trunk/wp-admin/includes/user.php

    r6615 r6875  
    290290    var $search_term;
    291291    var $page;
     292    var $role;
    292293    var $raw_page;
    293294    var $users_per_page = 50;
     
    300301    var $search_errors;
    301302
    302     function WP_User_Search ($search_term = '', $page = '') { // constructor
     303    function WP_User_Search ($search_term = '', $page = '', $role = '') { // constructor
    303304        $this->search_term = $search_term;
    304305        $this->raw_page = ( '' == $page ) ? false : (int) $page;
    305306        $this->page = (int) ( '' == $page ) ? 1 : $page;
     307        $this->role = $role;
    306308
    307309        $this->prepare_query();
     
    315317        $this->first_user = ($this->page - 1) * $this->users_per_page;
    316318        $this->query_limit = 'LIMIT ' . $this->first_user . ',' . $this->users_per_page;
     319        $search_sql = '';
    317320        if ( $this->search_term ) {
    318321            $searches = array();
     
    323326            $search_sql .= ')';
    324327        }
    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";
    326335
    327336    }
     
    346355                'total' => ceil($this->total_users_for_query / $this->users_per_page),
    347356                'current' => $this->page,
    348                 'prev_text' => __('&laquo; Previous Page'),
    349                 'next_text' => __('Next Page &raquo;'),
    350357                'base' => 'users.php?%_%',
    351358                'format' => 'userspage=%#%',
  • trunk/wp-admin/users.php

    r6852 r6875  
    1212$update = '';
    1313
    14 if ( empty($_POST) ) {
     14if ( empty($action) && isset($_GET['deleteit']) )
     15    $action = 'delete';
     16
     17if ( empty($_REQUEST) ) {
    1518    $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']));
    1821    $referer = '<input type="hidden" name="wp_http_referer" value="' . attribute_escape($redirect) . '" />';
    1922} else {
     
    2629    check_admin_referer('bulk-users');
    2730
    28     if (empty($_POST['users'])) {
     31    if (empty($_REQUEST['users'])) {
    2932        wp_redirect($redirect);
    3033        exit();
     
    3437        wp_die(__('You can&#8217;t edit users.'));
    3538
    36     $userids = $_POST['users'];
     39    $userids = $_REQUEST['users'];
    3740    $update = 'promote';
    3841    foreach($userids as $id) {
     
    4043            wp_die(__('You can&#8217;t edit that user.'));
    4144        // 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')) {
    4346            $update = 'err_admin_role';
    4447            continue;
     
    4649
    4750        $user = new WP_User($id);
    48         $user->set_role($_POST['new_role']);
     51        $user->set_role($_REQUEST['new_role']);
    4952    }
    5053
     
    5861    check_admin_referer('delete-users');
    5962
    60     if ( empty($_POST['users']) ) {
     63    if ( empty($_REQUEST['users']) ) {
    6164        wp_redirect($redirect);
    6265        exit();
     
    6669        wp_die(__('You can&#8217;t delete users.'));
    6770
    68     $userids = $_POST['users'];
     71    $userids = $_REQUEST['users'];
    6972    $update = 'del';
    7073    $delete_count = 0;
     
    7881            continue;
    7982        }
    80         switch($_POST['delete_option']) {
     83        switch($_REQUEST['delete_option']) {
    8184        case 'delete':
    8285            wp_delete_user($id);
    8386            break;
    8487        case 'reassign':
    85             wp_delete_user($id, $_POST['reassign_user']);
     88            wp_delete_user($id, $_REQUEST['reassign_user']);
    8689            break;
    8790        }
     
    99102    check_admin_referer('bulk-users');
    100103
    101     if ( empty($_POST['users']) ) {
     104    if ( empty($_REQUEST['users']) ) {
    102105        wp_redirect($redirect);
    103106        exit();
     
    107110        $errors = new WP_Error('edit_users', __('You can&#8217;t delete users.'));
    108111
    109     $userids = $_POST['users'];
     112    $userids = $_REQUEST['users'];
    110113
    111114    include ('admin-header.php');
     
    168171        $add_user_errors = $user_id;
    169172    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));
    171174        $redirect = add_query_arg( array('usersearch' => urlencode($new_user_login), 'update' => $update), $redirect );
    172175        wp_redirect( $redirect . '#user-' . $user_id );
     
    181184
    182185    // 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']);
    184187
    185188    // Make the user objects
     
    237240
    238241<div class="wrap">
    239 
     242<form id="posts-filter" action="" method="get">
    240243    <?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>
    242245    <?php else : ?>
    243         <h2><?php _e('User List by Role'); ?></h2>
     246        <h2><?php _e('Manage Users'); ?></h2>
    244247    <?php endif; ?>
    245248
    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 &raquo;'); ?>" class="button" /></p>
    248     </form>
     249<ul class="subsubsub">
     250<?php
     251$role_links = array();
     252foreach ( $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>";
     262echo implode(' |</li>', $role_links) . '</li>';
     263unset($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;" />
    249288
    250289    <?php if ( is_wp_error( $wp_user_search->search_errors ) ) : ?>
     
    272311        printf(__('%1$s &#8211; %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>
    273312
    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 
    278313<form action="" method="post" name="updateusers" id="updateusers">
    279314<?php wp_nonce_field('bulk-users') ?>
    280315<table class="widefat">
    281 <?php
    282 foreach($roleclasses as $role => $roleclass) {
    283     uksort($roleclass, "strnatcasecmp");
    284 ?>
    285316<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>
    293317<tr class="thead">
    294318    <th><input type="checkbox" onclick="checkAllUsers('<?php echo $role; ?>')"/> </th>
     
    296320    <th><?php _e('Name') ?></th>
    297321    <th><?php _e('E-mail') ?></th>
    298     <th><?php _e('Website') ?></th>
     322    <th><?php _e('Role') ?></th>
    299323    <th><?php _e('Posts') ?></th>
    300324</tr>
    301325</tbody>
     326<?php
     327foreach ($roleclasses as $role => $roleclass) {
     328    uksort($roleclass, "strnatcasecmp");
     329?>
    302330<tbody id="role-<?php echo $role; ?>" class="list:user user-list"><?php
    303331$style = '';
     
    312340</table>
    313341
     342<br style="clear:both;" />
     343
     344<div class="tablenav">
     345
    314346<?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 &raquo;'); ?>" />
    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
    330353</form>
    331354<?php endif; ?>
     355
    332356</div>
    333357
     
    336360        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 ) {
    337361            $var = 'new_' . $var;
    338             $$var = attribute_escape(stripslashes($_POST[$formpost]));
     362            $$var = attribute_escape(stripslashes($_REQUEST[$formpost]));
    339363        }
    340364        unset($name);
    341365    }
    342366?>
     367
     368<br style="clear:both;" />
    343369
    344370<div class="wrap">
Note: See TracChangeset for help on using the changeset viewer.