Make WordPress Core

Changeset 6697


Ignore:
Timestamp:
01/31/2008 09:44:17 PM (17 years ago)
Author:
ryan
Message:

Merge user-edit.php and profile.php. Props nbachiyski. fixes #5736

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/profile.php

    r6429 r6697  
    11<?php
    2 require_once('admin.php');
    3 
    4 function profile_js ( ) {
     2$is_profile_page = true;
     3require_once('user-edit.php');
    54?>
    6 <script type="text/javascript">
    7     function check_pass_strength ( ) {
    8 
    9         var pass = jQuery('#pass1').val();
    10         var user = jQuery('#user_login').val();
    11 
    12         // get the result as an object, i'm tired of typing it
    13         var res = jQuery('#pass-strength-result');
    14 
    15         var strength = passwordStrength(pass, user);
    16 
    17         jQuery(res).removeClass('short bad good strong');
    18 
    19         if ( strength == 'Bad' ) {
    20             jQuery(res).addClass('bad');
    21             jQuery(res).html( pwsL10n.bad );
    22         }
    23         else if ( strength == 'Good' ) {
    24             jQuery(res).addClass('good');
    25             jQuery(res).html( pwsL10n.good );
    26         }
    27         else if ( strength == 'Strong' ) {
    28             jQuery(res).addClass('strong');
    29             jQuery(res).html( pwsL10n.strong );
    30         }
    31         else {
    32             // this catches 'Too short' and the off chance anything else comes along
    33             jQuery(res).addClass('short');
    34             jQuery(res).html( pwsL10n.short );
    35         }
    36 
    37     }
    38 
    39     jQuery(document).ready( function() { jQuery('#pass1').keyup( check_pass_strength ) } );
    40 </script>
    41 <?php
    42 }
    43 
    44 add_action('admin_head', 'profile_js');
    45 
    46 wp_enqueue_script('jquery');
    47 wp_enqueue_script('password-strength-meter');
    48 
    49 $title = __('Profile');
    50 
    51 if ( current_user_can('edit_users') )
    52     $parent_file = 'users.php';
    53 else
    54     $parent_file = 'profile.php';
    55 include_once('admin-header.php');
    56 $profileuser = get_user_to_edit($user_ID);
    57 
    58 $bookmarklet_height= 440;
    59 ?>
    60 
    61 <?php if ( isset($_GET['updated']) ) { ?>
    62 <div id="message" class="updated fade">
    63 <p><strong><?php _e('Profile updated.') ?></strong></p>
    64 </div>
    65 <?php } ?>
    66 
    67 <div class="wrap">
    68 <h2><?php _e('Your Profile and Personal Options'); ?></h2>
    69 <form name="profile" id="your-profile" action="profile-update.php" method="post">
    70 <?php wp_nonce_field('update-profile_' . $user_ID) ?>
    71 <p>
    72 <input type="hidden" name="from" value="profile" />
    73 <input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" />
    74 </p>
    75 
    76 <h3><?php _e('Personal Options'); ?></h3>
    77 
    78 <?php if ( rich_edit_exists() ) : // don't bother showing the option if the editor has been removed ?>
    79 <p><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', get_user_option('rich_editing')); ?> />
    80 <?php _e('Use the visual editor when writing') ?></label></p>
    81 <?php endif; ?>
    82 
    83 <?php do_action('profile_personal_options'); ?>
    84 
    85 <p class="submit"><input type="submit" value="<?php _e('Update Profile &raquo;') ?>" name="submit" /></p>
    86 
    87 <fieldset id="information">
    88 <legend><?php _e('Name'); ?></legend>
    89 <p><label><?php _e('Username: (no editing)'); ?><br />
    90 <input type="text" name="user_login" id="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" />
    91 </label></p>
    92 
    93 <p><label><?php _e('First name:') ?><br />
    94 <input type="text" name="first_name" id="first_name" value="<?php echo $profileuser->first_name ?>" /></label></p>
    95 
    96 <p><label><?php _e('Last name:') ?><br />
    97 <input type="text" name="last_name" id="last_name"  value="<?php echo $profileuser->last_name ?>" /></label></p>
    98 
    99 <p><label><?php _e('Nickname:') ?><br />
    100 <input type="text" name="nickname" id="nickname" value="<?php echo $profileuser->nickname ?>" /></label></p>
    101 
    102 <p><label><?php _e('Display name publicly as:') ?> <br />
    103 <select name="display_name" id="display_name">
    104 <option value="<?php echo $profileuser->display_name; ?>"><?php echo $profileuser->display_name; ?></option>
    105 <option value="<?php echo $profileuser->nickname ?>"><?php echo $profileuser->nickname ?></option>
    106 <option value="<?php echo $profileuser->user_login ?>"><?php echo $profileuser->user_login ?></option>
    107 <?php if ( !empty( $profileuser->first_name ) ) : ?>
    108 <option value="<?php echo $profileuser->first_name ?>"><?php echo $profileuser->first_name ?></option>
    109 <?php endif; ?>
    110 <?php if ( !empty( $profileuser->last_name ) ) : ?>
    111 <option value="<?php echo $profileuser->last_name ?>"><?php echo $profileuser->last_name ?></option>
    112 <?php endif; ?>
    113 <?php if ( !empty( $profileuser->first_name ) && !empty( $profileuser->last_name ) ) : ?>
    114 <option value="<?php echo $profileuser->first_name." ".$profileuser->last_name ?>"><?php echo $profileuser->first_name." ".$profileuser->last_name ?></option>
    115 <option value="<?php echo $profileuser->last_name." ".$profileuser->first_name ?>"><?php echo $profileuser->last_name." ".$profileuser->first_name ?></option>
    116 <?php endif; ?>
    117 </select></label></p>
    118 </fieldset>
    119 
    120 <fieldset id="contact-info">
    121 <legend><?php _e('Contact Info'); ?></legend>
    122 
    123 <p><label><?php _e('E-mail: (required)') ?><br />
    124 <input type="text" name="email" id="email" value="<?php echo $profileuser->user_email ?>" /></label></p>
    125 
    126 <p><label><?php _e('Website:') ?><br />
    127 <input type="text" name="url" id="url" value="<?php echo $profileuser->user_url ?>" />
    128 </label></p>
    129 
    130 <p><label><?php _e('AIM:') ?><br />
    131 <input type="text" name="aim" id="aim" value="<?php echo $profileuser->aim ?>" />
    132 </label></p>
    133 
    134 <p><label><?php _e('Yahoo IM:') ?><br />
    135 <input type="text" name="yim" id="yim" value="<?php echo $profileuser->yim ?>" />
    136 </label></p>
    137 
    138 <p><label><?php _e('Jabber / Google Talk:') ?><br />
    139 <input type="text" name="jabber" id="jabber" value="<?php echo $profileuser->jabber ?>" /></label>
    140 </p>
    141 </fieldset>
    142 <br clear="all" />
    143 <fieldset id="about-yourself">
    144 <legend><?php _e('About Yourself'); ?></legend>
    145 <p class="desc"><?php _e('Share a little biographical information. '); ?></p>
    146 <p><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea></p>
    147 </fieldset>
    148 
    149 <?php
    150 $show_password_fields = apply_filters('show_password_fields', true);
    151 if ( $show_password_fields ) :
    152 ?>
    153 <fieldset id="update-password">
    154 <legend><?php _e('Update Your Password'); ?></legend>
    155 <p class="desc"><?php _e('If you would like to change your password type a new one twice below. Otherwise leave this blank.'); ?></p>
    156 <p><label><?php _e('New Password:'); ?><br />
    157 <input type="password" name="pass1" id="pass1" size="16" value="" />
    158 </label></p>
    159 <p><label><?php _e('Type it one more time:'); ?><br />
    160 <input type="password" name="pass2" id="pass2" size="16" value="" />
    161 </label></p>
    162 <p><strong><?php _e('Password Strength:'); ?></strong></p>
    163 <div id="pass-strength-result"><?php _e('Too short'); ?></div>
    164 <p><?php _e('Hint: Use upper and lower case characters, numbers and symbols like !"?$%^&( in your password.'); ?></p>
    165 </fieldset>
    166 <?php endif; ?>
    167 
    168 <?php do_action('show_user_profile'); ?>
    169 
    170 <br clear="all" />
    171 
    172     <table width="99%"  border="0" cellspacing="2" cellpadding="3" class="editform">
    173         <?php
    174         if(count($profileuser->caps) > count($profileuser->roles)):
    175         ?>
    176         <tr>
    177             <th scope="row"><?php _e('Additional Capabilities:') ?></th>
    178             <td><?php
    179             $output = '';
    180             foreach($profileuser->caps as $cap => $value) {
    181                 if(!$wp_roles->is_role($cap)) {
    182                     if($output != '') $output .= ', ';
    183                     $output .= $value ? $cap : "Denied: {$cap}";
    184                 }
    185             }
    186             echo $output;
    187             ?></td>
    188     </tr>
    189     <?php
    190     endif;
    191     ?>
    192   </table>
    193 <p class="submit"><input type="submit" value="<?php _e('Update Profile &raquo;') ?>" name="submit" /></p>
    194 </form>
    195 
    196 </div>
    197 
    198 <?php include('admin-footer.php'); ?>
  • trunk/wp-admin/user-edit.php

    r6652 r6697  
    11<?php
     2
     3$is_profile_page = isset($is_profile_page) && $is_profile_page? true : false;
     4
    25require_once('admin.php');
    36
    4 $title = __('Edit User');
    5 if ( current_user_can('edit_users') )
     7function profile_js ( ) {
     8?>
     9<script type="text/javascript">
     10    function check_pass_strength ( ) {
     11
     12        var pass = jQuery('#pass1').val();
     13        var user = jQuery('#user_login').val();
     14
     15        // get the result as an object, i'm tired of typing it
     16        var res = jQuery('#pass-strength-result');
     17
     18        var strength = passwordStrength(pass, user);
     19
     20        jQuery(res).removeClass('short bad good strong');
     21
     22        if ( strength == 'Bad' ) {
     23            jQuery(res).addClass('bad');
     24            jQuery(res).html( pwsL10n.bad );
     25        }
     26        else if ( strength == 'Good' ) {
     27            jQuery(res).addClass('good');
     28            jQuery(res).html( pwsL10n.good );
     29        }
     30        else if ( strength == 'Strong' ) {
     31            jQuery(res).addClass('strong');
     32            jQuery(res).html( pwsL10n.strong );
     33        }
     34        else {
     35            // this catches 'Too short' and the off chance anything else comes along
     36            jQuery(res).addClass('short');
     37            jQuery(res).html( pwsL10n.short );
     38        }
     39
     40    }
     41
     42    jQuery(document).ready( function() { jQuery('#pass1').keyup( check_pass_strength ) } );
     43</script>
     44<?php
     45}
     46
     47if ( $is_profile_page ) {
     48    add_action('admin_head', 'profile_js');
     49    wp_enqueue_script('jquery');
     50    wp_enqueue_script('password-strength-meter');
     51}
     52
     53$title = $is_profile_page? __('Profile') : __('Edit User');
     54if ( current_user_can('edit_users') && !$is_profile_page )
    655    $parent_file = 'users.php';
    756else
     
    1665
    1766if ( !$user_id )
    18     wp_die(__('Invalid user ID.'));
     67    if ( $is_profile_page ) {
     68        $current_user = wp_get_current_user();
     69        $user_id = $current_user->ID;
     70    } else {
     71        wp_die(__('Invalid user ID.'));
     72    }
    1973
    2074switch ($action) {
     
    3488    wp_die(__('You do not have permission to edit this user.'));
    3589
     90if ( $is_profile_page ) {
     91    do_action('personal_options_update');
     92}
     93
    3694$errors = edit_user($user_id);
    3795
    3896if( !is_wp_error( $errors ) ) {
    39     $redirect = "user-edit.php?user_id=$user_id&updated=true";
     97    $redirect = ($is_profile_page? "profile.php?" : "user-edit.php?user_id=$user_id&"). "updated=true";
    4098    $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
    4199    wp_redirect($redirect);
     
    55113<div id="message" class="updated fade">
    56114    <p><strong><?php _e('User updated.') ?></strong></p>
    57     <?php if ( $wp_http_referer ) : ?>
     115    <?php if ( $wp_http_referer && !$is_profile_page ) : ?>
    58116    <p><a href="users.php"><?php _e('&laquo; Back to Authors and Users'); ?></a></p>
    59117    <?php endif; ?>
     
    72130
    73131<div class="wrap">
    74 <h2><?php _e('Edit User'); ?></h2>
    75 
    76 <form name="profile" id="your-profile" action="user-edit.php" method="post">
     132<h2><?php $is_profile_page? _e('Your Profile and Personal Options') : _e('Edit User'); ?></h2>
     133
     134<form name="profile" id="your-profile" action="" method="post">
    77135<?php wp_nonce_field('update-user_' . $user_id) ?>
    78136<?php if ( $wp_http_referer ) : ?>
     
    84142</p>
    85143
     144<h3><?php _e('Personal Options'); ?></h3>
     145
     146<?php if ( rich_edit_exists() ) : // don't bother showing the option if the editor has been removed ?>
    86147<p><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', $profileuser->rich_editing); ?> /> <?php _e('Use the visual editor when writing'); ?></label></p>
    87 
    88 <p class="submit"><input type="submit" value="<?php _e('Update User &raquo;'); ?>" name="submit" /></p>
     148<?php endif; ?>
     149
     150<?php
     151    if ( $is_profile_page ) {
     152        do_action('profile_personal_options');
     153    }
     154?>
     155
     156<p class="submit"><input type="submit" value="<?php $is_profile_page? _e('Update Profile &raquo;') : _e('Update User &raquo;'); ?>" name="submit" /></p>
    89157
    90158<fieldset>
    91159<legend><?php _e('Name'); ?></legend>
    92160<p><label><?php _e('Username: (no editing)'); ?><br />
    93 <input type="text" name="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" />
    94 </label></p>
    95 
     161<input type="text" name="user_login" id="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" />
     162</label></p>
     163
     164<?php if ( !$is_profile_page ): ?>
    96165<p><label><?php _e('Role:') ?><br />
    97166<?php
     
    115184echo $role_list . '</select>';
    116185?></label></p>
     186<?php endif; ?>
    117187
    118188<p><label><?php _e('First name:') ?><br />
     
    169239<br clear="all" />
    170240<fieldset>
    171 <legend><?php _e('About the user'); ?></legend>
     241<legend><?php $is_profile_page? _e('About Yourself') : _e('About the user'); ?></legend>
    172242<p class="desc"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></p>
    173243<p><textarea name="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea></p>
     
    179249?>
    180250<fieldset>
    181 <legend><?php _e("Update User's Password"); ?></legend>
    182 <p class="desc"><?php _e("If you would like to change the user's password type a new one twice below. Otherwise leave this blank."); ?></p>
     251<legend><?php $is_profile_page? _e('Update Your Password') : _e("Update User's Password"); ?></legend>
     252<p class="desc"><?php _e("If you would like to change the password type a new one twice below. Otherwise leave this blank."); ?></p>
    183253<p><label><?php _e('New Password:'); ?><br />
    184 <input type="password" name="pass1" size="16" value="" />
     254<input type="password" name="pass1" id="pass1" size="16" value="" />
    185255</label></p>
    186256<p><label><?php _e('Type it one more time:'); ?><br />
    187 <input type="password" name="pass2" size="16" value="" />
    188 </label></p>
     257<input type="password" name="pass2" id="pass2" size="16" value="" />
     258</label></p>
     259<?php if ( $is_profile_page ): ?>
     260<p><strong><?php _e('Password Strength:'); ?></strong></p>
     261<div id="pass-strength-result"><?php _e('Too short'); ?></div>
     262<p><?php _e('Hint: Use upper and lower case characters, numbers and symbols like !"?$%^&( in your password.'); ?></p>
     263<?php endif; ?>
    189264</fieldset>
    190265<?php endif; ?>
    191266
    192 <?php do_action('edit_user_profile'); ?>
     267<?php
     268    if ( $is_profile_page ) {
     269        do_action('show_user_profile');
     270    } else {
     271        do_action('edit_user_profile');
     272    }
     273?>
    193274
    194275<br clear="all" />
     
    217298    <input type="hidden" name="action" value="update" />
    218299    <input type="hidden" name="user_id" id="user_id" value="<?php echo $user_id; ?>" />
    219     <input type="submit" value="<?php _e('Update User &raquo;') ?>" name="submit" />
     300    <input type="submit" value="<?php $is_profile_page? _e('Update Profile &raquo;') : _e('Update User &raquo;') ?>" name="submit" />
    220301 </p>
    221302</form>
  • trunk/wp-includes/capabilities.php

    r6364 r6697  
    291291        break;
    292292    case 'edit_user':
    293         $caps[] = 'edit_users';
     293        if ( !isset($args[0]) || $user_id != $args[0] ) {
     294            $caps[] = 'edit_users';
     295        }
    294296        break;
    295297    case 'delete_post':
Note: See TracChangeset for help on using the changeset viewer.