Ticket #40265: 40265.3.diff
File 40265.3.diff, 7.1 KB (added by , 4 years ago) |
---|
-
src/wp-admin/includes/class-wp-users-list-table.php
101 101 'search' => $usersearch, 102 102 'fields' => 'all_with_meta', 103 103 ); 104 } elseif ( '-1' === $role && is_multisite() && current_user_can( 'manage_network_users' ) ) { 105 $args = array( 106 'number' => $users_per_page, 107 'offset' => ( $paged - 1 ) * $users_per_page, 108 'blog_id' => 0, 109 'search' => $usersearch, 110 'fields' => 'all_with_meta' 111 ); 104 112 } else { 105 113 $args = array( 106 114 'number' => $users_per_page, … … 115 123 $args['search'] = '*' . $args['search'] . '*'; 116 124 } 117 125 118 if ( $this->is_site_users ) {126 if ( $this->is_site_users && ! isset( $args['blog_id'] ) ) { 119 127 $args['blog_id'] = $this->site_id; 120 128 } 121 129 … … 191 199 $avail_roles =& $users_of_blog['avail_roles']; 192 200 unset( $users_of_blog ); 193 201 202 $role_links = array(); 203 204 if ( is_multisite() && current_user_can( 'manage_network_users' ) ) { 205 $current_link_attributes = ''; 206 207 if ( '-1' === $role ) { 208 $current_link_attributes = ' class="current" aria-current="page"'; 209 } 210 211 $name = __( 'All Network Users' ); 212 213 $role_links['all_network'] = "<a href='" . esc_url( add_query_arg( 'role', '-1', $url ) ) . "'$current_link_attributes>$name</a>"; 214 215 /* translators: %s: Number of users. */ 216 $all_users_label = _nx( 217 'All Site Users <span class="count">(%s)</span>', 218 'All Site Users <span class="count">(%s)</span>', 219 $total_users, 220 'users' 221 ); 222 } else { 223 /* translators: %s: Number of users. */ 224 $all_users_label = _nx( 225 'All <span class="count">(%s)</span>', 226 'All <span class="count">(%s)</span>', 227 $total_users, 228 'users' 229 ); 230 } 231 194 232 $current_link_attributes = empty( $role ) ? ' class="current" aria-current="page"' : ''; 195 233 196 $role_links = array();197 234 $role_links['all'] = sprintf( 198 235 '<a href="%s"%s>%s</a>', 199 236 $url, 200 237 $current_link_attributes, 201 238 sprintf( 202 /* translators: %s: Number of users. */ 203 _nx( 204 'All <span class="count">(%s)</span>', 205 'All <span class="count">(%s)</span>', 206 $total_users, 207 'users' 208 ), 239 $all_users_label, 209 240 number_format_i18n( $total_users ) 210 241 ) 211 242 ); … … 454 485 if ( ! is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'delete_user', $user_object->ID ) ) { 455 486 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "users.php?action=delete&user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Delete' ) . '</a>'; 456 487 } 457 if ( is_multisite() && current_user_can( 'remove_user', $user_object->ID ) ) { 488 489 if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'remove_user', $user_object->ID ) && is_user_member_of_blog( $user_object->ID, $this->site_id ) ) { 458 490 $actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( $url . "action=remove&user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . '</a>'; 459 491 } 460 492 … … 551 583 $r .= "<a href='" . esc_url( "mailto:$email" ) . "'>$email</a>"; 552 584 break; 553 585 case 'role': 554 $r .= esc_html( $roles_list ); 586 if ( empty( $roles_list ) ) { 587 $r .= sprintf( 588 '<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>', 589 __( 'User is not a member of this site' ) 590 ); 591 } else { 592 $r .= esc_html( $roles_list ); 593 } 555 594 break; 556 595 case 'posts': 557 596 if ( $numposts > 0 ) { … … 623 662 } 624 663 } 625 664 626 if ( empty( $role_list ) ) {665 if ( empty( $role_list ) && is_user_member_of_blog( $user_object->ID, $this->site_id ) ) { 627 666 $role_list['none'] = _x( 'None', 'no user roles' ); 628 667 } 629 668 -
src/wp-admin/network/site-users.php
15 15 } 16 16 17 17 $wp_list_table = _get_list_table( 'WP_Users_List_Table' ); 18 $wp_list_table->prepare_items();19 18 20 19 get_current_screen()->add_help_tab( get_site_screen_help_tab_args() ); 21 20 get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() ); … … 54 53 55 54 switch_to_blog( $id ); 56 55 56 $wp_list_table->prepare_items(); 57 57 58 $action = $wp_list_table->current_action(); 58 59 59 60 if ( $action ) { … … 157 158 foreach ( $userids as $user_id ) { 158 159 $user_id = (int) $user_id; 159 160 160 // If the user doesn't already belong to the blog , bail.161 // If the user doesn't already belong to the blog: 161 162 if ( ! is_user_member_of_blog( $user_id ) ) { 162 wp_die( 163 '<h1>' . __( 'Something went wrong.' ) . '</h1>' . 164 '<p>' . __( 'One of the selected users is not a member of this site.' ) . '</p>', 165 403 166 ); 163 if ( current_user_can( 'manage_network_users' ) ) { 164 add_existing_user_to_blog( array( 165 'user_id' => $user_id, 166 'role' => $role, 167 ) ); 168 } else { 169 wp_die( 170 '<h1>' . __( 'Something went wrong.' ) . '</h1>' . 171 '<p>' . __( 'One of the selected users is not a member of this site.' ) . '</p>', 172 403 173 ); 174 } 175 } else { 176 $user = get_userdata( $user_id ); 177 $user->set_role( $role ); 167 178 } 168 169 $user = get_userdata( $user_id );170 $user->set_role( $role );171 179 } 172 180 } else { 173 181 $update = 'err_promote'; … … 278 286 <form class="search-form" method="get"> 279 287 <?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?> 280 288 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" /> 289 <?php if ( isset( $_GET['role'] ) && '-1' === $_GET['role'] ) { ?> 290 <input type="hidden" name="role" value="-1" /> 291 <?php } ?> 281 292 </form> 282 293 283 294 <?php $wp_list_table->views(); ?> -
src/wp-admin/users.php
139 139 continue; 140 140 } 141 141 142 // If the user doesn't already belong to the blog, bail. 143 if ( is_multisite() && ! is_user_member_of_blog( $id ) ) { 144 wp_die( 145 '<h1>' . __( 'Something went wrong.' ) . '</h1>' . 146 '<p>' . __( 'One of the selected users is not a member of this site.' ) . '</p>', 147 403 148 ); 142 // If the user doesn't already belong to the blog: 143 if ( ! is_user_member_of_blog( $id ) ) { 144 if ( current_user_can( 'manage_network_users' ) ) { 145 add_existing_user_to_blog( array( 146 'user_id' => $id, 147 'role' => $role, 148 ) ); 149 } else { 150 wp_die( 151 '<h1>' . __( 'Something went wrong.' ) . '</h1>' . 152 '<p>' . __( 'One of the selected users is not a member of this site.' ) . '</p>', 153 403 154 ); 155 } 156 } else { 157 $user = get_userdata( $id ); 158 $user->set_role( $role ); 149 159 } 150 151 $user = get_userdata( $id );152 $user->set_role( $role );153 160 } 154 161 155 162 wp_redirect( add_query_arg( 'update', $update, $redirect ) );