Index: webform.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.module,v
retrieving revision 1.196.2.10
diff -u -r1.196.2.10 webform.module
--- webform.module	26 Mar 2010 03:04:09 -0000	1.196.2.10
+++ webform.module	27 Mar 2010 04:59:51 -0000
@@ -833,7 +833,7 @@
   module_load_include('inc', 'webform', 'includes/webform.components');
 
   // Insert the webform.
-  db_query("INSERT INTO {webform} (nid, confirmation, confirmation_format, redirect_url, teaser, allow_draft, submit_notice, submit_text, submit_limit, submit_interval, additional_validate, additional_submit) VALUES (%d, '%s', %d, '%s', %d, %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['allow_draft'], $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, allow_draft, submit_notice, submit_text, submit_limit, submit_interval) VALUES (%d, '%s', %d, '%s', %d, %d, %d, '%s', %d, %d)", $node->nid, $node->webform['confirmation'], $node->webform['confirmation_format'], $node->webform['redirect_url'], $node->webform['teaser'], $node->webform['allow_draft'], $node->webform['submit_notice'], $node->webform['submit_text'], $node->webform['submit_limit'], $node->webform['submit_interval']);
 
   // Insert the components into the database. Used with clone.module.
   if (isset($node->webform['components']) && !empty($node->webform['components'])) {
@@ -930,8 +930,6 @@
       'submit_text' => '',
       'submit_limit' => -1,
       'submit_interval' => -1,
-      'additional_validate' => '',
-      'additional_submit' => '',
       'roles' => array(1, 2),
       'emails' => array(),
     );
@@ -1249,8 +1247,8 @@
     $form['#action'] = url('node/' . $node->nid);
   }
 
-  $form['#submit'][] = 'webform_client_form_submit';
-  $form['#validate'][] = 'webform_client_form_validate';
+  $form['#submit'] = array('webform_client_form_pages', 'webform_client_form_submit');
+  $form['#validate'] = array('webform_client_form_validate');
 
   if (is_array($node->webform['components']) && !empty($node->webform['components'])) {
     // Prepare a new form array.
@@ -1538,23 +1536,6 @@
   // Run all #element_validate and #required checks. These are skipped initially
   // by setting #validated = TRUE on all components when they are added.
   _webform_client_form_validate($form, $form_state);
-
-  // TODO: Remove additional validation (and submission) handling entirely? This
-  // is a terrible hack where we need to flatten the submission for validation
-  // but then restore the tree version so that the submit handling functions.
-  if (trim($node->webform['additional_validate'])) {
-    // Flatten trees within the submission.
-    $form_state['values']['submitted_tree'] = $form_state['values']['submitted'];
-    $form_state['values']['submitted'] = _webform_client_form_submit_flatten($node, $form_state['values']['submitted']);
-
-    // Support for Drupal 5 validation code.
-    $form_values =& $form_state['values'];
-    // We use eval here (rather than drupal_eval) because the user needs access to local variables.
-    eval('?>' . $node->webform['additional_validate']);
-
-    // Restore the original form state so that the submit handler can reflatten.
-    $form_state['values']['submitted'] = $form_state['values']['submitted_tree'];
-  }
 }
 
 /**
@@ -1627,10 +1608,10 @@
   }
 }
 
-function webform_client_form_submit($form, &$form_state) {
-  global $user, $base_url;
-  module_load_include('inc', 'webform', 'includes/webform.submissions');
-
+/**
+ * Handle the processing of pages and conditional logic.
+ */
+function webform_client_form_pages($form, &$form_state) {
   $node = node_load($form_state['values']['details']['nid']);
 
   // Move special settings to storage.
@@ -1732,17 +1713,19 @@
   // Flatten trees within the submission.
   $form_state['values']['submitted_tree'] = $form_state['values']['submitted'];
   $form_state['values']['submitted'] = _webform_client_form_submit_flatten($node, $form_state['values']['submitted']);
+}
 
