Commit 66e1bbfb authored by Kjartan's avatar Kjartan

- pending user accounts will not be notified to the site_email.

- fixed access checks on the register form, do this before you enter the
  _save function. If registrations are disabled the register link will
  no longer show (again).
- changed &#187 to &raquo, using the names of entities are better than
  the numbers.
- fixed user information being set when account is registered (properly this
  time, really!)
- reversed the if(!...) commit.
- node_add specifies more defaults.
- added link to blog entries from user page.
parent 5f6d733b
...@@ -39,6 +39,14 @@ function blog_access($op, $node) { ...@@ -39,6 +39,14 @@ function blog_access($op, $node) {
} }
function blog_user($type, &$edit, &$user) {
switch ($type) {
case "view_public":
case "view_private":
return form_item("Blog", lm(t("View recent entries."), array("mod" => "blog", "id" => $user->uid)) ."<br />". lm(t("View all entries."), array("mod" => "blog", "id" => $user->uid, "all" => 1)));
}
}
function blog_save($op, $node) { function blog_save($op, $node) {
if ($op == "approve") { if ($op == "approve") {
return array("promote" => 1); return array("promote" => 1);
...@@ -205,12 +213,6 @@ function blog_page_last() { ...@@ -205,12 +213,6 @@ function blog_page_last() {
function blog_form(&$node, &$help, &$error) { function blog_form(&$node, &$help, &$error) {
global $nid, $iid; global $nid, $iid;
if (!$node->status) {
$node->status = 1;
$node->moderate = 1;
$node->comment = 2;
}
if (isset($node->body)) { if (isset($node->body)) {
/* /*
......
...@@ -39,6 +39,14 @@ function blog_access($op, $node) { ...@@ -39,6 +39,14 @@ function blog_access($op, $node) {
} }
function blog_user($type, &$edit, &$user) {
switch ($type) {
case "view_public":
case "view_private":
return form_item("Blog", lm(t("View recent entries."), array("mod" => "blog", "id" => $user->uid)) ."<br />". lm(t("View all entries."), array("mod" => "blog", "id" => $user->uid, "all" => 1)));
}
}
function blog_save($op, $node) { function blog_save($op, $node) {
if ($op == "approve") { if ($op == "approve") {
return array("promote" => 1); return array("promote" => 1);
...@@ -205,12 +213,6 @@ function blog_page_last() { ...@@ -205,12 +213,6 @@ function blog_page_last() {
function blog_form(&$node, &$help, &$error) { function blog_form(&$node, &$help, &$error) {
global $nid, $iid; global $nid, $iid;
if (!$node->status) {
$node->status = 1;
$node->moderate = 1;
$node->comment = 2;
}
if (isset($node->body)) { if (isset($node->body)) {
/* /*
......
...@@ -170,13 +170,7 @@ function book_delete(&$node) { ...@@ -170,13 +170,7 @@ function book_delete(&$node) {
function book_form(&$node, &$help, &$error) { function book_form(&$node, &$help, &$error) {
global $user, $op; global $user, $op;
if (!$node->status) { $output = form_select(t("Parent"), "parent", $node->parent, book_toc(), t("The parent subject or category the page belongs in."));
$node->status = 1;
$node->moderate = 1;
$node->comment = 2;
}
$output .= form_select(t("Parent"), "parent", $node->parent, book_toc(), t("The parent subject or category the page belongs in."));
if ($node->format) { if ($node->format) {
if ($op != t("Preview")) { if ($op != t("Preview")) {
......
...@@ -170,13 +170,7 @@ function book_delete(&$node) { ...@@ -170,13 +170,7 @@ function book_delete(&$node) {
function book_form(&$node, &$help, &$error) { function book_form(&$node, &$help, &$error) {
global $user, $op; global $user, $op;
if (!$node->status) { $output = form_select(t("Parent"), "parent", $node->parent, book_toc(), t("The parent subject or category the page belongs in."));
$node->status = 1;
$node->moderate = 1;
$node->comment = 2;
}
$output .= form_select(t("Parent"), "parent", $node->parent, book_toc(), t("The parent subject or category the page belongs in."));
if ($node->format) { if ($node->format) {
if ($op != t("Preview")) { if ($op != t("Preview")) {
......
...@@ -55,12 +55,6 @@ function forum_view($node) { ...@@ -55,12 +55,6 @@ function forum_view($node) {
function forum_form(&$node, &$help, &$error) { function forum_form(&$node, &$help, &$error) {
if (!$node->status) {
$node->status = 1;
$node->moderate = 1;
$node->comment = 2;
}
if (function_exists("taxonomy_node_form")) { if (function_exists("taxonomy_node_form")) {
$output = implode("", taxonomy_node_form("forum", $node)); $output = implode("", taxonomy_node_form("forum", $node));
} }
......
...@@ -55,12 +55,6 @@ function forum_view($node) { ...@@ -55,12 +55,6 @@ function forum_view($node) {
function forum_form(&$node, &$help, &$error) { function forum_form(&$node, &$help, &$error) {
if (!$node->status) {
$node->status = 1;
$node->moderate = 1;
$node->comment = 2;
}
if (function_exists("taxonomy_node_form")) { if (function_exists("taxonomy_node_form")) {
$output = implode("", taxonomy_node_form("forum", $node)); $output = implode("", taxonomy_node_form("forum", $node));
} }
......
...@@ -892,7 +892,8 @@ function node_add($type) { ...@@ -892,7 +892,8 @@ function node_add($type) {
*/ */
if ($type && node_access("create", $type)) { if ($type && node_access("create", $type)) {
$output = node_form(array("uid" => $user->uid, "name" => $user->name, "type" => $type)); // Initialize settings
$output = node_form(array("uid" => $user->uid, "name" => $user->name, "type" => $type, "status" => 1, "moderate" => 1, "comment" => 2));
} }
else { else {
......
...@@ -892,7 +892,8 @@ function node_add($type) { ...@@ -892,7 +892,8 @@ function node_add($type) {
*/ */
if ($type && node_access("create", $type)) { if ($type && node_access("create", $type)) {
$output = node_form(array("uid" => $user->uid, "name" => $user->name, "type" => $type)); // Initialize settings
$output = node_form(array("uid" => $user->uid, "name" => $user->name, "type" => $type, "status" => 1, "moderate" => 1, "comment" => 2));
} }
else { else {
......
...@@ -129,12 +129,6 @@ function page_view($node, $main = 0) { ...@@ -129,12 +129,6 @@ function page_view($node, $main = 0) {
function page_form(&$node, &$help, &$error) { function page_form(&$node, &$help, &$error) {
global $op; global $op;
if (!$node->status) {
$node->status = 1;
$node->moderate = 1;
$node->comment = 2;
}
if ($node->format) { if ($node->format) {
if ($op != t("Preview")) { if ($op != t("Preview")) {
$node->body = addslashes($node->body); $node->body = addslashes($node->body);
......
...@@ -129,12 +129,6 @@ function page_view($node, $main = 0) { ...@@ -129,12 +129,6 @@ function page_view($node, $main = 0) {
function page_form(&$node, &$help, &$error) { function page_form(&$node, &$help, &$error) {
global $op; global $op;
if (!$node->status) {
$node->status = 1;
$node->moderate = 1;
$node->comment = 2;
}
if ($node->format) { if ($node->format) {
if ($op != t("Preview")) { if ($op != t("Preview")) {
$node->body = addslashes($node->body); $node->body = addslashes($node->body);
......
...@@ -40,12 +40,6 @@ function poll_delete($node) { ...@@ -40,12 +40,6 @@ function poll_delete($node) {
} }
function poll_form(&$node, &$help, &$error) { function poll_form(&$node, &$help, &$error) {
if (!$node->status) {
$node->status = 1;
$node->moderate = 1;
$node->comment = 2;
}
$admin = user_access("administer nodes"); $admin = user_access("administer nodes");
$_duration = array(0 => t("Unlimited"), 86400 => format_interval(86400), 172800 => format_interval(172800), 345600 => format_interval(345600), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200), 4838400 => format_interval(4838400), 9676800 => format_interval(9676800), 31536000 => format_interval(31536000)); $_duration = array(0 => t("Unlimited"), 86400 => format_interval(86400), 172800 => format_interval(172800), 345600 => format_interval(345600), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200), 4838400 => format_interval(4838400), 9676800 => format_interval(9676800), 31536000 => format_interval(31536000));
......
...@@ -40,12 +40,6 @@ function poll_delete($node) { ...@@ -40,12 +40,6 @@ function poll_delete($node) {
} }
function poll_form(&$node, &$help, &$error) { function poll_form(&$node, &$help, &$error) {
if (!$node->status) {
$node->status = 1;
$node->moderate = 1;
$node->comment = 2;
}
$admin = user_access("administer nodes"); $admin = user_access("administer nodes");
$_duration = array(0 => t("Unlimited"), 86400 => format_interval(86400), 172800 => format_interval(172800), 345600 => format_interval(345600), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200), 4838400 => format_interval(4838400), 9676800 => format_interval(9676800), 31536000 => format_interval(31536000)); $_duration = array(0 => t("Unlimited"), 86400 => format_interval(86400), 172800 => format_interval(172800), 345600 => format_interval(345600), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200), 4838400 => format_interval(4838400), 9676800 => format_interval(9676800), 31536000 => format_interval(31536000));
......
...@@ -65,12 +65,6 @@ function story_link($type) { ...@@ -65,12 +65,6 @@ function story_link($type) {
function story_form(&$node, &$help, &$error) { function story_form(&$node, &$help, &$error) {
if (!$node->status) {
$node->status = 1;
$node->moderate = 1;
$node->comment = 2;
}
if (isset($node->body)) { if (isset($node->body)) {
/* /*
......
...@@ -65,12 +65,6 @@ function story_link($type) { ...@@ -65,12 +65,6 @@ function story_link($type) {
function story_form(&$node, &$help, &$error) { function story_form(&$node, &$help, &$error) {
if (!$node->status) {
$node->status = 1;
$node->moderate = 1;
$node->comment = 2;
}
if (isset($node->body)) { if (isset($node->body)) {
/* /*
......
...@@ -481,9 +481,9 @@ function user_block() { ...@@ -481,9 +481,9 @@ function user_block() {
$output .= "<input name=\"edit[op]\" type=\"submit\" value=\"". t("Log in") ."\" /><br />\n"; $output .= "<input name=\"edit[op]\" type=\"submit\" value=\"". t("Log in") ."\" /><br />\n";
$output .= "</form></div>\n"; $output .= "</form></div>\n";
if (variable_get("user_register", 1)) { if (variable_get("user_register", 1)) {
$output .= "&#187; ". lm(t("Register"), array("mod" => "user", "op" => "register"), "", array("title" => t("Create a new user account."))) ."\n"; $output .= "&raquo; ". lm(t("Register"), array("mod" => "user", "op" => "register"), "", array("title" => t("Create a new user account."))) ."<br />\n";
} }
$output .= "<br />&#187; ". lm(t("New password"), array("mod" => "user", "op" => "password"), "", array("title" => t("Request new password via e-mail"))) ."<br />"; $output .= "&raquo; ". lm(t("New password"), array("mod" => "user", "op" => "password"), "", array("title" => t("Request new password via e-mail")));
$block[1]["content"] = $output; $block[1]["content"] = $output;
} }
...@@ -807,8 +807,11 @@ function user_login($edit = array(), $msg = "") { ...@@ -807,8 +807,11 @@ function user_login($edit = array(), $msg = "") {
$output .= form_password(t("Password"), "pass", $pass, 20, 64, t("Enter the password that accompanies your username.")); $output .= form_password(t("Password"), "pass", $pass, 20, 64, t("Enter the password that accompanies your username."));
$output .= form_checkbox(t("Remember me"), "remember_me", 1, 0, 0); $output .= form_checkbox(t("Remember me"), "remember_me", 1, 0, 0);
$output .= form_submit(t("Log in")); $output .= form_submit(t("Log in"));
$output .= "<p>&#187; ". lm(t("E-mail new password"), array("mod" => "user", "op" => "password")). "<br />"; $output .= "<p>&raquo; ". lm(t("E-mail new password"), array("mod" => "user", "op" => "password")). "<br />";
$output .= "&#187; " . lm(t("Create new account"), array("mod" => "user", "op" => "register")). "</p>"; if (variable_get("user_register", 1)) {
$output .= "&raquo; ". lm(t("Create new account"), array("mod" => "user", "op" => "register"));
}
$output .= "</p>";
return form($output, "post", drupal_url(array ("mod" => "user"), "module")); return form($output, "post", drupal_url(array ("mod" => "user"), "module"));
} }
...@@ -889,8 +892,11 @@ function user_pass($edit = array()) { ...@@ -889,8 +892,11 @@ function user_pass($edit = array()) {
$output .= form_textfield(t("Username"), "name", $edit["name"], 30, 64); $output .= form_textfield(t("Username"), "name", $edit["name"], 30, 64);
$output .= form_textfield(t("E-mail address"), "mail", $edit["mail"], 30, 64); $output .= form_textfield(t("E-mail address"), "mail", $edit["mail"], 30, 64);
$output .= form_submit(t("E-mail new password")); $output .= form_submit(t("E-mail new password"));
$output .= "<p>&#187; ". lm(t("Log in"), array("mod" =>user, "op" => "login")) ."<br />"; $output .= "<p>&raquo; ". lm(t("Log in"), array("mod" =>user, "op" => "login")) ."<br />";
$output .= "&#187; ". lm(t("Create new account"), array("mod" => "user", "op" => "register")) ."</p>"; if (variable_get("user_register", 1)) {
$output .= "&raquo; ". lm(t("Create new account"), array("mod" => "user", "op" => "register"));
}
$output .= "</p>";
return form($output, "post", drupal_url(array ("mod" => "user"), "module")); return form($output, "post", drupal_url(array ("mod" => "user"), "module"));
} }
...@@ -956,31 +962,41 @@ function user_register($edit = array()) { ...@@ -956,31 +962,41 @@ function user_register($edit = array()) {
$pass = user_password(); $pass = user_password();
// create new user account, noting whether administrator approval is required // create new user account, noting whether administrator approval is required
if (variable_get("user_register", 1) == 1) { $account = user_save("", array_merge(array("name" => $edit["name"], "pass" => $pass, "init" => $edit["mail"], "mail" => $edit["mail"], "rid" => _user_authenticated_id(), "status" => (variable_get("user_register", 1) == 1 ? 1 : 0)), $data));
$user = user_save("", array_merge(array("name" => $edit["name"], "pass" => $pass, "init" => $edit["mail"], "mail" => $edit["mail"], "rid" => _user_authenticated_id(), "status" => 1), $data));
}
else {
$user = user_save("", array_merge(array("name" => $edit["name"], "pass" => $pass, "init" => $edit["mail"], "mail" => $edit["mail"], "rid" => _user_authenticated_id(), "status" => 0), $data));
}
$variables = array("%username" => $edit["name"], "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => path_uri(), "%uri_brief" => path_uri(1), "%mailto" => $edit["mail"], "%date" => format_date(time())); $variables = array("%username" => $edit["name"], "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => path_uri(), "%uri_brief" => path_uri(1), "%mailto" => $edit["mail"], "%date" => format_date(time()));
//the first user may login immediately, and receives a customized welcome email. //the first user may login immediately, and receives a customized welcome email.
if ($user->uid == 1) { if ($account->uid == 1) {
user_mail($edit["mail"], t("drupal user account details for %s", array("%s" => $edit["name"])), strtr(t("%username,\n\nYou may now login to %uri using the following username and password:\n\n username: %username\n password: %password\n\nAfter logging in, you may wish to visit the following pages:\n\nAdministration: %uriadmin.php\nEdit user account: %uri". drupal_url(array("mod" => "user", "op" => "edit"), "module") ."\n\n--drupal"), $variables), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); user_mail($edit["mail"], t("drupal user account details for %s", array("%s" => $edit["name"])), strtr(t("%username,\n\nYou may now login to %uri using the following username and password:\n\n username: %username\n password: %password\n\nAfter logging in, you may wish to visit the following pages:\n\nAdministration: %uriadmin.php\nEdit user account: %uri". drupal_url(array("mod" => "user", "op" => "edit"), "module") ."\n\n--drupal"), $variables), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
// This should not be t()'ed. No point as its only shown once in the sites lifetime, and it would be bad to store the password // This should not be t()'ed. No point as its only shown once in the sites lifetime, and it would be bad to store the password
$output .= "<p>Welcome to Drupal. You are user #1, which gives you full and immediate access. All future registrants will receive their passwords via email, so please configure your email settings using the Administration pages.</p><p> Your password is <b>$pass</b>. You may change your password on the next page.</p><p>Please login below.</p>"; $output .= "<p>Welcome to Drupal. You are user #1, which gives you full and immediate access. All future registrants will receive their passwords via email, so please configure your email settings using the Administration pages.</p><p> Your password is <b>$pass</b>. You may change your password on the next page.</p><p>Please login below.</p>";
$output .= form_hidden("name", $user->name); $output .= form_hidden("name", $account->name);
$output .= form_hidden("pass", $pass); $output .= form_hidden("pass", $pass);
$output .= form_submit(t("Log in")); $output .= form_submit(t("Log in"));
return form($output); return form($output);
} }
else { else {
global $HTTP_HOST; if ($account->status) {
$subject = strtr(variable_get("user_mail_welcome_subject", t("User account details for %username at %site")), $variables); /*
$body = strtr(variable_get("user_mail_welcome_body", t("%username,\n\nThank you for registering at %site. You may now login to %uri". drupal_url(array("mod" => "user", "op" => "login"), "module") ." using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %urimodule.php?mod=user&op=edit\n\nYour new %site membership also enables to you to login to other Drupal powered web sites (e.g. http://www.drop.org) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), $variables); ** Create new user account, no administrator approval required:
user_mail($edit["mail"], $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); */
return t("Your password and further instructions have been sent to your e-mail address.");
$subject = strtr(variable_get("user_mail_welcome_subject", t("User account details for %username at %site")), $variables);
$body = strtr(variable_get("user_mail_welcome_body", t("%username,\n\nThank you for registering at %site. You may now login to %uri". drupal_url(array("mod" => "user", "op" => "login"), "module") ." using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %urimodule.php?mod=user&op=edit\n\nYour new %site membership also enables to you to login to other Drupal powered web sites (e.g. http://www.drop.org) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), $variables);
user_mail($edit["mail"], $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
return t("Your password and further instructions have been sent to your e-mail address.");
}
else {
/*
** Create new user account, administrator approval required:
*/
$subject = strtr(variable_get("user_mail_welcome_subject", t("User account details for %username at %site")), $variables);
$body = strtr(variable_get("user_mail_welcome_body", t("%username,\n\nThank you for registering at %site. Your account will have to be approved by the site administrator. You may now login to %uri". drupal_url(array("mod" => "user", "op" => "login"), "module") ." using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %urimodule.php?mod=user&op=edit\n\nYour new %site membership also enables to you to login to other Drupal powered web sites (e.g. http://www.drop.org) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), $variables);
user_mail($edit["mail"], $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
user_mail(variable_get("site_mail", ini_get("sendmail_from")), $subject, t("%u has applied for an account.\n\n%uri", array("%u" => $account->name, "%uri" => path_uri() . drupal_url(array("mod" => "user", "op" => "edit", "id" => $account->uid), "admin"))), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
return t("Your password and further instructions have been sent to your e-mail address.");
}
} }
} }
else { else {
...@@ -1003,10 +1019,8 @@ function user_register($edit = array()) { ...@@ -1003,10 +1019,8 @@ function user_register($edit = array()) {
} }
} }
$output .= form_submit(t("Create new account")); $output .= form_submit(t("Create new account"));
$output .= "<p>&#187; ". lm(t("E-mail new password"), array("mod" => "user", "op" => "password")). "<br />"; $output .= "<p>&raquo; ". lm(t("E-mail new password"), array("mod" => "user", "op" => "password")). "<br />";
$output .= "&#187; " .lm(t("Log in"), array("mod" => "user", "op" => "login")). "</p>"; $output .= "&raquo; " .lm(t("Log in"), array("mod" => "user", "op" => "login")). "</p>";
unset($user);
return form($output); return form($output);
} }
...@@ -1176,7 +1190,9 @@ function user_view($uid = 0) { ...@@ -1176,7 +1190,9 @@ function user_view($uid = 0) {
else { else {
$theme->header(); $theme->header();
$theme->box(t("Log in"), user_login()); $theme->box(t("Log in"), user_login());
$theme->box(t("Create new user account"), user_register()); if (variable_get("user_register", 1)) {
$theme->box(t("Create new user account"), user_register());
}
$theme->box(t("E-mail new password"), user_pass()); $theme->box(t("E-mail new password"), user_pass());
$theme->footer(); $theme->footer();
} }
...@@ -1196,7 +1212,12 @@ function user_page() { ...@@ -1196,7 +1212,12 @@ function user_page() {
case "register": case "register":
$output = user_register($edit); $output = user_register($edit);
$theme->header(); $theme->header();
$theme->box(t("Create new account"), $output); if (variable_get("user_register", 1)) {
$theme->box(t("Create new account"), $output);
}
else {
print message_access();
}
$theme->footer(); $theme->footer();
break; break;
case t("Log in"): case t("Log in"):
......
...@@ -481,9 +481,9 @@ function user_block() { ...@@ -481,9 +481,9 @@ function user_block() {
$output .= "<input name=\"edit[op]\" type=\"submit\" value=\"". t("Log in") ."\" /><br />\n"; $output .= "<input name=\"edit[op]\" type=\"submit\" value=\"". t("Log in") ."\" /><br />\n";
$output .= "</form></div>\n"; $output .= "</form></div>\n";
if (variable_get("user_register", 1)) { if (variable_get("user_register", 1)) {
$output .= "&#187; ". lm(t("Register"), array("mod" => "user", "op" => "register"), "", array("title" => t("Create a new user account."))) ."\n"; $output .= "&raquo; ". lm(t("Register"), array("mod" => "user", "op" => "register"), "", array("title" => t("Create a new user account."))) ."<br />\n";
} }
$output .= "<br />&#187; ". lm(t("New password"), array("mod" => "user", "op" => "password"), "", array("title" => t("Request new password via e-mail"))) ."<br />"; $output .= "&raquo; ". lm(t("New password"), array("mod" => "user", "op" => "password"), "", array("title" => t("Request new password via e-mail")));
$block[1]["content"] = $output; $block[1]["content"] = $output;
} }
...@@ -807,8 +807,11 @@ function user_login($edit = array(), $msg = "") { ...@@ -807,8 +807,11 @@ function user_login($edit = array(), $msg = "") {
$output .= form_password(t("Password"), "pass", $pass, 20, 64, t("Enter the password that accompanies your username.")); $output .= form_password(t("Password"), "pass", $pass, 20, 64, t("Enter the password that accompanies your username."));
$output .= form_checkbox(t("Remember me"), "remember_me", 1, 0, 0); $output .= form_checkbox(t("Remember me"), "remember_me", 1, 0, 0);
$output .= form_submit(t("Log in")); $output .= form_submit(t("Log in"));
$output .= "<p>&#187; ". lm(t("E-mail new password"), array("mod" => "user", "op" => "password")). "<br />"; $output .= "<p>&raquo; ". lm(t("E-mail new password"), array("mod" => "user", "op" => "password")). "<br />";
$output .= "&#187; " . lm(t("Create new account"), array("mod" => "user", "op" => "register")). "</p>"; if (variable_get("user_register", 1)) {
$output .= "&raquo; ". lm(t("Create new account"), array("mod" => "user", "op" => "register"));
}
$output .= "</p>";
return form($output, "post", drupal_url(array ("mod" => "user"), "module")); return form($output, "post", drupal_url(array ("mod" => "user"), "module"));
} }
...@@ -889,8 +892,11 @@ function user_pass($edit = array()) { ...@@ -889,8 +892,11 @@ function user_pass($edit = array()) {
$output .= form_textfield(t("Username"), "name", $edit["name"], 30, 64); $output .= form_textfield(t("Username"), "name", $edit["name"], 30, 64);
$output .= form_textfield(t("E-mail address"), "mail", $edit["mail"], 30, 64); $output .= form_textfield(t("E-mail address"), "mail", $edit["mail"], 30, 64);
$output .= form_submit(t("E-mail new password")); $output .= form_submit(t("E-mail new password"));
$output .= "<p>&#187; ". lm(t("Log in"), array("mod" =>user, "op" => "login")) ."<br />"; $output .= "<p>&raquo; ". lm(t("Log in"), array("mod" =>user, "op" => "login")) ."<br />";
$output .= "&#187; ". lm(t("Create new account"), array("mod" => "user", "op" => "register")) ."</p>"; if (variable_get("user_register", 1)) {
$output .= "&raquo; ". lm(t("Create new account"), array("mod" => "user", "op" => "register"));
}
$output .= "</p>";
return form($output, "post", drupal_url(array ("mod" => "user"), "module")); return form($output, "post", drupal_url(array ("mod" => "user"), "module"));
} }
...@@ -956,31 +962,41 @@ function user_register($edit = array()) { ...@@ -956,31 +962,41 @@ function user_register($edit = array()) {
$pass = user_password(); $pass = user_password();
// create new user account, noting whether administrator approval is required // create new user account, noting whether administrator approval is required
if (variable_get("user_register", 1) == 1) { $account = user_save("", array_merge(array("name" => $edit["name"], "pass" => $pass, "init" => $edit["mail"], "mail" => $edit["mail"], "rid" => _user_authenticated_id(), "status" => (variable_get("user_register", 1) == 1 ? 1 : 0)), $data));
$user = user_save("", array_merge(array("name" => $edit["name"], "pass" => $pass, "init" => $edit["mail"], "mail" => $edit["mail"], "rid" => _user_authenticated_id(), "status" => 1), $data));
}
else {
$user = user_save("", array_merge(array("name" => $edit["name"], "pass" => $pass, "init" => $edit["mail"], "mail" => $edit["mail"], "rid" => _user_authenticated_id(), "status" => 0), $data));
}
$variables = array("%username" => $edit["name"], "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => path_uri(), "%uri_brief" => path_uri(1), "%mailto" => $edit["mail"], "%date" => format_date(time())); $variables = array("%username" => $edit["name"], "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => path_uri(), "%uri_brief" => path_uri(1), "%mailto" => $edit["mail"], "%date" => format_date(time()));
//the first user may login immediately, and receives a customized welcome email. //the first user may login immediately, and receives a customized welcome email.
if ($user->uid == 1) { if ($account->uid == 1) {
user_mail($edit["mail"], t("drupal user account details for %s", array("%s" => $edit["name"])), strtr(t("%username,\n\nYou may now login to %uri using the following username and password:\n\n username: %username\n password: %password\n\nAfter logging in, you may wish to visit the following pages:\n\nAdministration: %uriadmin.php\nEdit user account: %uri". drupal_url(array("mod" => "user", "op" => "edit"), "module") ."\n\n--drupal"), $variables), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); user_mail($edit["mail"], t("drupal user account details for %s", array("%s" => $edit["name"])), strtr(t("%username,\n\nYou may now login to %uri using the following username and password:\n\n username: %username\n password: %password\n\nAfter logging in, you may wish to visit the following pages:\n\nAdministration: %uriadmin.php\nEdit user account: %uri". drupal_url(array("mod" => "user", "op" => "edit"), "module") ."\n\n--drupal"), $variables), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
// This should not be t()'ed. No point as its only shown once in the sites lifetime, and it would be bad to store the password // This should not be t()'ed. No point as its only shown once in the sites lifetime, and it would be bad to store the password
$output .= "<p>Welcome to Drupal. You are user #1, which gives you full and immediate access. All future registrants will receive their passwords via email, so please configure your email settings using the Administration pages.</p><p> Your password is <b>$pass</b>. You may change your password on the next page.</p><p>Please login below.</p>"; $output .= "<p>Welcome to Drupal. You are user #1, which gives you full and immediate access. All future registrants will receive their passwords via email, so please configure your email settings using the Administration pages.</p><p> Your password is <b>$pass</b>. You may change your password on the next page.</p><p>Please login below.</p>";
$output .= form_hidden("name", $user->name); $output .= form_hidden("name", $account->name);
$output .= form_hidden("pass", $pass); $output .= form_hidden("pass", $pass);
$output .= form_submit(t("Log in")); $output .= form_submit(t("Log in"));
return form($output); return form($output);
} }
else { else {
global $HTTP_HOST; if ($account->status) {
$subject = strtr(variable_get("user_mail_welcome_subject", t("User account details for %username at %site")), $variables); /*
$body = strtr(variable_get("user_mail_welcome_body", t("%username,\n\nThank you for registering at %site. You may now login to %uri". drupal_url(array("mod" => "user", "op" => "login"), "module") ." using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %urimodule.php?mod=user&op=edit\n\nYour new %site membership also enables to you to login to other Drupal powered web sites (e.g. http://www.drop.org) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), $variables); ** Create new user account, no administrator approval required:
user_mail($edit["mail"], $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); */
return t("Your password and further instructions have been sent to your e-mail address.");