Tabbed interface for site editing. see #15174

git-svn-id: https://develop.svn.wordpress.org/trunk@15903 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2010-10-21 18:35:52 +00:00
parent b41591f183
commit 69994bf7ca
9 changed files with 602 additions and 385 deletions
+1 -111
View File
@@ -160,117 +160,7 @@ switch ( $_GET['action'] ) {
break;
case 'updateblog':
check_admin_referer( 'editblog' );
if ( ! current_user_can( 'manage_sites' ) )
wp_die( __( 'You do not have permission to access this page.' ) );
if ( empty( $_POST ) )
wp_die( sprintf( __( 'You probably need to go back to the <a href="%s">sites page</a>', esc_url( network_admin_url( 'sites.php' ) ) ) ) );
switch_to_blog( $id );
// themes
$allowedthemes = array();
if ( isset($_POST['theme']) && is_array( $_POST['theme'] ) ) {
foreach ( $_POST['theme'] as $theme => $val ) {
if ( 'on' == $val )
$allowedthemes[$theme] = true;
}
}
update_option( 'allowedthemes', $allowedthemes );
// options
if ( is_array( $_POST['option'] ) ) {
$c = 1;
$count = count( $_POST['option'] );
$skip_options = array( 'allowedthemes' ); // Don't update these options since they are handled elsewhere in the form.
foreach ( (array) $_POST['option'] as $key => $val ) {
if ( $key === 0 || is_array( $val ) || in_array($key, $skip_options) )
continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options
if ( $c == $count )
update_option( $key, stripslashes( $val ) );
else
update_option( $key, stripslashes( $val ), false ); // no need to refresh blog details yet
$c++;
}
}
// home and siteurl
if ( isset( $_POST['update_home_url'] ) && $_POST['update_home_url'] == 'update' ) {
$blog_address = get_blogaddress_by_domain( $_POST['blog']['domain'], $_POST['blog']['path'] );
if ( get_option( 'siteurl' ) != $blog_address )
update_option( 'siteurl', $blog_address );
if ( get_option( 'home' ) != $blog_address )
update_option( 'home', $blog_address );
}
// rewrite rules can't be flushed during switch to blog
delete_option( 'rewrite_rules' );
// update blogs table
$blog_data = stripslashes_deep( $_POST['blog'] );
update_blog_details( $id, $blog_data );
// get blog prefix
$blog_prefix = $wpdb->get_blog_prefix( $id );
// user roles
if ( isset( $_POST['role'] ) && is_array( $_POST['role'] ) == true ) {
$newroles = $_POST['role'];
reset( $newroles );
foreach ( (array) $newroles as $userid => $role ) {
$user = new WP_User( $userid );
if ( empty( $user->ID ) )
continue;
$user->for_blog( $id );
$user->set_role( $role );
}
}
// remove user
if ( isset( $_POST['blogusers'] ) && is_array( $_POST['blogusers'] ) ) {
reset( $_POST['blogusers'] );
foreach ( (array) $_POST['blogusers'] as $key => $val )
remove_user_from_blog( $key, $id );
}
// change password
if ( isset( $_POST['user_password'] ) && is_array( $_POST['user_password'] ) ) {
reset( $_POST['user_password'] );
$newroles = $_POST['role'];
foreach ( (array) $_POST['user_password'] as $userid => $pass ) {
unset( $_POST['role'] );
$_POST['role'] = $newroles[ $userid ];
if ( $pass != '' ) {
$cap = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM {$wpdb->usermeta} WHERE user_id = %d AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'", $userid ) );
$userdata = get_userdata($userid);
$_POST['pass1'] = $_POST['pass2'] = $pass;
$_POST['email'] = $userdata->user_email;
$_POST['rich_editing'] = $userdata->rich_editing;
edit_user( $userid );
if ( $cap == null )
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->usermeta} WHERE user_id = %d AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'", $userid ) );
}
}
unset( $_POST['role'] );
$_POST['role'] = $newroles;
}
// add user
if ( !empty( $_POST['newuser'] ) ) {
$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'] );
}
}
do_action( 'wpmu_update_blog_options' );
restore_current_blog();
wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'editblog', 'id' => $id ), wp_get_referer() ) );
// No longer used.
break;
case 'deleteblog':