Make WordPress Core

Changeset 2704


Ignore:
Timestamp:
07/12/2005 03:53:13 PM (20 years ago)
Author:
ryan
Message:

Roles update + UI from Owen.

Location:
trunk
Files:
12 edited

Legend:

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

    r2702 r2704  
    302302}
    303303
    304 function wp_delete_user($id) {
     304function wp_delete_user($id, $reassign = 'novalue') {
    305305    global $wpdb;
    306306
    307307    $id = (int) $id;
    308 
    309     $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id");
    310 
    311     if ($post_ids) {
    312         $post_ids = implode(',', $post_ids);
    313        
    314         // Delete comments, *backs
    315         $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID IN ($post_ids)");
    316         // Clean cats
    317         $wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id IN ($post_ids)");
    318         // Clean post_meta
    319         $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id IN ($post_ids)");
     308   
     309    if($reassign == 'novalue') {
     310        $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id");
     311   
     312        if ($post_ids) {
     313            $post_ids = implode(',', $post_ids);
     314           
     315            // Delete comments, *backs
     316            $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID IN ($post_ids)");
     317            // Clean cats
     318            $wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id IN ($post_ids)");
     319            // Clean post_meta
     320            $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id IN ($post_ids)");
     321            // Delete posts
     322            $wpdb->query("DELETE FROM $wpdb->posts WHERE post_author = $id");
     323        }
     324   
    320325        // Clean links
    321326        $wpdb->query("DELETE FROM $wpdb->links WHERE link_owner = $id");
    322         // Delete posts
    323         $wpdb->query("DELETE FROM $wpdb->posts WHERE post_author = $id");
     327    } else {
     328        $reassign = (int)$reassign;
     329        $wpdb->query("UPDATE $wpdb->posts SET post_author = {$reassign} WHERE post_author = {$id}");
     330        $wpdb->query("UPDATE $wpdb->links SET link_owner = {$reassign} WHERE link_owner = {$id}");
    324331    }
    325332
  • trunk/wp-admin/options-general.php

    r2166 r2704  
    1212  <form name="form1" method="post" action="options.php">
    1313    <input type="hidden" name="action" value="update" />
    14     <input type="hidden" name="action" value="update" /> <input type="hidden" name="page_options" value="'blogname','blogdescription','siteurl','admin_email','users_can_register','gmt_offset','date_format','time_format','home','start_of_week','comment_registration'" />
     14    <input type="hidden" name="action" value="update" /> <input type="hidden" name="page_options" value="'blogname','blogdescription','siteurl','admin_email','users_can_register','gmt_offset','date_format','time_format','home','start_of_week','comment_registration','default_role'" />
    1515    <table width="100%" cellspacing="2" cellpadding="5" class="editform">
    1616      <tr valign="top">
     
    4848            </label>
    4949</td>
     50      </tr>
     51      <tr valign="top">
     52        <th scope="row"><?php _e('New User Default Role:') ?></th>
     53        <td><label for="default_role">
     54          <select name="default_role" id="default_role"><?php
     55                    foreach($wp_roles->role_names as $role => $name) {
     56                        $selected = (get_settings('default_role') == $role) ? 'selected="selected"' : '';
     57                        echo "<option {$selected} value=\"{$role}\">{$name}</option>";
     58                    }
     59                    ?></select></label>
     60                </td>
    5061      </tr>
    5162    </table>
  • trunk/wp-admin/options-writing.php

    r2639 r2704  
    1212  <form name="form1" method="post" action="options.php">
    1313    <input type="hidden" name="action" value="update" />
    14     <input type="hidden" name="page_options" value="'default_post_edit_rows','use_smilies','use_balanceTags','ping_sites','mailserver_url', 'mailserver_port','mailserver_login','mailserver_pass','default_category','default_email_category','new_users_can_blog'" />
     14    <input type="hidden" name="page_options" value="'default_post_edit_rows','use_smilies','use_balanceTags','ping_sites','mailserver_url', 'mailserver_port','mailserver_login','mailserver_pass','default_category','default_email_category'," />
    1515    <table width="100%" cellspacing="2" cellpadding="5" class="editform">
    1616      <tr valign="top">
     
    4040                </select></td>
    4141    </tr>
    42     <tr>
    43         <th scope="row"><?php _e('Newly registered members:') ?></th>
    44         <td> <label for="new_users_can_blog0"><input name="new_users_can_blog" id="new_users_can_blog0" type="radio" value="0" <?php checked('0', get_settings('new_users_can_blog')); ?> /> <?php _e('Cannot write articles') ?></label><br />
    45 <label for="new_users_can_blog1"><input name="new_users_can_blog" id="new_users_can_blog1" type="radio" value="1" <?php checked('1', get_settings('new_users_can_blog')); ?> /> <?php _e('May submit drafts for review') ?></label><br />
    46 <label for="new_users_can_blog2"><input name="new_users_can_blog" id="new_users_can_blog2" type="radio" value="2" <?php checked('2', get_settings('new_users_can_blog')); ?> /> <?php _e('May publish articles') ?></label><br /></td>
    47     </tr>
    4842</table>
    4943
  • trunk/wp-admin/profile.php

    r2638 r2704  
    2525switch($action) {
    2626
     27case 'IErightclick':
     28
     29    $bookmarklet_height= 550;
     30
     31    ?>
     32
     33    <div class="menutop">&nbsp;IE one-click bookmarklet</div>
     34
     35    <table width="100%" cellpadding="20">
     36    <tr><td>
     37
     38    <p>To have a one-click bookmarklet, just copy and paste this<br />into a new text file:</p>
     39    <?php
     40    $regedit = "REGEDIT4\r\n[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Post To &WP : ". get_settings('blogname') ."]\r\n@=\"javascript:doc=external.menuArguments.document;Q=doc.selection.createRange().text;void(btw=window.open('". get_settings('siteurl') ."/wp-admin/bookmarklet.php?text='+escape(Q)+'".$bookmarklet_tbpb."&popupurl='+escape(doc.location.href)+'&popuptitle='+escape(doc.title),'bookmarklet','scrollbars=no,width=480,height=".$bookmarklet_height.",left=100,top=150,status=yes'));btw.focus();\"\r\n\"contexts\"=hex:31\"";
     41    ?>
     42    <pre style="margin: 20px; background-color: #cccccc; border: 1px dashed #333333; padding: 5px; font-size: 12px;"><?php echo $regedit; ?></pre>
     43    <p>Save it as wordpress.reg, and double-click on this file in an Explorer<br />
     44    window. Answer Yes to the question, and restart Internet Explorer.<br /><br />
     45    That's it, you can now right-click in an IE window and select <br />
     46    'Post to WP' to make the bookmarklet appear. :)</p>
     47
     48    <p align="center">
     49      <form>
     50        <input class="search" type="button" value="1" name="Close this window" />
     51      </form>
     52    </p>
     53    </td></tr>
     54    </table>
     55    <?php
     56
     57break;
     58
    2759case 'update':
    2860
     
    101133break;
    102134
    103 case 'IErightclick':
    104 
    105     $bookmarklet_height= 550;
    106 
    107     ?>
    108 
    109     <div class="menutop">&nbsp;IE one-click bookmarklet</div>
    110 
    111     <table width="100%" cellpadding="20">
    112     <tr><td>
    113 
    114     <p>To have a one-click bookmarklet, just copy and paste this<br />into a new text file:</p>
    115     <?php
    116     $regedit = "REGEDIT4\r\n[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Post To &WP : ". get_settings('blogname') ."]\r\n@=\"javascript:doc=external.menuArguments.document;Q=doc.selection.createRange().text;void(btw=window.open('". get_settings('siteurl') ."/wp-admin/bookmarklet.php?text='+escape(Q)+'".$bookmarklet_tbpb."&popupurl='+escape(doc.location.href)+'&popuptitle='+escape(doc.title),'bookmarklet','scrollbars=no,width=480,height=".$bookmarklet_height.",left=100,top=150,status=yes'));btw.focus();\"\r\n\"contexts\"=hex:31\"";
    117     ?>
    118     <pre style="margin: 20px; background-color: #cccccc; border: 1px dashed #333333; padding: 5px; font-size: 12px;"><?php echo $regedit; ?></pre>
    119     <p>Save it as wordpress.reg, and double-click on this file in an Explorer<br />
    120     window. Answer Yes to the question, and restart Internet Explorer.<br /><br />
    121     That's it, you can now right-click in an IE window and select <br />
    122     'Post to WP' to make the bookmarklet appear. :)</p>
    123 
    124     <p align="center">
    125       <form>
    126         <input class="search" type="button" value="1" name="Close this window" />
    127       </form>
    128     </p>
    129     </td></tr>
    130     </table>
    131     <?php
    132 
    133 break;
    134 
    135135
    136136default:
    137137    $parent_file = 'profile.php';
    138138    include_once('admin-header.php');
    139     $profiledata = get_userdata($user_ID);
     139    $profileuser = new WP_User($user_ID);
     140    $profiledata = &$profileuser->data;
    140141
    141142    $bookmarklet_height= 440;
     
    160161    </tr>
    161162    <tr>
    162       <th scope="row"><?php _e('Level:') ?></th>
    163       <td><?php echo $profiledata->user_level; ?></td>
     163      <th scope="row"><?php _e('Role:') ?></th>
     164      <td><?php
     165            $output = '';
     166            foreach($profileuser->roles as $role => $value) {
     167                if($output != '') $output .= ', ';
     168                $output .= $wp_roles->role_names[$role];
     169            }
     170            echo $output;
     171            ?></td>
    164172    </tr>
    165173    <tr>
     
    170178    ?></td>
    171179    </tr>
     180    <?php
     181    if(count($profileuser->caps) > count($profileuser->roles)):
     182    ?>
     183    <tr>
     184      <th scope="row"><?php _e('Additional Capabilities:') ?></th>
     185      <td><?php
     186            $output = '';
     187            foreach($profileuser->caps as $cap => $value) {
     188                if(!$wp_roles->is_role($cap)) {
     189                    if($output != '') $output .= ', ';
     190                    $output .= $value ? $cap : "Denied: {$cap}";
     191                }
     192            }
     193            echo $output;
     194            ?></td>
     195    </tr>
     196    <?php
     197    endif;
     198    ?>
    172199    <tr>
    173200      <th scope="row"><?php _e('First name:') ?></th>
     
    230257    </tr>
    231258<?php
     259do_action('show_user_profile');
     260
    232261$show_password_fields = apply_filters('show_password_fields', true);
    233262if ( $show_password_fields ) :
  • trunk/wp-admin/upgrade-functions.php

    r2703 r2704  
    759759    case 9:
    760760    case 8:
    761         return 'publisher';
     761        return 'administrator';
    762762    case 7:
    763763    case 6:
    764764    case 5:
    765         return 'managing_editor';
     765        return 'editor';
    766766    case 4:
    767767    case 3:
    768         return 'copy_editor';
    769768    case 2:
    770         return 'staff_writer';
     769        return 'author';
    771770    case 1:
    772         return 'freelancer';
     771        return 'contributor';
    773772    case 0:
    774         return 'visitor';
     773        return 'subscriber';
    775774    }
    776775}
  • trunk/wp-admin/upgrade-schema.php

    r2703 r2704  
    216216    // 1.5.1
    217217    add_option('use_trackback', 0);
     218    // 1.6
     219    add_option('default_role', 'Inactive');
    218220
    219221    populate_roles();
    220222
    221223    // Delete unused options
    222     $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url');
     224    $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog');
    223225    foreach ($unusedoptions as $option) :
    224226        delete_option($option);
  • trunk/wp-admin/user-edit.php

    r2702 r2704  
    2323
    2424switch ($action) {
     25case 'switchposts':
     26
     27check_admin_referer();
     28
     29/* TODO: Switch all posts from one user to another user */
     30
     31break;
     32
    2533case 'update':
    2634
    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.') );
     35$errors = array();
     36if(empty($wp_user)) {
     37    $wp_user = new WP_User($user_id);
     38    $edituser = &$wp_user->data;
     39}
     40
     41if (!current_user_can('edit_users')) $errors['head'] = __('You do not have permission to edit this user.');
    3042
    3143/* checking the nickname has been typed */
    3244if (empty($_POST["new_nickname"])) {
    33     die (__("<strong>ERROR</strong>: please enter your nickname (can be the same as your username)"));
    34     return false;
     45    $errors['nickname'] = __("<strong>ERROR</strong>: please enter your nickname (can be the same as your username)");
    3546}
    3647
     
    4253if ( '' == $pass1 ) {
    4354    if ( '' != $pass2 )
    44         die (__("<strong>ERROR</strong>: you typed your new password only once. Go back to type it twice."));
     55        $errors['pass'] = __("<strong>ERROR</strong>: you typed your new password only once.");
    4556    $updatepassword = '';
    4657} else {
    4758    if ( '' == $pass2)
    48         die (__("<strong>ERROR</strong>: you typed your new password only once. Go back to type it twice."));
     59        $errors['pass'] = __("<strong>ERROR</strong>: you typed your new password only once.");
    4960    if ( $pass1 != $pass2 )
    50         die (__("<strong>ERROR</strong>: you typed two different passwords. Go back to correct that."));
     61        $errors['pass'] = __("<strong>ERROR</strong>: you typed two different passwords.");
    5162    $new_pass = $pass1;
    5263    $updatepassword = "user_pass=MD5('$new_pass'), ";
    5364}
    5465
    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 $display_name    = wp_specialchars($_POST['display_name']);
    67 $new_description = $_POST['new_description'];
    68 
    69 $result = $wpdb->query("UPDATE $wpdb->users SET user_login = '$new_user_login', $updatepassword user_email='$new_email', user_url='$new_url', user_nicename = '$new_nicename', display_name = '$display_name' WHERE ID = '$user_id'");
    70 
    71 update_usermeta( $user_id, 'first_name', $new_firstname );
    72 update_usermeta( $user_id, 'last_name', $new_lastname );
    73 update_usermeta( $user_id, 'nickname', $new_nickname );
    74 update_usermeta( $user_id, 'description', $new_description );
    75 update_usermeta( $user_id, 'icq', $new_icq );
    76 update_usermeta( $user_id, 'aim', $new_aim );
    77 update_usermeta( $user_id, 'msn', $new_msn );
    78 update_usermeta( $user_id, 'yim', $new_yim );
    79 
    80 header("Location: user-edit.php?user_id=$user_id&updated=true");
    81 
    82 break;
    83 
    84 case 'switchposts':
    85 
    86 check_admin_referer();
    87 
    88 /* TODO: Switch all posts from one user to another user */
    89 
    90 break;
     66$edituser->user_login       = wp_specialchars($_POST['new_user_login']);
     67$edituser->user_nicename    = sanitize_title($new_nickname, $user_id);
     68$edituser->user_email       = wp_specialchars($_POST['new_email']);
     69$edituser->user_url         = wp_specialchars($_POST['new_url']);
     70$edituser->user_url         = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $edituser->user_url) ? $edituser->user_url : 'http://' . $edituser->user_url;
     71$edituser->display_name     = wp_specialchars($_POST['display_name']);
     72
     73$edituser->first_name  = wp_specialchars($_POST['new_firstname']);
     74$edituser->last_name   = wp_specialchars($_POST['new_lastname']);
     75$edituser->nickname    = $_POST['new_nickname'];
     76$edituser->icq         = wp_specialchars($_POST['new_icq']);
     77$edituser->aim         = wp_specialchars($_POST['new_aim']);
     78$edituser->msn         = wp_specialchars($_POST['new_msn']);
     79$edituser->yim         = wp_specialchars($_POST['new_yim']);
     80$edituser->description = $_POST['new_description'];
     81
     82if(count($errors) == 0) {
     83    $result = $wpdb->query("UPDATE $wpdb->users SET user_login = '$edituser->user_login', $updatepassword user_email='$edituser->user_email', user_url='$edituser->user_url', user_nicename = '$edituser->user_nicename', display_name = '$edituser->display_name' WHERE ID = '$user_id'");
     84   
     85    update_usermeta( $user_id, 'first_name', $edituser->firstname );
     86    update_usermeta( $user_id, 'last_name', $edituser->lastname );
     87    update_usermeta( $user_id, 'nickname', $edituser->nickname );
     88    update_usermeta( $user_id, 'description', $edituser->description );
     89    update_usermeta( $user_id, 'icq', $edituser->icq );
     90    update_usermeta( $user_id, 'aim', $edituser->aim );
     91    update_usermeta( $user_id, 'msn', $edituser->msn );
     92    update_usermeta( $user_id, 'yim', $edituser->yim );
     93   
     94    $wp_user->set_role($_POST['new_role']);
     95   
     96    header("Location: user-edit.php?user_id=$user_id&updated=true");
     97} else {
     98    $wp_user->roles = array($_POST['new_role'] => true);
     99}
    91100
    92101default:
    93102include ('admin-header.php');
    94103
    95 $edituser = get_userdata($user_id);
    96 
    97 if ($edituser->user_level >= $user_level) die( __('You do not have permission to edit this user.') );
     104if(empty($wp_user)) {
     105    $wp_user = new WP_User($user_id);
     106    $edituser = &$wp_user->data;
     107}
     108
     109if (!current_user_can('edit_users')) $errors['head'] = __('You do not have permission to edit this user.');
    98110?>
    99111
     
    103115</div>
    104116<?php endif; ?>
     117<?php if ( isset($errors) ) : ?>
     118<div class="error">
     119    <ul>
     120    <?php
     121    foreach($errors as $error) echo "<li>$error</li>";
     122    ?>
     123    </ul>
     124</div>
     125<?php endif; ?>
    105126
    106127<div class="wrap">
     
    113134    </tr>
    114135    <tr>
    115         <th scope="row"><?php _e('Level:') ?></th>
    116         <td><?php echo $edituser->user_level; ?></td>
     136        <th scope="row"><?php _e('Role:') ?></th>
     137        <td><select name="new_role" id="new_role"><?php
     138        foreach($wp_roles->role_names as $role => $name) {
     139            $selected = (empty($wp_user->roles[$role])) ? '' : 'selected="selected"';
     140            echo "<option {$selected} value=\"{$role}\">{$name}</option>";
     141        }
     142        ?></select></td>
    117143    </tr>
    118144    <tr>
     
    120146        <td><?php echo get_usernumposts($edituser->ID); ?></td>
    121147    </tr>
    122 <?php if ( '0000-00-00 00:00:00' != $edituser->user_registered ) { ?>
     148<?php if ( isset($edituser->user_registered) && ('0000-00-00 00:00:00' != $edituser->user_registered) ) { ?>
    123149    <tr>
    124150        <th scope="row"><?php _e('Registered on:') ?></th>
     
    136162    <tr>
    137163        <th scope="row"><?php _e('Profile:') ?></th>
    138         <td><textarea name="new_description" rows="5" id="new_description" style="width: 99%; "><?php echo $edituser->user_description ?></textarea></td>
     164        <td><textarea name="new_description" rows="5" id="new_description" style="width: 99%; "><?php echo $edituser->description ?></textarea></td>
    139165    </tr>
    140166    <tr>
     
    190216    </tr>
    191217<?php
     218do_action('edit_user_profile');
     219
    192220$show_password_fields = apply_filters('show_password_fields', true);
    193221if ( $show_password_fields ) :
  • trunk/wp-admin/users.php

    r2702 r2704  
    99
    1010switch ($action) {
     11
     12case 'promote':
     13    check_admin_referer();
     14
     15    if (empty($_POST['users'])) {
     16        header('Location: users.php');
     17    }
     18
     19    if ( !current_user_can('edit_users') )
     20        die(__('You can&#8217;t edit users.'));
     21
     22    $userids = $_POST['users'];
     23    foreach($userids as $id) {
     24        $user = new WP_User($id);
     25        $user->set_role($_POST['new_role']);
     26    }
     27       
     28    header('Location: users.php?update=promote');
     29
     30break;
     31
     32case 'dodelete':
     33
     34    check_admin_referer();
     35
     36    if (empty($_POST['users'])) {
     37        header('Location: users.php');
     38    }
     39
     40    if ( !current_user_can('edit_users') )
     41        die(__('You can&#8217;t delete users.'));
     42
     43    $userids = $_POST['users'];
     44   
     45    foreach($userids as $id) {
     46        switch($_POST['delete_option']) {
     47        case 'delete':
     48            wp_delete_user($id);
     49            break;
     50        case 'reassign':
     51            wp_delete_user($id, $_POST['reassign_user']);
     52            break;
     53        }
     54    }
     55
     56    header('Location: users.php?update=del');
     57
     58break;
     59
     60case 'delete':
     61
     62    check_admin_referer();
     63
     64    if (empty($_POST['users'])) {
     65        header('Location: users.php');
     66    }
     67
     68    if ( !current_user_can('edit_users') )
     69        $error['edit_users'] = __('You can&#8217;t delete users.');
     70
     71    $userids = $_POST['users'];
     72
     73    include ('admin-header.php');
     74?>
     75<form action="" method="post" name="updateusers" id="updateusers">
     76<div class="wrap">
     77    <h2><?php _e('Delete Users'); ?></h2>
     78    <p><?php _e('You have specified these users for deletion:'); ?></p>
     79    <ul>
     80    <?php
     81    foreach($userids as $id) {
     82        $user = new WP_User($id);
     83        echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />";
     84        echo "{$id}: {$user->data->user_login}</li>\n";
     85    }
     86    $all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY user_login");
     87    $user_dropdown = '<select name="reassign_user">';
     88    foreach($all_logins as $login) {
     89        if(!in_array($login->ID, $userids)) {
     90            $user_dropdown .= "<option value=\"{$login->ID}\">{$login->user_login}</option>";
     91        }
     92    }
     93    $user_dropdown .= '</select>';
     94    ?>
     95    </ul>
     96    <p><?php _e('What should be done with posts and links owned by this user?'); ?></p>
     97    <ul style="list-style:none;">
     98        <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" checked="checked" />
     99        <?php _e('Delete all posts and links.'); ?></label></li>
     100        <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" />
     101        <?php echo sprintf(__('<label for="delete_option1">Attribute all posts and links to:</label> %s'), $user_dropdown); ?></li>
     102    </ul>
     103    <input type="hidden" name="action" value="dodelete" />
     104    <p class="submit"><input type="submit" name="submit" value="<?php _e('Confirm Deletion'); ?>" /></p>
     105</div>
     106</form>
     107<?php
     108
     109break;
     110
    11111case 'adduser':
    12112    check_admin_referer();
    13113
    14     $user_login     = wp_specialchars(trim($_POST['user_login']));
    15     $pass1          = $_POST['pass1'];
    16     $pass2          = $_POST['pass2'];
    17     $user_email     = wp_specialchars(trim($_POST['email']));
    18     $user_firstname = wp_specialchars(trim($_POST['firstname']));
    19     $user_lastname  = wp_specialchars(trim($_POST['lastname']));
    20     $user_uri       = wp_specialchars(trim($_POST['uri']));
     114    $new_user_login     = wp_specialchars(trim($_POST['user_login']));
     115    $new_pass1          = $_POST['pass1'];
     116    $new_pass2          = $_POST['pass2'];
     117    $new_user_email     = wp_specialchars(trim($_POST['email']));
     118    $new_user_firstname = wp_specialchars(trim($_POST['firstname']));
     119    $new_user_lastname  = wp_specialchars(trim($_POST['lastname']));
     120    $new_user_uri       = wp_specialchars(trim($_POST['uri']));
     121   
     122    $errors = array();
    21123       
    22124    /* checking that username has been typed */
    23     if ($user_login == '')
    24         die (__('<strong>ERROR</strong>: Please enter a username.'));
     125    if ($new_user_login == '')
     126        $errors['user_login'] = __('<strong>ERROR</strong>: Please enter a username.');
    25127
    26128    /* checking the password has been typed twice */
    27     do_action('check_passwords', array($user_login, &$pass1, &$pass2));
    28     if ($pass1 == '' || $pass2 == '')
    29         die (__('<strong>ERROR</strong>: Please enter your password twice.'));
     129    do_action('check_passwords', array($new_user_login, &$new_pass1, &$new_pass2));
     130    if ($new_pass1 == '' || $new_pass2 == '')
     131        $errors['pass'] = __('<strong>ERROR</strong>: Please enter your password twice.');
    30132
    31133    /* checking the password has been typed twice the same */
    32     if ($pass1 != $pass2)
    33         die (__('<strong>ERROR</strong>: Please type the same password in the two password fields.'));
    34 
    35     $user_nickname = $user_login;
    36 
    37     if ( username_exists( $user_login ) )
    38         die (__('<strong>ERROR</strong>: This username is already registered, please choose another one.'));
     134    if ($new_pass1 != $new_pass2)
     135        $errors['pass'] = __('<strong>ERROR</strong>: Please type the same password in the two password fields.');
     136
     137    $new_user_nickname = $new_user_login;
     138
     139  if ( username_exists( $new_user_login ) )
     140        $errors['pass'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.');
    39141
    40142    /* checking e-mail address */
    41     if (empty($user_email)) {
    42         die (__("<strong>ERROR</strong>: please type an e-mail address"));
    43         return false;
    44     } else if (!is_email($user_email)) {
    45         die (__("<strong>ERROR</strong>: the email address isn't correct"));
    46         return false;
    47     }
    48 
    49     $user_ID = create_user( $user_login, $pass1, $user_email, 0 );
    50 
    51     update_usermeta( $user_ID, 'first_name', $user_firstname);
    52     update_usermeta( $user_ID, 'last_name', $user_lastname);
    53     update_usermeta( $user_ID, 'first_name', $user_firstname);
    54    
    55     $stars = '';
    56     for ($i = 0; $i < strlen($pass1); $i = $i + 1)
    57         $stars .= '*';
    58 
    59     $user_login = stripslashes($user_login);
    60     $message  = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n";
    61     $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
    62     $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
    63 
    64     @wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message);
    65     header('Location: users.php');
    66 break;
    67 
    68 case 'promote':
    69     check_admin_referer();
    70 
    71     if (empty($_GET['prom'])) {
    72         header('Location: users.php');
    73     }
    74 
    75     $id = (int) $_GET['id'];
    76     $prom = $_GET['prom'];
    77 
    78     $user_data = get_userdata($id);
    79 
    80     $usertopromote_level = $user_data->user_level;
    81 
    82     if ( $user_level <= $usertopromote_level )
    83         die(__('Can&#8217;t change the level of a user whose level is higher than yours.'));
    84 
    85     if ('up' == $prom) {
    86         $new_level = $usertopromote_level + 1;
    87     } elseif ('down' == $prom) {
    88         $new_level = $usertopromote_level - 1;
    89     }
    90     update_usermeta( $id, $wpdb->prefix . 'user_level', $new_level);
    91 
    92     header('Location: users.php');
    93 
    94 break;
    95 
    96 case 'delete':
    97 
    98     check_admin_referer();
    99 
    100     $id = (int) $_GET['id'];
    101 
    102     if (!$id) {
    103         header('Location: users.php');
    104     }
    105 
    106     $user_data = get_userdata($id);
    107     $usertodelete_level = $user_data->user_level;
    108 
    109     if ($user_level <= $usertodelete_level)
    110         die(__('Can&#8217;t delete a user whose level is higher than yours.'));
    111 
    112     wp_delete_user($id);
    113 
    114     header('Location: users.php?deleted=true');
    115 
    116 break;
     143    if (empty($new_user_email)) {
     144        $errors['user_email'] = __("<strong>ERROR</strong>: please type an e-mail address");
     145    } else if (!is_email($new_user_email)) {
     146        $errors['user_email'] = __("<strong>ERROR</strong>: the email address isn't correct");
     147    }
     148
     149    if(count($errors) == 0) {   
     150        $user_ID = create_user( $new_user_login, $new_pass1, $new_user_email, 0 );
     151   
     152        update_usermeta( $user_ID, 'first_name', $new_user_firstname);
     153        update_usermeta( $user_ID, 'last_name', $new_user_lastname);
     154        update_usermeta( $user_ID, 'first_name', $new_user_firstname);
     155       
     156        $user = new WP_User($user_ID);
     157        $user->set_role(get_settings('default_role'));
     158       
     159        $stars = '';
     160        for ($i = 0; $i < strlen($pass1); $i = $i + 1)
     161            $stars .= '*';
     162   
     163        $user_login = stripslashes($new_user_login);
     164        $message  = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n";
     165        $message .= sprintf(__('Username: %s'), $new_user_login) . "\r\n\r\n";
     166        $message .= sprintf(__('E-mail: %s'), $new_user_email) . "\r\n";
     167   
     168        @wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message);
     169        header('Location: users.php?update=add');
     170        die();
     171    }
    117172
    118173default:
    119174   
    120175    include ('admin-header.php');
     176   
     177    $userids = $wpdb->get_col("SELECT ID FROM $wpdb->users;");
     178   
     179    foreach($userids as $userid) {
     180        $tmp_user = new WP_User($userid);
     181        $roles = array_keys($tmp_user->roles);
     182        $role = $roles[0];
     183        $roleclasses[$role][$tmp_user->data->user_login] = $tmp_user;
     184    }   
     185   
    121186    ?>
    122187
    123 <?php if (isset($_GET['deleted'])) : ?>
    124 <div class="updated"><p><?php _e('User deleted.') ?></p></div>
    125 <?php endif; ?>
     188    <?php
     189    if (isset($_GET['update'])) :
     190        switch($_GET['update']) {
     191        case 'del':
     192        ?>
     193            <div class="updated"><p><?php _e('User deleted.'); ?></p></div>
     194        <?php
     195            break;
     196        case 'add':
     197        ?>
     198            <div class="updated"><p><?php _e('New user created.'); ?></p></div>
     199        <?php
     200            break;
     201        case 'promote':
     202        ?>
     203            <div class="updated"><p><?php _e('Changed roles.'); ?></p></div>
     204        <?php
     205            break;
     206        }
     207    endif;
     208    if ( isset($errors) ) : ?>
     209    <div class="error">
     210        <ul>
     211        <?php
     212        foreach($errors as $error) echo "<li>$error</li>";
     213        ?>
     214        </ul>
     215    </div>
     216    <?php
     217    endif;
     218    ?>
     219   
     220<form action="" method="post" name="updateusers" id="updateusers">
    126221<div class="wrap">
    127   <h2><?php _e('Authors') ?></h2>
     222    <h2><?php _e('User List by Role'); ?></h2>
    128223  <table cellpadding="3" cellspacing="3" width="100%">
     224    <?php
     225    foreach($roleclasses as $role => $roleclass) {
     226        ksort($roleclass);
     227        ?>
     228
     229    <tr>
     230    <th colspan="8" align="left">
     231  <h3><?php echo $wp_roles->role_names[$role]; ?></h3>
     232  </th>
     233
    129234    <tr>
    130235    <th><?php _e('ID') ?></th>
    131     <th><?php _e('Nickname') ?></th>
     236    <th><?php _e('Username') ?></th>
    132237    <th><?php _e('Name') ?></th>
    133238    <th><?php _e('E-mail') ?></th>
    134239    <th><?php _e('Website') ?></th>
    135     <th><?php _e('Level') ?></th>
    136240    <th><?php _e('Posts') ?></th>
    137241    <th>&nbsp;</th>
    138242    </tr>
    139243    <?php
    140     $authors =
    141     $users = get_author_user_ids();
    142244    $style = '';
    143     foreach ($users as $user) {
    144         $user_data = get_userdata($user);
     245    foreach ($roleclass as $user_object) {
     246        $user_data = &$user_object->data;
    145247        $email = $user_data->user_email;
    146248        $url = $user_data->user_url;
     
    152254        $short_url =  substr($short_url, 0, 32).'...';
    153255        $style = ('class="alternate"' == $style) ? '' : 'class="alternate"';
    154         $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$user' and post_status = 'publish'");
     256        $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$user_data->ID' and post_status = 'publish'");
    155257        if (0 < $numposts) $numposts = "<a href='edit.php?author=$user_data->ID' title='" . __('View posts') . "'>$numposts</a>";
    156258        echo "
    157259<tr $style>
    158     <td align='center'>$user_data->ID</td>
    159     <td><strong>$user_data->user_login</strong></td>
    160     <td>$user_data->first_name $user_data->last_name</td>
     260    <td><input type='checkbox' name='users[]' id='user_{$user_data->ID}' value='{$user_data->ID}' /> <label for='user_{$user_data->ID}'>{$user_data->ID}</label></td>
     261    <td><label for='user_{$user_data->ID}'><strong>$user_data->user_login</strong></label></td>
     262    <td><label for='user_{$user_data->ID}'>$user_data->first_name $user_data->last_name</label></td>
    161263    <td><a href='mailto:$email' title='" . sprintf(__('e-mail: %s'), $email) . "'>$email</a></td>
    162     <td><a href='$url' title='website: $url'>$short_url</a></td>
    163     <td align='center'>";
    164     if (($user_level >= 2) and ($user_level > $user_data->user_level) and ($user_data->user_level > 0))
    165         echo " <a href=\"users.php?action=promote&amp;id=".$user_data->ID."&amp;prom=down\">-</a> ";
    166     echo $user_data->user_level;
    167     if (($user_level >= 2) and ($user_level > ($user_data->user_level + 1)))
    168         echo " <a href=\"users.php?action=promote&amp;id=".$user_data->ID."&amp;prom=up\">+</a> ";
    169     echo "</td><td align='right'>$numposts</td>";
     264    <td><a href='$url' title='website: $url'>$short_url</a></td>";
     265    echo "<td align='right'>$numposts</td>";
    170266    echo '<td>';
    171     if (($user_level >= 2) and ($user_level > $user_data->user_level))
     267    if (current_user_can('edit_users'))
    172268        echo "<a href='user-edit.php?user_id=$user_data->ID' class='edit'>".__('Edit')."</a>";
    173269    echo '</td>';
     
    177273    ?>
    178274   
     275
     276<?php
     277    }
     278?>
    179279  </table>
     280
     281
     282    <h2><?php _e('Update Users'); ?></h2>
     283<?php
     284$role_select = '<select name="new_role">';
     285foreach($wp_roles->role_names as $role => $name) {
     286    $role_select .= "<option value=\"{$role}\">{$name}</option>";
     287}
     288$role_select .= '</select>';
     289?> 
     290  <ul style="list-style:none;">
     291    <li><input type="radio" name="action" id="action0" value="delete"> <label for="action0"><?php _e('Delete checked users.'); ?></label></li>
     292    <li><input type="radio" name="action" id="action1" value="promote"> <?php echo sprintf(__('<label for="action1">Set the Role of checked users to:</label> %s'), $role_select); ?></li>
     293  </ul>
     294    <p class="submit"><input type="submit" value="<?php _e('Update &raquo;'); ?>"></p>
    180295</div>
    181 
    182 <?php
    183 $users = get_nonauthor_user_ids();
    184 if ($users) {
    185 ?>
    186 <div class="wrap">
    187     <h2><?php _e('Registered Users') ?></h2>
    188     <table cellpadding="3" cellspacing="3" width="100%">
    189     <tr>
    190         <th><?php _e('ID') ?></th>
    191         <th><?php _e('Nickname') ?></th>
    192         <th><?php _e('Name') ?></th>
    193         <th><?php _e('E-mail') ?></th>
    194         <th><?php _e('Website') ?></th>
    195         <th></th>
    196         <th></th>
    197         <th></th>
    198     </tr>
    199 <?php
    200 $style = '';
    201 foreach ($users as $user) {
    202     $user_data = get_userdata($user);
    203     $email = $user_data->user_email;
    204     $url = $user_data->user_url;
    205     $short_url = str_replace('http://', '', $url);
    206     $short_url = str_replace('www.', '', $short_url);
    207     if ('/' == substr($short_url, -1))
    208         $short_url = substr($short_url, 0, -1);
    209     if (strlen($short_url) > 35)
    210     $short_url =  substr($short_url, 0, 32).'...';
    211     $style = ('class="alternate"' == $style) ? '' : 'class="alternate"';
    212 echo "\n<tr $style>
    213 <td align='center'>$user_data->ID</td>
    214 <td><strong>$user_data->user_login</strong></td>
    215 <td>$user_data->first_name $user_data->last_name</td>
    216 <td><a href='mailto:$email' title='" . sprintf(__('e-mail: %s'), $email) . "'>$email</a></td>
    217 <td><a href='$url' title='website: $url'>$short_url</a></td>
    218 <td align='center'>";
    219 
    220     if ($user_level >= 6)
    221         echo "<a href='users.php?action=promote&amp;id=$user_data->ID&amp;prom=up' class='edit'>". __('Promote') . '</a>'; 
    222     echo "</td>\n";
    223     echo '<td>';
    224     if (($user_level >= 6) and ($user_level > $user_data->user_level))
    225         echo "<a href='user-edit.php?user_id=$user_data->ID' class='edit'>".__('Edit')."</a>";
    226     echo '</td><td>';
    227     if ($user_level >= 6)
    228         echo "<a href='users.php?action=delete&amp;id=$user_data->ID' class='delete' onclick='return confirm(\"" . __('You are about to delete this user \n  OK to delete, Cancel to stop.') . "\")'>" . __('Delete'). '</a>';
    229     echo '</td></tr>';
    230 
    231 }
    232 
    233 ?>
    234    
    235     </table>
    236       <p><?php _e('Deleting a user also deletes all posts made by that user.') ?></p>
    237 </div>
    238 
    239     <?php
    240     } ?>
     296</form>
     297
    241298<div class="wrap">
    242299<h2><?php _e('Add New User') ?></h2>
     
    247304      <th scope="row" width="33%"><?php _e('Nickname') ?>
    248305      <input name="action" type="hidden" id="action" value="adduser" /></th>
    249       <td width="66%"><input name="user_login" type="text" id="user_login" /></td>
     306      <td width="66%"><input name="user_login" type="text" id="user_login" value="<?php echo $new_user_login; ?>" /></td>
    250307    </tr>
    251308    <tr>
    252309      <th scope="row"><?php _e('First Name') ?> </th>
    253       <td><input name="firstname" type="text" id="firstname" /></td>
     310      <td><input name="firstname" type="text" id="firstname" value="<?php echo $new_user_firstname; ?>" /></td>
    254311    </tr>
    255312    <tr>
    256313      <th scope="row"><?php _e('Last Name') ?> </th>
    257       <td><input name="lastname" type="text" id="lastname" /></td>
     314      <td><input name="lastname" type="text" id="lastname" value="<?php echo $new_user_lastname; ?>" /></td>
    258315    </tr>
    259316    <tr>
    260317      <th scope="row"><?php _e('E-mail') ?></th>
    261       <td><input name="email" type="text" id="email" /></td>
     318      <td><input name="email" type="text" id="email" value="<?php echo $new_user_email; ?>" /></td>
    262319    </tr>
    263320    <tr>
    264321      <th scope="row"><?php _e('Website') ?></th>
    265       <td><input name="uri" type="text" id="uri" /></td>
     322      <td><input name="uri" type="text" id="uri" value="<?php echo $new_user_uri; ?>" /></td>
    266323    </tr>
    267324<?php
  • trunk/wp-admin/wp-admin.css

    r2639 r2704  
    243243    background: #f0f8ff;
    244244    border: 1px solid #69c;
     245    margin: 1em 5% 10px;
     246    padding: 0 1em 0 1em;
     247}
     248
     249.error {
     250    background: #FFEFF7;
     251    border: 1px solid #c69;
    245252    margin: 1em 5% 10px;
    246253    padding: 0 1em 0 1em;
  • trunk/wp-includes/functions.php

    r2703 r2704  
    12201220    global $cache_categories, $wpdb;
    12211221    if($dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories")):
    1222         foreach ($dogs as $catt)
    1223             $cache_categories[$catt->cat_ID] = $catt;
     1222    foreach ($dogs as $catt)
     1223        $cache_categories[$catt->cat_ID] = $catt;
    12241224        return true;
    1225     else:
     1225    else :
    12261226        return false;
    12271227    endif;
  • trunk/wp-includes/pluggable-functions.php

    r2703 r2704  
    3232    if ( $user_id == 0 )
    3333        return false;
    34        
     34
    3535    if ( isset( $cache_userdata[$user_id] ) )
    3636        return $cache_userdata[$user_id];
     
    5353
    5454    $cache_userdata[$user_id] = $user;
    55 
    5655    $cache_userdata[$cache_userdata[$userid]->user_login] =& $cache_userdata[$user_id];
    5756
    5857    return $cache_userdata[$user_id];
     58}
     59endif;
     60
     61if ( !function_exists('update_user_cache') ) :
     62function update_user_cache() {
     63    global $cache_userdata, $wpdb;
     64    $level_key = $wpdb->prefix . 'user_level';
     65    $user_ids = $wpdb->get_col("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key'");
     66    $user_ids = join(',', $user_ids);
     67    $query = apply_filters('user_cache_query', "SELECT * FROM $wpdb->users WHERE ID IN ($user_ids)");
     68    if ( $users = $wpdb->get_results( $query ) ) :
     69        foreach ($users as $user) :
     70            $metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user->ID'");
     71            foreach ( $metavalues as $meta ) {
     72                @ $value = unserialize($meta->meta_value);
     73                if ($value === FALSE)
     74                    $value = $meta->meta_value;
     75                $user->{$meta->meta_key} = $value;
     76                // We need to set user_level from meta, not row
     77                if ( $wpdb->prefix . 'user_level' == $meta->meta_key )
     78                    $user->user_level = $meta->meta_value;
     79            }
     80
     81            $cache_userdata[$user->ID] = $user;
     82            $cache_userdata[$user->user_login] =& $cache_userdata[$user->ID];
     83        endforeach;
     84        return true;
     85    else :
     86        return false;
     87    endif;
    5988}
    6089endif;
  • trunk/wp-register.php

    r2702 r2704  
    1515    $user_login = sanitize_user( $_POST['user_login'] );
    1616    $user_email = $_POST['user_email'];
     17   
     18    $errors = array();
    1719       
    1820    if ( $user_login == '' )
    19         die (__('<strong>ERROR</strong>: Please enter a username.'));
     21        $errors['user_login'] = __('<strong>ERROR</strong>: Please enter a username.');
    2022
    2123    /* checking e-mail address */
    2224    if ($user_email == '') {
    23         die (__('<strong>ERROR</strong>: Please type your e-mail address.'));
     25        $errors['user_email'] = __('<strong>ERROR</strong>: Please type your e-mail address.');
    2426    } else if (!is_email($user_email)) {
    25         die (__('<strong>ERROR</strong>: The email address isn&#8217;t correct.'));
     27        $errors['user_email'] = __('<strong>ERROR</strong>: The email address isn&#8217;t correct.');
    2628    }
    2729
    28     if ( username_exists( $user_login ) )
    29         die (__('<strong>ERROR</strong>: This username is already registered, please choose another one.'));
     30  if ( username_exists( $user_login ) )
     31        $errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.');
    3032
    31     $user_level = get_settings('new_users_can_blog');
    3233    $password = substr( md5( uniqid( microtime() ) ), 0, 7);
    3334
    34     $user_id = create_user( $user_login, $password, $user_email, $user_level );
    35 
    36     do_action('user_register', $user_id);
    37 
     35    $user_id = create_user( $user_login, $password, $user_email, 0 );
    3836    if ( !$user_id ) {
    39         die (sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_settings('admin_email')));
     37        $errors['user_id'] = sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_settings('admin_email'));
    4038    }
    4139
    42     $stars = '';
    43     for ($i = 0; $i < strlen($pass1); $i = $i + 1) {
    44         $stars .= '*';
    45     }
     40    if(count($errors) == 0) {
     41        $user = new WP_User($user_id);
     42        $user->set_role(get_settings('default_role'));
    4643   
    47     $message  = sprintf(__('Username: %s'), $user_login) . "\r\n";
    48     $message .= sprintf(__('Password: %s'), $password) . "\r\n";
    49     $message .= get_settings('siteurl') . "/wp-login.php\r\n";
     44        do_action('user_register', $user_id);
    5045   
    51     wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_settings('blogname')), $message);
    52 
    53     $message  = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n";
    54     $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
    55     $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
    56 
    57     @wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message);
     46   
     47        $stars = '';
     48        for ($i = 0; $i < strlen($pass1); $i = $i + 1) {
     49            $stars .= '*';
     50        }
     51       
     52        $message  = sprintf(__('Username: %s'), $user_login) . "\r\n";
     53        $message .= sprintf(__('Password: %s'), $password) . "\r\n";
     54        $message .= get_settings('siteurl') . "/wp-login.php\r\n";
     55       
     56        wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_settings('blogname')), $message);
     57   
     58        $message  = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n";
     59        $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
     60        $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
     61   
     62        @wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message);
    5863
    5964    ?>
     
    8287</html>
    8388
     89        <?php
     90        break;
     91    }
     92
     93default:
     94
     95?>
     96<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     97<html xmlns="http://www.w3.org/1999/xhtml">
     98<head>
     99    <title>WordPress &raquo; <?php _e('Registration Form') ?></title>
     100    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
     101    <link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css" />
     102    <style type="text/css">
     103    #user_email, #user_login, #submit {
     104        font-size: 1.7em;
     105    }
     106    </style>
     107</head>
     108
     109<body>
     110<div id="login">
     111<h1><a href="http://wordpress.org/">WordPress</a></h1>
     112<h2><?php _e('Register for this blog') ?></h2>
     113<?php if ( isset($errors) ) : ?>
     114<div class="error">
     115    <ul>
    84116    <?php
     117    foreach($errors as $error) echo "<li>$error</li>";
     118    ?>
     119    </ul>
     120</div>
     121<?php endif; ?>
     122<form method="post" action="wp-register.php" id="registerform">
     123    <p><input type="hidden" name="action" value="register" />
     124    <label for="user_login"><?php _e('Username:') ?></label><br /> <input type="text" name="user_login" id="user_login" size="20" maxlength="20" value="<?php echo $user_login; ?>" /><br /></p>
     125    <p><label for="user_email"><?php _e('E-mail:') ?></label><br /> <input type="text" name="user_email" id="user_email" size="25" maxlength="100" value="<?php echo $user_email; ?>" /></p>
     126    <p>A password will be emailed to you.</p>
     127    <p class="submit"><input type="submit" value="<?php _e('Register') ?> &raquo;" id="submit" name="submit" /></p>
     128</form>
     129<ul>
     130    <li><a href="<?php bloginfo('home'); ?>" title="<?php _e('Are you lost?') ?>">&laquo; <?php _e('Back to blog') ?></a></li>
     131    <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li>
     132    <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=lostpassword" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a></li>
     133</ul>
     134</div>
     135
     136</body>
     137</html>
     138<?php
     139
    85140break;
    86141
     
    111166break;
    112167
    113 default:
    114 
    115 ?>
    116 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    117 <html xmlns="http://www.w3.org/1999/xhtml">
    118 <head>
    119     <title>WordPress &raquo; <?php _e('Registration Form') ?></title>
    120     <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
    121     <link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css" />
    122     <style type="text/css">
    123     #user_email, #user_login, #submit {
    124         font-size: 1.7em;
    125     }
    126     </style>
    127 </head>
    128 
    129 <body>
    130 <div id="login">
    131 <h1><a href="http://wordpress.org/">WordPress</a></h1>
    132 <h2><?php _e('Register for this blog') ?></h2>
    133 
    134 <form method="post" action="wp-register.php" id="registerform">
    135     <p><input type="hidden" name="action" value="register" />
    136     <label for="user_login"><?php _e('Username:') ?></label><br /> <input type="text" name="user_login" id="user_login" size="20" maxlength="20" /><br /></p>
    137     <p><label for="user_email"><?php _e('E-mail:') ?></label><br /> <input type="text" name="user_email" id="user_email" size="25" maxlength="100" /></p>
    138     <p>A password will be emailed to you.</p>
    139     <p class="submit"><input type="submit" value="<?php _e('Register') ?> &raquo;" id="submit" name="submit" /></p>
    140 </form>
    141 <ul>
    142     <li><a href="<?php bloginfo('home'); ?>" title="<?php _e('Are you lost?') ?>">&laquo; <?php _e('Back to blog') ?></a></li>
    143     <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li>
    144     <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=lostpassword" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a></li>
    145 </ul>
    146 </div>
    147 
    148 </body>
    149 </html>
    150 <?php
    151 
    152 break;
    153168}
    154169?>
Note: See TracChangeset for help on using the changeset viewer.