diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index cb3fcff3e2..dad5cba88e 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -301,26 +301,33 @@ function wp_delete_category($cat_ID) { return 1; } -function wp_delete_user($id) { +function wp_delete_user($id, $reassign = 'novalue') { global $wpdb; $id = (int) $id; - - $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id"); - - if ($post_ids) { - $post_ids = implode(',', $post_ids); - - // Delete comments, *backs - $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID IN ($post_ids)"); - // Clean cats - $wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id IN ($post_ids)"); - // Clean post_meta - $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id IN ($post_ids)"); + + if($reassign == 'novalue') { + $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id"); + + if ($post_ids) { + $post_ids = implode(',', $post_ids); + + // Delete comments, *backs + $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID IN ($post_ids)"); + // Clean cats + $wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id IN ($post_ids)"); + // Clean post_meta + $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id IN ($post_ids)"); + // Delete posts + $wpdb->query("DELETE FROM $wpdb->posts WHERE post_author = $id"); + } + // Clean links $wpdb->query("DELETE FROM $wpdb->links WHERE link_owner = $id"); - // Delete posts - $wpdb->query("DELETE FROM $wpdb->posts WHERE post_author = $id"); + } else { + $reassign = (int)$reassign; + $wpdb->query("UPDATE $wpdb->posts SET post_author = {$reassign} WHERE post_author = {$id}"); + $wpdb->query("UPDATE $wpdb->links SET link_owner = {$reassign} WHERE link_owner = {$id}"); } // FINALLY, delete user diff --git a/wp-admin/options-general.php b/wp-admin/options-general.php index 6756670709..d435f6719d 100644 --- a/wp-admin/options-general.php +++ b/wp-admin/options-general.php @@ -11,7 +11,7 @@ include('admin-header.php');

- + @@ -48,6 +48,17 @@ include('admin-header.php'); + + + +
+
diff --git a/wp-admin/options-writing.php b/wp-admin/options-writing.php index 792e3be2a6..e0f5e92016 100644 --- a/wp-admin/options-writing.php +++ b/wp-admin/options-writing.php @@ -11,7 +11,7 @@ include('admin-header.php');

- + @@ -39,12 +39,6 @@ endforeach; ?> - - - -

-
-
@@ -98,4 +92,4 @@ endforeach; - \ No newline at end of file + diff --git a/wp-admin/profile.php b/wp-admin/profile.php index 4fe4162086..66ec010a12 100644 --- a/wp-admin/profile.php +++ b/wp-admin/profile.php @@ -24,6 +24,38 @@ require_once('../wp-config.php'); auth_redirect(); switch($action) { +case 'IErightclick': + + $bookmarklet_height= 550; + + ?> + + + + + +
+ +

To have a one-click bookmarklet, just copy and paste this
into a new text file:

+ +
+

Save it as wordpress.reg, and double-click on this file in an Explorer
+ window. Answer Yes to the question, and restart Internet Explorer.

+ That's it, you can now right-click in an IE window and select
+ 'Post to WP' to make the bookmarklet appear. :)

+ +

+

+ +
+

+
+ - - - - - -
- -

To have a one-click bookmarklet, just copy and paste this
into a new text file:

- -
-

Save it as wordpress.reg, and double-click on this file in an Explorer
- window. Answer Yes to the question, and restart Internet Explorer.

- That's it, you can now right-click in an IE window and select
- 'Post to WP' to make the bookmarklet appear. :)

- -

-

- -
-

