Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/wp-admin/includes/ms.php

    r17228 r15452  
    6666    do_action( 'delete_blog', $blog_id, $drop );
    6767
    68     $users = get_users( array( 'blog_id' => $blog_id, 'fields' => 'ids' ) );
     68    $users = get_users_of_blog( $blog_id );
    6969
    7070    // Remove users from this blog.
    7171    if ( ! empty( $users ) ) {
    72         foreach ( $users as $user_id ) {
    73             remove_user_from_blog( $user_id, $blog_id) ;
     72        foreach ( $users as $user ) {
     73            remove_user_from_blog( $user->user_id, $blog_id) ;
    7474        }
    7575    }
     
    175175    do_action( 'deleted_user', $id );
    176176
     177    return true;
     178}
     179
     180function confirm_delete_users( $users ) {
     181    $current_user = wp_get_current_user();
     182    if ( !is_array( $users ) )
     183        return false;
     184
     185    screen_icon();
     186    ?>
     187    <h2><?php esc_html_e( 'Users' ); ?></h2>
     188    <p><?php _e( 'Transfer or delete posts and links before deleting users.' ); ?></p>
     189    <form action="ms-edit.php?action=dodelete" method="post">
     190    <input type="hidden" name="dodelete" />
     191    <?php
     192    wp_nonce_field( 'ms-users-delete' );
     193    $site_admins = get_super_admins();
     194    $admin_out = "<option value='$current_user->ID'>$current_user->user_login</option>";
     195
     196    foreach ( ( $allusers = (array) $_POST['allusers'] ) as $key => $val ) {
     197        if ( $val != '' && $val != '0' ) {
     198            $delete_user = new WP_User( $val );
     199
     200            if ( in_array( $delete_user->user_login, $site_admins ) )
     201                wp_die( sprintf( __( 'Warning! User cannot be deleted. The user %s is a network admnistrator.' ), $delete_user->user_login ) );
     202
     203            echo "<input type='hidden' name='user[]' value='{$val}'/>\n";
     204            $blogs = get_blogs_of_user( $val, true );
     205
     206            if ( !empty( $blogs ) ) {
     207                ?>
     208                <br /><fieldset><p><legend><?php printf( __( "What should be done with posts and links owned by <em>%s</em>?" ), $delete_user->user_login ); ?></legend></p>
     209                <?php
     210                foreach ( (array) $blogs as $key => $details ) {
     211                    $blog_users = get_users_of_blog( $details->userblog_id );
     212                    if ( is_array( $blog_users ) && !empty( $blog_users ) ) {
     213                        $user_site = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>";
     214                        $user_dropdown = "<select name='blog[$val][{$key}]'>";
     215                        $user_list = '';
     216                        foreach ( $blog_users as $user ) {
     217                            if ( $user->user_id != $val && !in_array( $user->user_id, $allusers ) )
     218                                $user_list .= "<option value='{$user->user_id}'>{$user->user_login}</option>";
     219                        }
     220                        if ( '' == $user_list )
     221                            $user_list = $admin_out;
     222                        $user_dropdown .= $user_list;
     223                        $user_dropdown .= "</select>\n";
     224                        ?>
     225                        <ul style="list-style:none;">
     226                            <li><?php printf( __( 'Site: %s' ), $user_site ); ?></li>
     227                            <li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="delete" checked="checked" />
     228                            <?php _e( 'Delete all posts and links.' ); ?></label></li>
     229                            <li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="reassign" />
     230                            <?php echo __( 'Attribute all posts and links to:' ) . '</label>' . $user_dropdown; ?></li>
     231                        </ul>
     232                        <?php
     233                    }
     234                }
     235                echo "</fieldset>";
     236            }
     237        }
     238    }
     239    ?>
     240    <p class="submit"><input type="submit" class="button-secondary delete" value="<?php esc_attr_e( 'Confirm Deletion' ); ?>" /></p>
     241    </form>
     242    <?php
    177243    return true;
    178244}
     
    341407}
    342408
    343 /**
     409/*
    344410 * @since 3.0.0
    345411 *
     
    348414function upload_size_limit_filter( $size ) {
    349415    $fileupload_maxk = 1024 * get_site_option( 'fileupload_maxk', 1500 );
    350     if ( get_site_option( 'upload_space_check_disabled' ) )
    351         return min( $size, $fileupload_maxk );
    352 
    353416    return min( $size, $fileupload_maxk, get_upload_space_available() );
    354417}
     
    421484}
    422485
     486// Display File upload quota on dashboard
     487function dashboard_quota() {
     488    if ( get_site_option( 'upload_space_check_disabled' ) )
     489        return true;
     490
     491    $quota = get_space_allowed();
     492    $used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024;
     493
     494    if ( $used > $quota )
     495        $percentused = '100';
     496    else
     497        $percentused = ( $used / $quota ) * 100;
     498    $used_color = ( $percentused < 70 ) ? ( ( $percentused >= 40 ) ? 'waiting' : 'approved' ) : 'spam';
     499    $used = round( $used, 2 );
     500    $percentused = number_format( $percentused );
     501
     502    ?>
     503    <p class="sub musub"><?php _e( 'Storage Space' ); ?></p>
     504    <div class="table table_content musubtable">
     505    <table>
     506        <tr class="first">
     507            <td class="first b b-posts"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB</a>' ), esc_url( admin_url( 'upload.php' ) ), $quota ); ?></td>
     508            <td class="t posts"><?php _e( 'Space Allowed' ); ?></td>
     509        </tr>
     510    </table>
     511    </div>
     512    <div class="table table_discussion musubtable">
     513    <table>
     514        <tr class="first">
     515            <td class="b b-comments"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB (%3$s%%)</a>' ), esc_url( admin_url( 'upload.php' ) ), $used, $percentused ); ?></td>
     516            <td class="last t comments <?php echo $used_color;?>"><?php _e( 'Space Used' );?></td>
     517        </tr>
     518    </table>
     519    </div>
     520    <br class="clear" />
     521    <?php
     522}
     523if ( current_user_can( 'edit_posts' ) )
     524    add_action( 'activity_box_end', 'dashboard_quota' );
     525
    423526// Edit blog upload space setting on Edit Blog page
    424527function upload_space_setting( $id ) {
     
    436539add_action( 'wpmueditblogaction', 'upload_space_setting' );
    437540
    438 function update_user_status( $id, $pref, $value, $deprecated = null ) {
     541function update_user_status( $id, $pref, $value, $refresh = 1 ) {
    439542    global $wpdb;
    440543
    441     if ( null !== $deprecated  )
    442         _deprecated_argument( __FUNCTION__, '3.1' );
    443 
    444544    $wpdb->update( $wpdb->users, array( $pref => $value ), array( 'ID' => $id ) );
    445545
    446     clean_user_cache( $id );
     546    if ( $refresh == 1 )
     547        refresh_user_details( $id );
    447548
    448549    if ( $pref == 'spam' ) {
     
    508609
    509610    $blog = get_active_blog_for_user( get_current_user_id() );
    510 
     611    $dashboard_blog = get_dashboard_blog();
    511612    if ( is_object( $blog ) ) {
    512613        wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) ); // redirect and count to 5, "just in case"
    513     } else {
    514         wp_redirect( user_admin_url( '?c=' . $c ) ); // redirect and count to 5, "just in case"
    515     }
    516     exit;
     614        exit;
     615    }
     616
     617    /*
     618       If the user is a member of only 1 blog and the user's primary_blog isn't set to that blog,
     619       then update the primary_blog record to match the user's blog
     620     */
     621    $blogs = get_blogs_of_user( get_current_user_id() );
     622
     623    if ( !empty( $blogs ) ) {
     624        foreach( $blogs as $blogid => $blog ) {
     625            if ( $blogid != $dashboard_blog->blog_id && get_user_meta( get_current_user_id() , 'primary_blog', true ) == $dashboard_blog->blog_id ) {
     626                update_user_meta( get_current_user_id(), 'primary_blog', $blogid );
     627                continue;
     628            }
     629        }
     630        $blog = get_blog_details( get_user_meta( get_current_user_id(), 'primary_blog', true ) );
     631            wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) );
     632        exit;
     633    }
     634    wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
    517635}
    518636add_action( 'admin_page_access_denied', 'redirect_user_to_blog', 99 );
     
    576694    }
    577695}
    578 add_action( 'network_admin_notices', 'secret_salt_warning' );
     696add_action( 'admin_notices', 'secret_salt_warning' );
     697
     698function admin_notice_feed() {
     699    global $current_screen;
     700    if ( $current_screen->id != 'dashboard' )
     701        return;
     702
     703    if ( !empty( $_GET['feed_dismiss'] ) ) {
     704        update_user_option( get_current_user_id(), 'admin_feed_dismiss', $_GET['feed_dismiss'], true );
     705        return;
     706    }
     707
     708    $url = get_site_option( 'admin_notice_feed' );
     709    if ( empty( $url ) )
     710        return;
     711
     712    $rss = fetch_feed( $url );
     713    if ( ! is_wp_error( $rss ) && $item = $rss->get_item() ) {
     714        $title = $item->get_title();
     715        if ( md5( $title ) == get_user_option( 'admin_feed_dismiss' ) )
     716            return;
     717        $msg = "<h3>" . esc_html( $title ) . "</h3>\n";
     718        $content = $item->get_description();
     719        $content = $content ? wp_html_excerpt( $content, 200 ) . ' &hellip; ' : '';
     720        $link = esc_url( strip_tags( $item->get_link() ) );
     721        $msg .= "<p>" . $content . "<a href='$link'>" . __( 'Read More' ) . "</a> <a href='index.php?feed_dismiss=" . md5( $title ) . "'>" . __( 'Dismiss' ) . "</a></p>";
     722        echo "<div class='updated'>$msg</div>";
     723    } elseif ( is_super_admin() ) {
     724        printf( '<div class="update-nag">' . __( 'Your feed at %s is empty.' ) . '</div>', esc_html( $url ) );
     725    }
     726}
     727add_action( 'admin_notices', 'admin_notice_feed' );
    579728
    580729function site_admin_notice() {
     
    583732        return false;
    584733    if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version )
    585         echo "<div class='update-nag'>" . sprintf( __( 'Thank you for Updating! Please visit the <a href="%s">Update Network</a> page to update all your sites.' ), esc_url( network_admin_url( 'upgrade.php' ) ) ) . "</div>";
     734        echo "<div class='update-nag'>" . sprintf( __( 'Thank you for Updating! Please visit the <a href="%s">Update Network</a> page to update all your sites.' ), esc_url( admin_url( 'ms-upgrade-network.php' ) ) ) . "</div>";
    586735}
    587736add_action( 'admin_notices', 'site_admin_notice' );
    588 add_action( 'network_admin_notices', 'site_admin_notice' );
    589737
    590738function avoid_blog_page_permalink_collision( $data, $postarr ) {
     
    658806}
    659807
     808function show_post_thumbnail_warning() {
     809    if ( ! is_super_admin() )
     810        return;
     811    $mu_media_buttons = get_site_option( 'mu_media_buttons', array() );
     812    if ( empty($mu_media_buttons['image']) && current_theme_supports( 'post-thumbnails' ) ) {
     813        echo "<div class='update-nag'>" . sprintf( __( "Warning! The current theme supports Featured Images. You must enable image uploads on <a href='%s'>the options page</a> for it to work." ), esc_url( admin_url( 'ms-options.php' ) ) ) . "</div>";
     814    }
     815}
     816add_action( 'admin_notices', 'show_post_thumbnail_warning' );
     817
    660818function ms_deprecated_blogs_file() {
    661819    if ( ! is_super_admin() )
     
    665823    echo '<div class="update-nag">' . sprintf( __( 'The <code>%1$s</code> file is deprecated. Please remove it and update your server rewrite rules to use <code>%2$s</code> instead.' ), 'wp-content/blogs.php', 'wp-includes/ms-files.php' ) . '</div>';
    666824}
    667 add_action( 'network_admin_notices', 'ms_deprecated_blogs_file' );
     825add_action( 'admin_notices', 'ms_deprecated_blogs_file' );
     826
     827/**
     828 * Outputs the notice message for multisite regarding activation of plugin page.
     829 *
     830 * @since 3.0.0
     831 * @return none
     832 */
     833function _admin_notice_multisite_activate_plugins_page() {
     834    $message = sprintf( __( 'The plugins page is not visible to normal users. It must be activated first. %s' ), '<a href="' . esc_url( admin_url( 'ms-options.php#menu' ) ) . '">' . __( 'Activate' ) . '</a>' );
     835    echo "<div class='error'><p>$message</p></div>";
     836}
    668837
    669838/**
     
    671840 *
    672841 * @since 3.0.0
    673  * @param int $user_id
     842 * @param $user_id
    674843 */
    675844function grant_super_admin( $user_id ) {
     
    699868 *
    700869 * @since 3.0.0
    701  * @param int $user_id
     870 * @param $user_id
    702871 */
    703872function revoke_super_admin( $user_id ) {
     
    724893    return false;
    725894}
    726 
    727 /**
    728  * Whether or not we can edit this network from this page
    729  *
    730  * By default editing of network is restricted to the Network Admin for that site_id this allows for this to be overridden
    731  *
    732  * @since 3.1.0
    733  * @param integer $site_id The network/site id to check.
    734  */
    735 function can_edit_network( $site_id ) {
    736     global $wpdb;
    737 
    738     if ($site_id == $wpdb->siteid )
    739         $result = true;
    740     else
    741         $result = false;
    742 
    743     return apply_filters( 'can_edit_network', $result, $site_id );
    744 }
    745 
    746 /**
    747  * Thickbox image paths for Network Admin.
    748  *
    749  * @since 3.1.0
    750  * @access private
    751  */
    752 function _thickbox_path_admin_subfolder() {
    753895?>
    754 <script type="text/javascript">
    755 //<![CDATA[
    756 var tb_pathToImage = "../../wp-includes/js/thickbox/loadingAnimation.gif";
    757 var tb_closeImage = "../../wp-includes/js/thickbox/tb-close.png";
    758 //]]>
    759 </script>
    760 <?php
    761 }
    762 
    763 ?>
Note: See TracChangeset for help on using the changeset viewer.