X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/38ca813a0e312e2768e5b9519f0415cd0aa84781..341dfbb66f24f5145174c373267f889c31615cc5:/wp-includes/ms-functions.php diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index 6c1f80a1..17e0e670 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -1,6 +1,6 @@ get_blog_count(), + 'users' => get_user_count(), + ); return $stats; } @@ -79,7 +81,7 @@ function get_active_blog_for_user( $user_id ) { if ( false !== $primary_blog ) { if ( ! isset( $blogs[ $primary_blog ] ) ) { update_user_meta( $user_id, 'primary_blog', $first_blog->userblog_id ); - $primary = $first_blog; + $primary = get_blog_details( $first_blog->userblog_id ); } else { $primary = get_blog_details( $primary_blog ); } @@ -90,7 +92,7 @@ function get_active_blog_for_user( $user_id ) { $primary = $first_blog; } - if ( ( ! is_object( $primary ) ) || ( is_object( $primary ) && $primary->archived == 1 || $primary->spam == 1 || $primary->deleted == 1 ) ) { + if ( ( ! is_object( $primary ) ) || ( $primary->archived == 1 || $primary->spam == 1 || $primary->deleted == 1 ) ) { $blogs = get_blogs_of_user( $user_id, true ); // if a user's primary blog is shut down, check their other blogs. $ret = false; if ( is_array( $blogs ) && count( $blogs ) > 0 ) { @@ -116,32 +118,6 @@ function get_active_blog_for_user( $user_id ) { } } -/** - * Find out whether a user is a member of a given blog. - * - * @since MU 1.1 - * @uses get_blogs_of_user() - * - * @param int $user_id The unique ID of the user - * @param int $blog Optional. If no blog_id is provided, current site is used - * @return bool - */ -function is_user_member_of_blog( $user_id, $blog_id = 0 ) { - $user_id = (int) $user_id; - $blog_id = (int) $blog_id; - - if ( $blog_id == 0 ) { - global $wpdb; - $blog_id = $wpdb->blogid; - } - - $blogs = get_blogs_of_user( $user_id ); - if ( is_array( $blogs ) ) - return array_key_exists( $blog_id, $blogs ); - else - return false; -} - /** * The number of active users in your installation. * @@ -291,6 +267,8 @@ function remove_user_from_blog($user_id, $blog_id = '', $reassign = '') { } restore_current_blog(); + + return true; } /** @@ -314,14 +292,14 @@ function create_empty_blog( $domain, $path, $weblog_title, $site_id = 1 ) { // Check if the domain has been used already. We should return an error message. if ( domain_exists($domain, $path, $site_id) ) - return __( 'Error: Site URL already taken.' ); + return __( 'ERROR: Site URL already taken.' ); // Need to back up wpdb table names, and create a new wp_blogs entry for new blog. // Need to get blog_id from wp_blogs, and create new table names. // Must restore table names at the end of function. if ( ! $blog_id = insert_blog($domain, $path, $site_id) ) - return __( 'Error: problem creating site entry.' ); + return __( 'ERROR: problem creating site entry.' ); switch_to_blog($blog_id); install_blog($blog_id); @@ -391,68 +369,6 @@ function get_blog_id_from_url( $domain, $path = '/' ) { // Admin functions -/** - * Redirect a user based on $_GET or $_POST arguments. - * - * The function looks for redirect arguments in the following order: - * 1) $_GET['ref'] - * 2) $_POST['ref'] - * 3) $_SERVER['HTTP_REFERER'] - * 4) $_GET['redirect'] - * 5) $_POST['redirect'] - * 6) $url - * - * @since MU - * @uses wpmu_admin_redirect_add_updated_param() - * - * @param string $url - */ -function wpmu_admin_do_redirect( $url = '' ) { - $ref = ''; - if ( isset( $_GET['ref'] ) ) - $ref = $_GET['ref']; - if ( isset( $_POST['ref'] ) ) - $ref = $_POST['ref']; - - if ( $ref ) { - $ref = wpmu_admin_redirect_add_updated_param( $ref ); - wp_redirect( $ref ); - exit(); - } - if ( empty( $_SERVER['HTTP_REFERER'] ) == false ) { - wp_redirect( $_SERVER['HTTP_REFERER'] ); - exit(); - } - - $url = wpmu_admin_redirect_add_updated_param( $url ); - if ( isset( $_GET['redirect'] ) ) { - if ( substr( $_GET['redirect'], 0, 2 ) == 's_' ) - $url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) ); - } elseif ( isset( $_POST['redirect'] ) ) { - $url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] ); - } - wp_redirect( $url ); - exit(); -} - -/** - * Adds an 'updated=true' argument to a URL. - * - * @since MU - * - * @param string $url - * @return string - */ -function wpmu_admin_redirect_add_updated_param( $url = '' ) { - if ( strpos( $url, 'updated=true' ) === false ) { - if ( strpos( $url, '?' ) === false ) - return $url . '?updated=true'; - else - return $url . '&updated=true'; - } - return $url; -} - /** * Checks an email address against a list of banned domains. * @@ -644,13 +560,10 @@ function wpmu_validate_blog_signup($blogname, $blog_title, $user = '') { if (! is_subdomain_install() ) $illegal_names = array_merge($illegal_names, apply_filters( 'subdirectory_reserved_names', array( 'page', 'comments', 'blog', 'files', 'feed' ) ) ); - if ( empty( $blogname ) ) $errors->add('blogname', __('Please enter a site name')); - $maybe = array(); - preg_match( '/[a-z0-9]+/', $blogname, $maybe ); - if ( $blogname != $maybe[0] ) + if ( preg_match( '/[^a-z0-9]+/', $blogname ) ) $errors->add('blogname', __('Only lowercase letters and numbers allowed')); if ( in_array( $blogname, $illegal_names ) == true ) @@ -792,7 +705,7 @@ function wpmu_signup_user($user, $user_email, $meta = '') { * replace it with your own notification behavior. * * Filter 'wpmu_signup_blog_notification_email' and - * 'wpmu_signup_blog_notification_email' to change the content + * 'wpmu_signup_blog_notification_subject' to change the content * and subject line of the email sent to newly registered users. * * @since MU @@ -1078,7 +991,7 @@ function wpmu_create_blog($domain, $path, $title, $user_id, $meta = '', $site_id add_option( 'WPLANG', get_site_option( 'WPLANG' ) ); update_option( 'blog_public', (int)$meta['public'] ); - if ( !is_super_admin() && ! get_user_meta( $user_id, 'primary_blog', true ) ) + if ( ! is_super_admin( $user_id ) && ! get_user_meta( $user_id, 'primary_blog', true ) ) update_user_meta( $user_id, 'primary_blog', $blog_id ); restore_current_blog(); @@ -1233,7 +1146,7 @@ function install_blog($blog_id, $blog_title = '') { $url = get_blogaddress_by_id($blog_id); // Set everything up - make_db_current_silent(); + make_db_current_silent( 'blog' ); populate_options(); populate_roles(); $wp_roles->_init(); @@ -1520,8 +1433,7 @@ function get_dirsize( $directory ) { function recurse_dirsize( $directory ) { $size = 0; - if ( substr( $directory, -1 ) == '/' ) - $directory = substr($directory,0,-1); + $directory = untrailingslashit( $directory ); if ( !file_exists($directory) || !is_dir( $directory ) || !is_readable( $directory ) ) return false; @@ -1564,8 +1476,7 @@ function upload_is_user_over_quota( $echo = true ) { if ( empty( $spaceAllowed ) || !is_numeric( $spaceAllowed ) ) $spaceAllowed = 10; // Default space allowed is 10 MB - $dirName = BLOGUPLOADDIR; - $size = get_dirsize($dirName) / 1024 / 1024; + $size = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024; if ( ($spaceAllowed-$size) < 0 ) { if ( $echo ) @@ -1646,8 +1557,7 @@ function fix_import_form_size( $size ) { return 0; $spaceAllowed = 1024 * 1024 * get_space_allowed(); - $dirName = BLOGUPLOADDIR; - $dirsize = get_dirsize($dirName) ; + $dirsize = get_dirsize( BLOGUPLOADDIR ); if ( $size > $spaceAllowed - $dirsize ) return $spaceAllowed - $dirsize; // remaining space else @@ -1826,7 +1736,7 @@ function maybe_add_existing_user_to_blog() { if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) ) wp_die( sprintf(__('An error occurred adding you to this site. Back to the homepage.'), site_url() ) ); - wp_die( sprintf(__('You have been added to this site. Please visit the homepage or login using your username and password.'), site_url(), admin_url() ), __('Success') ); + wp_die( sprintf(__('You have been added to this site. Please visit the homepage or log in using your username and password.'), site_url(), admin_url() ), __('Success') ); } /**