Ticket #2793: 2793.4.diff
File 2793.4.diff, 10.4 KB (added by , 18 years ago) |
---|
-
wp-includes/functions.php
1295 1295 function add_query_arg() { 1296 1296 $ret = ''; 1297 1297 if ( is_array(func_get_arg(0)) ) { 1298 if ( @func_num_args() < 2 )1298 if ( @func_num_args() < 2 || '' == @func_get_arg(1) ) 1299 1299 $uri = $_SERVER['REQUEST_URI']; 1300 1300 else 1301 1301 $uri = @func_get_arg(1); 1302 1302 } else { 1303 if ( @func_num_args() < 3 )1303 if ( @func_num_args() < 3 || '' == @func_get_arg(2) ) 1304 1304 $uri = $_SERVER['REQUEST_URI']; 1305 1305 else 1306 1306 $uri = @func_get_arg(2); … … 1343 1343 return trim($ret, '?'); 1344 1344 } 1345 1345 1346 function remove_query_arg($key, $query ) {1346 function remove_query_arg($key, $query='') { 1347 1347 return add_query_arg($key, '', $query); 1348 1348 } 1349 1349 -
wp-admin/users.php
3 3 require_once( ABSPATH . WPINC . '/registration-functions.php'); 4 4 5 5 $title = __('Users'); 6 $parent_file = 'profile.php'; 6 if ( current_user_can('edit_users') ) 7 $parent_file = 'users.php'; 8 else 9 $parent_file = 'profile.php'; 7 10 8 11 $action = $_REQUEST['action']; 9 12 $update = ''; … … 84 87 } 85 88 86 89 if ( !current_user_can('delete_users') ) 87 $error = new WP_Error('edit_users', __('You can’t delete users.'));90 $errors = new WP_Error('edit_users', __('You can’t delete users.')); 88 91 89 92 $userids = $_POST['users']; 90 93 … … 155 158 156 159 include ('admin-header.php'); 157 160 158 $userids = $wpdb->get_col("SELECT ID FROM $wpdb->users;");161 /* Paging and Search by Mark Jaquith, June 6th, 2006 */ 159 162 160 foreach($userids as $userid) { 163 $users_per_page = 50; 164 165 $page = (int) $_GET['userspage']; 166 if ( !$page ) 167 $page = 1; 168 169 $starton = ($page - 1) * $users_per_page; 170 171 $limit = 'LIMIT ' . $starton . ',' . $users_per_page; 172 173 $search_term = $_GET['usersearch']; 174 if ( $search_term ) { 175 $search = array(); 176 $search_sql = 'AND ('; 177 foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col ) 178 $searches[] = $col . " LIKE '%$search_term%'"; 179 $search_sql .= implode(' OR ', $searches); 180 $search_sql .= ')'; 181 } 182 183 if ( !$_GET['update'] && !$search_term && !$_GET['userspage'] && $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users") > $users_per_page ) 184 $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); 185 186 $from_where = "FROM $wpdb->users WHERE 1=1 $search_sql"; 187 $userids = $wpdb->get_col('SELECT ID ' . $from_where . $limit); 188 189 if ( $userids ) { 190 $total_users_for_this_query = $wpdb->get_var('SELECT COUNT(ID) ' . $from_where); // no limit 191 } else { 192 $errors = new WP_Error('no_matching_users_found', __('No matching users were found!')); 193 } 194 195 // Now for the paging 196 if ( $total_users_for_this_query > $users_per_page ) { // have to page the results 197 $prev_page = ( $page > 1) ? true : false; 198 $next_page = ( ($page * $users_per_page) < $total_users_for_this_query ) ? true : false; 199 $paging_text = ''; 200 if ( $prev_page ) 201 $paging_text .= '<p class="alignleft"><a href="' . add_query_arg('userspage', $page - 1, remove_query_arg('update')) . '">« Previous Page</a></p>'; 202 if ( $next_page ) 203 $paging_text .= '<p class="alignright"><a href="' . add_query_arg('userspage', $page + 1, remove_query_arg('update')) . '">Next Page »</a></p>'; 204 if ( $prev_page || $next_page ) 205 $paging_text .= '<br style="clear:both" />'; 206 } 207 208 // Make the user objects 209 foreach ( (array) $userids as $userid ) { 161 210 $tmp_user = new WP_User($userid); 162 211 $roles = $tmp_user->roles; 163 212 $role = array_shift($roles); … … 197 246 <?php 198 247 break; 199 248 } 200 endif; 201 if ( is_wp_error( $errors ) ) : ?> 249 endif; ?> 250 251 <?php if ( is_wp_error( $errors ) ) : ?> 202 252 <div class="error"> 203 253 <ul> 204 254 <?php … … 207 257 ?> 208 258 </ul> 209 259 </div> 210 <?php 211 endif; 212 ?> 260 <?php endif; ?> 213 261 262 <?php if ( $too_many_users ) : ?> 263 <div id="message" class="updated"> 264 <p><?php echo $too_many_users; ?></p> 265 </div> 266 <?php endif; ?> 267 268 <div class="wrap"> 269 <h2><?php _e('Search For Users'); ?></h2> 270 <form action="" method="get" name="search" id="search"> 271 <p><input type="text" name="usersearch" id="usersearch" value="<?php echo wp_specialchars($_GET['usersearch']); ?>" /> <input type="submit" value="Search »" /></p> 272 </form> 273 <?php if ( $search_term ) : ?> 274 <p><a href="users.php"><?php _e('« Back to All Users'); ?></a></p> 275 <?php endif; ?> 276 </div> 277 278 <?php if ( $userids ) : ?> 279 214 280 <form action="" method="post" name="updateusers" id="updateusers"> 215 281 <?php wp_nonce_field('bulk-users') ?> 216 282 <div class="wrap"> 217 <h2><?php _e('User List by Role'); ?></h2> 283 <?php if ( $search_term ) : ?> 284 <h2><?php printf(__('Users Matching "%s" by Role'), $search_term); ?></h2> 285 <div class="user-paging-text"><?php echo $paging_text; ?></div> 286 <?php else : ?> 287 <h2><?php _e('User List by Role'); ?></h2> 288 <?php if ( $paging_text ) : ?> 289 <div class="user-paging-text"><?php echo $paging_text; ?></p></div> 290 <?php endif; ?> 291 <?php endif; ?> 292 <h3><?php printf(__('Results %1$s - %2$s of %3$s shown below'), $starton + 1, min($starton + $users_per_page, $total_users_for_this_query), $total_users_for_this_query); ?></h3> 218 293 <table class="widefat"> 219 294 <?php 220 295 foreach($roleclasses as $role => $roleclass) { … … 222 297 ?> 223 298 224 299 <tr> 225 <th colspan=" 8" align="left"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th>300 <th colspan="7" align="left"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th> 226 301 </tr> 227 <thead> 228 <tr> 302 <tr class="thead"> 229 303 <th style="text-align: left"><?php _e('ID') ?></th> 230 304 <th style="text-align: left"><?php _e('Username') ?></th> 231 305 <th style="text-align: left"><?php _e('Name') ?></th> 232 306 <th style="text-align: left"><?php _e('E-mail') ?></th> 233 307 <th style="text-align: left"><?php _e('Website') ?></th> 234 <th><?php _e('Posts') ?></th> 235 <th> </th> 308 <th colspan="2"><?php _e('Actions') ?></th> 236 309 </tr> 237 310 </thead> 238 311 <tbody id="role-<?php echo $role; ?>"><?php … … 250 323 ?> 251 324 </table> 252 325 326 <div class="user-paging-text"><?php echo $paging_text; ?></div> 253 327 254 328 <h2><?php _e('Update Users'); ?></h2> 255 329 <ul style="list-style:none;"> … … 263 337 </div> 264 338 </form> 265 339 340 <?php endif; // if users were returned ?> 341 266 342 <div class="wrap"> 267 343 <h2><?php _e('Add New User') ?></h2> 268 344 <?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/wp-admin.css
52 52 font-size: 16px; 53 53 } 54 54 55 thead {55 thead, .thead { 56 56 background: #dfdfdf 57 57 } 58 58 -
wp-admin/admin-functions.php
729 729 if (strlen($short_url) > 35) 730 730 $short_url = substr($short_url, 0, 32).'...'; 731 731 $numposts = get_usernumposts($user_object->ID); 732 if (0 < $numposts) $numposts = "<a href='edit.php?author=$user_object->ID' title='" . __('View posts') . "'>$numposts</a>";733 732 $r = "<tr id='user-$user_object->ID'$style> 734 733 <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> 735 734 <td><label for='user_{$user_object->ID}'><strong>$user_object->user_login</strong></label></td> 736 735 <td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></td> 737 736 <td><a href='mailto:$email' title='" . sprintf(__('e-mail: %s'), $email) . "'>$email</a></td> 738 737 <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 %1$s %2$s'), $numposts, __ngettext('post', 'posts', $numposts)); 742 } 743 $r .= "</td>\n\t\t<td>"; 741 744 if ( current_user_can('edit_user', $user_object->ID) ) 742 745 $r .= "<a href='user-edit.php?user_id=$user_object->ID' class='edit'>".__('Edit')."</a>"; 743 746 $r .= "</td>\n\t</tr>"; -
wp-admin/menu.php
11 11 $menu[25] = array(__('Presentation'), 'switch_themes', 'themes.php'); 12 12 $menu[30] = array(__('Plugins'), 'activate_plugins', 'plugins.php'); 13 13 if ( current_user_can('edit_users') ) 14 $menu[35] = array(__('Users'), ' read', 'profile.php');14 $menu[35] = array(__('Users'), 'edit_users', 'users.php'); 15 15 else 16 16 $menu[35] = array(__('Profile'), 'read', 'profile.php'); 17 17 $menu[40] = array(__('Options'), 'manage_options', 'options-general.php'); … … 34 34 $submenu['link-manager.php'][10] = array(__('Add Bookmark'), 'manage_links', 'link-add.php'); 35 35 $submenu['link-manager.php'][20] = array(__('Import Bookmarks'), 'manage_links', 'link-import.php'); 36 36 37 $submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php'); 38 $submenu['profile.php'][10] = array(__('Authors & Users'), 'edit_users', 'users.php'); 37 if ( current_user_can('edit_users') ) { 38 $submenu['users.php'][5] = array(__('Authors & Users'), 'edit_users', 'users.php'); 39 $submenu['users.php'][10] = array(__('Your Profile'), 'read', 'profile.php'); 40 } else { 41 $submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php'); 42 } 39 43 40 44 $submenu['options-general.php'][10] = array(__('General'), 'manage_options', 'options-general.php'); 41 45 $submenu['options-general.php'][15] = array(__('Writing'), 'manage_options', 'options-writing.php'); -
wp-admin/profile.php
3 3 4 4 $title = __('Profile'); 5 5 6 $parent_file = 'profile.php'; 6 if ( current_user_can('edit_users') ) 7 $parent_file = 'users.php'; 8 else 9 $parent_file = 'profile.php'; 7 10 include_once('admin-header.php'); 8 11 $profileuser = new WP_User($user_ID); 9 12