-
- data; $bookmarklet_height= 440; @@ -159,8 +160,15 @@ if (isset($updated)) { ?> user_login; ?> - - user_level; ?> + + roles as $role => $value) { + if($output != '') $output .= ', '; + $output .= $wp_roles->role_names[$role]; + } + echo $output; + ?> @@ -169,6 +177,25 @@ if (isset($updated)) { ?> echo $posts; ?> + caps) > count($profileuser->roles)): + ?> + + + caps as $cap => $value) { + if(!$wp_roles->is_role($cap)) { + if($output != '') $output .= ', '; + $output .= $value ? $cap : "Denied: {$cap}"; + } + } + echo $output; + ?> + + @@ -229,6 +256,8 @@ if (isset($updated)) { ?> diff --git a/wp-admin/upgrade-functions.php b/wp-admin/upgrade-functions.php index 4653ef5d3d..e77abdd9df 100644 --- a/wp-admin/upgrade-functions.php +++ b/wp-admin/upgrade-functions.php @@ -758,21 +758,20 @@ function translate_level_to_role($level) { case 10: case 9: case 8: - return 'publisher'; + return 'administrator'; case 7: case 6: case 5: - return 'managing_editor'; + return 'editor'; case 4: case 3: - return 'copy_editor'; case 2: - return 'staff_writer'; + return 'author'; case 1: - return 'freelancer'; + return 'contributor'; case 0: - return 'visitor'; + return 'subscriber'; } } -?> \ No newline at end of file +?> diff --git a/wp-admin/upgrade-schema.php b/wp-admin/upgrade-schema.php index 8ffa6d5fda..1e4b23967a 100644 --- a/wp-admin/upgrade-schema.php +++ b/wp-admin/upgrade-schema.php @@ -215,11 +215,13 @@ function populate_options() { add_option('html_type', 'text/html'); // 1.5.1 add_option('use_trackback', 0); + // 1.6 + add_option('default_role', 'Inactive'); populate_roles(); // Delete unused options - $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'); + $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'); foreach ($unusedoptions as $option) : delete_option($option); endforeach; diff --git a/wp-admin/user-edit.php b/wp-admin/user-edit.php index adac5a0416..20737b2ece 100644 --- a/wp-admin/user-edit.php +++ b/wp-admin/user-edit.php @@ -22,16 +22,27 @@ for ($i=0; $iuser_level >= $user_level) die( __('You do not have permission to edit this user.') ); +$errors = array(); +if(empty($wp_user)) { + $wp_user = new WP_User($user_id); + $edituser = &$wp_user->data; +} + +if (!current_user_can('edit_users')) $errors['head'] = __('You do not have permission to edit this user.'); /* checking the nickname has been typed */ if (empty($_POST["new_nickname"])) { - die (__("ERROR: please enter your nickname (can be the same as your username)")); - return false; + $errors['nickname'] = __("ERROR: please enter your nickname (can be the same as your username)"); } $new_user_login = wp_specialchars($_POST['new_user_login']); @@ -41,60 +52,61 @@ do_action('check_passwords', array($new_user_login, &$pass1, &$pass2)); if ( '' == $pass1 ) { if ( '' != $pass2 ) - die (__("ERROR: you typed your new password only once. Go back to type it twice.")); + $errors['pass'] = __("ERROR: you typed your new password only once."); $updatepassword = ''; } else { if ( '' == $pass2) - die (__("ERROR: you typed your new password only once. Go back to type it twice.")); + $errors['pass'] = __("ERROR: you typed your new password only once."); if ( $pass1 != $pass2 ) - die (__("ERROR: you typed two different passwords. Go back to correct that.")); + $errors['pass'] = __("ERROR: you typed two different passwords."); $new_pass = $pass1; $updatepassword = "user_pass=MD5('$new_pass'), "; } -$new_firstname = wp_specialchars($_POST['new_firstname']); -$new_lastname = wp_specialchars($_POST['new_lastname']); -$new_nickname = $_POST['new_nickname']; -$new_nicename = sanitize_title($new_nickname, $user_id); -$new_icq = wp_specialchars($_POST['new_icq']); -$new_aim = wp_specialchars($_POST['new_aim']); -$new_msn = wp_specialchars($_POST['new_msn']); -$new_yim = wp_specialchars($_POST['new_yim']); -$new_email = wp_specialchars($_POST['new_email']); -$new_url = wp_specialchars($_POST['new_url']); -$new_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $new_url) ? $new_url : 'http://' . $new_url; -$display_name = wp_specialchars($_POST['display_name']); -$new_description = $_POST['new_description']; +$edituser->user_login = wp_specialchars($_POST['new_user_login']); +$edituser->user_nicename = sanitize_title($new_nickname, $user_id); +$edituser->user_email = wp_specialchars($_POST['new_email']); +$edituser->user_url = wp_specialchars($_POST['new_url']); +$edituser->user_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $edituser->user_url) ? $edituser->user_url : 'http://' . $edituser->user_url; +$edituser->display_name = wp_specialchars($_POST['display_name']); -$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'"); +$edituser->first_name = wp_specialchars($_POST['new_firstname']); +$edituser->last_name = wp_specialchars($_POST['new_lastname']); +$edituser->nickname = $_POST['new_nickname']; +$edituser->icq = wp_specialchars($_POST['new_icq']); +$edituser->aim = wp_specialchars($_POST['new_aim']); +$edituser->msn = wp_specialchars($_POST['new_msn']); +$edituser->yim = wp_specialchars($_POST['new_yim']); +$edituser->description = $_POST['new_description']; -update_usermeta( $user_id, 'first_name', $new_firstname ); -update_usermeta( $user_id, 'last_name', $new_lastname ); -update_usermeta( $user_id, 'nickname', $new_nickname ); -update_usermeta( $user_id, 'description', $new_description ); -update_usermeta( $user_id, 'icq', $new_icq ); -update_usermeta( $user_id, 'aim', $new_aim ); -update_usermeta( $user_id, 'msn', $new_msn ); -update_usermeta( $user_id, 'yim', $new_yim ); - -header("Location: user-edit.php?user_id=$user_id&updated=true"); - -break; - -case 'switchposts': - -check_admin_referer(); - -/* TODO: Switch all posts from one user to another user */ - -break; +if(count($errors) == 0) { + $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'"); + + update_usermeta( $user_id, 'first_name', $edituser->firstname ); + update_usermeta( $user_id, 'last_name', $edituser->lastname ); + update_usermeta( $user_id, 'nickname', $edituser->nickname ); + update_usermeta( $user_id, 'description', $edituser->description ); + update_usermeta( $user_id, 'icq', $edituser->icq ); + update_usermeta( $user_id, 'aim', $edituser->aim ); + update_usermeta( $user_id, 'msn', $edituser->msn ); + update_usermeta( $user_id, 'yim', $edituser->yim ); + + $wp_user->set_role($_POST['new_role']); + + header("Location: user-edit.php?user_id=$user_id&updated=true"); +} else { + $wp_user->roles = array($_POST['new_role'] => true); +} default: include ('admin-header.php'); -$edituser = get_userdata($user_id); +if(empty($wp_user)) { + $wp_user = new WP_User($user_id); + $edituser = &$wp_user->data; +} -if ($edituser->user_level >= $user_level) die( __('You do not have permission to edit this user.') ); +if (!current_user_can('edit_users')) $errors['head'] = __('You do not have permission to edit this user.'); ?> @@ -102,6 +114,15 @@ if ($edituser->user_level >= $user_level) die( __('You do not have permission to

+ +
+
    + $error"; + ?> +
+
+

@@ -112,14 +133,19 @@ if ($edituser->user_level >= $user_level) die( __('You do not have permission to - - user_level; ?> + + ID); ?> -user_registered ) { ?> +user_registered) && ('0000-00-00 00:00:00' != $edituser->user_registered) ) { ?> user_registered, 0, 11); ?> @@ -135,7 +161,7 @@ if ($edituser->user_level >= $user_level) die( __('You do not have permission to - + @@ -189,6 +215,8 @@ if ($edituser->user_level >= $user_level) die( __('You do not have permission to diff --git a/wp-admin/users.php b/wp-admin/users.php index 296c6a82bb..7e91124dba 100644 --- a/wp-admin/users.php +++ b/wp-admin/users.php @@ -8,88 +8,52 @@ $parent_file = 'profile.php'; $action = $_REQUEST['action']; switch ($action) { -case 'adduser': - check_admin_referer(); - - $user_login = wp_specialchars(trim($_POST['user_login'])); - $pass1 = $_POST['pass1']; - $pass2 = $_POST['pass2']; - $user_email = wp_specialchars(trim($_POST['email'])); - $user_firstname = wp_specialchars(trim($_POST['firstname'])); - $user_lastname = wp_specialchars(trim($_POST['lastname'])); - $user_uri = wp_specialchars(trim($_POST['uri'])); - - /* checking that username has been typed */ - if ($user_login == '') - die (__('ERROR: Please enter a username.')); - - /* checking the password has been typed twice */ - do_action('check_passwords', array($user_login, &$pass1, &$pass2)); - if ($pass1 == '' || $pass2 == '') - die (__('ERROR: Please enter your password twice.')); - - /* checking the password has been typed twice the same */ - if ($pass1 != $pass2) - die (__('ERROR: Please type the same password in the two password fields.')); - - $user_nickname = $user_login; - - if ( username_exists( $user_login ) ) - die (__('ERROR: This username is already registered, please choose another one.')); - - /* checking e-mail address */ - if (empty($user_email)) { - die (__("ERROR: please type an e-mail address")); - return false; - } else if (!is_email($user_email)) { - die (__("ERROR: the email address isn't correct")); - return false; - } - - $user_ID = create_user( $user_login, $pass1, $user_email, 0 ); - - update_usermeta( $user_ID, 'first_name', $user_firstname); - update_usermeta( $user_ID, 'last_name', $user_lastname); - update_usermeta( $user_ID, 'first_name', $user_firstname); - - $stars = ''; - for ($i = 0; $i < strlen($pass1); $i = $i + 1) - $stars .= '*'; - - $user_login = stripslashes($user_login); - $message = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n"; - $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; - $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n"; - - @wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message); - header('Location: users.php'); -break; case 'promote': check_admin_referer(); - if (empty($_GET['prom'])) { + if (empty($_POST['users'])) { header('Location: users.php'); } - $id = (int) $_GET['id']; - $prom = $_GET['prom']; + if ( !current_user_can('edit_users') ) + die(__('You can’t edit users.')); - $user_data = get_userdata($id); - - $usertopromote_level = $user_data->user_level; - - if ( $user_level <= $usertopromote_level ) - die(__('Can’t change the level of a user whose level is higher than yours.')); - - if ('up' == $prom) { - $new_level = $usertopromote_level + 1; - } elseif ('down' == $prom) { - $new_level = $usertopromote_level - 1; + $userids = $_POST['users']; + foreach($userids as $id) { + $user = new WP_User($id); + $user->set_role($_POST['new_role']); } - update_usermeta( $id, $wpdb->prefix . 'user_level', $new_level); + + header('Location: users.php?update=promote'); - header('Location: users.php'); +break; + +case 'dodelete': + + check_admin_referer(); + + if (empty($_POST['users'])) { + header('Location: users.php'); + } + + if ( !current_user_can('edit_users') ) + die(__('You can’t delete users.')); + + $userids = $_POST['users']; + + foreach($userids as $id) { + switch($_POST['delete_option']) { + case 'delete': + wp_delete_user($id); + break; + case 'reassign': + wp_delete_user($id, $_POST['reassign_user']); + break; + } + } + + header('Location: users.php?update=del'); break; @@ -97,51 +61,189 @@ case 'delete': check_admin_referer(); - $id = (int) $_GET['id']; - - if (!$id) { + if (empty($_POST['users'])) { header('Location: users.php'); } - $user_data = get_userdata($id); - $usertodelete_level = $user_data->user_level; + if ( !current_user_can('edit_users') ) + $error['edit_users'] = __('You can’t delete users.'); - if ($user_level <= $usertodelete_level) - die(__('Can’t delete a user whose level is higher than yours.')); + $userids = $_POST['users']; - wp_delete_user($id); - - header('Location: users.php?deleted=true'); + include ('admin-header.php'); +?> +
+
+

+

+
    + "; + echo "{$id}: {$user->data->user_login}\n"; + } + $all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY user_login"); + $user_dropdown = ''; + ?> +
+

+
    +
  • +
  • + Attribute all posts and links to: %s'), $user_dropdown); ?>
  • +
+ +

+
+
+ERROR: Please enter a username.'); + + /* checking the password has been typed twice */ + do_action('check_passwords', array($new_user_login, &$new_pass1, &$new_pass2)); + if ($new_pass1 == '' || $new_pass2 == '') + $errors['pass'] = __('ERROR: Please enter your password twice.'); + + /* checking the password has been typed twice the same */ + if ($new_pass1 != $new_pass2) + $errors['pass'] = __('ERROR: Please type the same password in the two password fields.'); + + $new_user_nickname = $new_user_login; + + if ( username_exists( $new_user_login ) ) + $errors['pass'] = __('ERROR: This username is already registered, please choose another one.'); + + /* checking e-mail address */ + if (empty($new_user_email)) { + $errors['user_email'] = __("ERROR: please type an e-mail address"); + } else if (!is_email($new_user_email)) { + $errors['user_email'] = __("ERROR: the email address isn't correct"); + } + + if(count($errors) == 0) { + $user_ID = create_user( $new_user_login, $new_pass1, $new_user_email, 0 ); + + update_usermeta( $user_ID, 'first_name', $new_user_firstname); + update_usermeta( $user_ID, 'last_name', $new_user_lastname); + update_usermeta( $user_ID, 'first_name', $new_user_firstname); + + $user = new WP_User($user_ID); + $user->set_role(get_settings('default_role')); + + $stars = ''; + for ($i = 0; $i < strlen($pass1); $i = $i + 1) + $stars .= '*'; + + $user_login = stripslashes($new_user_login); + $message = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n"; + $message .= sprintf(__('Username: %s'), $new_user_login) . "\r\n\r\n"; + $message .= sprintf(__('E-mail: %s'), $new_user_email) . "\r\n"; + + @wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message); + header('Location: users.php?update=add'); + die(); + } + default: include ('admin-header.php'); + + $userids = $wpdb->get_col("SELECT ID FROM $wpdb->users;"); + + foreach($userids as $userid) { + $tmp_user = new WP_User($userid); + $roles = array_keys($tmp_user->roles); + $role = $roles[0]; + $roleclasses[$role][$tmp_user->data->user_login] = $tmp_user; + } + ?> - -

- + +

+ +

+ +

+ +
+
    + $error"; + ?> +
+
+ + +
-

+

+ $roleclass) { + ksort($roleclass); + ?> + + + + - + - data; $email = $user_data->user_email; $url = $user_data->user_url; $short_url = str_replace('http://', '', $url); @@ -151,24 +253,18 @@ default: if (strlen($short_url) > 35) $short_url = substr($short_url, 0, 32).'...'; $style = ('class="alternate"' == $style) ? '' : 'class="alternate"'; - $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$user' and post_status = 'publish'"); + $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$user_data->ID' and post_status = 'publish'"); if (0 < $numposts) $numposts = "$numposts"; echo " - - - + + + - - "; + "; + echo ""; echo ''; echo ''; @@ -176,68 +272,29 @@ default: ?> + +
+

role_names[$role]; ?>

+
 
$user_data->ID$user_data->user_login$user_data->first_name $user_data->last_name $email$short_url"; - if (($user_level >= 2) and ($user_level > $user_data->user_level) and ($user_data->user_level > 0)) - echo " ID."&prom=down\">- "; - echo $user_data->user_level; - if (($user_level >= 2) and ($user_level > ($user_data->user_level + 1))) - echo " ID."&prom=up\">+ "; - echo "$numposts$short_url$numposts'; - if (($user_level >= 2) and ($user_level > $user_data->user_level)) + if (current_user_can('edit_users')) echo "".__('Edit').""; echo '
-
+ +

-
-

- - - - - - - - - - - -user_email; - $url = $user_data->user_url; - $short_url = str_replace('http://', '', $url); - $short_url = str_replace('www.', '', $short_url); - if ('/' == substr($short_url, -1)) - $short_url = substr($short_url, 0, -1); - if (strlen($short_url) > 35) - $short_url = substr($short_url, 0, 32).'...'; - $style = ('class="alternate"' == $style) ? '' : 'class="alternate"'; -echo "\n - - - - - -\n"; - echo ''; - +$role_select = '
$user_data->ID$user_data->user_login$user_data->first_name $user_data->last_name$email$short_url"; - - if ($user_level >= 6) - echo "". __('Promote') . ''; - echo "'; - if (($user_level >= 6) and ($user_level > $user_data->user_level)) - echo "".__('Edit').""; - echo ''; - if ($user_level >= 6) - echo "" . __('Delete'). ''; - echo '
-

+$role_select .= ''; +?> +
    +
  • +
  • Set the Role of checked users to: %s'), $role_select); ?>
  • +
+

+
-

Users can register themselves or you can manually create users here.

'), get_settings('siteurl')); ?> @@ -246,23 +303,23 @@ echo "\n - + - + - + - + - + get_results("SELECT * FROM $wpdb->categories")): - foreach ($dogs as $catt) - $cache_categories[$catt->cat_ID] = $catt; + foreach ($dogs as $catt) + $cache_categories[$catt->cat_ID] = $catt; return true; - else: + else : return false; endif; } diff --git a/wp-includes/pluggable-functions.php b/wp-includes/pluggable-functions.php index 4d25ffd781..5ca232800d 100644 --- a/wp-includes/pluggable-functions.php +++ b/wp-includes/pluggable-functions.php @@ -31,7 +31,7 @@ function get_userdata( $user_id ) { $user_id = (int) $user_id; if ( $user_id == 0 ) return false; - + if ( isset( $cache_userdata[$user_id] ) ) return $cache_userdata[$user_id]; @@ -52,13 +52,42 @@ function get_userdata( $user_id ) { } $cache_userdata[$user_id] = $user; - $cache_userdata[$cache_userdata[$userid]->user_login] =& $cache_userdata[$user_id]; return $cache_userdata[$user_id]; } endif; +if ( !function_exists('update_user_cache') ) : +function update_user_cache() { + global $cache_userdata, $wpdb; + $level_key = $wpdb->prefix . 'user_level'; + $user_ids = $wpdb->get_col("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key'"); + $user_ids = join(',', $user_ids); + $query = apply_filters('user_cache_query', "SELECT * FROM $wpdb->users WHERE ID IN ($user_ids)"); + if ( $users = $wpdb->get_results( $query ) ) : + foreach ($users as $user) : + $metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user->ID'"); + foreach ( $metavalues as $meta ) { + @ $value = unserialize($meta->meta_value); + if ($value === FALSE) + $value = $meta->meta_value; + $user->{$meta->meta_key} = $value; + // We need to set user_level from meta, not row + if ( $wpdb->prefix . 'user_level' == $meta->meta_key ) + $user->user_level = $meta->meta_value; + } + + $cache_userdata[$user->ID] = $user; + $cache_userdata[$user->user_login] =& $cache_userdata[$user->ID]; + endforeach; + return true; + else : + return false; + endif; +} +endif; + if ( !function_exists('get_userdatabylogin') ) : function get_userdatabylogin($user_login) { global $cache_userdata, $wpdb; @@ -279,4 +308,4 @@ function wp_notify_moderator($comment_id) { } endif; -?> \ No newline at end of file +?> diff --git a/wp-register.php b/wp-register.php index 4a3e0d3ca1..327c7fc19c 100644 --- a/wp-register.php +++ b/wp-register.php @@ -14,47 +14,52 @@ case 'register': $user_login = sanitize_user( $_POST['user_login'] ); $user_email = $_POST['user_email']; + + $errors = array(); if ( $user_login == '' ) - die (__('ERROR: Please enter a username.')); + $errors['user_login'] = __('ERROR: Please enter a username.'); /* checking e-mail address */ if ($user_email == '') { - die (__('ERROR: Please type your e-mail address.')); + $errors['user_email'] = __('ERROR: Please type your e-mail address.'); } else if (!is_email($user_email)) { - die (__('ERROR: The email address isn’t correct.')); + $errors['user_email'] = __('ERROR: The email address isn’t correct.'); } - if ( username_exists( $user_login ) ) - die (__('ERROR: This username is already registered, please choose another one.')); + if ( username_exists( $user_login ) ) + $errors['user_login'] = __('ERROR: This username is already registered, please choose another one.'); - $user_level = get_settings('new_users_can_blog'); $password = substr( md5( uniqid( microtime() ) ), 0, 7); - $user_id = create_user( $user_login, $password, $user_email, $user_level ); - - do_action('user_register', $user_id); - + $user_id = create_user( $user_login, $password, $user_email, 0 ); if ( !$user_id ) { - die (sprintf(__('ERROR: Couldn’t register you... please contact the webmaster !'), get_settings('admin_email'))); + $errors['user_id'] = sprintf(__('ERROR: Couldn’t register you... please contact the webmaster !'), get_settings('admin_email')); } - $stars = ''; - for ($i = 0; $i < strlen($pass1); $i = $i + 1) { - $stars .= '*'; - } + if(count($errors) == 0) { + $user = new WP_User($user_id); + $user->set_role(get_settings('default_role')); - $message = sprintf(__('Username: %s'), $user_login) . "\r\n"; - $message .= sprintf(__('Password: %s'), $password) . "\r\n"; - $message .= get_settings('siteurl') . "/wp-login.php\r\n"; + do_action('user_register', $user_id); - wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_settings('blogname')), $message); - - $message = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n"; - $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; - $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n"; - - @wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message); + + $stars = ''; + for ($i = 0; $i < strlen($pass1); $i = $i + 1) { + $stars .= '*'; + } + + $message = sprintf(__('Username: %s'), $user_login) . "\r\n"; + $message .= sprintf(__('Password: %s'), $password) . "\r\n"; + $message .= get_settings('siteurl') . "/wp-login.php\r\n"; + + wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_settings('blogname')), $message); + + $message = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n"; + $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; + $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n"; + + @wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message); ?> @@ -81,7 +86,57 @@ case 'register': + + + + + WordPress » <?php _e('Registration Form') ?> + + + + + + +
+

WordPress

+

+ +
+
    $error"; + ?> +
+
+ +
+

+

+


+

A password will be emailed to you.

+

+
+ +
+ + + + - - - - WordPress » <?php _e('Registration Form') ?> - - - - - - -
-

WordPress

-

- -
-

-

-


-

A password will be emailed to you.

-

-
- -
- - - - \ No newline at end of file +?> diff --git a/wp-settings.php b/wp-settings.php index c45cb4827a..4d9571955e 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -165,4 +165,4 @@ $wp_roles = new WP_Roles(); // Everything is loaded and initialized. do_action('init'); -?> \ No newline at end of file +?>