X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/f9001779751f83dc8a10e478bfecb4d8dd5f964c..2394dc71e94f8323dc422e89f9841959de78d328:/wp-admin/includes/ms.php?ds=sidebyside diff --git a/wp-admin/includes/ms.php b/wp-admin/includes/ms.php index 84585264..2c275dfc 100644 --- a/wp-admin/includes/ms.php +++ b/wp-admin/includes/ms.php @@ -53,16 +53,17 @@ add_filter( 'wp_handle_upload_prefilter', 'check_upload_size' ); * @return void */ function wpmu_delete_blog( $blog_id, $drop = false ) { - global $wpdb; + global $wpdb, $current_site; $switch = false; if ( $blog_id != $wpdb->blogid ) { $switch = true; switch_to_blog( $blog_id ); + $blog = get_blog_details( $blog_id ); + } else { + $blog = $GLOBALS['current_blog']; } - $blog_prefix = $wpdb->get_blog_prefix( $blog_id ); - do_action( 'delete_blog', $blog_id, $drop ); $users = get_users( array( 'blog_id' => $blog_id, 'fields' => 'ids' ) ); @@ -70,23 +71,24 @@ function wpmu_delete_blog( $blog_id, $drop = false ) { // Remove users from this blog. if ( ! empty( $users ) ) { foreach ( $users as $user_id ) { - remove_user_from_blog( $user_id, $blog_id) ; + remove_user_from_blog( $user_id, $blog_id ); } } update_blog_status( $blog_id, 'deleted', 1 ); + // Don't destroy the initial, main, or root blog. + if ( $drop && ( 1 == $blog_id || is_main_site( $blog_id ) || ( $blog->path == $current_site->path && $blog->domain == $current_site->domain ) ) ) + $drop = false; + if ( $drop ) { - if ( substr( $blog_prefix, -1 ) == '_' ) - $blog_prefix = substr( $blog_prefix, 0, -1 ) . '\_'; - $drop_tables = $wpdb->get_results( "SHOW TABLES LIKE '{$blog_prefix}%'", ARRAY_A ); - $drop_tables = apply_filters( 'wpmu_drop_tables', $drop_tables ); + $drop_tables = apply_filters( 'wpmu_drop_tables', $wpdb->tables( 'blog' ) ); - reset( $drop_tables ); - foreach ( (array) $drop_tables as $drop_table) { - $wpdb->query( "DROP TABLE IF EXISTS ". current( $drop_table ) ."" ); + foreach ( (array) $drop_tables as $table ) { + $wpdb->query( "DROP TABLE IF EXISTS `$table`" ); } + $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->blogs WHERE blog_id = %d", $blog_id ) ); $dir = apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id ); $dir = rtrim( $dir, DIRECTORY_SEPARATOR ); @@ -120,17 +122,7 @@ function wpmu_delete_blog( $blog_id, $drop = false ) { } } - $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = '{$blog_prefix}autosave_draft_ids'" ); - $blogs = get_site_option( 'blog_list' ); - if ( is_array( $blogs ) ) { - foreach ( $blogs as $n => $blog ) { - if ( $blog['blog_id'] == $blog_id ) - unset( $blogs[$n] ); - } - update_site_option( 'blog_list', $blogs ); - } - - if ( $switch === true ) + if ( $switch ) restore_current_blog(); } @@ -250,7 +242,7 @@ function send_confirmation_on_profile_email() { if ( ! is_object($errors) ) $errors = new WP_Error(); - if ( $current_user->id != $_POST['user_id'] ) + if ( $current_user->ID != $_POST['user_id'] ) return false; if ( $current_user->user_email != $_POST['email'] ) { @@ -393,9 +385,11 @@ function get_upload_space_available() { */ function get_space_allowed() { $space_allowed = get_option( 'blog_upload_space' ); - if ( $space_allowed == false ) + + if ( ! is_numeric( $space_allowed ) ) $space_allowed = get_site_option( 'blog_upload_space' ); - if ( empty( $space_allowed ) || !is_numeric( $space_allowed ) ) + + if ( empty( $space_allowed ) || ! is_numeric( $space_allowed ) ) $space_allowed = 50; return $space_allowed; @@ -496,26 +490,41 @@ function sync_category_tag_slugs( $term, $taxonomy ) { } add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 ); -function redirect_user_to_blog() { - $c = 0; - if ( isset( $_GET['c'] ) ) - $c = (int) $_GET['c']; +function _access_denied_splash() { + if ( ! is_user_logged_in() || is_network_admin() ) + return; - if ( $c >= 5 ) { - wp_die( __( "You don’t have permission to view this site. Please contact the system administrator." ) ); - } - $c ++; + $blogs = get_blogs_of_user( get_current_user_id() ); - $blog = get_active_blog_for_user( get_current_user_id() ); + if ( wp_list_filter( $blogs, array( 'userblog_id' => get_current_blog_id() ) ) ) + return; - if ( is_object( $blog ) ) { - wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) ); // redirect and count to 5, "just in case" - } else { - wp_redirect( user_admin_url( '?c=' . $c ) ); // redirect and count to 5, "just in case" + $blog_name = get_bloginfo( 'name' ); + + if ( empty( $blogs ) ) + wp_die( sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) ); + + $output = '

' . sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) . '

'; + $output .= '

' . __( 'If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.' ) . '

'; + + $output .= '

' . __('Your Sites') . '

'; + $output .= ''; + + foreach ( $blogs as $blog ) { + $output .= ""; + $output .= ""; + $output .= ""; + $output .= ""; } - exit; + $output .= '
"; + $output .= "{$blog->blogname}"; + $output .= ""; + $output .= "" . __( 'Visit Dashboard' ) . " | " . __( 'View Site' ) . "" ; + $output .= "
'; + + wp_die( $output ); } -add_action( 'admin_page_access_denied', 'redirect_user_to_blog', 99 ); +add_action( 'admin_page_access_denied', '_access_denied_splash', 99 ); function check_import_new_users( $permission ) { if ( !is_super_admin() ) @@ -760,4 +769,23 @@ var tb_closeImage = "../../wp-includes/js/thickbox/tb-close.png"; 10000, 'users', $count ); + } + + $count = get_blog_count(); + return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count ); +} ?>