home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 108 / MacAddict108.iso / Software / Internet & Communication / WordPress 1.5.1.dmg / wordpress / wp-admin / user-edit.php < prev    next >
Encoding:
PHP Script  |  2005-03-29  |  7.5 KB  |  213 lines

  1. <?php
  2. require_once('admin.php');
  3.  
  4. $title = __('Edit User');
  5. $parent_file = 'profile.php';    
  6. $submenu_file = 'users.php';
  7.  
  8. $wpvarstoreset = array('action', 'redirect', 'profile', 'user_id');
  9. for ($i=0; $i<count($wpvarstoreset); $i += 1) {
  10.     $wpvar = $wpvarstoreset[$i];
  11.     if (!isset($$wpvar)) {
  12.         if (empty($_POST["$wpvar"])) {
  13.             if (empty($_GET["$wpvar"])) {
  14.                 $$wpvar = '';
  15.             } else {
  16.                 $$wpvar = $_GET["$wpvar"];
  17.             }
  18.         } else {
  19.             $$wpvar = $_POST["$wpvar"];
  20.         }
  21.     }
  22. }
  23.  
  24. switch ($action) {
  25. case 'update':
  26.  
  27. get_currentuserinfo();
  28. $edituser = get_userdata($user_id);
  29. if ($edituser->user_level >= $user_level) die( __('You do not have permission to edit this user.') );
  30.  
  31. /* checking the nickname has been typed */
  32. if (empty($_POST["new_nickname"])) {
  33.     die (__("<strong>ERROR</strong>: please enter your nickname (can be the same as your username)"));
  34.     return false;
  35. }
  36.  
  37. $new_user_login  = wp_specialchars($_POST['new_user_login']);
  38. $pass1 = $_POST['pass1'];
  39. $pass2 = $_POST['pass2'];
  40. do_action('check_passwords', array($new_user_login, &$pass1, &$pass2));
  41.  
  42. if ( '' == $pass1 ) {
  43.     if ( '' != $pass2 )
  44.         die (__("<strong>ERROR</strong>: you typed your new password only once. Go back to type it twice."));
  45.     $updatepassword = '';
  46. } else {
  47.     if ( '' == $pass2)
  48.         die (__("<strong>ERROR</strong>: you typed your new password only once. Go back to type it twice."));
  49.     if ( $pass1 != $pass2 )
  50.         die (__("<strong>ERROR</strong>: you typed two different passwords. Go back to correct that."));
  51.     $new_pass = $pass1;
  52.     $updatepassword = "user_pass=MD5('$new_pass'), ";
  53. }
  54.  
  55. $new_firstname   = wp_specialchars($_POST['new_firstname']);
  56. $new_lastname    = wp_specialchars($_POST['new_lastname']);
  57. $new_nickname    = $_POST['new_nickname'];
  58. $new_nicename    = sanitize_title($new_nickname, $user_id);
  59. $new_icq         = wp_specialchars($_POST['new_icq']);
  60. $new_aim         = wp_specialchars($_POST['new_aim']);
  61. $new_msn         = wp_specialchars($_POST['new_msn']);
  62. $new_yim         = wp_specialchars($_POST['new_yim']);
  63. $new_email       = wp_specialchars($_POST['new_email']);
  64. $new_url         = wp_specialchars($_POST['new_url']);
  65. $new_url         = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $new_url) ? $new_url : 'http://' . $new_url; 
  66. $new_idmode      = wp_specialchars($_POST['new_idmode']);
  67. $new_description = $_POST['new_description'];
  68.  
  69. $result = $wpdb->query("UPDATE $wpdb->users SET user_login = '$new_user_login', user_firstname = '$new_firstname', $updatepassword user_lastname='$new_lastname', user_nickname='$new_nickname', user_icq='$new_icq', user_email='$new_email', user_url='$new_url', user_aim='$new_aim', user_msn='$new_msn', user_yim='$new_yim', user_idmode='$new_idmode', user_description = '$new_description', user_nicename = '$new_nicename' WHERE ID = $user_id");
  70.  
  71. header("Location: user-edit.php?user_id=$user_id&updated=true");
  72.  
  73. break;
  74.  
  75. case 'switchposts':
  76.  
  77. check_admin_referer();
  78.  
  79. /* TODO: Switch all posts from one user to another user */
  80.  
  81. break;
  82.  
  83. default:
  84. include ('admin-header.php');
  85.  
  86. $edituser = get_userdata($user_id);
  87.  
  88. if ($edituser->user_level >= $user_level) die( __('You do not have permission to edit this user.') );
  89. ?>
  90.  
  91. <?php if ( isset($_GET['updated']) ) : ?>
  92. <div class="updated">
  93.     <p><strong><?php _e('User updated.') ?></strong></p>
  94. </div>
  95. <?php endif; ?>
  96.  
  97. <div class="wrap">
  98. <h2><?php _e('Edit User'); ?></h2>
  99. <form name="edituser" id="edituser" action="user-edit.php" method="post">
  100. <table width="99%"  border="0" cellspacing="2" cellpadding="3">
  101.     <tr>
  102.         <th width="33%" scope="row"><?php _e('Username:') ?></th>
  103.         <td width="73%"><input type="text" name="new_user_login" id="new_user_login" value="<?php echo $edituser->user_login; ?>" /></td>
  104.     </tr>
  105.     <tr>
  106.         <th scope="row"><?php _e('Level:') ?></th>
  107.         <td><?php echo $edituser->user_level; ?></td>
  108.     </tr>
  109.     <tr>
  110.         <th scope="row"><?php _e('Posts:') ?></th>
  111.         <td><?php echo get_usernumposts($edituser->ID); ?></td>
  112.     </tr>
  113. <?php if ( '0000-00-00 00:00:00' != $edituser->user_registered ) { ?>
  114.     <tr>
  115.         <th scope="row"><?php _e('Registered on:') ?></th>
  116.         <td><?php echo substr($edituser->user_registered, 0, 11); ?></td>
  117.     </tr>
  118. <?php } ?>
  119.     <tr>
  120.         <th scope="row"><?php _e('First name:') ?></th>
  121.         <td><input type="text" name="new_firstname" id="new_firstname" value="<?php echo $edituser->user_firstname ?>" /></td>
  122.     </tr>
  123.     <tr>
  124.         <th scope="row"><?php _e('Last name:') ?></th>
  125.         <td><input type="text" name="new_lastname" id="new_lastname2" value="<?php echo $edituser->user_lastname ?>" /></td>
  126.     </tr>
  127.     <tr>
  128.         <th scope="row"><?php _e('Profile:') ?></th>
  129.         <td><textarea name="new_description" rows="5" id="new_description" style="width: 99%; "><?php echo $edituser->user_description ?></textarea></td>
  130.     </tr>
  131.     <tr>
  132.         <th scope="row"><?php _e('Nickname:') ?></th>
  133.         <td><input type="text" name="new_nickname" id="new_nickname" value="<?php echo $edituser->user_nickname ?>" /></td>
  134.     </tr>
  135.     <tr>
  136.         <th scope="row"><?php _e('E-mail:') ?></th>
  137.         <td><input type="text" name="new_email" id="new_email" value="<?php echo $edituser->user_email ?>" /></td>
  138.     </tr>
  139.     <tr>
  140.         <th scope="row"><?php _e('Website:') ?></th>
  141.         <td><input type="text" name="new_url" id="new_url" value="<?php echo $edituser->user_url ?>" /></td>
  142.     </tr>
  143.     <tr>
  144.         <th scope="row"><?php _e('ICQ:') ?></th>
  145.         <td><input type="text" name="new_icq" id="new_icq" value="<?php if ($edituser->user_icq > 0) { echo $edituser->user_icq; } ?>" /></td>
  146.     </tr>
  147.     <tr>
  148.         <th scope="row"><?php _e('AIM:') ?></th>
  149.         <td><input type="text" name="new_aim" id="new_aim" value="<?php echo $edituser->user_aim ?>" /></td>
  150.     </tr>
  151.     <tr>
  152.         <th scope="row"><?php _e('MSN IM:') ?>
  153.         </th>
  154.         <td><input type="text" name="new_msn" id="new_msn" value="<?php echo $edituser->user_msn ?>" /></td>
  155.     </tr>
  156.     <tr>
  157.         <th scope="row"><?php _e('Yahoo IM:') ?>
  158.         </th>
  159.         <td><input type="text" name="new_yim" id="new_yim" value="<?php echo $edituser->user_yim ?>" />
  160.         </td>
  161.     </tr>
  162.     <tr>
  163.         <th scope="row"><?php _e('Identity on blog:') ?>
  164.         </th>
  165.         <td><select name="new_idmode">
  166.                 <option value="nickname"<?php
  167.     if ($edituser->user_idmode == 'nickname')
  168.     echo ' selected="selected"'; ?>><?php echo $edituser->user_nickname ?></option>
  169.                 <option value="login"<?php
  170.     if ($edituser->user_idmode=="login")
  171.     echo ' selected="selected"'; ?>><?php echo $edituser->user_login ?></option>
  172.                 <option value="firstname"<?php
  173.     if ($edituser->user_idmode=="firstname")
  174.     echo ' selected="selected"'; ?>><?php echo $edituser->user_firstname ?></option>
  175.                 <option value="lastname"<?php
  176.     if ($edituser->user_idmode=="lastname")
  177.     echo ' selected="selected"'; ?>><?php echo $edituser->user_lastname ?></option>
  178.                 <option value="namefl"<?php
  179.     if ($edituser->user_idmode=="namefl")
  180.     echo ' selected="selected"'; ?>><?php echo $edituser->user_firstname." ".$edituser->user_lastname ?></option>
  181.                 <option value="namelf"<?php
  182.     if ($edituser->user_idmode=="namelf")
  183.     echo ' selected="selected"'; ?>><?php echo $edituser->user_lastname." ".$edituser->user_firstname ?></option>
  184.             </select>
  185.         </td>
  186.     </tr>
  187. <?php
  188. $show_password_fields = apply_filters('show_password_fields', true);
  189. if ( $show_password_fields ) :
  190. ?>
  191.     <tr>
  192.         <th scope="row"><?php _e('New <strong>Password</strong> (Leave blank to stay the same.)') ?></th>
  193.         <td><input type="password" name="pass1" size="16" value="" />
  194.             <br />
  195.             <input type="password" name="pass2" size="16" value="" /></td>
  196.     </tr>
  197. <?php endif; ?>
  198. </table>
  199.   <p class="submit">
  200.     <input type="hidden" name="action" value="update" />
  201.     <input type="hidden" name="user_id" id="user_id" value="<?php echo $user_id; ?>" />
  202.     <input type="submit" value="<?php _e('Update User »') ?>" name="submit" />
  203.   </p>
  204. </form>
  205. </div>
  206.  
  207. <?php
  208. break;
  209. }
  210.  
  211. include('admin-footer.php');
  212. ?>
  213.