Make WordPress Core


Ignore:
Timestamp:
01/18/2010 10:21:36 PM (17 years ago)
Author:
ryan
Message:

Use cap checks instead of multisite and super admin checks. Add some new caps. Merge cleanup. see #11644.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/users.php

    r12752 r12753  
    1515if ( !current_user_can('edit_users') )
    1616        wp_die(__('Cheatin’ uh?'));
     17
     18$del_cap_type = 'remove';
     19if ( !is_multisite() && current_user_can('delete_users') )
     20        $del_cap_type = 'delete';
    1721
    1822$title = __('Users');
    … …  
    4448        check_admin_referer('bulk-users');
    4549
    46         if (empty($_REQUEST['users'])) {
     50        if ( empty($_REQUEST['users']) ) {
    4751                wp_redirect($redirect);
    4852                exit();
    … …  
    5054
    5155        $editable_roles = get_editable_roles();
    52         if (!$editable_roles[$_REQUEST['new_role']])
     56        if ( !$editable_roles[$_REQUEST['new_role']] )
    5357                wp_die(__('You can’t give users that role.'));
    5458
    5559        $userids = $_REQUEST['users'];
    5660        $update = 'promote';
    57         foreach($userids as $id) {
     61        foreach ( $userids as $id ) {
    5862                if ( ! current_user_can('edit_user', $id) )
    5963                        wp_die(__('You can’t edit that user.'));
    6064                // The new role of the current user must also have edit_users caps
    61                 if($id == $current_user->ID && !$wp_roles->role_objects[$_REQUEST['new_role']]->has_cap('edit_users')) {
     65                if ( $id == $current_user->ID && !$wp_roles->role_objects[$_REQUEST['new_role']]->has_cap('edit_users') ) {
    6266                        $update = 'err_admin_role';
    6367                        continue;
    … …  
    8286        }
    8387
    84         if ( !current_user_can('delete_users') )
     88        if ( !current_user_can($del_cap_type . '_users') )
    8589                wp_die(__('You can’t delete users.'));
    8690
    … …  
    9094
    9195        foreach ( (array) $userids as $id) {
    92                 if ( ! current_user_can('delete_user', $id) )
     96                if ( ! current_user_can($del_cap_type . '_user', $id) )
    9397                        wp_die(__('You can’t delete that user.'));
    9498
    95                 if ($id == $current_user->ID) {
     99                if ( $id == $current_user->ID ) {
    96100                        $update = 'err_admin_del';
    97101                        continue;
    98102                }
    99                 switch($_REQUEST['delete_option']) {
     103                switch ( $_REQUEST['delete_option'] ) {
    100104                case 'delete':
    101                         if ( !is_multisite() ) {
     105                        if ( !is_multisite() && current_user_can('delete_user', $id) )
    102106                                wp_delete_user($id);
    103                         } else {
     107                        else
    104108                                remove_user_from_blog($id, $blog_id); // WPMU only remove user from blog
    105                         }
    106109                        break;
    107110                case 'reassign':
    108                         if ( !is_multisite() ) {
     111                        if ( !is_multisite() && current_user_can('delete_user', $id) )
    109112                                wp_delete_user($id, $_REQUEST['reassign_user']);
    110                         } else {
     113                        else
    111114                                remove_user_from_blog($id, $blog_id, $_REQUEST['reassign_user']);
    112                         }
    113115                        break;
    114116                }
    … …  
    131133        }
    132134
    133         if ( !current_user_can('delete_users') )
     135        if ( !current_user_can($del_cap_type . '_users') )
    134136                $errors = new WP_Error('edit_users', __('You can’t delete users.'));
    135137
Note: See TracChangeset for help on using the changeset viewer.