From 73fc0295887441a53c30f432763577b77256c75f Mon Sep 17 00:00:00 2001
From: Victor Kareh <vkareh@vkareh.net>
Date: Fri, 18 Mar 2011 01:15:45 -0400
Subject: [PATCH] Issue #967782: Destination prevents node delete.

---
 node_destination.module |   29 +++++++++++++++++------------
 1 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/node_destination.module b/node_destination.module
index 8d913ba..5d518e1 100644
--- a/node_destination.module
+++ b/node_destination.module
@@ -17,15 +17,24 @@ function node_destination_form_alter(&$form, $form_state, $form_id) {
   elseif (isset($form['#node']) && isset($form['#method']) && $form['#node']->type .'_node_form' == $form_id) {
     
     $option = node_destination_get_setting($form['#node']->type);
-		
-		if ($option) {
-			$form['#redirect'] = $option;
-		}
+    
+    if ($option) {
+      $form['buttons']['submit']['#submit'][] = 'node_destination_redirect';
+    }
   }
 }
 
 
 /**
+ * Redirect form on save.
+ */
+function node_destination_redirect(&$form, &$form_state) {
+  $option = node_destination_get_setting($form['#node']->type);
+  $form_state['redirect'] = $option;
+}
+
+
+/**
  * Returns the node_destination setting depending on the content type paramatar.
  */
 function node_destination_get_setting($type) {
@@ -47,14 +56,10 @@ function node_destination_node_settings_form(&$form) {
   );
   
   $form['node_destination']['ndest'] = array(
-		'#title' => 'Path to destination',
-	 	'#description' => 'Specify the path a user should be sent to, after adding or editing a node. Simple leave blank to use Drupal\'s default behaviour.',
-   	'#type' => 'textfield',
-   	'#default_value' => node_destination_get_setting($form['#node_type']->type),
+    '#title' => 'Path to destination',
+     '#description' => 'Specify the path a user should be sent to, after adding or editing a node. Simple leave blank to use Drupal\'s default behaviour.',
+     '#type' => 'textfield',
+     '#default_value' => node_destination_get_setting($form['#node_type']->type),
   );
 
 }
-
-
-
-
-- 
1.7.1

