X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/f9001779751f83dc8a10e478bfecb4d8dd5f964c..fa11948979fd6a4ea5705dc613b239699a459db3:/wp-admin/network/site-users.php diff --git a/wp-admin/network/site-users.php b/wp-admin/network/site-users.php index 9366cb93..62c6212c 100644 --- a/wp-admin/network/site-users.php +++ b/wp-admin/network/site-users.php @@ -8,7 +8,7 @@ */ /** Load WordPress Administration Bootstrap */ -require_once( './admin.php' ); +require_once( dirname( __FILE__ ) . '/admin.php' ); if ( ! is_multisite() ) wp_die( __( 'Multisite support is not enabled.' ) ); @@ -19,52 +19,52 @@ if ( ! current_user_can('manage_sites') ) $wp_list_table = _get_list_table('WP_Users_List_Table'); $wp_list_table->prepare_items(); -$action = $wp_list_table->current_action(); - -add_contextual_help($current_screen, - '

' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '

' . - '

' . __('Info - The domain and path are rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.') . '

' . - '

' . __('Users - This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.') . '

' . - '

' . sprintf( __('Themes - This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site’s Appearance menu. To enable a theme for the entire network, see the Network Themes screen.' ), network_admin_url( 'themes.php' ) ) . '

' . - '

' . __('Settings - This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '

' . +get_current_screen()->add_help_tab( array( + 'id' => 'overview', + 'title' => __('Overview'), + 'content' => + '

' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '

' . + '

' . __('Info - The domain and path are rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.') . '

' . + '

' . __('Users - This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.') . '

' . + '

' . sprintf( __('Themes - This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site’s Appearance menu. To enable a theme for the entire network, see the Network Themes screen.' ), network_admin_url( 'themes.php' ) ) . '

' . + '

' . __('Settings - This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '

' +) ); + +get_current_screen()->set_help_sidebar( '

' . __('For more information:') . '

' . - '

' . __('Documentation on Site Management') . '

' . + '

' . __('Documentation on Site Management') . '

' . '

' . __('Support Forums') . '

' ); +$_SERVER['REQUEST_URI'] = remove_query_arg( 'update', $_SERVER['REQUEST_URI'] ); +$referer = remove_query_arg( 'update', wp_get_referer() ); + $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; if ( ! $id ) wp_die( __('Invalid site ID.') ); $details = get_blog_details( $id ); -if ( !can_edit_network( $details->site_id ) ) +if ( ! can_edit_network( $details->site_id ) ) wp_die( __( 'You do not have permission to access this page.' ) ); $is_main_site = is_main_site( $id ); -// get blog prefix -$blog_prefix = $wpdb->get_blog_prefix( $id ); +switch_to_blog( $id ); -// @todo This is a hack. Eventually, add API to WP_Roles allowing retrieval of roles for a particular blog. -if ( ! empty($wp_roles->use_db) ) { - $editblog_roles = get_blog_option( $id, "{$blog_prefix}user_roles" ); -} else { - // Roles are stored in memory, not the DB. - $editblog_roles = $wp_roles->roles; -} -$default_role = get_blog_option( $id, 'default_role' ); +$editblog_roles = $wp_roles->roles; + +$default_role = get_option( 'default_role' ); $action = $wp_list_table->current_action(); if ( $action ) { - switch_to_blog( $id ); - + switch ( $action ) { case 'newuser': check_admin_referer( 'add-user', '_wpnonce_add-new-user' ); $user = $_POST['user']; - if ( !is_array( $_POST['user'] ) || empty( $user['username'] ) || empty( $user['email'] ) ) { + if ( ! is_array( $_POST['user'] ) || empty( $user['username'] ) || empty( $user['email'] ) ) { $update = 'err_new'; } else { $password = wp_generate_password( 12, false); @@ -84,12 +84,11 @@ if ( $action ) { check_admin_referer( 'add-user', '_wpnonce_add-user' ); if ( !empty( $_POST['newuser'] ) ) { $update = 'adduser'; - $newuser = $_POST['newuser']; - $userid = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->users . " WHERE user_login = %s", $newuser ) ); - if ( $userid ) { - $user = $wpdb->get_var( "SELECT user_id FROM " . $wpdb->usermeta . " WHERE user_id='$userid' AND meta_key='{$blog_prefix}capabilities'" ); - if ( $user == false ) - add_user_to_blog( $id, $userid, $_POST['new_role'] ); + $newuser = $_POST['newuser']; + $user = get_user_by( 'login', $newuser ); + if ( $user && $user->exists() ) { + if ( ! is_user_member_of_blog( $user->ID, $id ) ) + add_user_to_blog( $id, $user->ID, $_POST['new_role'] ); else $update = 'err_add_member'; } else { @@ -99,12 +98,12 @@ if ( $action ) { $update = 'err_add_notfound'; } break; - + case 'remove': - if ( !current_user_can('remove_users') ) + if ( ! current_user_can( 'remove_users' ) ) die(__('You can’t remove users.')); check_admin_referer( 'bulk-users' ); - + $update = 'remove'; if ( isset( $_REQUEST['users'] ) ) { $userids = $_REQUEST['users']; @@ -136,7 +135,7 @@ if ( $action ) { if ( !is_user_member_of_blog( $user_id ) ) wp_die(__('Cheatin’ uh?')); - $user = new WP_User( $user_id ); + $user = get_userdata( $user_id ); $user->set_role( $_REQUEST['new_role'] ); } } else { @@ -144,28 +143,42 @@ if ( $action ) { } break; } - - restore_current_blog(); - wp_redirect( add_query_arg( 'update', $update, wp_get_referer() ) ); + + wp_safe_redirect( add_query_arg( 'update', $update, $referer ) ); exit(); } +restore_current_blog(); + if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) { - wp_redirect( wp_get_referer() ); + wp_safe_redirect( $referer ); exit(); } add_screen_option( 'per_page', array( 'label' => _x( 'Users', 'users per page (screen options)' ) ) ); -$title = sprintf( __('Edit Site: %s'), get_blogaddress_by_id($id)); +$site_url_no_http = preg_replace( '#^http(s)?://#', '', get_blogaddress_by_id( $id ) ); +$title_site_url_linked = sprintf( __('Edit Site: %2$s'), get_blogaddress_by_id( $id ), $site_url_no_http ); +$title = sprintf( __('Edit Site: %s'), $site_url_no_http ); + $parent_file = 'sites.php'; $submenu_file = 'sites.php'; -require('../admin-header.php'); ?> +if ( ! wp_is_large_network( 'users' ) && apply_filters( 'show_network_site_users_add_existing_form', true ) ) + wp_enqueue_script( 'user-suggest' ); + +require( ABSPATH . 'wp-admin/admin-header.php' ); ?> + + +
-

+

views(); ?>
- display(); ?> @@ -234,44 +246,35 @@ endif; ?> -

- -

- -

- -
+

- - + - +
- + 'submit-add-existing-user' ) ); ?>
-
+

- @@ -283,14 +286,13 @@ endif; ?> - + @@ -300,9 +302,9 @@ endif; ?>
- + 'submit-add-user' ) ); ?>