? .DS_Store
? webform-520524-6.patch
Index: webform.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.install,v
retrieving revision 1.27
diff -u -p -r1.27 webform.install
--- webform.install	19 Jun 2009 19:16:24 -0000	1.27
+++ webform.install	29 Oct 2009 14:05:08 -0000
@@ -32,6 +32,12 @@ function webform_schema() {
         'not null' => TRUE,
         'default' => 0,
       ),
+      'redirect_url' => array(
+        'description' => 'The URL a user is redirect to after submitting a form.',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => FALSE,
+      ),
       'teaser' => array(
         'description' => 'Boolean value for whether the entire form should be displayed on the teaser.',
         'type' => 'int',
@@ -1179,6 +1185,37 @@ function webform_update_6303() {
 }
 
 /**
+ * Add the redirect_url field and update all existing webforms to merge the changes.
+ */
+function webform_update_6304() {
+  $ret = array();
+
+  // Safety check to prevent re-adding existing column.
+  if (db_column_exists('webform', 'redirect_url')) {
+    return $ret;
+  }
+
+  // add the new redirect_url column
+  db_add_field($ret, 'webform', 'redirect_url', array('type' => 'varchar', 'length' => '255', 'not null' => FALSE));
+
+  // if the webform is using the confirmation field as a redirect
+  // then move it to the new redirect_url field
+  $result = db_query("SELECT nid, confirmation FROM {webform}");
+  while ($row = db_fetch_object($result)) {
+    if (valid_url(trim($row->confirmation), TRUE) || preg_match('/^internal:/', $row->confirmation)) {
+      db_query("UPDATE {webform} SET redirect_url = '%s' WHERE nid = %d", $row->confirmation, $row->nid);
+      db_query("UPDATE {webform} SET confirmation = '' WHERE nid = %d", '', $row->nid);
+    }
+    elseif (preg_match('/^message:/', $row->confirmation)) {
+      $message = preg_replace('/^message:/', '', $row->confirmation);
+      db_query("UPDATE {webform} SET confirmation = '%s' WHERE nid = %d", $message, $row->nid);
+    }
+  }
+
+  return $ret;
+}
+
+/**
  * Recursively delete all files and folders in the specified filepath, then
  * delete the containing folder.
  *
Index: webform.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.module,v
retrieving revision 1.137
diff -u -p -r1.137 webform.module
--- webform.module	15 Oct 2009 01:29:30 -0000	1.137
+++ webform.module	29 Oct 2009 14:05:08 -0000
@@ -27,7 +27,7 @@ function webform_help($section = 'admin/
       <ul>
        <li>Go to Create Content and add a webform</li>
        <li>Add a description to be displayed as a teaser and above the actual form.</li>
-       <li>Add a confirmation message or redirect node that is to be displayed after successful submission.</li>
+       <li>Add a confirmation message and/or redirect node that is to be displayed after successful submission.</li>
        <li>Add one or more components to your form.</li>
        <li>Optionally add an e-mail address to which submissions will be sent. If no email address is specified, no e-mail will be sent when submissions are made through the form.</li>
        <li>Optionally select an e-mail (or hidden) component that will be used to populate the return e-mail address on any sent e-mail.</li>
@@ -571,7 +571,7 @@ function webform_insert($node) {
   module_load_include('inc', 'webform', 'includes/webform.components');
 
   // Insert the Webform.
-  db_query("INSERT INTO {webform} (nid, confirmation, confirmation_format, teaser, submit_notice, submit_text, submit_limit, submit_interval, additional_validate, additional_submit) VALUES (%d, '%s', %d, %d, %d, '%s', %d, %d, '%s', '%s')", $node->nid, $node->webform['confirmation'], $node->webform['confirmation_format'], $node->webform['teaser'], $node->webform['submit_notice'], $node->webform['submit_text'], $node->webform['submit_limit'], $node->webform['submit_interval'], $node->webform['additional_validate'], $node->webform['additional_submit']);
+  db_query("INSERT INTO {webform} (nid, confirmation, confirmation_format, redirect_url, teaser, submit_notice, submit_text, submit_limit, submit_interval, additional_validate, additional_submit) VALUES (%d, '%s', %d, '%s', %d, %d, '%s', %d, %d, '%s', '%s')", $node->nid, $node->webform['confirmation'], $node->webform['confirmation_format'], $node->webform['redirect_url'], $node->webform['teaser'], $node->webform['submit_notice'], $node->webform['submit_text'], $node->webform['submit_limit'], $node->webform['submit_interval'], $node->webform['additional_validate'], $node->webform['additional_submit']);
 
   // Insert the components into the database. Used with clone.module.
   if (isset($node->webform['components']) && !empty($node->webform['components'])) {
@@ -642,6 +642,7 @@ function webform_load($node) {
     $additions->webform = array(
       'confirmation' => '',
       'confirmation_format' => FILTER_FORMAT_DEFAULT,
+      'redirect_url' => '',
       'teaser' => 0,
       'submit_notice' => 0,
       'submit_text' => '',
@@ -1543,26 +1544,25 @@ function webform_client_form_submit($for
     watchdog('webform', t('Submission posted to %title. <a href="!url">Results</a>. !details', array('%title' => $node->title, '!url' => url('node/'. $node->nid .'/submission/'. $sid), '!results' => "<br />\n<pre>". htmlentities(print_r($form_state['values'], TRUE)) .'</pre>')));
   }
 
-  // Check confirmation field to see if redirect should be to another node or a message.
+  // Check redirect_url field to see if redirect should be to another node.
   if (isset($form_state['values']['submission'])) {
     drupal_set_message(t('Submission updated.'));
     $redirect = NULL;
   }
-  elseif (valid_url(trim($node->webform['confirmation']), TRUE)) {
-    $redirect = trim($node->webform['confirmation']);
+  elseif (valid_url(trim($node->webform['redirect_url']), TRUE)) {
+    $redirect = trim($node->webform['redirect_url']);
   }
-  elseif (preg_match('/^internal:/', $node->webform['confirmation'])) {
-    $path = preg_replace('/^internal:/', '', $node->webform['confirmation']);
+  elseif (preg_match('/^internal:/', $node->webform['redirect_url'])) {
+    $path = preg_replace('/^internal:/', '', $node->webform['redirect_url']);
     $redirect = array(trim($path), 'sid='. $sid);
-  }
-  elseif (preg_match('/^message:/', $node->webform['confirmation'])) {
-    $message = preg_replace('/^message:/', '', $node->webform['confirmation']);
-    drupal_set_message($message);
-    $redirect = NULL;
+    if (!empty($node->webform['confirmation'])) {
+      drupal_set_message($node->webform['confirmation']);
+    }
   }
   else {
     $redirect = array('node/'. $node->nid .'/done', 'sid='. $sid);
   }
+
   $form_state['redirect'] = $redirect;
 }
 
@@ -1649,7 +1649,6 @@ function template_preprocess_webform_for
 function template_preprocess_webform_confirmation(&$vars) {
   if (empty($vars['node']->webform['confirmation'])) {
     drupal_set_message(t('Thank you, your submission has been received.'));
-    drupal_goto('node/'. $vars['node']->nid);
   }
 
   $vars['confirmation_message'] = check_markup($vars['node']->webform['confirmation'], $vars['node']->webform['confirmation_format'], FALSE);
Index: includes/webform.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/includes/webform.pages.inc,v
retrieving revision 1.5
diff -u -p -r1.5 webform.pages.inc
--- includes/webform.pages.inc	19 Jun 2009 19:16:24 -0000	1.5
+++ includes/webform.pages.inc	29 Oct 2009 14:05:08 -0000
@@ -29,8 +29,8 @@ function webform_configure_form(&$form_s
 
   $form['submission']['confirmation_wrapper']['confirmation'] = array(
     '#type' => 'textarea',
-    '#title' => t('Confirmation message or redirect URL'),
-    '#description' => t('Message to be shown upon successful submission or a path to a redirect page. Preface message with <em>message:</em> for a simple message that does not require a page refresh. Redirect pages must start with <em>http://</em> for external sites or <em>internal:</em> for an internal path. i.e. <em>http://www.example.com</em> or <em>internal:node/10</em>'),
+    '#title' => t('Confirmation message'),
+    '#description' => t('Message to be shown upon successful submission.'),
     '#default_value' => $node->webform['confirmation'],
     '#cols' => 40,
     '#rows' => 10,
@@ -38,6 +38,16 @@ function webform_configure_form(&$form_s
 
   $form['submission']['confirmation_wrapper']['format'] = filter_form($node->webform['confirmation_format'], NULL, array('confirmation_format'));
 
+  // Redirect URL
+  $form['submission']['redirect_url'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Redirect URL'),
+    '#description' => t('URL to be redirected to upon successful submission. Redirect pages must start with <em>http://</em> for external sites or <em>internal:</em> for an internal path. i.e. <em>http://www.example.com</em> or <em>internal:node/10</em>'),
+    '#default_value' => $node->webform['redirect_url'],
+    '#size' => 60,
+    '#maxlength' => 172,
+  );
+
   // Submission limit settings.
   $form['submission']['submit_limit'] = array(
     '#type' => 'item',
@@ -185,6 +195,9 @@ function webform_configure_form_submit($
   $node->webform['confirmation'] = $form_state['values']['confirmation'];
   $node->webform['confirmation_format'] = $form_state['values']['confirmation_format'];
 
+  // Save the redirect URL
+  $node->webform['redirect_url'] = $form_state['values']['redirect_url'];
+
   // Save roles.
   $node->webform['roles'] = $form_state['values']['roles'];
 
