Make WordPress Core


Ignore:
Timestamp:
09/27/2010 08:26:36 PM (16 years ago)
Author:
ryan
Message:

Admin bar, first pass. see #14772

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/ms-functions.php

    r15621 r15671  
    2929
    3030        return false;
    31 }
    32 
    33 function get_blogs_of_user( $id, $all = false ) {
    34         global $wpdb;
    35 
    36         $cache_suffix = $all ? '_all' : '_short';
    37         $return = wp_cache_get( 'blogs_of_user_' . $id . $cache_suffix, 'users' );
    38         if ( $return )
    39                 return apply_filters( 'get_blogs_of_user', $return, $id, $all );
    40 
    41         $user = get_userdata( (int) $id );
    42         if ( !$user )
    43                 return false;
    44 
    45         $blogs = $match = array();
    46         $prefix_length = strlen($wpdb->base_prefix);
    47         foreach ( (array) $user as $key => $value ) {
    48                 if ( $prefix_length && substr($key, 0, $prefix_length) != $wpdb->base_prefix )
    49                         continue;
    50                 if ( substr($key, -12, 12) != 'capabilities' )
    51                         continue;
    52                 if ( preg_match( '/^' . $wpdb->base_prefix . '((\d+)_)?capabilities$/', $key, $match ) ) {
    53                         if ( count( $match ) > 2 )
    54                                 $blog_id = $match[ 2 ];
    55                         else
    56                                 $blog_id = 1;
    57                         $blog = get_blog_details( $blog_id );
    58                         if ( $blog && isset( $blog->domain ) && ( $all == true || $all == false && ( $blog->archived == 0 && $blog->spam == 0 && $blog->deleted == 0 ) ) ) {
    59                                 $blogs[ $blog_id ]->userblog_id = $blog_id;
    60                                 $blogs[ $blog_id ]->blogname            = $blog->blogname;
    61                                 $blogs[ $blog_id ]->domain              = $blog->domain;
    62                                 $blogs[ $blog_id ]->path                        = $blog->path;
    63                                 $blogs[ $blog_id ]->site_id             = $blog->site_id;
    64                                 $blogs[ $blog_id ]->siteurl             = $blog->siteurl;
    65                         }
    66                 }
    67         }
    68 
    69         wp_cache_add( 'blogs_of_user_' . $id . $cache_suffix, $blogs, 'users', 5 );
    70         return apply_filters( 'get_blogs_of_user', $blogs, $id, $all );
    7131}
    7232
    … …  
    367327}
    368328
    369 function is_blog_user( $blog_id = 0 ) {
    370         global $wpdb;
    371  
    372         $current_user = wp_get_current_user();
    373         if ( !$blog_id )
    374                 $blog_id = $wpdb->blogid;
    375 
    376         $cap_key = $wpdb->base_prefix . $blog_id . '_capabilities';
    377 
    378         if ( is_array($current_user->$cap_key) && in_array(1, $current_user->$cap_key) )
    379                 return true;
    380 
    381         return false;
    382 }
    383 
    384329function is_email_address_unsafe( $user_email ) {
    385330        $banned_names = get_site_option( 'banned_email_domains' );
Note: See TracChangeset for help on using the changeset viewer.