Changeset 3859

Show
Ignore:
Timestamp:
06/10/06 20:26:26 (3 years ago)
Author:
ryan
Message:

Better handling of users with no role. Props Mark Jaquith. #2809

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/user-edit.php

    r3857 r3859  
    104104// print_r($profileuser); 
    105105echo '<select name="role">'; 
     106$role_list = ''; 
     107$user_has_role = false; 
    106108foreach($wp_roles->role_names as $role => $name) { 
    107     $selected = ($profileuser->has_cap($role)) ? ' selected="selected"' : ''; 
    108     echo "<option value=\"{$role}\"{$selected}>{$name}</option>"; 
    109 
    110 echo '</select>'; 
     109    if ( $profileuser->has_cap($role) ) { 
     110        $selected = ' selected="selected"'; 
     111        $user_has_role = true; 
     112    } else { 
     113        $selected = ''; 
     114    } 
     115    $role_list .= "<option value=\"{$role}\"{$selected}>{$name}</option>"; 
     116
     117if ( $user_has_role ) 
     118    $role_list .= '<option value="">' . __('&mdash; No role for this blog &mdash;') . '</option>'; 
     119else 
     120    $role_list .= '<option value="" selected="selected">' . __('&mdash; No role for this blog &mdash;') . '</option>'; 
     121echo $role_list . '</select>'; 
    111122?></label></p> 
    112123 
  • trunk/wp-admin/users.php

    r3857 r3859  
    314314 
    315315<tr> 
     316<?php if ( !empty($role) ) : ?> 
    316317    <th colspan="7" align="left"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th> 
     318<?php else : ?> 
     319    <th colspan="7" align="left"><h3><em><?php _e('No role for this blog'); ?></h3></th> 
     320<?php endif; ?> 
    317321</tr> 
    318322<tr class="thead"> 
  • trunk/wp-includes/capabilities.php

    r3846 r3859  
    175175        //Build $allcaps from role caps, overlay user's $caps 
    176176        $this->allcaps = array(); 
    177         foreach($this->roles as $role) { 
     177        foreach( (array) $this->roles as $role) { 
    178178            $role = $wp_roles->get_role($role); 
    179179            $this->allcaps = array_merge($this->allcaps, $role->capabilities); 
     
    200200        foreach($this->roles as $oldrole) 
    201201            unset($this->caps[$oldrole]); 
    202         $this->caps[$role] = true; 
    203         $this->roles = array($role => true); 
     202        if ( !empty($role) ) { 
     203            $this->caps[$role] = true; 
     204            $this->roles = array($role => true); 
     205        } else { 
     206            $this->roles = false; 
     207        } 
    204208        update_usermeta($this->id, $this->cap_key, $this->caps); 
    205209        $this->get_role_caps(); 
  • trunk/wp-includes/registration-functions.php

    r3800 r3859  
    103103    update_usermeta( $user_id, 'yim', $yim ); 
    104104 
    105     if ($update && !empty($role)) { 
     105    if ( $update ) { 
    106106        $user = new WP_User($user_id); 
    107107        $user->set_role($role);