Make WordPress Core

Changeset 13956


Ignore:
Timestamp:
04/03/2010 05:14:34 AM (14 years ago)
Author:
nacin
Message:

Make remove_user a meta capability. see #12793

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/schema.php

    r13827 r13956  
    608608    if ( !empty( $role ) ) {
    609609        $role->add_cap( 'update_core' );
    610         $role->add_cap( 'remove_user' );
    611610        $role->add_cap( 'remove_users' );
    612611    }
  • trunk/wp-admin/includes/upgrade.php

    r13827 r13956  
    11261126        $wpdb->update( $wpdb->postmeta, array( 'meta_key' => '_menu_item_xfn' ), array( 'meta_key' => 'menu_item_xfn' ) );
    11271127        $wpdb->update( $wpdb->postmeta, array( 'meta_key' => '_menu_item_url' ), array( 'meta_key' => 'menu_item_url' ) );
     1128    }
     1129
     1130    // 3.0-beta1 remove_user primitive->meta cap. can be removed before release
     1131    if ( $wp_current_db_version >= 12751 && $wp_current_db_version < 12751 ) {
     1132        $role =& get_role( 'administrator' );
     1133        if ( ! empty( $role ) )
     1134            $role->remove_cap( 'remove_user' );
    11281135    }
    11291136}
  • trunk/wp-admin/users.php

    r13894 r13956  
    1616    wp_die(__('Cheatin&#8217; uh?'));
    1717
    18 $del_cap_type = 'remove';
    19 if ( !is_multisite() && current_user_can('delete_users') )
    20     $del_cap_type = 'delete';
     18if ( ! is_multisite() && current_user_can('delete_users') ) {
     19    $del_cap_user = 'delete_user';
     20    $del_cap_users = 'delete_users';
     21} else {
     22    $del_cap_user = 'remove_user';
     23    $del_cap_users = 'remove_users';
     24}
    2125
    2226$title = __('Users');
     
    8690    }
    8791
    88     if ( !current_user_can($del_cap_type . '_users') )
    89         wp_die(__('You can&#8217;t delete users.'));
     92    if ( ! current_user_can($del_cap_users ) )
     93        wp_die(__('You can&#8217;t remove users.'));
    9094
    9195    $userids = $_REQUEST['users'];
     
    9498
    9599    foreach ( (array) $userids as $id) {
    96         if ( ! current_user_can($del_cap_type . '_user', $id) )
    97             wp_die(__('You can&#8217;t delete that user.'));
     100        if ( ! current_user_can( $del_cap_user, $id ) )
     101            wp_die(__( 'You can&#8217;t remove that user.' ) );
    98102
    99103        if ( $id == $current_user->ID ) {
     
    133137    }
    134138
    135     if ( !current_user_can($del_cap_type . '_users') )
    136         $errors = new WP_Error('edit_users', __('You can&#8217;t delete users.'));
     139    if ( ! current_user_can( $del_cap_users ) )
     140        $errors = new WP_Error( 'edit_users', __( 'You can&#8217;t delete users.' ) );
    137141
    138142    if ( empty($_REQUEST['users']) )
  • trunk/wp-includes/capabilities.php

    r13883 r13956  
    797797
    798798    switch ( $cap ) {
     799    case 'remove_user':
     800        $caps[] = 'remove_users';
     801        break;
    799802    case 'delete_user':
    800803        $caps[] = 'delete_users';
  • trunk/wp-includes/version.php

    r13954 r13956  
    1616 * @global int $wp_db_version
    1717 */
    18 $wp_db_version = 13803;
     18$wp_db_version = 13956;
    1919
    2020/**
Note: See TracChangeset for help on using the changeset viewer.