From 58d9b02e3e9673f0f4447446f8f1736bd9233e31 Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Sun, 26 Feb 2006 19:44:45 +0000
Subject: [PATCH] - Patch #51189: fixed submit redirects.

---
 modules/node.module          | 17 +++++++++--------
 modules/node/node.module     | 17 +++++++++--------
 modules/system.module        |  2 +-
 modules/system/system.module |  2 +-
 modules/user.module          |  4 ++--
 modules/user/user.module     |  4 ++--
 6 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/modules/node.module b/modules/node.module
index bb5700483de6..14d7ac80b1ac 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -1115,11 +1115,6 @@ function node_filter_form_submit() {
     case t('Reset'):
       $_SESSION['node_overview_filter'] = array();
       break;
-    case t('Update'):
-      return;
-  }
-  if ($op != '') {
-    return 'admin/node';
   }
 }
 
@@ -1137,7 +1132,6 @@ function node_admin_nodes_submit($form_id, $edit) {
       }
     }
     drupal_set_message(t('The update has been performed.'));
-    return 'admin/node';
   }
 }
 
@@ -1874,9 +1868,16 @@ function node_form_submit($form_id, $edit) {
       drupal_set_message(t('Your %post was created.', array ('%post' => node_get_name($node))));
     }
   }
-  if ($node->nid && node_access('view', $node)) {
-    return 'node/'. $node->nid;
+  if ($node->nid) {
+    if (node_access('view', $node)) {
+      return 'node/'. $node->nid;
+    }
+    else {
+      return '';
+    }
   }
+  // it is very unlikely we get here
+  return FALSE;
 }
 
 /**
diff --git a/modules/node/node.module b/modules/node/node.module
index bb5700483de6..14d7ac80b1ac 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -1115,11 +1115,6 @@ function node_filter_form_submit() {
     case t('Reset'):
       $_SESSION['node_overview_filter'] = array();
       break;
-    case t('Update'):
-      return;
-  }
-  if ($op != '') {
-    return 'admin/node';
   }
 }
 
@@ -1137,7 +1132,6 @@ function node_admin_nodes_submit($form_id, $edit) {
       }
     }
     drupal_set_message(t('The update has been performed.'));
-    return 'admin/node';
   }
 }
 
@@ -1874,9 +1868,16 @@ function node_form_submit($form_id, $edit) {
       drupal_set_message(t('Your %post was created.', array ('%post' => node_get_name($node))));
     }
   }
-  if ($node->nid && node_access('view', $node)) {
-    return 'node/'. $node->nid;
+  if ($node->nid) {
+    if (node_access('view', $node)) {
+      return 'node/'. $node->nid;
+    }
+    else {
+      return '';
+    }
   }
+  // it is very unlikely we get here
+  return FALSE;
 }
 
 /**
diff --git a/modules/system.module b/modules/system.module
index 56e54885d3ca..494c9fa5f594 100644
--- a/modules/system.module
+++ b/modules/system.module
@@ -55,7 +55,7 @@ function system_perm() {
  */
 function system_elements() {
   // Top level form
-  $type['form'] = array('#method' => 'post', '#action' => request_uri(), '#redirect' => '');
+  $type['form'] = array('#method' => 'post', '#action' => request_uri(), '#redirect' => $_GET['q']);
 
   // Inputs
   $type['checkbox'] = array('#input' => TRUE, '#return_value' => 1);
diff --git a/modules/system/system.module b/modules/system/system.module
index 56e54885d3ca..494c9fa5f594 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -55,7 +55,7 @@ function system_perm() {
  */
 function system_elements() {
   // Top level form
-  $type['form'] = array('#method' => 'post', '#action' => request_uri(), '#redirect' => '');
+  $type['form'] = array('#method' => 'post', '#action' => request_uri(), '#redirect' => $_GET['q']);
 
   // Inputs
   $type['checkbox'] = array('#input' => TRUE, '#return_value' => 1);
diff --git a/modules/user.module b/modules/user.module
index d2c3d94de8fa..1601ba02a7dd 100644
--- a/modules/user.module
+++ b/modules/user.module
@@ -1034,7 +1034,7 @@ function user_pass_submit($form_id, $form_values) {
   $mail_success = user_mail($account->mail, $subject, $body, $headers);
 
   if ($mail_success) {
-      watchdog('user', t('Password reset instructions mailed to %name at %email.', array('%name' => '<em>'. $account->name .'</em>', '%email' => '<em>'. $account->mail .'</em>')));
+    watchdog('user', t('Password reset instructions mailed to %name at %email.', array('%name' => '<em>'. $account->name .'</em>', '%email' => '<em>'. $account->mail .'</em>')));
     drupal_set_message(t('Further instructions have been sent to your e-mail address.'));
   }
   else {
@@ -1220,7 +1220,7 @@ function user_register_submit($form_id, $form_values) {
       $body = _user_mail_text('welcome_body', $variables);
       user_mail($mail, $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
       drupal_set_message(t('Your password and further instructions have been sent to your e-mail address.'));
-
+      return '';
     }
     else {
       // Create new user account, administrator approval required.
diff --git a/modules/user/user.module b/modules/user/user.module
index d2c3d94de8fa..1601ba02a7dd 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -1034,7 +1034,7 @@ function user_pass_submit($form_id, $form_values) {
   $mail_success = user_mail($account->mail, $subject, $body, $headers);
 
   if ($mail_success) {
-      watchdog('user', t('Password reset instructions mailed to %name at %email.', array('%name' => '<em>'. $account->name .'</em>', '%email' => '<em>'. $account->mail .'</em>')));
+    watchdog('user', t('Password reset instructions mailed to %name at %email.', array('%name' => '<em>'. $account->name .'</em>', '%email' => '<em>'. $account->mail .'</em>')));
     drupal_set_message(t('Further instructions have been sent to your e-mail address.'));
   }
   else {
@@ -1220,7 +1220,7 @@ function user_register_submit($form_id, $form_values) {
       $body = _user_mail_text('welcome_body', $variables);
       user_mail($mail, $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
       drupal_set_message(t('Your password and further instructions have been sent to your e-mail address.'));
-
+      return '';
     }
     else {
       // Create new user account, administrator approval required.
-- 
GitLab