Ticket #3152: 3152.diff
| File 3152.diff, 4.9 KB (added by , 20 years ago) |
|---|
-
wp-admin/admin-db.php
47 47 48 48 if ( ! $user->has_cap('edit_others_posts') ) { 49 49 if ( $user->has_cap('edit_posts') || $exclude_zeros == false ) 50 return array($user-> id);50 return array($user->ID); 51 51 else 52 52 return false; 53 53 } -
wp-admin/users.php
136 136 if ( ! current_user_can('edit_user', $id) ) 137 137 wp_die(__('You can’t edit that user.')); 138 138 // The new role of the current user must also have edit_users caps 139 if($id == $current_user-> id&& !$wp_roles->role_objects[$_POST['new_role']]->has_cap('edit_users')) {139 if($id == $current_user->ID && !$wp_roles->role_objects[$_POST['new_role']]->has_cap('edit_users')) { 140 140 $update = 'err_admin_role'; 141 141 continue; 142 142 } … … 168 168 if ( ! current_user_can('delete_user', $id) ) 169 169 wp_die(__('You can’t delete that user.')); 170 170 171 if($id == $current_user-> id) {171 if($id == $current_user->ID) { 172 172 $update = 'err_admin_del'; 173 173 continue; 174 174 } … … 214 214 $go_delete = false; 215 215 foreach ( (array) $userids as $id ) { 216 216 $user = new WP_User($id); 217 if ( $id == $current_user-> id) {217 if ( $id == $current_user->ID ) { 218 218 echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n"; 219 219 } else { 220 220 echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf(__('ID #%1s: %2s'), $id, $user->user_login) . "</li>\n"; … … 224 224 $all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY user_login"); 225 225 $user_dropdown = '<select name="reassign_user">'; 226 226 foreach ( (array) $all_logins as $login ) 227 if ( $login->ID == $current_user-> id|| !in_array($login->ID, $userids) )227 if ( $login->ID == $current_user->ID || !in_array($login->ID, $userids) ) 228 228 $user_dropdown .= "<option value=\"{$login->ID}\">{$login->user_login}</option>"; 229 229 $user_dropdown .= '</select>'; 230 230 ?> -
wp-includes/capabilities.php
130 130 131 131 class WP_User { 132 132 var $data; 133 var $id = 0; 133 var $ID = 0; 134 var $id = 0; // Deprecated, use $ID instead. 134 135 var $caps = array(); 135 136 var $cap_key; 136 137 var $roles = array(); … … 193 194 194 195 function add_role($role) { 195 196 $this->caps[$role] = true; 196 update_usermeta($this-> id, $this->cap_key, $this->caps);197 update_usermeta($this->ID, $this->cap_key, $this->caps); 197 198 $this->get_role_caps(); 198 199 $this->update_user_level_from_caps(); 199 200 } … … 202 203 if ( empty($this->roles[$role]) || (count($this->roles) <= 1) ) 203 204 return; 204 205 unset($this->caps[$role]); 205 update_usermeta($this-> id, $this->cap_key, $this->caps);206 update_usermeta($this->ID, $this->cap_key, $this->caps); 206 207 $this->get_role_caps(); 207 208 } 208 209 … … 215 216 } else { 216 217 $this->roles = false; 217 218 } 218 update_usermeta($this-> id, $this->cap_key, $this->caps);219 update_usermeta($this->ID, $this->cap_key, $this->caps); 219 220 $this->get_role_caps(); 220 221 $this->update_user_level_from_caps(); 221 222 } … … 232 233 function update_user_level_from_caps() { 233 234 global $wpdb; 234 235 $this->user_level = array_reduce(array_keys($this->allcaps), array(&$this, 'level_reduction'), 0); 235 update_usermeta($this-> id, $wpdb->prefix.'user_level', $this->user_level);236 update_usermeta($this->ID, $wpdb->prefix.'user_level', $this->user_level); 236 237 } 237 238 238 239 function add_cap($cap, $grant = true) { 239 240 $this->caps[$cap] = $grant; 240 update_usermeta($this-> id, $this->cap_key, $this->caps);241 update_usermeta($this->ID, $this->cap_key, $this->caps); 241 242 } 242 243 243 244 function remove_cap($cap) { 244 245 if ( empty($this->caps[$cap]) ) return; 245 246 unset($this->caps[$cap]); 246 update_usermeta($this-> id, $this->cap_key, $this->caps);247 update_usermeta($this->ID, $this->cap_key, $this->caps); 247 248 } 248 249 249 250 function remove_all_caps() { 250 251 global $wpdb; 251 252 $this->caps = array(); 252 update_usermeta($this-> id, $this->cap_key, '');253 update_usermeta($this-> id, $wpdb->prefix.'user_level', '');253 update_usermeta($this->ID, $this->cap_key, ''); 254 update_usermeta($this->ID, $wpdb->prefix.'user_level', ''); 254 255 $this->get_role_caps(); 255 256 } 256 257 … … 261 262 $cap = $this->translate_level_to_cap($cap); 262 263 263 264 $args = array_slice(func_get_args(), 1); 264 $args = array_merge(array($cap, $this-> id), $args);265 $args = array_merge(array($cap, $this->ID), $args); 265 266 $caps = call_user_func_array('map_meta_cap', $args); 266 267 // Must have ALL requested caps 267 268 $capabilities = apply_filters('user_has_cap', $this->allcaps, $caps, $args);