From 0915aa2eee474b275e270dc017782574b0ef469d Mon Sep 17 00:00:00 2001
From: Victor Kareh <vkareh@vkareh.net>
Date: Fri, 18 Mar 2011 00:14:50 -0400
Subject: [PATCH] Add token replacement in path.

---
 node_destination.module |   30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/node_destination.module b/node_destination.module
index 8d913ba..eeb1084 100644
--- a/node_destination.module
+++ b/node_destination.module
@@ -17,10 +17,11 @@ 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) {
+      $options = token_replace($option, 'node', $form['#node']);
+      $form['#redirect'] = $url;
+    }
   }
 }
 
@@ -47,11 +48,24 @@ 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),
   );
+  
+  if (module_exists('token')) {
+    $form['node_destination']['token_help'] = array(
+      '#title' => t('Replacement patterns'),
+      '#type' => 'fieldset',
+      '#collapsible' => TRUE,
+      '#collapsed' => TRUE,
+      '#description' => t('Prefer raw-text replacements for text to avoid problems with HTML entities!'),
+    );
+    $form['node_destination']['token_help']['help'] = array(
+      '#value' => theme('token_help', 'node'),
+    );
+  }
 
 }
 
-- 
1.7.1

