wp/wp-admin/network/site-users.php
author ymh <ymh.work@gmail.com>
Wed, 06 Nov 2013 03:21:17 +0000
changeset 0 d970ebf37754
child 5 5e2f62d02dcd
permissions -rw-r--r--
first import
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Edit Site Users Administration Screen
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * @subpackage Multisite
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
/** Load WordPress Administration Bootstrap */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
require_once( dirname( __FILE__ ) . '/admin.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
if ( ! is_multisite() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
	wp_die( __( 'Multisite support is not enabled.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
if ( ! current_user_can('manage_sites') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
	wp_die(__('You do not have sufficient permissions to edit this site.'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
$wp_list_table = _get_list_table('WP_Users_List_Table');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
$wp_list_table->prepare_items();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
get_current_screen()->add_help_tab( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
	'id'      => 'overview',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
	'title'   => __('Overview'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
	'content' =>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
		'<p>' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
		'<p>' . __('<strong>Info</strong> - 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.') . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
		'<p>' . __('<strong>Users</strong> - 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.') . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
		'<p>' . sprintf( __('<strong>Themes</strong> - 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&#8217;s Appearance menu. To enable a theme for the entire network, see the <a href="%s">Network Themes</a> screen.' ), network_admin_url( 'themes.php' ) ) . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
		'<p>' . __('<strong>Settings</strong> - 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.') . '</p>'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
get_current_screen()->set_help_sidebar(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
	'<p><strong>' . __('For more information:') . '</strong></p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
	'<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>') . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
	'<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
$_SERVER['REQUEST_URI'] = remove_query_arg( 'update', $_SERVER['REQUEST_URI'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
$referer = remove_query_arg( 'update', wp_get_referer() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
if ( ! $id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
	wp_die( __('Invalid site ID.') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
$details = get_blog_details( $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
if ( ! can_edit_network( $details->site_id ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
	wp_die( __( 'You do not have permission to access this page.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
$is_main_site = is_main_site( $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
switch_to_blog( $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
$editblog_roles = $wp_roles->roles;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
$default_role = get_option( 'default_role' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
$action = $wp_list_table->current_action();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
if ( $action ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
	switch ( $action ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
		case 'newuser':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
			check_admin_referer( 'add-user', '_wpnonce_add-new-user' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
			$user = $_POST['user'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
			if ( ! is_array( $_POST['user'] ) || empty( $user['username'] ) || empty( $user['email'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
				$update = 'err_new';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
				$password = wp_generate_password( 12, false);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
				$user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
				if ( false == $user_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
		 			$update = 'err_new_dup';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
				} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
					wp_new_user_notification( $user_id, $password );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
					add_user_to_blog( $id, $user_id, $_POST['new_role'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
					$update = 'newuser';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
		case 'adduser':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
			check_admin_referer( 'add-user', '_wpnonce_add-user' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
			if ( !empty( $_POST['newuser'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
				$update = 'adduser';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
				$newuser = $_POST['newuser'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
				$user = get_user_by( 'login', $newuser );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
				if ( $user && $user->exists() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
					if ( ! is_user_member_of_blog( $user->ID, $id ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
						add_user_to_blog( $id, $user->ID, $_POST['new_role'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
					else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
						$update = 'err_add_member';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
				} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
					$update = 'err_add_notfound';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
				$update = 'err_add_notfound';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
		case 'remove':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
			if ( ! current_user_can( 'remove_users' )  )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
				die(__('You can&#8217;t remove users.'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
			check_admin_referer( 'bulk-users' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
			$update = 'remove';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
			if ( isset( $_REQUEST['users'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
				$userids = $_REQUEST['users'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
				foreach ( $userids as $user_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
					$user_id = (int) $user_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
					remove_user_from_blog( $user_id, $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
			} elseif ( isset( $_GET['user'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
				remove_user_from_blog( $_GET['user'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
				$update = 'err_remove';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
		case 'promote':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
			check_admin_referer( 'bulk-users' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
			$editable_roles = get_editable_roles();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
			if ( empty( $editable_roles[$_REQUEST['new_role']] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
				wp_die(__('You can&#8217;t give users that role.'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
			if ( isset( $_REQUEST['users'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
				$userids = $_REQUEST['users'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
				$update = 'promote';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
				foreach ( $userids as $user_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
					$user_id = (int) $user_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
					// If the user doesn't already belong to the blog, bail.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
					if ( !is_user_member_of_blog( $user_id ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
						wp_die(__('Cheatin&#8217; uh?'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
					$user = get_userdata( $user_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
					$user->set_role( $_REQUEST['new_role'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
				$update = 'err_promote';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
	wp_safe_redirect( add_query_arg( 'update', $update, $referer ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
	exit();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
restore_current_blog();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
	wp_safe_redirect( $referer );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
	exit();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
add_screen_option( 'per_page', array( 'label' => _x( 'Users', 'users per page (screen options)' ) ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
$site_url_no_http = preg_replace( '#^http(s)?://#', '', get_blogaddress_by_id( $id ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
$title_site_url_linked = sprintf( __('Edit Site: <a href="%1$s">%2$s</a>'), get_blogaddress_by_id( $id ), $site_url_no_http );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
$title = sprintf( __('Edit Site: %s'), $site_url_no_http );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
$parent_file = 'sites.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
$submenu_file = 'sites.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
if ( ! wp_is_large_network( 'users' ) && apply_filters( 'show_network_site_users_add_existing_form', true ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
	wp_enqueue_script( 'user-suggest' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
require( ABSPATH . 'wp-admin/admin-header.php' ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
<script type='text/javascript'>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
/* <![CDATA[ */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
var current_site_id = <?php echo $id; ?>;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
/* ]]> */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
</script>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
<div class="wrap">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
<?php screen_icon('ms-admin'); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
<h2 id="edit-site"><?php echo $title_site_url_linked ?></h2>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
<h3 class="nav-tab-wrapper">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
$tabs = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
	'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
	'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php'    ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
	'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php'   ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
	'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
foreach ( $tabs as $tab_id => $tab ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
	$class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
	echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' . esc_html( $tab['label'] ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
</h3><?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
if ( isset($_GET['update']) ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
	switch($_GET['update']) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
	case 'adduser':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
		echo '<div id="message" class="updated"><p>' . __( 'User added.' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
	case 'err_add_member':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
		echo '<div id="message" class="error"><p>' . __( 'User is already a member of this site.' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
	case 'err_add_notfound':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
		echo '<div id="message" class="error"><p>' . __( 'Enter the username of an existing user.' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
	case 'promote':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
		echo '<div id="message" class="updated"><p>' . __( 'Changed roles.' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
	case 'err_promote':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
		echo '<div id="message" class="error"><p>' . __( 'Select a user to change role.' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
	case 'remove':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
		echo '<div id="message" class="updated"><p>' . __( 'User removed from this site.' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
	case 'err_remove':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
		echo '<div id="message" class="error"><p>' . __( 'Select a user to remove.' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
	case 'newuser':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
		echo '<div id="message" class="updated"><p>' . __( 'User created.' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
	case 'err_new':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
		echo '<div id="message" class="error"><p>' . __( 'Enter the username and email.' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
	case 'err_new_dup':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
		echo '<div id="message" class="error"><p>' . __( 'Duplicated username or email address.' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
<form class="search-form" action="" method="get">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
<?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
<?php $wp_list_table->views(); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
<form method="post" action="site-users.php?action=update-site">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
	<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
<?php $wp_list_table->display(); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
<?php do_action( 'network_site_users_after_list_table', '' );?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
<?php if ( current_user_can( 'promote_users' ) && apply_filters( 'show_network_site_users_add_existing_form', true ) ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
<h3 id="add-existing-user"><?php _e( 'Add Existing User' ); ?></h3>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
<form action="site-users.php?action=adduser" id="adduser" method="post">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
	<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
	<table class="form-table">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
		<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
			<th scope="row"><?php _e( 'Username' ); ?></th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
			<td><input type="text" class="regular-text wp-suggest-user" name="newuser" id="newuser" /></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
		</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
		<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
			<th scope="row"><?php _e( 'Role' ); ?></th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
			<td><select name="new_role" id="new_role_0">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
			<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
			reset( $editblog_roles );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
			foreach ( $editblog_roles as $role => $role_assoc ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
				$name = translate_user_role( $role_assoc['name'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
				echo '<option ' . selected( $default_role, $role, false ) . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
			?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
			</select></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
		</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
	</table>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
	<?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ) ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
	<?php submit_button( __( 'Add User' ), 'primary', 'add-user', true, array( 'id' => 'submit-add-existing-user' ) ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
<?php if ( current_user_can( 'create_users' ) && apply_filters( 'show_network_site_users_add_new_form', true ) ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
<h3 id="add-new-user"><?php _e( 'Add New User' ); ?></h3>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
<form action="<?php echo network_admin_url('site-users.php?action=newuser'); ?>" id="newuser" method="post">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
	<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
	<table class="form-table">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
		<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
			<th scope="row"><?php _e( 'Username' ) ?></th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
			<td><input type="text" class="regular-text" name="user[username]" /></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
		</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
		<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
			<th scope="row"><?php _e( 'Email' ) ?></th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
			<td><input type="text" class="regular-text" name="user[email]" /></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
		</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
		<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
			<th scope="row"><?php _e( 'Role' ); ?></th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
			<td><select name="new_role" id="new_role_0">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
			<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
			reset( $editblog_roles );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
			foreach ( $editblog_roles as $role => $role_assoc ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
				$name = translate_user_role( $role_assoc['name'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
				echo '<option ' . selected( $default_role, $role, false ) . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
			?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
			</select></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
		</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
		<tr class="form-field">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
			<td colspan="2"><?php _e( 'Username and password will be mailed to the above email address.' ) ?></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
		</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
	</table>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
	<?php wp_nonce_field( 'add-user', '_wpnonce_add-new-user' ) ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
	<?php submit_button( __( 'Add New User' ), 'primary', 'add-user', true, array( 'id' => 'submit-add-user' ) ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
require( ABSPATH . 'wp-admin/admin-footer.php' );