Make WordPress Core


Ignore:
Timestamp:
10/19/2010 03:32:33 PM (14 years ago)
Author:
ryan
Message:

Lose get_ordered_blogs_of_user() and set_visibility(). Not using them yet. see #14772

File:
1 edited

Legend:

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

    r15843 r15851  
    638638}
    639639
    640 function get_ordered_blogs_of_user( $user_id, $visibility = true ) {
    641     $newblogs      = $ordered = array();
    642     $blogs         = get_blogs_of_user( $user_id );
    643     $order_meta    = get_user_meta( $user_id, 'blog_order' );
    644     $visible_meta  = get_user_meta( $user_id, 'blog_visibility' );
    645 
    646     $order = $order_meta;
    647     if ( !is_array( $order ) )
    648         $order = array();
    649 
    650     $visible = $visible_meta;
    651     if ( !is_array( $visible ) )
    652         $visible = array();
    653 
    654     // Index the blogs by userblog_id and set the visibility flag
    655     // Visibility is on by default, unless a linked site then off
    656     foreach ( $blogs as $blog ) {
    657         $blog->visible = true;
    658 
    659         if ( isset( $visible[$blog->userblog_id] ) )
    660             $blog->visible = $visible[$blog->userblog_id];
    661 
    662         $newblogs[$blog->userblog_id] = $blog;
    663     }
    664 
    665     // Add the blogs to our list by order
    666     foreach ( (array)$order as $id ) {
    667         // A previous change was saving the entire blog details into ordered, not just the blog ID - this detects it
    668         if ( is_object( $id ) && isset( $id->userblog_id ) )
    669             $id = $id->userblog_id;
    670        
    671         if ( is_numeric( $id ) && isset( $newblogs[intval( $id )] ) ) {
    672             $ordered[$id] = $newblogs[$id];
    673             unset( $newblogs[$id] );
    674         }
    675     }
    676 
    677     // Add any blog not yet ordered to the end
    678     foreach ( $newblogs as $blog ) {
    679         $ordered[$blog->userblog_id] = $blog;
    680     }
    681 
    682     // If we're only interested in visible blogs then remove the rest
    683     if ( $visibility ) {
    684         foreach ( (array)$ordered as $pos => $blog ) {
    685             if ( $blog->visible == false )
    686                 unset( $ordered[$pos] );
    687         }
    688     }
    689 
    690 /*
    691     // Set the order and visible options if the user doesn't have any,
    692     // but rate limit it so that the global DB doesn't get hammered
    693     if ( !is_array( $order_meta ) && ( 1 == mt_rand( 1, 10 ) ) )
    694         update_usermeta( $user_id, 'blog_order', array() );
    695 
    696     if ( !is_array( $visible_meta ) && ( 1 == mt_rand( 1, 10 ) ) )
    697         update_usermeta( $user_id, 'blog_visibility', array() );
    698 */
    699 
    700     return apply_filters( 'ordered_blogs', $ordered );
    701 }
    702 
    703 function set_blog_visibility( $blog_id, $visible ) {
    704     global $current_user;
    705 
    706     if ( is_blog_user( $blog_id ) ) {
    707         $visibility = get_user_meta( $current_user->ID, 'blog_visibility' );
    708         if ( !is_array( $visibility ) )
    709             $visibility = array();
    710 
    711         $visibility[$blog_id] = $visible;
    712 
    713         update_user_meta( $current_user->ID, 'blog_visibility', $visibility );
    714     }
    715 }
    716 
    717640/**
    718641 * Checks if the current user belong to a given blog.
Note: See TracChangeset for help on using the changeset viewer.