Make WordPress Core


Ignore:
Timestamp:
10/21/2010 06:35:52 PM (16 years ago)
Author:
ryan
Message:

Tabbed interface for site editing. see #15174

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/network/edit.php

    r15886 r15903  
    161161
    162162    case 'updateblog':
    163         check_admin_referer( 'editblog' );
    164         if ( ! current_user_can( 'manage_sites' ) )
    165             wp_die( __( 'You do not have permission to access this page.' ) );
    166 
    167         if ( empty( $_POST ) )
    168             wp_die( sprintf( __( 'You probably need to go back to the <a href="%s">sites page</a>', esc_url( network_admin_url( 'sites.php' ) ) ) ) );
    169 
    170         switch_to_blog( $id );
    171 
    172         // themes
    173         $allowedthemes = array();
    174         if ( isset($_POST['theme']) && is_array( $_POST['theme'] ) ) {
    175             foreach ( $_POST['theme'] as $theme => $val ) {
    176                 if ( 'on' == $val )
    177                     $allowedthemes[$theme] = true;
    178             }
    179         }
    180         update_option( 'allowedthemes',  $allowedthemes );
    181 
    182         // options
    183         if ( is_array( $_POST['option'] ) ) {
    184             $c = 1;
    185             $count = count( $_POST['option'] );
    186             $skip_options = array( 'allowedthemes' ); // Don't update these options since they are handled elsewhere in the form.
    187             foreach ( (array) $_POST['option'] as $key => $val ) {
    188                 if ( $key === 0 || is_array( $val ) || in_array($key, $skip_options) )
    189                     continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options
    190                 if ( $c == $count )
    191                     update_option( $key, stripslashes( $val ) );
    192                 else
    193                     update_option( $key, stripslashes( $val ), false ); // no need to refresh blog details yet
    194                 $c++;
    195             }
    196         }
    197 
    198         // home and siteurl
    199         if ( isset( $_POST['update_home_url'] ) && $_POST['update_home_url'] == 'update' ) {
    200             $blog_address = get_blogaddress_by_domain( $_POST['blog']['domain'], $_POST['blog']['path'] );
    201             if ( get_option( 'siteurl' ) !=  $blog_address )
    202                 update_option( 'siteurl', $blog_address );
    203 
    204             if ( get_option( 'home' ) != $blog_address )
    205                 update_option( 'home', $blog_address );
    206         }
    207 
    208         // rewrite rules can't be flushed during switch to blog
    209         delete_option( 'rewrite_rules' );
    210 
    211         // update blogs table
    212         $blog_data = stripslashes_deep( $_POST['blog'] );
    213         update_blog_details( $id, $blog_data );
    214 
    215         // get blog prefix
    216         $blog_prefix = $wpdb->get_blog_prefix( $id );
    217 
    218         // user roles
    219         if ( isset( $_POST['role'] ) && is_array( $_POST['role'] ) == true ) {
    220             $newroles = $_POST['role'];
    221 
    222             reset( $newroles );
    223             foreach ( (array) $newroles as $userid => $role ) {
    224                 $user = new WP_User( $userid );
    225                 if ( empty( $user->ID ) )
    226                     continue;
    227                 $user->for_blog( $id );
    228                 $user->set_role( $role );
    229             }
    230         }
    231 
    232         // remove user
    233         if ( isset( $_POST['blogusers'] ) && is_array( $_POST['blogusers'] ) ) {
    234             reset( $_POST['blogusers'] );
    235             foreach ( (array) $_POST['blogusers'] as $key => $val )
    236                 remove_user_from_blog( $key, $id );
    237         }
    238 
    239         // change password
    240         if ( isset( $_POST['user_password'] ) && is_array( $_POST['user_password'] ) ) {
    241             reset( $_POST['user_password'] );
    242             $newroles = $_POST['role'];
    243             foreach ( (array) $_POST['user_password'] as $userid => $pass ) {
    244                 unset( $_POST['role'] );
    245                 $_POST['role'] = $newroles[ $userid ];
    246                 if ( $pass != '' ) {
    247                     $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 ) );
    248                     $userdata = get_userdata($userid);
    249                     $_POST['pass1'] = $_POST['pass2'] = $pass;
    250                     $_POST['email'] = $userdata->user_email;
    251                     $_POST['rich_editing'] = $userdata->rich_editing;
    252                     edit_user( $userid );
    253                     if ( $cap == null )
    254                         $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->usermeta} WHERE user_id = %d AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'", $userid ) );
    255                 }
    256             }
    257             unset( $_POST['role'] );
    258             $_POST['role'] = $newroles;
    259         }
    260 
    261         // add user
    262         if ( !empty( $_POST['newuser'] ) ) {
    263             $newuser = $_POST['newuser'];
    264             $userid = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->users . " WHERE user_login = %s", $newuser ) );
    265             if ( $userid ) {
    266                 $user = $wpdb->get_var( "SELECT user_id FROM " . $wpdb->usermeta . " WHERE user_id='$userid' AND meta_key='{$blog_prefix}capabilities'" );
    267                 if ( $user == false )
    268                     add_user_to_blog( $id, $userid, $_POST['new_role'] );
    269             }
    270         }
    271         do_action( 'wpmu_update_blog_options' );
    272         restore_current_blog();
    273         wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'editblog', 'id' => $id ), wp_get_referer() ) );
     163        // No longer used.
    274164    break;
    275165
Note: See TracChangeset for help on using the changeset viewer.