WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/15/2010 12:21:13 AM (10 years ago)
Author:
wpmuguru
Message:

merge multisite wp-admin/includes except schema, See #11644

File:
1 edited

Legend:

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

    r12652 r12726  
    198198function get_author_user_ids() {
    199199    global $wpdb;
    200     $level_key = $wpdb->prefix . 'user_level';
     200    if( !is_multisite() ) {
     201        $level_key = $wpdb->get_blog_prefix() . 'user_level';
     202    } else {
     203        $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
     204    }
    201205    return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) );
    202206}
     
    249253            return array();
    250254    }
    251 
    252     $level_key = $wpdb->prefix . 'user_level';
     255    if( !is_multisite() ) {
     256        $level_key = $wpdb->get_blog_prefix() . 'user_level';
     257    } else {
     258        $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
     259    }
    253260
    254261    $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
     
    295302function get_nonauthor_user_ids() {
    296303    global $wpdb;
    297     $level_key = $wpdb->prefix . 'user_level';
     304
     305    if ( !is_multisite() ) {
     306        $level_key = $wpdb->get_blog_prefix() . 'user_level';
     307    } else {
     308        $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
     309    }
    298310
    299311    return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
     
    441453
    442454    // FINALLY, delete user
    443 
    444     $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) );
    445     $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d", $id) );
     455    if ( !is_multisite() ) {
     456        $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) );
     457        $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d", $id) );
     458    } else {
     459        $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
     460        $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = $id AND meta_key = '{$level_key}'");
     461    }
    446462
    447463    wp_cache_delete($id, 'users');
     
    662678        if ( $this->role )
    663679            $this->query_from_where .= $wpdb->prepare(" INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
    664         else
     680        elseif ( !is_multisite() )
    665681            $this->query_from_where .= " WHERE 1=1";
     682        else {
     683            $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
     684            $this->query_from_where .= ", $wpdb->usermeta WHERE $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
     685        }
    666686        $this->query_from_where .= " $search_sql";
    667687
Note: See TracChangeset for help on using the changeset viewer.