Changeset 16582
- Timestamp:
- 11/25/2010 09:13:38 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/network/site-users.php
r16560 r16582 52 52 $action = $wp_list_table->current_action(); 53 53 54 if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) 55 wp_redirect( wp_get_referer() ); 56 54 57 if ( $action ) { 55 58 switch_to_blog( $id ); … … 58 61 case 'adduser': 59 62 if ( !empty( $_POST['newuser'] ) ) { 60 $newuser = $_POST['newuser']; 63 $update = 'add'; 64 $newuser = $_POST['newuser']; 61 65 $userid = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->users . " WHERE user_login = %s", $newuser ) ); 62 66 if ( $userid ) { … … 64 68 if ( $user == false ) 65 69 add_user_to_blog( $id, $userid, $_POST['new_role'] ); 70 else 71 $update = 'err_add_member'; 72 } else { 73 $update = 'err_add_notfound'; 66 74 } 75 } else { 76 $update = 'err_add_notfound'; 67 77 } 68 78 break; … … 71 81 if ( !current_user_can('remove_users') ) 72 82 die(__('You can’t remove users.')); 73 83 84 $update = 'remove'; 74 85 if ( isset( $_REQUEST['users'] ) ) { 75 86 $userids = $_REQUEST['users']; … … 79 90 remove_user_from_blog( $user_id, $id ); 80 91 } 92 } elseif ( isset( $_GET['user'] ) ) { 93 remove_user_from_blog( $_GET['user'] ); 81 94 } else { 82 remove_user_from_blog( $_GET['user'] );95 $update = 'err_remove'; 83 96 } 84 97 break; … … 89 102 wp_die(__('You can’t give users that role.')); 90 103 91 $userids = $_REQUEST['users']; 92 $update = 'promote'; 93 foreach ( $userids as $user_id ) { 94 $user_id = (int) $user_id; 95 96 // If the user doesn't already belong to the blog, bail. 97 if ( !is_user_member_of_blog( $user_id ) ) 98 wp_die(__('Cheatin’ uh?')); 99 100 $user = new WP_User( $user_id ); 101 $user->set_role( $_REQUEST['new_role'] ); 104 if ( isset( $_REQUEST['users'] ) ) { 105 $userids = $_REQUEST['users']; 106 $update = 'promote'; 107 foreach ( $userids as $user_id ) { 108 $user_id = (int) $user_id; 109 110 // If the user doesn't already belong to the blog, bail. 111 if ( !is_user_member_of_blog( $user_id ) ) 112 wp_die(__('Cheatin’ uh?')); 113 114 $user = new WP_User( $user_id ); 115 $user->set_role( $_REQUEST['new_role'] ); 116 } 117 } else { 118 $update = 'err_promote'; 102 119 } 103 120 break; … … 105 122 106 123 restore_current_blog(); 107 wp_redirect( wp_get_referer() ); // @todo add_query_arg for update message124 wp_redirect( add_query_arg( 'update', $update, wp_get_referer() ) ); 108 125 } 109 126 … … 114 131 $submenu_file = 'sites.php'; 115 132 116 require('../admin-header.php'); 117 118 ?> 133 require('../admin-header.php'); ?> 119 134 120 135 <div class="wrap"> … … 130 145 } 131 146 ?> 132 </h3> 147 </h3><?php 148 149 if ( isset($_GET['update']) ) : 150 switch($_GET['update']) { 151 case 'add': 152 echo '<div id="message" class="updated"><p>' . __( 'User added.' ) . '</p></div>'; 153 break; 154 case 'err_add_member': 155 echo '<div id="message" class="error"><p>' . __( 'User is already a member of this site.' ) . '</p></div>'; 156 break; 157 case 'err_add_notfound': 158 echo '<div id="message" class="error"><p>' . __( 'Enter the username of an existing user.' ) . '</p></div>'; 159 break; 160 case 'promote': 161 echo '<div id="message" class="updated"><p>' . __( 'Changed roles.' ) . '</p></div>'; 162 break; 163 case 'err_promote': 164 echo '<div id="message" class="error"><p>' . __( 'Select a user to change role.' ) . '</p></div>'; 165 break; 166 case 'remove': 167 echo '<div id="message" class="updated fade"><p>' . __( 'User removed from this site.' ) . '</p></div>'; 168 break; 169 case 'err_remove': 170 echo '<div id="message" class="error"><p>' . __( 'Select a user to remove.' ) . '</p></div>'; 171 break; 172 } 173 endif; ?> 174 133 175 <form class="search-form" action="" method="get"> 134 176 <p class="search-box">
Note: See TracChangeset
for help on using the changeset viewer.