First pass of user admin. Network admin and screen cleanups. see #14696

git-svn-id: http://svn.automattic.com/wordpress/trunk@15746 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan
2010-10-07 19:34:18 +00:00
parent 307790b5ff
commit 9c31fd7c70
42 changed files with 311 additions and 281 deletions
+4 -55
View File
@@ -52,8 +52,8 @@ function confirm_delete_users( $users ) {
$user_dropdown = "<select name='blog[$val][{$key}]'>";
$user_list = '';
foreach ( $blog_users as $user ) {
if ( $user->user_id != $val && !in_array( $user->user_id, $allusers ) )
$user_list .= "<option value='{$user->user_id}'>{$user->user_login}</option>";
if ( $user->user_id != $val && !in_array( $user->id, $allusers ) )
$user_list .= "<option value='{$user->id}'>{$user->user_login}</option>";
}
if ( '' == $user_list )
$user_list = $admin_out;
@@ -137,53 +137,8 @@ switch ( $_GET['action'] ) {
} else {
update_site_option( 'banned_email_domains', '' );
}
update_site_option( 'default_user_role', $_POST['default_user_role'] );
if ( trim( $_POST['dashboard_blog_orig'] ) == '' )
$_POST['dashboard_blog_orig'] = $current_site->blog_id;
if ( trim( $_POST['dashboard_blog'] ) == '' ) {
$_POST['dashboard_blog'] = $current_site->blog_id;
$dashboard_blog_id = $current_site->blog_id;
} elseif ( ! preg_match( '/(--|\.)/', $_POST['dashboard_blog'] ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $_POST['dashboard_blog'] ) ) {
$dashboard_blog = $_POST['dashboard_blog'];
$blog_details = get_blog_details( $dashboard_blog );
if ( false === $blog_details ) {
if ( is_numeric( $dashboard_blog ) )
wp_die( __( 'A dashboard site referenced by ID must already exist' ) );
if ( is_subdomain_install() ) {
$domain = $dashboard_blog . '.' . $current_site->domain;
$path = $current_site->path;
} else {
$domain = $current_site->domain;
$path = trailingslashit( $current_site->path . $dashboard_blog );
}
$wpdb->hide_errors();
$dashboard_blog_id = wpmu_create_blog( $domain, $path, __( 'My Dashboard' ), $current_user->id , array( 'public' => 0 ), $current_site->id );
$wpdb->show_errors();
} else {
$dashboard_blog_id = $blog_details->blog_id;
}
}
if ( is_wp_error( $dashboard_blog_id ) )
wp_die( __( 'Problem creating dashboard site: ' ) . $dashboard_blog_id->get_error_message() );
if ( $_POST['dashboard_blog_orig'] != $_POST['dashboard_blog'] ) {
$users = get_users_of_blog( get_site_option( 'dashboard_blog' ) );
$move_users = array();
foreach ( (array)$users as $user ) {
$user_meta_value = unserialize( $user->meta_value );
if ( is_array( $user_meta_value ) && array_pop( $var_by_ref = array_keys( $user_meta_value ) ) == 'subscriber' )
$move_users[] = $user->user_id;
}
if ( false == empty( $move_users ) ) {
foreach ( (array)$move_users as $user_id ) {
remove_user_from_blog($user_id, get_site_option( 'dashboard_blog' ) );
add_user_to_blog( $dashboard_blog_id, $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
update_user_meta( $user_id, 'primary_blog', $dashboard_blog_id );
}
}
}
update_site_option( 'dashboard_blog', $dashboard_blog_id );
$options = array( 'registrationnotification', 'registration', 'add_new_users', 'menu_items', 'mu_media_buttons', 'upload_space_check_disabled', 'blog_upload_space', 'upload_filetypes', 'site_name', 'first_post', 'first_page', 'first_comment', 'first_comment_url', 'first_comment_author', 'welcome_email', 'welcome_user_email', 'fileupload_maxk', 'admin_notice_feed', 'global_terms_enabled' );
$options = array( 'registrationnotification', 'registration', 'add_new_users', 'menu_items', 'mu_media_buttons', 'upload_space_check_disabled', 'blog_upload_space', 'upload_filetypes', 'site_name', 'first_post', 'first_page', 'first_comment', 'first_comment_url', 'first_comment_author', 'welcome_email', 'welcome_user_email', 'fileupload_maxk', 'global_terms_enabled' );
$checked_options = array( 'mu_media_buttons' => array(), 'menu_items' => array(), 'registrationnotification' => 'no', 'upload_space_check_disabled' => 1, 'add_new_users' => 0 );
foreach ( $checked_options as $option_name => $option_unchecked_value ) {
if ( ! isset( $_POST[$option_name] ) )
@@ -255,8 +210,7 @@ switch ( $_GET['action'] ) {
$id = wpmu_create_blog( $newdomain, $path, $title, $user_id , array( 'public' => 1 ), $current_site->id );
$wpdb->show_errors();
if ( !is_wp_error( $id ) ) {
$dashboard_blog = get_dashboard_blog();
if ( !is_super_admin( $user_id ) && get_user_option( 'primary_blog', $user_id ) == $dashboard_blog->blog_id )
if ( !is_super_admin( $user_id ) && !get_user_option( 'primary_blog', $user_id ) )
update_user_option( $user_id, 'primary_blog', $id, true );
$content_mail = sprintf( __( "New site created by %1s\n\nAddress: http://%2s\nName: %3s"), $current_user->user_login , $newdomain . $path, stripslashes( $title ) );
wp_mail( get_site_option('admin_email'), sprintf( __( '[%s] New Site Created' ), $current_site->site_name ), $content_mail, 'From: "Site Admin" <' . get_site_option( 'admin_email' ) . '>' );
@@ -687,11 +641,6 @@ switch ( $_GET['action'] ) {
else
wp_new_user_notification( $user_id, $password );
if ( get_site_option( 'dashboard_blog' ) == false )
add_user_to_blog( $current_site->blog_id, $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
else
add_user_to_blog( get_site_option( 'dashboard_blog' ), $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'add' ), wp_get_referer() ) );
exit();
break;
+1 -39
View File
@@ -43,7 +43,7 @@ if (isset($_GET['updated'])) {
?>
<div class="wrap">
<?php screen_icon(); ?>
<?php screen_icon('options-general'); ?>
<h2><?php _e( 'Network Options' ) ?></h2>
<form method="post" action="edit.php?action=siteoptions">
<?php wp_nonce_field( 'siteoptions' ); ?>
@@ -67,44 +67,6 @@ if (isset($_GET['updated'])) {
</td>
</tr>
</table>
<h3><?php _e( 'Dashboard Settings' ); ?></h3>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="dashboard_blog"><?php _e( 'Dashboard Site' ) ?></label></th>
<td>
<?php
if ( $dashboard_blog = get_site_option( 'dashboard_blog' ) ) {
$details = get_blog_details( $dashboard_blog );
$blogname = untrailingslashit( sanitize_user( str_replace( '.', '', str_replace( $current_site->domain . $current_site->path, '', $details->domain . $details->path ) ) ) );
} else {
$blogname = '';
}?>
<input name="dashboard_blog_orig" type="hidden" id="dashboard_blog_orig" value="<?php echo esc_attr( $blogname ); ?>" />
<input name="dashboard_blog" type="text" id="dashboard_blog" value="<?php echo esc_attr( $blogname ); ?>" class="regular-text" />
<br />
<?php _e( 'Site path (&#8220;dashboard&#8221;, &#8220;control&#8221;, &#8220;manager&#8221;, etc.) or blog ID.<br />New users are added to this site as the user role defined below if they don&#8217;t have a site. Leave blank for the main site. Users with the Subscriber role on the old site will be moved to the new site if changed. The new site will be created if it does not exist.' ); ?>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="default_user_role"><?php _e( 'Dashboard User Default Role' ) ?></label></th>
<td>
<select name="default_user_role" id="default_user_role"><?php
wp_dropdown_roles( get_site_option( 'default_user_role', 'subscriber' ) );
?>
</select>
<br />
<?php _e( 'The default role for new users on the Dashboard site. &#8220;Subscriber&#8221; or &#8220;Contributor&#8221; roles are recommended.' ); ?>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="admin_notice_feed"><?php _e( 'Admin Notice Feed' ) ?></label></th>
<td><input name="admin_notice_feed" class="large-text" type="text" id="admin_notice_feed" value="<?php echo esc_attr( get_site_option( 'admin_notice_feed' ) ) ?>" size="80" /><br />
<?php _e( 'Display the latest post from this RSS or Atom feed on all site dashboards. Leave blank to disable.' ); ?><br />
<?php if ( get_site_option( 'admin_notice_feed' ) != get_home_url( $current_site->id, 'feed/' ) )
echo __( 'A good one to use would be the feed from your main site: ' ) . esc_url( get_home_url( $current_site->id, 'feed/' ) ) ?></td>
</tr>
</table>
<h3><?php _e( 'Registration Settings' ); ?></h3>
<table class="form-table">
<tr valign="top">
+4 -2
View File
@@ -18,6 +18,8 @@ $wp_list_table->check_permissions();
$title = __( 'Sites' );
$parent_file = 'sites.php';
add_screen_option( 'per_page', array('label' => _x( 'Sites', 'sites per page (screen options)' )) );
if ( isset( $_REQUEST['action'] ) && 'editblog' == $_REQUEST['action'] ) {
add_contextual_help($current_screen,
'<p>' . __('This extensive list of options has five modules: Site Info, Site Options, allowing Site Themes for this given site, changing user roles and passwords for that site, adding a new user, and Miscellaneous Site Actions (upload size limits).') . '</p>' .
@@ -109,7 +111,7 @@ switch ( $action ) {
require_once( '../admin-header.php' );
?>
<div class="wrap">
<?php screen_icon(); ?>
<?php screen_icon('index'); ?>
<h2><?php _e( 'Edit Site' ); ?> - <a href="<?php echo esc_url( get_home_url( $id ) ); ?>"><?php echo esc_url( get_home_url( $id ) ); ?></a></h2>
<?php echo $msg; ?>
<form method="post" action="edit.php?action=updateblog">
@@ -347,7 +349,7 @@ switch ( $action ) {
?>
<div class="wrap">
<?php screen_icon(); ?>
<?php screen_icon('index'); ?>
<h2><?php _e('Sites') ?>
<?php echo $msg; ?>
<a href="#form-add-site" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'sites' ); ?></a>
+1 -1
View File
@@ -32,7 +32,7 @@ if ( ! current_user_can( 'manage_network' ) )
wp_die( __( 'You do not have permission to access this page.' ) );
echo '<div class="wrap">';
screen_icon();
screen_icon('tools');
echo '<h2>' . __( 'Update Network' ) . '</h2>';
$action = isset($_GET['action']) ? $_GET['action'] : 'show';
+2
View File
@@ -16,6 +16,8 @@ $wp_list_table->prepare_items();
$title = __( 'Users' );
$parent_file = 'users.php';
add_screen_option( 'per_page', array('label' => _x( 'Users', 'users per page (screen options)' )) );
add_contextual_help($current_screen,
'<p>' . __('This table shows all users across the network and the sites to which they are assigned.') . '</p>' .
'<p>' . __('Hover over any user on the list to make the edit links appear. The Edit link on the left will take you to his or her Edit User profile page; the Edit link on the right by any site name goes to an Edit Site screen for that site.') . '</p>' .