Make WordPress Core

Ticket #2793: 2793.diff

File 2793.diff, 9.4 KB (added by davidhouse, 17 years ago)

Several additions to Mark's patch; see my comment(s) below.

  • wp-admin/users.php

     
    8484        }
    8585
    8686        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.'));
    8888
    8989        $userids = $_POST['users'];
    9090
     
    155155
    156156        include ('admin-header.php');
    157157
    158         $userids = $wpdb->get_col("SELECT ID FROM $wpdb->users;");
     158        //
     159        // Paging and Search by Mark Jaquith, June 6th, 2006
     160        //
    159161
    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) . '">&laquo; Previous Page</a></p>';
     201                if ( $next_page )
     202                        $paging_text .= '<p class="alignright"><a href="' . add_query_arg('userspage', $page + 1) . '">Next Page &raquo;</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 ) {
    161210                $tmp_user = new WP_User($userid);
    162211                $roles = $tmp_user->roles;
    163212                $role = array_shift($roles);
     
    211260        endif;
    212261        ?>
    213262
     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 &raquo;" /></p>
     267        </form>
     268        <?php if ($_GET['usersearch']) { ?>
     269                <p><a href="users.php">Reset search</a></p>
     270        <?php } ?>
     271</div>
     272
     273<?php if ( $too_many_users ) : ?>
     274<div id="message" class="updated">
     275        <p><?php echo $too_many_users; ?></p>
     276</div>
     277<?php endif; ?>
     278
     279<?php if ( $userids ) : ?>
     280
    214281<form action="" method="post" name="updateusers" id="updateusers">
    215282<?php wp_nonce_field('bulk-users') ?>
    216283<div class="wrap">
    217         <h2><?php _e('User List by Role'); ?></h2>
     284        <?php if ( $search_term ) : ?>
     285                <h2><?php printf(__('Users Matching "%s" by Role'), $search_term); ?></h2>
     286                <div class="user-paging-text"><?php echo $paging_text; ?></div>
     287        <?php else : ?>
     288                <h2><?php _e('User List by Role'); ?></h2>
     289                <?php if ( $paging_text ) : ?>
     290                        <div class="user-paging-text"><?php echo $paging_text; ?></p></div>
     291                <?php endif; ?>
     292        <?php endif; ?>
     293        <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>
    218294<table class="widefat">
    219295<?php
    220296foreach($roleclasses as $role => $roleclass) {
     
    222298?>
    223299
    224300<tr>
    225         <th colspan="8" align="left"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th>
     301        <th colspan="7" align="left"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th>
    226302</tr>
    227 <thead>
    228 <tr>
     303<tr class="thead">
    229304        <th style="text-align: left"><?php _e('ID') ?></th>
    230305        <th style="text-align: left"><?php _e('Username') ?></th>
    231306        <th style="text-align: left"><?php _e('Name') ?></th>
    232307        <th style="text-align: left"><?php _e('E-mail') ?></th>
    233308        <th style="text-align: left"><?php _e('Website') ?></th>
    234         <th><?php _e('Posts') ?></th>
    235         <th>&nbsp;</th>
     309        <th colspan="2"><?php _e('Actions') ?></th>
    236310</tr>
    237311</thead>
    238312<tbody id="role-<?php echo $role; ?>"><?php
     
    250324?>
    251325</table>
    252326
     327<div class="user-paging-text"><?php echo $paging_text; ?></div>
    253328
    254329        <h2><?php _e('Update Users'); ?></h2>
    255330  <ul style="list-style:none;">
     
    263338</div>
    264339</form>
    265340
     341<?php endif; // if users were returned ?>
     342
    266343<div class="wrap">
    267344<h2><?php _e('Add New User') ?></h2>
    268345<?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/custom-fields.js

     
    2222        }
    2323
    2424        document.getElementById('metakeyinput').onkeypress = function(e) {return killSubmit('theList.inputData+="&id="+document.getElementById("post_ID").value;theList.ajaxAdder("meta", "newmeta");', e); };
    25         document.getElementById('updatemetasub').onclick = function(e) {return killSubmit('theList.inputData+="&id="+document.getElementById("post_ID").value;theList.ajaxAdder("meta", "newmeta");', e); };
     25        document.getElementById('newmetasub').onclick = function(e) {return killSubmit('theList.inputData+="&id="+document.getElementById("post_ID").value;theList.ajaxAdder("meta", "newmeta");', e); };
    2626}
  • wp-admin/wp-admin.css

     
    5252        font-size: 16px;
    5353}
    5454
    55 thead {
     55thead, .thead {
    5656        background: #dfdfdf
    5757}
    5858
  • wp-admin/admin-functions.php

     
    729729        if (strlen($short_url) > 35)
    730730                $short_url =  substr($short_url, 0, 32).'...';
    731731        $numposts = get_usernumposts($user_object->ID);
    732         if (0 < $numposts) $numposts = "<a href='edit.php?author=$user_object->ID' title='" . __('View posts') . "'>$numposts</a>";
    733732        $r = "<tr id='user-$user_object->ID'$style>
    734733                <td><input type='checkbox' name='users[]' id='user_{$user_object->ID}' value='{$user_object->ID}' /> <label for='user_{$user_object->ID}'>{$user_object->ID}</label></td>
    735734                <td><label for='user_{$user_object->ID}'><strong>$user_object->user_login</strong></label></td>
    736735                <td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></td>
    737736                <td><a href='mailto:$email' title='" . sprintf(__('e-mail: %s'), $email) . "'>$email</a></td>
    738737                <td><a href='$url' title='website: $url'>$short_url</a></td>";
    739         $r .= "\n\t\t<td align='center'>$numposts</td>";
    740         $r .= "\n\t\t<td>";
     738        $r .= "\n\t\t<td align='center'>";
     739        if ($numposts > 0) {
     740                $r .= "<a href='edit.php?author=$user_object->ID' title='" . __('View posts by this author') . "' class='edit'>";
     741                $r .= sprintf(__('View %s %s'), $numposts, __ngettext('post', 'posts', $numposts));
     742        }
     743        $r .= "</td>\n\t\t<td>";
    741744        if ( current_user_can('edit_user', $user_object->ID) )
    742745                $r .= "<a href='user-edit.php?user_id=$user_object->ID' class='edit'>".__('Edit')."</a>";
    743746        $r .= "</td>\n\t</tr>";
     
    966969        </tr>
    967970
    968971</table>
    969 <p class="submit"><input type="submit" id="updatemetasub" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field &raquo;') ?>" /></p>
     972<p class="submit"><input type="submit" id="newmetasub" name="newmeta" tabindex="9" value="<?php _e('Add Custom Field &raquo;') ?>" /></p>
    970973<?php
    971974
    972975}
  • wp-admin/menu.php

     
    1111$menu[25] = array(__('Presentation'), 'switch_themes', 'themes.php');
    1212$menu[30] = array(__('Plugins'), 'activate_plugins', 'plugins.php');
    1313if ( current_user_can('edit_users') )
    14         $menu[35] = array(__('Users'), 'read', 'profile.php');
     14        $menu[35] = array(__('Users'), 'read', 'users.php');
    1515else
    1616        $menu[35] = array(__('Profile'), 'read', 'profile.php');
    1717$menu[40] = array(__('Options'), 'manage_options', 'options-general.php');
     
    3434$submenu['link-manager.php'][10] = array(__('Add Bookmark'), 'manage_links', 'link-add.php');
    3535$submenu['link-manager.php'][20] = array(__('Import Bookmarks'), 'manage_links', 'link-import.php');
    3636
     37$submenu['profile.php'][10] = array(__('Authors &amp; Users'), 'edit_users', 'users.php');
    3738$submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php');
    38 $submenu['profile.php'][10] = array(__('Authors &amp; Users'), 'edit_users', 'users.php');
    3939
    4040$submenu['options-general.php'][10] = array(__('General'), 'manage_options', 'options-general.php');
    4141$submenu['options-general.php'][15] = array(__('Writing'), 'manage_options', 'options-writing.php');