-  // Perform additional submit processing.
-  if (trim($node->webform['additional_submit'])) {
-    // Support for Drupal 5 validation code.
-    $form_values =& $form_state['values'];
-    // We use eval here (rather than drupal_eval) because the user needs access to local variables.
-    eval('?>' . $node->webform['additional_submit']);
-  }
+/**
+ * Submit handler for saving the form values and sending e-mails.
+ */
+function webform_client_form_submit($form, &$form_state) {
+  module_load_include('inc', 'webform', 'includes/webform.submissions');
+  global $user;
+
+  $node = node_load($form_state['values']['details']['nid']);
 
   // Check if user is submitting as a draft.
-  $is_draft = $form_state['values']['op'] == $draft_op;
+  $is_draft = $form_state['values']['op'] == t('Save Draft');
 
   // Create a submission object.
   $submission = (object) array(
Index: webform.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.install,v
retrieving revision 1.40.2.6
diff -u -r1.40.2.6 webform.install
--- webform.install	21 Mar 2010 02:04:30 -0000	1.40.2.6
+++ webform.install	27 Mar 2010 04:59:49 -0000
@@ -76,16 +76,6 @@
         'not null' => TRUE,
         'default' => -1,
       ),
-      'additional_validate' => array(
-        'description' => 'PHP code for additional functionality when validating a form.',
-        'type' => 'text',
-        'not null' => TRUE,
-      ),
-      'additional_submit' => array(
-        'description' => 'PHP code for additional functionality when submitting a form.',
-        'type' => 'text',
-        'not null' => TRUE,
-      ),
     ),
     'primary key' => array('nid'),
   );
Index: includes/webform.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/includes/webform.pages.inc,v
retrieving revision 1.10
diff -u -r1.10 webform.pages.inc
--- includes/webform.pages.inc	11 Feb 2010 22:05:27 -0000	1.10
+++ includes/webform.pages.inc	27 Mar 2010 04:59:51 -0000
@@ -139,36 +139,6 @@
     '#default_value' => $node->webform['submit_text'],
     '#description' => t('By default the submit button on this form will have the label <em>Submit</em>. Enter a new title here to override the default.'),
   );
-  if (user_access('use PHP for additional processing')) {
-    $form['advanced']['additional_validate'] = array(
-      '#type' => 'textarea',
-      '#title' => t('Additional Validation'),
-      '#description' => t('Enter PHP code to perform additional validation for this form. Include the &lt;?php ?&gt; tags. $form and $form_state are available variables. If validation fails, use the form_set_error function to prevent the form from being submitted. Use the same syntax as a _validate function used in the <a href="http://api.drupal.org/api/file/developer/topics/forms_api.html">Forms API</a>.'),
-      '#default_value' => $node->webform['additional_validate'],
-      '#cols' => 40,
-      '#rows' => 10,
-    );
-
-    $form['advanced']['additional_submit'] = array(
-      '#type' => 'textarea',
-      '#title' => t('Additional Processing'),
-      '#description' => t('Enter PHP code to perform additional processing for this form (after the validation). Include the &lt;?php ?&gt; tags. $form and $form_state are available variables, use the same syntax as a _submit function used in the <a href="http://api.drupal.org/api/file/developer/topics/forms_api.html">Forms API</a>.'),
-      '#default_value' => $node->webform['additional_submit'],
-      '#cols' => 40,
-      '#rows' => 10,
-    );
-  }
-  else {
-    $form['advanced']['additional_validate'] = array(
-      '#type' => 'value',
-      '#value' => $node->webform['additional_validate'],
-    );
-
-    $form['advanced']['additional_submit'] = array(
-      '#type' => 'value',
-      '#value' => $node->webform['additional_submit'],
-    );
-  }
   /* End Advanced Settings Form */
 
   $form['submit'] = array(
@@ -243,10 +213,6 @@
   // Set submit button text.
   $node->webform['submit_text'] = $form_state['values']['submit_text'];
 
-  // Set additional validation and submission code.
-  $node->webform['additional_validate'] = $form_state['values']['additional_validate'];
-  $node->webform['additional_submit'] = $form_state['values']['additional_submit'];
-
   node_save($node);
 
   drupal_set_message(t('The form settings have been updated.'));
Index: tests/webform.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/tests/webform.test,v
retrieving revision 1.5
diff -u -r1.5 webform.test
--- tests/webform.test	9 Feb 2010 22:52:19 -0000	1.5
+++ tests/webform.test	27 Mar 2010 04:59:51 -0000
@@ -611,8 +611,6 @@
         'submit_limit' => '-1',
         'submit_interval' => '-1',
         'submit_notice' => '1',
-        'additional_validate' => '',
-        'additional_submit' => '',
         'roles' => array('1', '2'),
         'components' => array(),
         'emails' => array(),
