Changeset 1037

Show
Ignore:
Timestamp:
08/09/07 12:53:32 (1 year ago)
Author:
donncha
Message:

Use blog's default role when editing it, props jeffoire, fixes #399

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/wpmu-blogs.php

    r1031 r1037  
    1717                $options_table_name = "$wpmuBaseTablePrefix{$id}_options"; 
    1818                $options = $wpdb->get_results( "SELECT * FROM {$options_table_name} WHERE option_name NOT LIKE 'rss%' AND option_name NOT LIKE '%user_roles'", ARRAY_A ); 
    19                 $details = $wpdb->get_row( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = '{$_GET[ 'id' ]}'", ARRAY_A ); 
     19                $details = $wpdb->get_row( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = '{$id}'", ARRAY_A ); 
     20                $editblog_roles = get_blog_option( $id, "$wpmuBaseTablePrefix{$id}_user_roles" ); 
    2021 
    2122                print "<h2>" . __('Edit Blog') . "</h2>"; 
     
    2425    <form name="form1" method="post" action="wpmu-edit.php?action=updateblog">  
    2526    <?php wp_nonce_field( "editblog" ); ?> 
    26     <input type="hidden" name="id" value="<?php echo $_GET[ 'id' ] ?>" />  
     27    <input type="hidden" name="id" value="<?php echo $id ?>" />  
    2728    <table><td valign='top'> 
    2829    <div class="wrap"> 
     
    7980    </td></tr> 
    8081    <?php 
    81     while( list( $key, $val ) = each( $options ) ) {  
    82         $disabled = ''; 
    83         if ( is_serialized($val[ 'option_value' ]) ) { 
    84                 if ( is_serialized_string($val[ 'option_value' ]) ) { 
    85                         $val[ 'option_value' ] = wp_specialchars(maybe_unserialize($val[ 'option_value' ]), 'single'); 
    86                 } else { 
    87                         $val[ 'option_value' ] = "SERIALIZED DATA"; 
    88                         $disabled = ' disabled="disabled"'; 
    89                 } 
    90         } 
     82        $editblog_default_role = 'subscriber'; 
     83        while( list( $key, $val ) = each( $options ) ) {  
     84                if( $val[ 'option_name' ] == 'default_role' ) 
     85                        $editblog_default_role = $val[ 'option_value' ]; 
     86                $disabled = ''; 
     87                if ( is_serialized($val[ 'option_value' ]) ) { 
     88                        if ( is_serialized_string($val[ 'option_value' ]) ) { 
     89                                $val[ 'option_value' ] = wp_specialchars(maybe_unserialize($val[ 'option_value' ]), 'single'); 
     90                        } else { 
     91                                $val[ 'option_value' ] = "SERIALIZED DATA"; 
     92                                $disabled = ' disabled="disabled"'; 
     93                        } 
     94                } 
    9195                if ( stristr($val[ 'option_value' ], "\r") or stristr($val[ 'option_value' ], "\n") or stristr($val[ 'option_value' ], "\r\n") ) { 
    9296                ?> 
     
    144148                print "</table></div>"; 
    145149        } 
    146     $blogusers = get_users_of_blog( $_GET[ 'id' ] ); 
     150    $blogusers = get_users_of_blog( $id ); 
    147151    print '<div class="wrap"><h3>' . __('Blog Users') . '</h3>'; 
    148152    if( is_array( $blogusers ) ) { 
     
    161165                            ?> 
    162166                            <td><select name="role[<?php echo $val->user_id ?>]" id="new_role"><?php  
    163                                     foreach($wp_roles->role_names as $role => $name)
     167                                    foreach( $editblog_roles as $role => $role_assoc )
    164168                                            $selected = ''; 
    165169                                            if( $role == $existing_role ) 
    166170                                                    $selected = 'selected="selected"'; 
    167                                             echo "<option {$selected} value=\"{$role}\">{$name}</option>"; 
     171                                            echo "<option {$selected} value=\"{$role}\">{$role_assoc['name']}</option>"; 
    168172                                    } 
    169173                            ?></select></td><td><input type='text' name='user_password[<?php echo $val->user_id ?>]'></td><?php 
     
    185189                <th scope="row"><?php _e('Role:') ?></th> 
    186190                <td><select name="new_role" id="new_role"><?php  
    187                 foreach($wp_roles->role_names as $role => $name) { 
     191                reset( $editblog_roles ); 
     192                foreach( $editblog_roles as $role => $role_assoc ){ 
    188193                        $selected = ''; 
    189                         if( $role == 'subscriber'
     194                        if( $role == $editblog_default_role
    190195                                $selected = 'selected="selected"'; 
    191                         echo "<option {$selected} value=\"{$role}\">{$name}</option>"; 
     196                        echo "<option {$selected} value=\"{$role}\">{$role_assoc['name']}</option>"; 
    192197                } 
    193198                ?></select></td>