-
+ BD680733B9A2364A0CF4391C935F575CDF48C2F5A4DBDE611521B1928DF6A81F9575B0FB45828558540230DB415A24D5363E0902188B82B4AFF5D23A12B0C144
mp-wp/wp-admin/user-edit.php
(0 . 0)(1 . 403)
59005 <?php
59006 /**
59007 * Edit user administration panel.
59008 *
59009 * @package WordPress
59010 * @subpackage Administration
59011 */
59012
59013 /** WordPress Administration Bootstrap */
59014 require_once('admin.php');
59015
59016 if ( defined('IS_PROFILE_PAGE') && IS_PROFILE_PAGE )
59017 $is_profile_page = true;
59018 else
59019 $is_profile_page = false;
59020
59021 /**
59022 * Display JavaScript for profile page.
59023 *
59024 * @since 2.5.0
59025 */
59026 function profile_js ( ) {
59027 ?>
59028 <script type="text/javascript">
59029 (function($){
59030
59031 function check_pass_strength () {
59032
59033 var pass = $('#pass1').val();
59034 var user = $('#user_login').val();
59035
59036 $('#pass-strength-result').removeClass('short bad good strong');
59037 if ( ! pass ) {
59038 $('#pass-strength-result').html( pwsL10n.empty );
59039 return;
59040 }
59041
59042 var strength = passwordStrength(pass, user);
59043
59044 if ( 2 == strength )
59045 $('#pass-strength-result').addClass('bad').html( pwsL10n.bad );
59046 else if ( 3 == strength )
59047 $('#pass-strength-result').addClass('good').html( pwsL10n.good );
59048 else if ( 4 == strength )
59049 $('#pass-strength-result').addClass('strong').html( pwsL10n.strong );
59050 else
59051 // this catches 'Too short' and the off chance anything else comes along
59052 $('#pass-strength-result').addClass('short').html( pwsL10n.short );
59053
59054 }
59055
59056 function update_nickname () {
59057
59058 var nickname = $('#nickname').val();
59059 var display_nickname = $('#display_nickname').val();
59060
59061 if ( nickname == '' ) {
59062 $('#display_nickname').remove();
59063 }
59064 $('#display_nickname').val(nickname).html(nickname);
59065
59066 }
59067
59068 $(document).ready( function() {
59069 $('#nickname').blur(update_nickname);
59070 $('#pass1').val('').keyup( check_pass_strength );
59071 $('.color-palette').click(function(){$(this).siblings('input[name=admin_color]').attr('checked', 'checked')});
59072 });
59073 })(jQuery);
59074 </script>
59075 <?php
59076 }
59077
59078 if ( $is_profile_page ) {
59079 add_action('admin_head', 'profile_js');
59080 wp_enqueue_script('jquery');
59081 wp_enqueue_script('password-strength-meter');
59082 }
59083
59084 $title = $is_profile_page? __('Profile') : __('Edit User');
59085 if ( current_user_can('edit_users') && !$is_profile_page )
59086 $submenu_file = 'users.php';
59087 else
59088 $submenu_file = 'profile.php';
59089 $parent_file = 'users.php';
59090
59091 wp_reset_vars(array('action', 'redirect', 'profile', 'user_id', 'wp_http_referer'));
59092
59093 $wp_http_referer = remove_query_arg(array('update', 'delete_count'), stripslashes($wp_http_referer));
59094
59095 $user_id = (int) $user_id;
59096
59097 if ( !$user_id ) {
59098 if ( $is_profile_page ) {
59099 $current_user = wp_get_current_user();
59100 $user_id = $current_user->ID;
59101 } else {
59102 wp_die(__('Invalid user ID.'));
59103 }
59104 } elseif ( !get_userdata($user_id) ) {
59105 wp_die( __('Invalid user ID.') );
59106 }
59107
59108 /**
59109 * Optional SSL preference that can be turned on by hooking to the 'personal_options' action.
59110 *
59111 * @since 2.7.0
59112 *
59113 * @param object $user User data object
59114 */
59115 function use_ssl_preference($user) {
59116 ?>
59117 <tr>
59118 <th scope="row"><?php _e('Use https')?></th>
59119 <td><label for="use_ssl"><input name="use_ssl" type="checkbox" id="use_ssl" value="1" <?php checked('1', $user->use_ssl); ?> /> <?php _e('Always use https when visiting the admin'); ?></label></td>
59120 </tr>
59121 <?php
59122 }
59123
59124 switch ($action) {
59125 case 'switchposts':
59126
59127 check_admin_referer();
59128
59129 /* TODO: Switch all posts from one user to another user */
59130
59131 break;
59132
59133 case 'update':
59134
59135 check_admin_referer('update-user_' . $user_id);
59136
59137 if ( !current_user_can('edit_user', $user_id) )
59138 wp_die(__('You do not have permission to edit this user.'));
59139
59140 if ($is_profile_page)
59141 do_action('personal_options_update');
59142 else
59143 do_action('edit_user_profile_update');
59144
59145 $errors = edit_user($user_id);
59146
59147 if ( !is_wp_error( $errors ) ) {
59148 $redirect = ($is_profile_page? "profile.php?" : "user-edit.php?user_id=$user_id&"). "updated=true";
59149 $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
59150 wp_redirect($redirect);
59151 exit;
59152 }
59153
59154 default:
59155 $profileuser = get_user_to_edit($user_id);
59156
59157 if ( !current_user_can('edit_user', $user_id) )
59158 wp_die(__('You do not have permission to edit this user.'));
59159
59160 include ('admin-header.php');
59161 ?>
59162
59163 <?php if ( isset($_GET['updated']) ) : ?>
59164 <div id="message" class="updated fade">
59165 <p><strong><?php _e('User updated.') ?></strong></p>
59166 <?php if ( $wp_http_referer && !$is_profile_page ) : ?>
59167 <p><a href="users.php"><?php _e('← Back to Authors and Users'); ?></a></p>
59168 <?php endif; ?>
59169 </div>
59170 <?php endif; ?>
59171 <?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
59172 <div class="error">
59173 <ul>
59174 <?php
59175 foreach( $errors->get_error_messages() as $message )
59176 echo "<li>$message</li>";
59177 ?>
59178 </ul>
59179 </div>
59180 <?php endif; ?>
59181
59182 <div class="wrap" id="profile-page">
59183 <?php screen_icon(); ?>
59184 <h2><?php echo wp_specialchars( $title ); ?></h2>
59185
59186 <form id="your-profile" action="" method="post">
59187 <?php wp_nonce_field('update-user_' . $user_id) ?>
59188 <?php if ( $wp_http_referer ) : ?>
59189 <input type="hidden" name="wp_http_referer" value="<?php echo clean_url($wp_http_referer); ?>" />
59190 <?php endif; ?>
59191 <p>
59192 <input type="hidden" name="from" value="profile" />
59193 <input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" />
59194 </p>
59195
59196 <h3><?php _e('Personal Options'); ?></h3>
59197
59198 <table class="form-table">
59199 <?php if ( rich_edit_exists() ) : // don't bother showing the option if the editor has been removed ?>
59200 <tr>
59201 <th scope="row"><?php _e('Visual Editor')?></th>
59202 <td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php checked('false', $profileuser->rich_editing); ?> /> <?php _e('Disable the visual editor when writing'); ?></label></td>
59203 </tr>
59204 <?php endif; ?>
59205 <?php if (count($_wp_admin_css_colors) > 1 ) : ?>
59206 <tr>
59207 <th scope="row"><?php _e('Admin Color Scheme')?></th>
59208 <td><fieldset><legend class="hidden"><?php _e('Admin Color Scheme')?></legend>
59209 <?php
59210 $current_color = get_user_option('admin_color', $user_id);
59211 if ( empty($current_color) )
59212 $current_color = 'fresh';
59213 foreach ( $_wp_admin_css_colors as $color => $color_info ): ?>
59214 <div class="color-option"><input name="admin_color" id="admin_color_<?php echo $color; ?>" type="radio" value="<?php echo $color ?>" class="tog" <?php checked($color, $current_color); ?> />
59215 <table class="color-palette">
59216 <tr>
59217 <?php foreach ( $color_info->colors as $html_color ): ?>
59218 <td style="background-color: <?php echo $html_color ?>" title="<?php echo $color ?>"> </td>
59219 <?php endforeach; ?>
59220 </tr>
59221 </table>
59222
59223 <label for="admin_color_<?php echo $color; ?>"><?php echo $color_info->name ?></label>
59224 </div>
59225 <?php endforeach; ?>
59226 </fieldset></td>
59227 </tr>
59228 <tr>
59229 <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th>
59230 <td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( !empty($profileuser->comment_shortcuts) ) checked('true', $profileuser->comment_shortcuts); ?> /> <?php _e( 'Enable keyboard shortcuts for comment moderation. <a href="http://codex.wordpress.org/Keyboard_Shortcuts">More information</a>' ); ?></label></td>
59231 </tr>
59232 <?php
59233 endif;
59234 do_action('personal_options', $profileuser);
59235 ?>
59236 </table>
59237 <?php
59238 if ( $is_profile_page )
59239 do_action('profile_personal_options', $profileuser);
59240 ?>
59241
59242 <h3><?php _e('Name') ?></h3>
59243
59244 <table class="form-table">
59245 <tr>
59246 <th><label for="user_login"><?php _e('Username'); ?></label></th>
59247 <td><input type="text" name="user_login" id="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" class="regular-text" /> <?php _e('Your username cannot be changed.'); ?></td>
59248 </tr>
59249
59250 <?php if ( !$is_profile_page ): ?>
59251 <tr><th><label for="role"><?php _e('Role:') ?></label></th>
59252 <?php
59253 // print_r($profileuser);
59254 echo '<td><select name="role" id="role">';
59255 $role_list = '';
59256 $user_has_role = false;
59257 foreach($wp_roles->role_names as $role => $name) {
59258 $name = translate_with_context($name);
59259 if ( $profileuser->has_cap($role) ) {
59260 $selected = ' selected="selected"';
59261 $user_has_role = true;
59262 } else {
59263 $selected = '';
59264 }
59265 $role_list .= "<option value=\"{$role}\"{$selected}>{$name}</option>";
59266 }
59267 if ( $user_has_role )
59268 $role_list .= '<option value="">' . __('— No role for this blog —') . '</option>';
59269 else
59270 $role_list .= '<option value="" selected="selected">' . __('— No role for this blog —') . '</option>';
59271 echo $role_list . '</select></td></tr>';
59272 ?>
59273 <?php endif; ?>
59274
59275 <tr>
59276 <th><label for="first_name"><?php _e('First name') ?></label></th>
59277 <td><input type="text" name="first_name" id="first_name" value="<?php echo $profileuser->first_name ?>" class="regular-text" /></td>
59278 </tr>
59279
59280 <tr>
59281 <th><label for="last_name"><?php _e('Last name') ?></label></th>
59282 <td><input type="text" name="last_name" id="last_name" value="<?php echo $profileuser->last_name ?>" class="regular-text" /></td>
59283 </tr>
59284
59285 <tr>
59286 <th><label for="nickname"><?php _e('Nickname') ?></label></th>
59287 <td><input type="text" name="nickname" id="nickname" value="<?php echo $profileuser->nickname ?>" class="regular-text" /></td>
59288 </tr>
59289
59290 <tr>
59291 <th><label for="display_name"><?php _e('Display name publicly as') ?></label></th>
59292 <td>
59293 <select name="display_name" id="display_name">
59294 <?php
59295 $public_display = array();
59296 $public_display['display_displayname'] = $profileuser->display_name;
59297 $public_display['display_nickname'] = $profileuser->nickname;
59298 $public_display['display_username'] = $profileuser->user_login;
59299 $public_display['display_firstname'] = $profileuser->first_name;
59300 $public_display['display_firstlast'] = $profileuser->first_name.' '.$profileuser->last_name;
59301 $public_display['display_lastfirst'] = $profileuser->last_name.' '.$profileuser->first_name;
59302 $public_display = array_unique(array_filter(array_map('trim', $public_display)));
59303 foreach($public_display as $id => $item) {
59304 ?>
59305 <option id="<?php echo $id; ?>" value="<?php echo $item; ?>"><?php echo $item; ?></option>
59306 <?php
59307 }
59308 ?>
59309 </select>
59310 </td>
59311 </tr>
59312 </table>
59313
59314 <h3><?php _e('Contact Info') ?></h3>
59315
59316 <table class="form-table">
59317 <tr>
59318 <th><label for="email"><?php _e('E-mail') ?></label></th>
59319 <td><input type="text" name="email" id="email" value="<?php echo $profileuser->user_email ?>" class="regular-text" /> <?php _e('Required.');?></td>
59320 </tr>
59321
59322 <tr>
59323 <th><label for="url"><?php _e('Website') ?></label></th>
59324 <td><input type="text" name="url" id="url" value="<?php echo $profileuser->user_url ?>" class="regular-text" /></td>
59325 </tr>
59326
59327 <tr>
59328 <th><label for="aim"><?php _e('AIM') ?></label></th>
59329 <td><input type="text" name="aim" id="aim" value="<?php echo $profileuser->aim ?>" class="regular-text" /></td>
59330 </tr>
59331
59332 <tr>
59333 <th><label for="yim"><?php _e('Yahoo IM') ?></label></th>
59334 <td><input type="text" name="yim" id="yim" value="<?php echo $profileuser->yim ?>" class="regular-text" /></td>
59335 </tr>
59336
59337 <tr>
59338 <th><label for="jabber"><?php _e('Jabber / Google Talk') ?></label></th>
59339 <td><input type="text" name="jabber" id="jabber" value="<?php echo $profileuser->jabber ?>" class="regular-text" /></td>
59340 </tr>
59341 </table>
59342
59343 <h3><?php $is_profile_page? _e('About Yourself') : _e('About the user'); ?></h3>
59344
59345 <table class="form-table">
59346 <tr>
59347 <th><label for="description"><?php _e('Biographical Info'); ?></label></th>
59348 <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea><br /><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></td>
59349 </tr>
59350
59351 <?php
59352 $show_password_fields = apply_filters('show_password_fields', true);
59353 if ( $show_password_fields ) :
59354 ?>
59355 <tr>
59356 <th><label for="pass1"><?php _e('New Password'); ?></label></th>
59357 <td><input type="password" name="pass1" id="pass1" size="16" value="" autocomplete="off" /> <?php _e("If you would like to change the password type a new one. Otherwise leave this blank."); ?><br />
59358 <input type="password" name="pass2" id="pass2" size="16" value="" autocomplete="off" /> <?php _e("Type your new password again."); ?><br />
59359 <?php if ( $is_profile_page ): ?>
59360 <div id="pass-strength-result"><?php _e('Strength indicator'); ?></div>
59361 <p><?php _e('Hint: Your password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ & ).'); ?></p>
59362 <?php endif; ?>
59363 </td>
59364 </tr>
59365 <?php endif; ?>
59366 </table>
59367
59368 <?php
59369 if ( $is_profile_page ) {
59370 do_action('show_user_profile');
59371 } else {
59372 do_action('edit_user_profile');
59373 }
59374 ?>
59375
59376 <?php if (count($profileuser->caps) > count($profileuser->roles)): ?>
59377 <br class="clear" />
59378 <table width="99%" style="border: none;" cellspacing="2" cellpadding="3" class="editform">
59379 <tr>
59380 <th scope="row"><?php _e('Additional Capabilities') ?></th>
59381 <td><?php
59382 $output = '';
59383 foreach($profileuser->caps as $cap => $value) {
59384 if(!$wp_roles->is_role($cap)) {
59385 if($output != '') $output .= ', ';
59386 $output .= $value ? $cap : "Denied: {$cap}";
59387 }
59388 }
59389 echo $output;
59390 ?></td>
59391 </tr>
59392 </table>
59393 <?php endif; ?>
59394
59395 <p class="submit">
59396 <input type="hidden" name="action" value="update" />
59397 <input type="hidden" name="user_id" id="user_id" value="<?php echo $user_id; ?>" />
59398 <input type="submit" class="button-primary" value="<?php $is_profile_page? _e('Update Profile') : _e('Update User') ?>" name="submit" />
59399 </p>
59400 </form>
59401 </div>
59402 <?php
59403 break;
59404 }
59405
59406 include('admin-footer.php');
59407 ?>