- Fixed bug/warning when an anonymous users tries to post a node. Reported

by David.
4.2.x
Dries Buytaert 2003-01-15 19:51:08 +00:00
parent 6f15124748
commit 045f92d2b7
2 changed files with 36 additions and 18 deletions

View File

@ -303,12 +303,13 @@ function user_search($keys) {
function user_block($op = "list", $delta = 0) { function user_block($op = "list", $delta = 0) {
global $user, $edit; global $user, $edit;
if ($op == "list") {
$blocks[0]["info"] = t("Log in");
$blocks[1]["info"] = t("User information");
$blocks[2]["info"] = t("Who's new");
return $blocks; if ($op == "list") {
$blocks[0]["info"] = t("Log in");
$blocks[1]["info"] = t("User information");
$blocks[2]["info"] = t("Who's new");
return $blocks;
} }
else { else {
switch ($delta) { switch ($delta) {
@ -316,9 +317,17 @@ function user_block($op = "list", $delta = 0) {
if (!$user->uid) { if (!$user->uid) {
$output = "<div align=\"center\">\n"; $output = "<div align=\"center\">\n";
$output .= "<form action=\"". url("user/login") ."\" method=\"post\">\n"; $output .= "<form action=\"". url("user/login") ."\" method=\"post\">\n";
// Save the referer. We record where the user came from such that we /*
// can redirect him after having completed the login form. ** Save the referer. We record where the user came from such
if (!$edit["destination"]) $edit["destination"] = request_uri(); ** that we/ can redirect him after having completed the login
** form.
*/
if (empty($edit)) {
$edit["destination"] = request_uri();
}
// NOTE: special care needs to be taken because on pages with forms, such as node and comment submission pages, the $edit variable might already be set.
$output .= "<input name=\"edit[destination]\" type=\"hidden\" value=\"" . $edit["destination"] . "\" />"; $output .= "<input name=\"edit[destination]\" type=\"hidden\" value=\"" . $edit["destination"] . "\" />";
$output .= "<b>". t("Username") .":</b><br /><input name=\"edit[name]\" size=\"15\" /><br />\n"; $output .= "<b>". t("Username") .":</b><br /><input name=\"edit[name]\" size=\"15\" /><br />\n";
$output .= "<b>". t("Password") .":</b><br /><input name=\"edit[pass]\" size=\"15\" type=\"password\" /><br />\n"; $output .= "<b>". t("Password") .":</b><br /><input name=\"edit[pass]\" size=\"15\" type=\"password\" /><br />\n";
@ -610,7 +619,7 @@ function user_login($edit = array(), $msg = "") {
** can redirect him after having completed the login form. ** can redirect him after having completed the login form.
*/ */
if (!$edit["destination"]) { if (empty($edit)) {
$edit["destination"] = request_uri(); $edit["destination"] = request_uri();
} }
$output .= form_hidden("destination", $edit["destination"]); $output .= form_hidden("destination", $edit["destination"]);

View File

@ -303,12 +303,13 @@ function user_search($keys) {
function user_block($op = "list", $delta = 0) { function user_block($op = "list", $delta = 0) {
global $user, $edit; global $user, $edit;
if ($op == "list") {
$blocks[0]["info"] = t("Log in");
$blocks[1]["info"] = t("User information");
$blocks[2]["info"] = t("Who's new");
return $blocks; if ($op == "list") {
$blocks[0]["info"] = t("Log in");
$blocks[1]["info"] = t("User information");
$blocks[2]["info"] = t("Who's new");
return $blocks;
} }
else { else {
switch ($delta) { switch ($delta) {
@ -316,9 +317,17 @@ function user_block($op = "list", $delta = 0) {
if (!$user->uid) { if (!$user->uid) {
$output = "<div align=\"center\">\n"; $output = "<div align=\"center\">\n";
$output .= "<form action=\"". url("user/login") ."\" method=\"post\">\n"; $output .= "<form action=\"". url("user/login") ."\" method=\"post\">\n";
// Save the referer. We record where the user came from such that we /*
// can redirect him after having completed the login form. ** Save the referer. We record where the user came from such
if (!$edit["destination"]) $edit["destination"] = request_uri(); ** that we/ can redirect him after having completed the login
** form.
*/
if (empty($edit)) {
$edit["destination"] = request_uri();
}
// NOTE: special care needs to be taken because on pages with forms, such as node and comment submission pages, the $edit variable might already be set.
$output .= "<input name=\"edit[destination]\" type=\"hidden\" value=\"" . $edit["destination"] . "\" />"; $output .= "<input name=\"edit[destination]\" type=\"hidden\" value=\"" . $edit["destination"] . "\" />";
$output .= "<b>". t("Username") .":</b><br /><input name=\"edit[name]\" size=\"15\" /><br />\n"; $output .= "<b>". t("Username") .":</b><br /><input name=\"edit[name]\" size=\"15\" /><br />\n";
$output .= "<b>". t("Password") .":</b><br /><input name=\"edit[pass]\" size=\"15\" type=\"password\" /><br />\n"; $output .= "<b>". t("Password") .":</b><br /><input name=\"edit[pass]\" size=\"15\" type=\"password\" /><br />\n";
@ -610,7 +619,7 @@ function user_login($edit = array(), $msg = "") {
** can redirect him after having completed the login form. ** can redirect him after having completed the login form.
*/ */
if (!$edit["destination"]) { if (empty($edit)) {
$edit["destination"] = request_uri(); $edit["destination"] = request_uri();
} }
$output .= form_hidden("destination", $edit["destination"]); $output .= form_hidden("destination", $edit["destination"]);