Ticket #15558: 15558.diff
| File 15558.diff, 7.9 KB (added by , 15 years ago) |
|---|
-
wp-admin/includes/class-wp-users-list-table.php
7 7 * @since 3.1.0 8 8 */ 9 9 class WP_Users_List_Table extends WP_List_Table { 10 11 var $site_id; 12 var $is_site_users; 13 14 function WP_Users_List_Table() { 15 $screen = get_current_screen(); 16 $this->is_site_users = ( 'site-users-network' == $screen->id ) ? true : false; 10 17 18 if ( $this->is_site_users ) 19 $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; 20 21 parent::WP_List_Table( array( 22 'singular' => 'user', 23 'plural' => 'users' 24 ) ); 25 } 26 11 27 function check_permissions() { 12 28 if ( !current_user_can('list_users') ) 13 29 wp_die(__('Cheatin’ uh?')); … … 30 46 'role' => $role, 31 47 'search' => $usersearch 32 48 ); 49 50 if ( $this->is_site_users ) 51 $args['blog_id'] = $this->site_id; 33 52 34 53 if ( isset( $_REQUEST['orderby'] ) ) 35 54 $args['orderby'] = $_REQUEST['orderby']; … … 59 78 $total_users = $users_of_blog['total_users']; 60 79 $avail_roles =& $users_of_blog['avail_roles']; 61 80 unset($users_of_blog); 81 82 if ( $this->is_site_users ) 83 $url = 'site-users.php?id=' . $this->site_id; 84 else 85 $url = 'users.php'; 62 86 63 87 $current_role = false; 64 88 $class = empty($role) ? ' class="current"' : ''; 65 89 $role_links = array(); 66 $role_links['all'] = "<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>';90 $role_links['all'] = "<a href='$url'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>'; 67 91 foreach ( $wp_roles->get_names() as $this_role => $name ) { 68 92 if ( !isset($avail_roles[$this_role]) ) 69 93 continue; … … 78 102 $name = translate_user_role( $name ); 79 103 /* translators: User role name with count */ 80 104 $name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, $avail_roles[$this_role] ); 81 $role_links[$this_role] = "<a href=' users.php?role=$this_role'$class>$name</a>";105 $role_links[$this_role] = "<a href='" . add_query_arg( 'role', $this_role, $url ) . "'$class>$name</a>"; 82 106 } 83 107 84 108 return $role_links; … … 171 195 $user_object = new WP_User( (int) $user_object ); 172 196 $user_object = sanitize_user_object( $user_object, 'display' ); 173 197 $email = $user_object->user_email; 198 199 if ( $this->is_site_users ) 200 $url = "site-users.php?id={$this->site_id}&"; 201 else 202 $url = 'users.php?'; 174 203 175 204 $checkbox = ''; 176 205 // Check if the user for this row is editable … … 197 226 if ( !is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'delete_user', $user_object->ID ) ) 198 227 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "users.php?action=delete&user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Delete' ) . "</a>"; 199 228 if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'remove_user', $user_object->ID ) ) 200 $actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( " users.php?action=remove&user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . "</a>";229 $actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( "$url?action=remove&user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . "</a>"; 201 230 $actions = apply_filters( 'user_row_actions', $actions, $user_object ); 202 231 $edit .= $this->row_actions( $actions ); 203 232 -
wp-admin/network/site-users.php
1 1 <?php 2 2 /** 3 * Edit Site Users Administration Screen3 * Edit Site Themes Administration Screen 4 4 * 5 5 * @package WordPress 6 6 * @subpackage Multisite … … 13 13 if ( ! is_multisite() ) 14 14 wp_die( __( 'Multisite support is not enabled.' ) ); 15 15 16 if ( ! current_user_can('manage_sites') ) 17 wp_die(__('You do not have sufficient permissions to edit this site.')); 16 $wp_list_table = get_list_table('WP_Users_List_Table'); 17 $wp_list_table->check_permissions(); 18 $wp_list_table->prepare_items(); 18 19 20 $action = $wp_list_table->current_action(); 21 22 $s = isset($_REQUEST['s']) ? $_REQUEST['s'] : ''; 23 24 // Clean up request URI from temporary args for screen options/paging uri's to work as expected. 25 $_SERVER['REQUEST_URI'] = remove_query_arg(array('enable', 'disable', 'enable-selected', 'disable-selected'), $_SERVER['REQUEST_URI']); 26 19 27 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; 20 28 21 29 if ( ! $id ) … … 38 46 $editblog_roles = $wp_roles->roles; 39 47 } 40 48 41 if ( isset($_REQUEST['action']) && 'update-site' == $_REQUEST['action'] ) { 49 $action = $wp_list_table->current_action(); 50 51 if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] ) { 42 52 check_admin_referer( 'edit-site' ); 43 53 44 54 switch_to_blog( $id ); … … 107 117 $messages[] = __('Site users updated.'); 108 118 } 109 119 120 add_screen_option( 'per_page', array( 'label' => _x( 'Users', 'users per page (screen options)' ) ) ); 121 110 122 $title = sprintf( __('Edit Site: %s'), get_blogaddress_by_id($id)); 111 123 $parent_file = 'sites.php'; 112 124 $submenu_file = 'sites.php'; … … 128 140 } 129 141 ?> 130 142 </h3> 131 <?php 132 if ( ! empty( $messages ) ) { 133 foreach ( $messages as $msg ) 134 echo '<div id="message" class="updated"><p>' . $msg . '</p></div>'; 135 } ?> 143 <form method="get" action=""> 144 <p class="search-box"> 145 <label class="screen-reader-text" for="user-search-input"><?php _e( 'Search Users' ); ?>:</label> 146 <input type="text" id="user-search-input" name="s" value="<?php _admin_search_query(); ?>" /> 147 <?php submit_button( __( 'Search Users' ), 'button', '', false ); ?> 148 </p> 149 </form> 150 151 <?php //$wp_list_table->views(); ?> 152 136 153 <form method="post" action="site-users.php?action=update-site"> 137 154 <?php wp_nonce_field( 'edit-site' ); ?> 138 155 <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" /> 139 <?php140 $blogusers = get_users( array( 'blog_id' => $id, 'number' => 20 ) );141 156 142 if ( is_array( $blogusers ) ) { 143 echo '<table class="form-table">'; 144 echo "<tr><th>" . __( 'User' ) . "</th><th>" . __( 'Role' ) . "</th><th>" . __( 'Password' ) . "</th><th>" . __( 'Remove' ) . "</th></tr>"; 145 $user_count = 0; 157 <?php $wp_list_table->display(); ?> 146 158 147 foreach ( $blogusers as $user_id => $user_object ) {148 $user_count++;149 $existing_role = reset( $user_object->roles );150 151 echo '<tr><td><a href="user-edit.php?user_id=' . $user_id . '">' . $user_object->user_login . '</a></td>';152 if ( $user_id != $current_user->data->ID ) {153 ?>154 <td>155 <select name="role[<?php echo $user_id ?>]" id="new_role_1"><?php156 foreach ( $editblog_roles as $role => $role_assoc ){157 $name = translate_user_role( $role_assoc['name'] );158 echo '<option ' . selected( $role, $existing_role, false ) . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>';159 }160 ?>161 </select>162 </td>163 <td>164 <input type="text" name="user_password[<?php echo esc_attr( $user_id ) ?>]" />165 </td>166 <?php167 echo '<td><input title="' . __( 'Click to remove user' ) . '" type="checkbox" name="blogusers[' . esc_attr( $user_id ) . ']" /></td>';168 } else {169 echo "<td><strong>" . __ ( 'N/A' ) . "</strong></td><td><strong>" . __ ( 'N/A' ) . "</strong></td><td><strong>" . __( 'N/A' ) . "</strong></td>";170 }171 echo '</tr>';172 }173 echo "</table>";174 submit_button();175 if ( 20 == $user_count )176 echo '<p>' . sprintf( __('First 20 users shown. <a href="%s">Manage all users</a>.'), get_admin_url($id, 'users.php') ) . '</p>';177 } else {178 _e('This site has no users.');179 }180 ?>181 159 </form> 182 160 183 161 <h3 id="add-new-user"><?php _e('Add Existing User') ?></h3>