summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorKjartan Mannes <kjartan@2.no-reply.drupal.org>2002-05-23 14:14:48 +0000
committerKjartan Mannes <kjartan@2.no-reply.drupal.org>2002-05-23 14:14:48 +0000
commit66e1bbfb937cab81c5943c264ff52208b0a71286 (patch)
tree60c7499fc183d2a894889a8d22df7cc0ffebfc83 /modules
parent5f6d733b70cdc374053e1e415d225008e04bbef4 (diff)
downloadbrdo-66e1bbfb937cab81c5943c264ff52208b0a71286.tar.gz
brdo-66e1bbfb937cab81c5943c264ff52208b0a71286.tar.bz2
- 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.
Diffstat (limited to 'modules')
-rw-r--r--modules/blog.module14
-rw-r--r--modules/blog/blog.module14
-rw-r--r--modules/book.module8
-rw-r--r--modules/book/book.module8
-rw-r--r--modules/forum.module6
-rw-r--r--modules/forum/forum.module6
-rw-r--r--modules/node.module3
-rw-r--r--modules/node/node.module3
-rw-r--r--modules/page.module6
-rw-r--r--modules/page/page.module6
-rw-r--r--modules/poll.module6
-rw-r--r--modules/poll/poll.module6
-rw-r--r--modules/story.module6
-rw-r--r--modules/story/story.module6
-rw-r--r--modules/user.module71
-rw-r--r--modules/user/user.module71
16 files changed, 114 insertions, 126 deletions
diff --git a/modules/blog.module b/modules/blog.module
index 2677f8e04..f3603bc5d 100644
--- a/modules/blog.module
+++ b/modules/blog.module
@@ -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) {
if ($op == "approve") {
return array("promote" => 1);
@@ -205,12 +213,6 @@ function blog_page_last() {
function blog_form(&$node, &$help, &$error) {
global $nid, $iid;
- if (!$node->status) {
- $node->status = 1;
- $node->moderate = 1;
- $node->comment = 2;
- }
-
if (isset($node->body)) {
/*
diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index 2677f8e04..f3603bc5d 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -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) {
if ($op == "approve") {
return array("promote" => 1);
@@ -205,12 +213,6 @@ function blog_page_last() {
function blog_form(&$node, &$help, &$error) {
global $nid, $iid;
- if (!$node->status) {
- $node->status = 1;
- $node->moderate = 1;
- $node->comment = 2;
- }
-
if (isset($node->body)) {
/*
diff --git a/modules/book.module b/modules/book.module
index 055b3681e..f6dab9d06 100644
--- a/modules/book.module
+++ b/modules/book.module
@@ -170,13 +170,7 @@ function book_delete(&$node) {
function book_form(&$node, &$help, &$error) {
global $user, $op;
- if (!$node->status) {
- $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."));
+ $output = form_select(t("Parent"), "parent", $node->parent, book_toc(), t("The parent subject or category the page belongs in."));
if ($node->format) {
if ($op != t("Preview")) {
diff --git a/modules/book/book.module b/modules/book/book.module
index 055b3681e..f6dab9d06 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -170,13 +170,7 @@ function book_delete(&$node) {
function book_form(&$node, &$help, &$error) {
global $user, $op;
- if (!$node->status) {
- $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."));
+ $output = form_select(t("Parent"), "parent", $node->parent, book_toc(), t("The parent subject or category the page belongs in."));
if ($node->format) {
if ($op != t("Preview")) {
diff --git a/modules/forum.module b/modules/forum.module
index 69a26b289..e5b487f09 100644
--- a/modules/forum.module
+++ b/modules/forum.module
@@ -55,12 +55,6 @@ function forum_view($node) {
function forum_form(&$node, &$help, &$error) {
- if (!$node->status) {
- $node->status = 1;
- $node->moderate = 1;
- $node->comment = 2;
- }
-
if (function_exists("taxonomy_node_form")) {
$output = implode("", taxonomy_node_form("forum", $node));
}
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index 69a26b289..e5b487f09 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -55,12 +55,6 @@ function forum_view($node) {
function forum_form(&$node, &$help, &$error) {
- if (!$node->status) {
- $node->status = 1;
- $node->moderate = 1;
- $node->comment = 2;
- }
-
if (function_exists("taxonomy_node_form")) {
$output = implode("", taxonomy_node_form("forum", $node));
}
diff --git a/modules/node.module b/modules/node.module
index a74dacaf3..635d9a725 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -892,7 +892,8 @@ function node_add($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 {
diff --git a/modules/node/node.module b/modules/node/node.module
index a74dacaf3..635d9a725 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -892,7 +892,8 @@ function node_add($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 {
diff --git a/modules/page.module b/modules/page.module
index da8258888..06762b671 100644
--- a/modules/page.module
+++ b/modules/page.module
@@ -129,12 +129,6 @@ function page_view($node, $main = 0) {
function page_form(&$node, &$help, &$error) {
global $op;
- if (!$node->status) {
- $node->status = 1;
- $node->moderate = 1;
- $node->comment = 2;
- }
-
if ($node->format) {
if ($op != t("Preview")) {
$node->body = addslashes($node->body);
diff --git a/modules/page/page.module b/modules/page/page.module
index da8258888..06762b671 100644
--- a/modules/page/page.module
+++ b/modules/page/page.module
@@ -129,12 +129,6 @@ function page_view($node, $main = 0) {
function page_form(&$node, &$help, &$error) {
global $op;
- if (!$node->status) {
- $node->status = 1;
- $node->moderate = 1;
- $node->comment = 2;
- }
-
if ($node->format) {
if ($op != t("Preview")) {
$node->body = addslashes($node->body);
diff --git a/modules/poll.module b/modules/poll.module
index 2bfdd7d0d..68b54eb58 100644
--- a/modules/poll.module
+++ b/modules/poll.module
@@ -40,12 +40,6 @@ function poll_delete($node) {
}
function poll_form(&$node, &$help, &$error) {
- if (!$node->status) {
- $node->status = 1;
- $node->moderate = 1;
- $node->comment = 2;
- }
-
$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));
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index 2bfdd7d0d..68b54eb58 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -40,12 +40,6 @@ function poll_delete($node) {
}
function poll_form(&$node, &$help, &$error) {
- if (!$node->status) {
- $node->status = 1;
- $node->moderate = 1;
- $node->comment = 2;
- }
-
$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));
diff --git a/modules/story.module b/modules/story.module
index 5c84baa0d..f4366d0cb 100644
--- a/modules/story.module
+++ b/modules/story.module
@@ -65,12 +65,6 @@ function story_link($type) {
function story_form(&$node, &$help, &$error) {
- if (!$node->status) {
- $node->status = 1;
- $node->moderate = 1;
- $node->comment = 2;
- }
-
if (isset($node->body)) {
/*
diff --git a/modules/story/story.module b/modules/story/story.module
index 5c84baa0d..f4366d0cb 100644
--- a/modules/story/story.module
+++ b/modules/story/story.module
@@ -65,12 +65,6 @@ function story_link($type) {
function story_form(&$node, &$help, &$error) {
- if (!$node->status) {
- $node->status = 1;
- $node->moderate = 1;
- $node->comment = 2;
- }
-
if (isset($node->body)) {
/*
diff --git a/modules/user.module b/modules/user.module
index 8a54366c5..b671915ab 100644
--- a/modules/user.module
+++ b/modules/user.module
@@ -481,9 +481,9 @@ function user_block() {
$output .= "<input name=\"edit[op]\" type=\"submit\" value=\"". t("Log in") ."\" /><br />\n";
$output .= "</form></div>\n";
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;
}
@@ -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_checkbox(t("Remember me"), "remember_me", 1, 0, 0);
$output .= form_submit(t("Log in"));
- $output .= "<p>&#187; ". 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>";
+ $output .= "<p>&raquo; ". lm(t("E-mail new password"), array("mod" => "user", "op" => "password")). "<br />";
+ 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"));
}
@@ -889,8 +892,11 @@ function user_pass($edit = array()) {
$output .= form_textfield(t("Username"), "name", $edit["name"], 30, 64);
$output .= form_textfield(t("E-mail address"), "mail", $edit["mail"], 30, 64);
$output .= form_submit(t("E-mail new password"));
- $output .= "<p>&#187; ". lm(t("Log in"), array("mod" =>user, "op" => "login")) ."<br />";
- $output .= "&#187; ". lm(t("Create new account"), array("mod" => "user", "op" => "register")) ."</p>";
+ $output .= "<p>&raquo; ". lm(t("Log in"), array("mod" =>user, "op" => "login")) ."<br />";
+ 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"));
}
@@ -956,31 +962,41 @@ function user_register($edit = array()) {
$pass = user_password();
// create new user account, noting whether administrator approval is required
- if (variable_get("user_register", 1) == 1) {
- $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));
- }
+ $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));
$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.
- 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");
// 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 .= form_hidden("name", $user->name);
+ $output .= form_hidden("name", $account->name);
$output .= form_hidden("pass", $pass);
$output .= form_submit(t("Log in"));
return form($output);
}
else {
- global $HTTP_HOST;
- $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.");
+ if ($account->status) {
+ /*
+ ** Create new user account, no 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. 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 {
@@ -1003,10 +1019,8 @@ function user_register($edit = array()) {
}
}
$output .= form_submit(t("Create new account"));
- $output .= "<p>&#187; ". lm(t("E-mail new password"), array("mod" => "user", "op" => "password")). "<br />";
- $output .= "&#187; " .lm(t("Log in"), array("mod" => "user", "op" => "login")). "</p>";
-
- unset($user);
+ $output .= "<p>&raquo; ". lm(t("E-mail new password"), array("mod" => "user", "op" => "password")). "<br />";
+ $output .= "&raquo; " .lm(t("Log in"), array("mod" => "user", "op" => "login")). "</p>";
return form($output);
}
@@ -1176,7 +1190,9 @@ function user_view($uid = 0) {
else {
$theme->header();
$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->footer();
}
@@ -1196,7 +1212,12 @@ function user_page() {
case "register":
$output = user_register($edit);
$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();
break;
case t("Log in"):
diff --git a/modules/user/user.module b/modules/user/user.module
index 8a54366c5..b671915ab 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -481,9 +481,9 @@ function user_block() {
$output .= "<input name=\"edit[op]\" type=\"submit\" value=\"". t("Log in") ."\" /><br />\n";
$output .= "</form></div>\n";
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;
}
@@ -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_checkbox(t("Remember me"), "remember_me", 1, 0, 0);
$output .= form_submit(t("Log in"));
- $output .= "<p>&#187; ". 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>";
+ $output .= "<p>&raquo; ". lm(t("E-mail new password"), array("mod" => "user", "op" => "password")). "<br />";
+ 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"));
}
@@ -889,8 +892,11 @@ function user_pass($edit = array()) {
$output .= form_textfield(t("Username"), "name", $edit["name"], 30, 64);
$output .= form_textfield(t("E-mail address"), "mail", $edit["mail"], 30, 64);
$output .= form_submit(t("E-mail new password"));
- $output .= "<p>&#187; ". lm(t("Log in"), array("mod" =>user, "op" => "login")) ."<br />";
- $output .= "&#187; ". lm(t("Create new account"), array("mod" => "user", "op" => "register")) ."</p>";
+ $output .= "<p>&raquo; ". lm(t("Log in"), array("mod" =>user, "op" => "login")) ."<br />";
+ 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"));
}
@@ -956,31 +962,41 @@ function user_register($edit = array()) {
$pass = user_password();
// create new user account, noting whether administrator approval is required
- if (variable_get("user_register", 1) == 1) {
- $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));
- }
+ $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));
$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.
- 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");
// 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 .= form_hidden("name", $user->name);
+ $output .= form_hidden("name", $account->name);
$output .= form_hidden("pass", $pass);
$output .= form_submit(t("Log in"));
return form($output);
}
else {
- global $HTTP_HOST;
- $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.");
+ if ($account->status) {
+ /*
+ ** Create new user account, no 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. 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 {
@@ -1003,10 +1019,8 @@ function user_register($edit = array()) {
}
}
$output .= form_submit(t("Create new account"));
- $output .= "<p>&#187; ". lm(t("E-mail new password"), array("mod" => "user", "op" => "password")). "<br />";
- $output .= "&#187; " .lm(t("Log in"), array("mod" => "user", "op" => "login")). "</p>";
-
- unset($user);
+ $output .= "<p>&raquo; ". lm(t("E-mail new password"), array("mod" => "user", "op" => "password")). "<br />";
+ $output .= "&raquo; " .lm(t("Log in"), array("mod" => "user", "op" => "login")). "</p>";
return form($output);
}
@@ -1176,7 +1190,9 @@ function user_view($uid = 0) {
else {
$theme->header();
$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->footer();
}
@@ -1196,7 +1212,12 @@ function user_page() {
case "register":
$output = user_register($edit);
$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();
break;
case t("Log in"):