| 1 | Index: wp-admin/users.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-admin/users.php (revision 3850) |
|---|
| 4 | +++ wp-admin/users.php (working copy) |
|---|
| 5 | @@ -84,7 +84,7 @@ |
|---|
| 6 | } |
|---|
| 7 | |
|---|
| 8 | if ( !current_user_can('delete_users') ) |
|---|
| 9 | - $error = new WP_Error('edit_users', __('You can’t delete users.')); |
|---|
| 10 | + $errors = new WP_Error('edit_users', __('You can’t delete users.')); |
|---|
| 11 | |
|---|
| 12 | $userids = $_POST['users']; |
|---|
| 13 | |
|---|
| 14 | @@ -155,9 +155,58 @@ |
|---|
| 15 | |
|---|
| 16 | include ('admin-header.php'); |
|---|
| 17 | |
|---|
| 18 | - $userids = $wpdb->get_col("SELECT ID FROM $wpdb->users;"); |
|---|
| 19 | + // |
|---|
| 20 | + // Paging and Search by Mark Jaquith, June 6th, 2006 |
|---|
| 21 | + // |
|---|
| 22 | |
|---|
| 23 | - foreach($userids as $userid) { |
|---|
| 24 | + $users_per_page = 50; |
|---|
| 25 | + |
|---|
| 26 | + $page = (int) $_GET['userspage']; |
|---|
| 27 | + if ( !$page ) |
|---|
| 28 | + $page = 1; |
|---|
| 29 | + |
|---|
| 30 | + $starton = ($page - 1) * $users_per_page; |
|---|
| 31 | + |
|---|
| 32 | + $limit = 'LIMIT ' . $starton . ',' . $users_per_page; |
|---|
| 33 | + |
|---|
| 34 | + $search_term = $_GET['usersearch']; |
|---|
| 35 | + if ( $search_term ) { |
|---|
| 36 | + $search = array(); |
|---|
| 37 | + $search_sql = 'AND ('; |
|---|
| 38 | + foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col ) |
|---|
| 39 | + $searches[] = $col . " LIKE '%$search_term%'"; |
|---|
| 40 | + $search_sql .= implode(' OR ', $searches); |
|---|
| 41 | + $search_sql .= ')'; |
|---|
| 42 | + } |
|---|
| 43 | + |
|---|
| 44 | + if ( !$search_term && $page == 1 && $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users") > $users_per_page ) |
|---|
| 45 | + $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); |
|---|
| 46 | + |
|---|
| 47 | + $from_where = "FROM $wpdb->users WHERE 1=1 $search_sql"; |
|---|
| 48 | + $userids = $wpdb->get_col('SELECT ID ' . $from_where . $limit); |
|---|
| 49 | + |
|---|
| 50 | + if ( $userids ) { |
|---|
| 51 | + $total_users_for_this_query = $wpdb->get_var('SELECT COUNT(ID) ' . $from_where); // no limit |
|---|
| 52 | + } else { |
|---|
| 53 | + $errors = new WP_Error('no_matching_users_found', __('No matching users were found!')); |
|---|
| 54 | + } |
|---|
| 55 | + |
|---|
| 56 | + // Now for the paging |
|---|
| 57 | + if ( $total_users_for_this_query > $users_per_page ) { // have to page the results |
|---|
| 58 | + $prev_page = ( $page > 1) ? true : false; |
|---|
| 59 | + $next_page = ( ($page * $users_per_page) < $total_users_for_this_query ) ? true : false; |
|---|
| 60 | + $paging_text = ''; |
|---|
| 61 | + if ( $prev_page ) |
|---|
| 62 | + $paging_text .= '<p class="alignleft"><a href="' . add_query_arg('userspage', $page - 1) . '">« Previous Page</a></p>'; |
|---|
| 63 | + if ( $next_page ) |
|---|
| 64 | + $paging_text .= '<p class="alignright"><a href="' . add_query_arg('userspage', $page + 1) . '">Next Page »</a></p>'; |
|---|
| 65 | + if ( $prev_page || $next_page ) |
|---|
| 66 | + $paging_text .= '<br style="clear:both" />'; |
|---|
| 67 | + } |
|---|
| 68 | + |
|---|
| 69 | + // DONE WITH PAGING AND SEARCH |
|---|
| 70 | + |
|---|
| 71 | + foreach ( (array) $userids as $userid ) { |
|---|
| 72 | $tmp_user = new WP_User($userid); |
|---|
| 73 | $roles = $tmp_user->roles; |
|---|
| 74 | $role = array_shift($roles); |
|---|
| 75 | @@ -211,10 +260,37 @@ |
|---|
| 76 | endif; |
|---|
| 77 | ?> |
|---|
| 78 | |
|---|
| 79 | +<div class="wrap"> |
|---|
| 80 | + <h2><?php _e('Search For Users'); ?></h2> |
|---|
| 81 | + <form action="" method="get" name="search" id="search"> |
|---|
| 82 | + <p><input type="text" name="usersearch" id="usersearch" value="<?php echo wp_specialchars($_GET['usersearch']); ?>" /> <input type="submit" value="Search »" /></p> |
|---|
| 83 | + </form> |
|---|
| 84 | + <?php if ($_GET['usersearch']) { ?> |
|---|
| 85 | + <p><a href="users.php">Reset search</a></p> |
|---|
| 86 | + <?php } ?> |
|---|
| 87 | +</div> |
|---|
| 88 | + |
|---|
| 89 | +<?php if ( $too_many_users ) : ?> |
|---|
| 90 | +<div id="message" class="updated"> |
|---|
| 91 | + <p><?php echo $too_many_users; ?></p> |
|---|
| 92 | +</div> |
|---|
| 93 | +<?php endif; ?> |
|---|
| 94 | + |
|---|
| 95 | +<?php if ( $userids ) : ?> |
|---|
| 96 | + |
|---|
| 97 | <form action="" method="post" name="updateusers" id="updateusers"> |
|---|
| 98 | <?php wp_nonce_field('bulk-users') ?> |
|---|
| 99 | <div class="wrap"> |
|---|
| 100 | - <h2><?php _e('User List by Role'); ?></h2> |
|---|
| 101 | + <?php if ( $search_term ) : ?> |
|---|
| 102 | + <h2><?php printf(__('Users Matching "%s" by Role'), $search_term); ?></h2> |
|---|
| 103 | + <div class="user-paging-text"><?php echo $paging_text; ?></div> |
|---|
| 104 | + <?php else : ?> |
|---|
| 105 | + <h2><?php _e('User List by Role'); ?></h2> |
|---|
| 106 | + <?php if ( $paging_text ) : ?> |
|---|
| 107 | + <div class="user-paging-text"><?php echo $paging_text; ?></p></div> |
|---|
| 108 | + <?php endif; ?> |
|---|
| 109 | + <?php endif; ?> |
|---|
| 110 | + <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> |
|---|
| 111 | <table class="widefat"> |
|---|
| 112 | <?php |
|---|
| 113 | foreach($roleclasses as $role => $roleclass) { |
|---|
| 114 | @@ -222,17 +298,15 @@ |
|---|
| 115 | ?> |
|---|
| 116 | |
|---|
| 117 | <tr> |
|---|
| 118 | - <th colspan="8" align="left"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th> |
|---|
| 119 | + <th colspan="7" align="left"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th> |
|---|
| 120 | </tr> |
|---|
| 121 | -<thead> |
|---|
| 122 | -<tr> |
|---|
| 123 | +<tr class="thead"> |
|---|
| 124 | <th style="text-align: left"><?php _e('ID') ?></th> |
|---|
| 125 | <th style="text-align: left"><?php _e('Username') ?></th> |
|---|
| 126 | <th style="text-align: left"><?php _e('Name') ?></th> |
|---|
| 127 | <th style="text-align: left"><?php _e('E-mail') ?></th> |
|---|
| 128 | <th style="text-align: left"><?php _e('Website') ?></th> |
|---|
| 129 | - <th><?php _e('Posts') ?></th> |
|---|
| 130 | - <th> </th> |
|---|
| 131 | + <th colspan="2"><?php _e('Actions') ?></th> |
|---|
| 132 | </tr> |
|---|
| 133 | </thead> |
|---|
| 134 | <tbody id="role-<?php echo $role; ?>"><?php |
|---|
| 135 | @@ -250,6 +324,7 @@ |
|---|
| 136 | ?> |
|---|
| 137 | </table> |
|---|
| 138 | |
|---|
| 139 | +<div class="user-paging-text"><?php echo $paging_text; ?></div> |
|---|
| 140 | |
|---|
| 141 | <h2><?php _e('Update Users'); ?></h2> |
|---|
| 142 | <ul style="list-style:none;"> |
|---|
| 143 | @@ -263,6 +338,8 @@ |
|---|
| 144 | </div> |
|---|
| 145 | </form> |
|---|
| 146 | |
|---|
| 147 | +<?php endif; // if users were returned ?> |
|---|
| 148 | + |
|---|
| 149 | <div class="wrap"> |
|---|
| 150 | <h2><?php _e('Add New User') ?></h2> |
|---|
| 151 | <?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>'; ?> |
|---|
| 152 | Index: wp-admin/wp-admin.css |
|---|
| 153 | =================================================================== |
|---|
| 154 | --- wp-admin/wp-admin.css (revision 3850) |
|---|
| 155 | +++ wp-admin/wp-admin.css (working copy) |
|---|
| 156 | @@ -52,7 +52,7 @@ |
|---|
| 157 | font-size: 16px; |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | -thead { |
|---|
| 161 | +thead, .thead { |
|---|
| 162 | background: #dfdfdf |
|---|
| 163 | } |
|---|
| 164 | |
|---|
| 165 | Index: wp-admin/admin-functions.php |
|---|
| 166 | =================================================================== |
|---|
| 167 | --- wp-admin/admin-functions.php (revision 3850) |
|---|
| 168 | +++ wp-admin/admin-functions.php (working copy) |
|---|
| 169 | @@ -729,15 +729,18 @@ |
|---|
| 170 | if (strlen($short_url) > 35) |
|---|
| 171 | $short_url = substr($short_url, 0, 32).'...'; |
|---|
| 172 | $numposts = get_usernumposts($user_object->ID); |
|---|
| 173 | - if (0 < $numposts) $numposts = "<a href='edit.php?author=$user_object->ID' title='" . __('View posts') . "'>$numposts</a>"; |
|---|
| 174 | $r = "<tr id='user-$user_object->ID'$style> |
|---|
| 175 | <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> |
|---|
| 176 | <td><label for='user_{$user_object->ID}'><strong>$user_object->user_login</strong></label></td> |
|---|
| 177 | <td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></td> |
|---|
| 178 | <td><a href='mailto:$email' title='" . sprintf(__('e-mail: %s'), $email) . "'>$email</a></td> |
|---|
| 179 | <td><a href='$url' title='website: $url'>$short_url</a></td>"; |
|---|
| 180 | - $r .= "\n\t\t<td align='center'>$numposts</td>"; |
|---|
| 181 | - $r .= "\n\t\t<td>"; |
|---|
| 182 | + $r .= "\n\t\t<td align='center'>"; |
|---|
| 183 | + if ($numposts > 0) { |
|---|
| 184 | + $r .= "<a href='edit.php?author=$user_object->ID' title='" . __('View posts by this author') . "' class='edit'>"; |
|---|
| 185 | + $r .= sprintf(__('View %1$s %2$s'), $numposts, __ngettext('post', 'posts', $numposts)); |
|---|
| 186 | + } |
|---|
| 187 | + $r .= "</td>\n\t\t<td>"; |
|---|
| 188 | if ( current_user_can('edit_user', $user_object->ID) ) |
|---|
| 189 | $r .= "<a href='user-edit.php?user_id=$user_object->ID' class='edit'>".__('Edit')."</a>"; |
|---|
| 190 | $r .= "</td>\n\t</tr>"; |
|---|
| 191 | @@ -966,7 +969,7 @@ |
|---|
| 192 | </tr> |
|---|
| 193 | |
|---|
| 194 | </table> |
|---|
| 195 | -<p class="submit"><input type="submit" id="updatemetasub" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field »') ?>" /></p> |
|---|
| 196 | +<p class="submit"><input type="submit" id="newmetasub" name="newmeta" tabindex="9" value="<?php _e('Add Custom Field »') ?>" /></p> |
|---|
| 197 | <?php |
|---|
| 198 | |
|---|
| 199 | } |
|---|
| 200 | Index: wp-admin/menu.php |
|---|
| 201 | =================================================================== |
|---|
| 202 | --- wp-admin/menu.php (revision 3850) |
|---|
| 203 | +++ wp-admin/menu.php (working copy) |
|---|
| 204 | @@ -11,7 +11,7 @@ |
|---|
| 205 | $menu[25] = array(__('Presentation'), 'switch_themes', 'themes.php'); |
|---|
| 206 | $menu[30] = array(__('Plugins'), 'activate_plugins', 'plugins.php'); |
|---|
| 207 | if ( current_user_can('edit_users') ) |
|---|
| 208 | - $menu[35] = array(__('Users'), 'read', 'profile.php'); |
|---|
| 209 | + $menu[35] = array(__('Users'), 'read', 'users.php'); |
|---|
| 210 | else |
|---|
| 211 | $menu[35] = array(__('Profile'), 'read', 'profile.php'); |
|---|
| 212 | $menu[40] = array(__('Options'), 'manage_options', 'options-general.php'); |
|---|
| 213 | @@ -34,8 +34,8 @@ |
|---|
| 214 | $submenu['link-manager.php'][10] = array(__('Add Bookmark'), 'manage_links', 'link-add.php'); |
|---|
| 215 | $submenu['link-manager.php'][20] = array(__('Import Bookmarks'), 'manage_links', 'link-import.php'); |
|---|
| 216 | |
|---|
| 217 | +$submenu['profile.php'][10] = array(__('Authors & Users'), 'edit_users', 'users.php'); |
|---|
| 218 | $submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php'); |
|---|
| 219 | -$submenu['profile.php'][10] = array(__('Authors & Users'), 'edit_users', 'users.php'); |
|---|
| 220 | |
|---|
| 221 | $submenu['options-general.php'][10] = array(__('General'), 'manage_options', 'options-general.php'); |
|---|
| 222 | $submenu['options-general.php'][15] = array(__('Writing'), 'manage_options', 'options-writing.php'); |
|---|