--- old/modules/user.module 2005-09-23 16:42:15.000000000 -0400 +++ new/modules/user.module 2005-09-24 02:48:10.000000000 -0400 @@ -965,10 +965,14 @@ } if ($account) { $from = variable_get('site_mail', ini_get('sendmail_from')); + $pass = user_password(); - // Mail one time login URL and instructions. - $variables = array('%username' => $account->name, '%site' => variable_get('site_name', 'drupal'), '%login_url' => user_pass_reset_url($account), '%uri' => $base_url, '%uri_brief' => substr($base_url, strlen('http://')), '%mailto' => $account->mail, '%date' => format_date(time()), '%login_uri' => url('user', NULL, NULL, TRUE), '%edit_uri' => url('user/'. $account->uid .'/edit', NULL, NULL, TRUE)); - $subject = _user_mail_text('pass_subject', $variables); + // Save new password: + user_save($account, array('pass' => $pass)); + + // Mail new password: + $variables = array('%username' => $account->name, '%site' => variable_get('site_name', 'drupal'), '%password' => $pass, '%login_url' => user_pass_reset_url($account), '%uri' => $base_url, '%uri_brief' => substr($base_url, strlen('http://')), '%mailto' => $account->mail, '%date' => format_date(time()), '%login_uri' => url('user', NULL, NULL, TRUE), '%edit_uri' => url('user/'. $account->uid .'/edit', NULL, NULL, TRUE)); + $subject = _user_mail_text('pass_subject', $variables); $body = _user_mail_text('pass_body', $variables); $headers = "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"; $mail_success = user_mail($account->mail, $subject, $body, $headers); @@ -1055,8 +1059,11 @@ if (!form_get_errors()) { $from = variable_get('site_mail', ini_get('sendmail_from')); - $pass = $admin ? $edit['pass'] : user_password(); - + if(!$edit["pass"]) { + $pass = user_password(); + } else { + $pass = $edit["pass"]; + }; // TODO: Is this necessary? Won't session_write() replicate this? unset($edit['session']); if (!$admin && array_intersect(array_keys($edit), array('uid', 'roles', 'init', 'session', 'status'))) { @@ -1078,9 +1085,17 @@ $output .= form_hidden('pass', $pass); $output .= form_submit(t('Log in')); return form($output); - } - else { - if ($admin) { + } elseif (variable_get("user_mail_verify", '1') == 0) { + // Create new user account, no email verification is required. + $subject = _user_mail_text('welcome_subject', $variables); + $body = _user_mail_text('welcome_body', $variables); + user_mail($edit['mail'], $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); + $edit["pass"] = $pass; + $edit["name"] = $account->name; + user_login($edit); + + } else { + if ($admin) { drupal_set_message(t('Created a new user account. No e-mail has been sent.')); drupal_goto('admin/user'); @@ -1106,6 +1121,9 @@ } // Display the registration form. + if (empty($edit)) { + $edit['destination'] = $_GET['destination']; + } $output .= variable_get('user_registration_help', ''); $affiliates = user_auth_help_links(); if (!$admin && count($affiliates) > 0) { @@ -1113,12 +1131,13 @@ $output .= '

'. t('Note: if you have an account with one of our affiliates (%s), you may login now instead of registering.', array('%s' => $affiliates, '%login_uri' => url('user'))) .'

'; } $default = form_textfield(t('Username'), 'name', $edit['name'], 30, 64, t('Your full name or your preferred username; only letters, numbers and spaces are allowed.'), NULL, TRUE); - $default .= form_textfield(t('E-mail address'), 'mail', $edit['mail'], 30, 64, t('A password and instructions will be sent to this e-mail address, so make sure it is accurate.'), NULL, TRUE); - if ($admin) { - $default .= form_password(t('Password'), 'pass', $edit['pass'], 30, 55,t('Provide a password for the new account.'), NULL, TRUE); + $default .= form_textfield(t('E-mail address'), 'mail', $edit['mail'], 30, 64, t('Your password and instructions will be sent to this e-mail address, so make sure it is accurate.'), NULL, TRUE); + if (variable_get("user_mail_verify", '1') == 0 || $admin) { + $default .= form_password(t("Password"), "pass", $edit["pass"], 30, 55, t("Provide a password for the new account. The password must contain at least %num characters.", array("%num" => variable_get("user_password_length", 6)))); } $extra = _user_forms($edit, $account, $category, 'register'); // Only display form_group around default fields if there are other groups. + $default .= form_hidden('destination', $edit['destination']); if ($extra) { $output .= form_group(t('Account information'), $default); $output .= $extra; @@ -1369,6 +1388,7 @@ function user_configure_settings() { // User registration settings. $group = form_radios(t('Public registrations'), 'user_register', variable_get('user_register', 1), array(t('Only site administrators can create new user accounts.'), t('Visitors can create accounts and no administrator approval is required.'), t('Visitors can create accounts but administrator approval is required.'))); + $group .= form_checkbox(t('Require email verification when a visitor creates an account'), 'user_mail_verify', 1, variable_get('user_mail_verify', 1), t('Check this box to require email verification.')); $group .= form_textarea(t('User registration guidelines'), 'user_registration_help', variable_get('user_registration_help', ''), 60, 5, t('This text is displayed at the top of the user registration form. It\'s useful for helping or instructing your users.')); $output = form_group(t('User registration settings'), $group);