The MU forums have moved to WordPress.org

fixes to wpmu-blogs.php -- wrong roles used in Edit Blog user management section (6 posts)

  1. jeffoire
    Member
    Posted 16 years ago #

    wordpress-mu-1.2.3 : Site Admin : Blogs : Edit Blog

    1) displays the roles for the blog logged in under rather than the roles for the blog being edited
    2) always marks "Subscriber" as the selected role for Add User rather than the default role specified in options

    --- wp-admin\wpmu-blogs.php	2007-05-28 12:50:56.000000000 -0600
    +++ wpmu-blogs.php	2007-08-01 18:07:49.645373100 -0600
    @@ -17,6 +17,7 @@
     		$options_table_name = "$wpmuBaseTablePrefix{$id}_options";
     		$options = $wpdb->get_results( "SELECT * FROM {$options_table_name} WHERE option_name NOT LIKE 'rss%' AND option_name NOT LIKE '%user_roles'", ARRAY_A );
     		$details = $wpdb->get_row( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = '{$_GET[ 'id' ]}'", ARRAY_A );
    +		$editblog_roles = get_blog_option( $id, "$wpmuBaseTablePrefix{$id}_user_roles" ); // jao 20070801 get the list of roles for target blog
    
     		print "<h2>" . __('Edit Blog') . "</h2>";
     		print "<a href='http://{$details[ 'domain' ]}/'>{$details[ 'domain' ]}</a>";
    @@ -79,6 +80,7 @@
         </td></tr>
         <?php
         while( list( $key, $val ) = each( $options ) ) {
    +		if( $val[ 'option_name' ] == 'default_role' )$editblog_default_role = $val[ 'option_value' ]; // jao 20070801 use this instead of hardcoded 'subscriber'
     	$disabled = '';
     	if ( is_serialized($val[ 'option_value' ]) ) {
     		if ( is_serialized_string($val[ 'option_value' ]) ) {
    @@ -151,11 +153,11 @@
     		    if( $val->user_id != $current_user->data->ID ) {
     			    ?>
     			    <td><select name="role[<?php echo $val->user_id ?>]" id="new_role"><?php
    -				    foreach($wp_roles->role_names as $role => $name) {
    +				    foreach( $editblog_roles as $role => $role_assoc ){ // jao 20070801 using "raw" role data instead of making an object
     					    $selected = '';
     					    if( $role == $existing_role )
     						    $selected = 'selected="selected"';
    -					    echo "<option {$selected} value=\"{$role}\">{$name}</option>";
    +					    echo "<option {$selected} value=\"{$role}\">{$role_assoc['name']}</option>"; // jao 20070801 using "raw" role data instead of making an object
     				    }
     			    ?></select></td><td><input type='text' name='user_password[<?php echo $val->user_id ?>]'></td><?php
     			    print '<td><input title="' . __('Click to remove user') . '" type="checkbox" name="blogusers[' . $val->user_id . ']"></td>';
    @@ -175,11 +177,11 @@
     	<tr>
     		<th scope="row"><?php _e('Role:') ?></th>
     		<td><select name="new_role" id="new_role"><?php
    -		foreach($wp_roles->role_names as $role => $name) {
    +		foreach( $editblog_roles as $role => $role_assoc ){ // jao 20070801 using "raw" role data instead of making an object
     			$selected = '';
    -			if( $role == 'subscriber' )
    +			if( $role == $editblog_default_role ) // jao 20070801 replace the hardcoded default role with the actual value fetched from options
     				$selected = 'selected="selected"';
    -			echo "<option {$selected} value=\"{$role}\">{$name}</option>";
    +			echo "<option {$selected} value=\"{$role}\">{$role_assoc['name']}</option>"; // jao 20070801 using "raw" role data instead of making an object
     		}
     		?></select></td>
     	</tr>
  2. donncha
    Key Master
    Posted 16 years ago #

    You should create a ticket in Trac and attach this as a patch - go to http://trac.mu.wordpress.org/
    It would be much easier to apply.

  3. jeffoire
    Member
    Posted 16 years ago #

    I'm sorry, I guess my cold medication has fogged my brain -- I don't see where I register an account on trac.

  4. drmiketemp
    Member
    Posted 16 years ago #

    Click the login link. It'll tell you to use your wp.org username and password.

  5. jeffoire
    Member
    Posted 16 years ago #

    ok I put it into trac as #399

  6. drmiketemp
    Member
    Posted 16 years ago #

    Thanks

About this Topic

  • Started 16 years ago by jeffoire
  • Latest reply from drmiketemp