]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/registration.php
Wordpress 2.8-scripts
[autoinstalls/wordpress.git] / wp-includes / registration.php
index 8e822834ddd657e65fa40704116f08d387b71801..3dfb672c1fe7f67e87ae605e8014d1a7763533e3 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 /**
  */
 
 /**
- * username_exists() - Checks whether the given username exists.
+ * Checks whether the given username exists.
  *
  * @since 2.0.0
  *
  *
  * @since 2.0.0
  *
@@ -22,7 +22,7 @@ function username_exists( $username ) {
 }
 
 /**
 }
 
 /**
- * email_exists() - Checks whether the given email exists.
+ * Checks whether the given email exists.
  *
  * @since 2.1.0
  * @uses $wpdb
  *
  * @since 2.1.0
  * @uses $wpdb
@@ -38,7 +38,7 @@ function email_exists( $email ) {
 }
 
 /**
 }
 
 /**
- * validate_username() - Checks whether an username is valid.
+ * Checks whether an username is valid.
  *
  * @since 2.0.1
  * @uses apply_filters() Calls 'validate_username' hook on $valid check and $username as parameters
  *
  * @since 2.0.1
  * @uses apply_filters() Calls 'validate_username' hook on $valid check and $username as parameters
@@ -53,21 +53,19 @@ function validate_username( $username ) {
 }
 
 /**
 }
 
 /**
- * wp_insert_user() - Insert an user into the database.
+ * Insert an user into the database.
  *
  *
- * Can update a current user or insert a new user based on whether
- * the user's ID is present.
+ * Can update a current user or insert a new user based on whether the user's ID
+ * is present.
  *
  *
- * Can be used to update the user's info (see below), set the user's
- * role, and set the user's preference on whether they want the rich
- * editor on.
+ * Can be used to update the user's info (see below), set the user's role, and
+ * set the user's preference on whether they want the rich editor on.
  *
  *
- * Most of the $userdata array fields have filters associated with
- * the values. The exceptions are 'rich_editing', 'role', 'jabber',
- * 'aim', 'yim', 'user_registered', and 'ID'. The filters have the
- * prefix 'pre_user_' followed by the field name. An example using
- * 'description' would have the filter called, 'pre_user_description'
- * that can be hooked into.
+ * Most of the $userdata array fields have filters associated with the values.
+ * The exceptions are 'rich_editing', 'role', 'jabber', 'aim', 'yim',
+ * 'user_registered', and 'ID'. The filters have the prefix 'pre_user_' followed
+ * by the field name. An example using 'description' would have the filter
+ * called, 'pre_user_description' that can be hooked into.
  *
  * The $userdata array can contain the following fields:
  * 'ID' - An integer that will be used for updating an existing user.
  *
  * The $userdata array can contain the following fields:
  * 'ID' - An integer that will be used for updating an existing user.
@@ -77,15 +75,16 @@ function validate_username( $username ) {
  *             The default is the user's username.
  * 'user_url' - A string containing the user's URL for the user's web site.
  * 'user_email' - A string containing the user's email address.
  *             The default is the user's username.
  * 'user_url' - A string containing the user's URL for the user's web site.
  * 'user_email' - A string containing the user's email address.
- * 'display_name' - A string that will be shown on the site. Defaults to user's username.
- *             It is likely that you will want to change this, for both appearance and security
- *             through obscurity (that is if you don't use and delete the default 'admin' user).
+ * 'display_name' - A string that will be shown on the site. Defaults to user's
+ *             username. It is likely that you will want to change this, for both
+ *             appearance and security through obscurity (that is if you don't use and
+ *             delete the default 'admin' user).
  * 'nickname' - The user's nickname, defaults to the user's username.
  * 'first_name' - The user's first name.
  * 'last_name' - The user's last name.
  * 'description' - A string containing content about the user.
  * 'nickname' - The user's nickname, defaults to the user's username.
  * 'first_name' - The user's first name.
  * 'last_name' - The user's last name.
  * 'description' - A string containing content about the user.
- * 'rich_editing' - A string for whether to enable the rich editor or not. False if not
- *             empty.
+ * 'rich_editing' - A string for whether to enable the rich editor or not. False
+ *             if not empty.
  * 'user_registered' - The date the user registered. Format is 'Y-m-d H:i:s'.
  * 'role' - A string used to set the user's role.
  * 'jabber' - User's Jabber account.
  * 'user_registered' - The date the user registered. Format is 'Y-m-d H:i:s'.
  * 'role' - A string used to set the user's role.
  * 'jabber' - User's Jabber account.
@@ -110,6 +109,7 @@ function wp_insert_user($userdata) {
        if ( !empty($ID) ) {
                $ID = (int) $ID;
                $update = true;
        if ( !empty($ID) ) {
                $ID = (int) $ID;
                $update = true;
+               $old_user_data = get_userdata($ID);
        } else {
                $update = false;
                // Hash the password
        } else {
                $update = false;
                // Hash the password
@@ -154,13 +154,40 @@ function wp_insert_user($userdata) {
        if ( empty($rich_editing) )
                $rich_editing = 'true';
 
        if ( empty($rich_editing) )
                $rich_editing = 'true';
 
+       if ( empty($comment_shortcuts) )
+               $comment_shortcuts = 'false';
+
        if ( empty($admin_color) )
                $admin_color = 'fresh';
        $admin_color = preg_replace('|[^a-z0-9 _.\-@]|i', '', $admin_color);
 
        if ( empty($admin_color) )
                $admin_color = 'fresh';
        $admin_color = preg_replace('|[^a-z0-9 _.\-@]|i', '', $admin_color);
 
+       if ( empty($use_ssl) )
+               $use_ssl = 0;
+
+       if ( empty($jabber) )
+               $jabber = '';
+
+       if ( empty($aim) )
+               $aim = '';
+
+       if ( empty($yim) )
+               $yim = '';
+
        if ( empty($user_registered) )
                $user_registered = gmdate('Y-m-d H:i:s');
 
        if ( empty($user_registered) )
                $user_registered = gmdate('Y-m-d H:i:s');
 
+       $user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1" , $user_nicename, $user_login));
+
+       if ($user_nicename_check) {
+               $suffix = 2;
+               while ($user_nicename_check) {
+                       $alt_user_nicename = $user_nicename . "-$suffix";
+                       $user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1" , $alt_user_nicename, $user_login));
+                       $suffix++;
+               }
+               $user_nicename = $alt_user_nicename;
+       }
+
        $data = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' );
        $data = stripslashes_deep( $data );
 
        $data = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' );
        $data = stripslashes_deep( $data );
 
@@ -180,14 +207,14 @@ function wp_insert_user($userdata) {
        update_usermeta( $user_id, 'aim', $aim );
        update_usermeta( $user_id, 'yim', $yim );
        update_usermeta( $user_id, 'rich_editing', $rich_editing);
        update_usermeta( $user_id, 'aim', $aim );
        update_usermeta( $user_id, 'yim', $yim );
        update_usermeta( $user_id, 'rich_editing', $rich_editing);
+       update_usermeta( $user_id, 'comment_shortcuts', $comment_shortcuts);
        update_usermeta( $user_id, 'admin_color', $admin_color);
        update_usermeta( $user_id, 'admin_color', $admin_color);
+       update_usermeta( $user_id, 'use_ssl', $use_ssl);
 
 
-       if ( $update && isset($role) ) {
+       if ( isset($role) ) {
                $user = new WP_User($user_id);
                $user->set_role($role);
                $user = new WP_User($user_id);
                $user->set_role($role);
-       }
-
-       if ( !$update ) {
+       } elseif ( !$update ) {
                $user = new WP_User($user_id);
                $user->set_role(get_option('default_role'));
        }
                $user = new WP_User($user_id);
                $user->set_role(get_option('default_role'));
        }
@@ -196,7 +223,7 @@ function wp_insert_user($userdata) {
        wp_cache_delete($user_login, 'userlogins');
 
        if ( $update )
        wp_cache_delete($user_login, 'userlogins');
 
        if ( $update )
-               do_action('profile_update', $user_id);
+               do_action('profile_update', $user_id, $old_user_data);
        else
                do_action('user_register', $user_id);
 
        else
                do_action('user_register', $user_id);
 
@@ -204,16 +231,16 @@ function wp_insert_user($userdata) {
 }
 
 /**
 }
 
 /**
- * wp_update_user() - Update an user in the database
+ * Update an user in the database.
  *
  *
- * It is possible to update a user's password by specifying the
- * 'user_pass' value in the $userdata parameter array.
+ * It is possible to update a user's password by specifying the 'user_pass'
+ * value in the $userdata parameter array.
  *
  *
- * If $userdata does not contain an 'ID' key, then a new user
- * will be created and the new user's ID will be returned.
+ * If $userdata does not contain an 'ID' key, then a new user will be created
+ * and the new user's ID will be returned.
  *
  *
- * If current user's password is being updated, then the cookies
- * will be cleared.
+ * If current user's password is being updated, then the cookies will be
+ * cleared.
  *
  * @since 2.0.0
  * @see wp_insert_user() For what fields can be set in $userdata
  *
  * @since 2.0.0
  * @see wp_insert_user() For what fields can be set in $userdata
@@ -254,7 +281,7 @@ function wp_update_user($userdata) {
 }
 
 /**
 }
 
 /**
- * wp_create_user() - A simpler way of inserting an user into the database.
+ * A simpler way of inserting an user into the database.
  *
  * Creates a new user with just the username, password, and email. For a more
  * detail creation of a user, use wp_insert_user() to specify more infomation.
  *
  * Creates a new user with just the username, password, and email. For a more
  * detail creation of a user, use wp_insert_user() to specify more infomation.