Index: webform.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.module,v
retrieving revision 1.113.2.70.2.39
diff -u -r1.113.2.70.2.39 webform.module
--- webform.module	9 May 2008 03:28:15 -0000	1.113.2.70.2.39
+++ webform.module	9 May 2008 05:45:51 -0000
@@ -319,9 +319,7 @@
   // Insert the components into the database.
   if (isset($node->webform['components']) && !empty($node->webform['components'])) {
     foreach ($node->webform['components'] as $cid => $component) {
-      db_query("INSERT INTO {webform_component} (nid, cid, pid, form_key, name, type, value, extra, mandatory, weight) VALUES (%d, %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d)",
-        $node->nid, $cid, $component['pid'], $component['form_key'], $component['name'], $component['type'], $component['value'], serialize($component['extra']), ($component['mandatory'] ? 1 : 0), $component['weight']
-      );
+      webform_component_insert($component);
     }
   }
 }
@@ -383,6 +381,7 @@
     $component['value'] = $c['value'];
     $component['extra'] = unserialize($c['extra']);
     $component['mandatory'] = $c['mandatory'];
+    $component['email'] = $c['email'];
     $component['pid'] = $c['pid'];
     $component['weight'] = $c['weight'];
     if (isset($component['extra']['email']) && $component['extra']['email']) {
@@ -1598,7 +1597,7 @@
  * Theme the fields portion of the e-mails sent by webform.
  * 
  * This function calls itself recursively to maintain the tree structure of
- * components in the webform. It is called intialy by
+ * components in the webform. It is called intially by
  * theme_webform_create_mailmessage().
  * 
  * @param $cid
@@ -1611,8 +1610,16 @@
  *   The current amount of indentation being applied to printed components.
  */
 function theme_webform_mail_fields($cid, $value, $node, $indent = "") {
+  $component = $node->webform['components'][$cid];
+
+  // Check if this component needs to be included in the email at all.
+  if ($cid && !$component['email'] && !in_array($component['type'], array('markup', 'fieldset', 'pagebreak'))) {
+    return '';
+  }
+
   // First check for component-level themes.
-  $themed_output = theme("webform_mail_". $node->webform['components'][$cid]['type'], $value, $node->webform['components'][$cid]);
+  $themed_output = theme("webform_mail_". $component['type'], $value, $component);
+
   if ($themed_output) {
     // Indent the output and add to message.
     $message .= $indent;
@@ -1623,15 +1630,15 @@
   // Generic output for single values.
   elseif (!is_array($value)) {
     // Note that newlines cannot be preceeded by spaces to display properly in some clients.
-    if ($node->webform['components'][$cid]['name']) {
+    if ($component['name']) {
       // If text is more than 60 characters, put it on a new line with space after.
-      $long = (strlen($indent . $node->webform['components'][$cid]['name'] . $value)) > 60;
-      $message .= $indent . $node->webform['components'][$cid]['name'] .":". (empty($value) ? "\n" : ($long ? "\n$value\n\n" : " $value\n"));
+      $long = (strlen($indent . $component['name'] . $value)) > 60;
+      $message .= $indent . $component['name'] .":". (empty($value) ? "\n" : ($long ? "\n$value\n\n" : " $value\n"));
     }
   }
   // Else use a generic output for arrays.
   else {
-    $message .= $indent . $node->webform['components'][$cid]['name'] .":\n";
+    $message .= $indent . $component['name'] .":\n";
     foreach ($value as $k => $v) {
       foreach ($node->webform['components'] as $local_key => $local_value) {
         if ($local_value['form_key'] == $k && $local_value['pid'] == $cid) {
@@ -1642,6 +1649,7 @@
       $message .= theme('webform_mail_fields', $form_key, $v, $node, $indent ."  ");
     }
   }
+
   return ($message);
 }
 
Index: webform.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.install,v
retrieving revision 1.14.2.16.2.17
diff -u -r1.14.2.16.2.17 webform.install
--- webform.install	27 Apr 2008 20:23:05 -0000	1.14.2.16.2.17
+++ webform.install	9 May 2008 05:45:51 -0000
@@ -38,6 +38,7 @@
         extra text,
         mandatory tinyint NOT NULL default '0',
         weight smallint NOT NULL default '0',
+        email tinyint NOT NULL default '0',
         PRIMARY KEY  (nid, cid)
         ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */"
       );
@@ -95,6 +96,7 @@
         extra text NOT NULL default '',
         mandatory smallint NOT NULL default '0',
         weight smallint NOT NULL default '0',
+        email smallint NOT NULL default '0',
         PRIMARY KEY (nid, cid)
         )"
       );
@@ -672,6 +674,16 @@
 }
 
 /**
+ * Add a column for email to the webform_component table.
+ */
+function webform_update_5201() {
+  $ret = array();
+  $ret[] = update_sql("ALTER TABLE {webform_component} ADD email int(1) UNSIGNED NOT NULL DEFAULT '0'");
+  $ret[] = update_sql("UPDATE {webform_component} SET email = 1");
+  return $ret;
+}
+
+/**
  * Recursively delete all files and folders in the specified filepath, then
  * delete the containing folder.
  *
Index: webform_components.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform_components.inc,v
retrieving revision 1.1.2.22
diff -u -r1.1.2.22 webform_components.inc
--- webform_components.inc	9 May 2008 03:57:58 -0000	1.1.2.22
+++ webform_components.inc	9 May 2008 05:45:51 -0000
@@ -41,16 +41,21 @@
     );
     $form['components'][$cid]['mandatory'] = array(
       '#type' => 'checkbox',
-      '#delta' => $component['mandatory'],
       '#title' => t("Mandatory"),
       '#default_value' => $component['mandatory'],
       '#access' => !in_array($component['type'], array('markup', 'fieldset', 'pagebreak')),
     );
+    $form['components'][$cid]['email'] = array(
+      '#type' => 'checkbox',
+      '#title' => t("E-mail"),
+      '#default_value' => $component['email'],
+      '#access' => !in_array($component['type'], array('markup', 'fieldset', 'pagebreak')),
+    );
   }
 
   $form['add']['name'] = array(
     '#type' => 'textfield',
-    '#size' => 30,
+    '#size' => 24,
   );
 
   $component_types = webform_load_components();
@@ -64,6 +69,10 @@
   $form['add']['mandatory'] = array(
     '#type' => 'checkbox',
   );
+  $form['add']['email'] = array(
+    '#type' => 'checkbox',
+    '#default_value' => 1,
+  );
   $form['add']['cid'] = array(
     '#type' => 'hidden',
     '#default_value' => '',
@@ -115,7 +124,7 @@
 
   $node = $form['#node'];
 
-  $headers = array(t('Name'), t('Type'), t('Value'), t('Mandatory'), t('Weight'), array('data' => t('Operations'), 'colspan' => 3));
+  $headers = array(t('Name'), t('Type'), t('Value'), t('Mandatory'), t('E-mail'), t('Weight'), array('data' => t('Operations'), 'colspan' => 3));
   $rows = array();
 
   // Add a row containing form elements for a new item.
@@ -130,6 +139,7 @@
     drupal_render($form['add']['type']),
     '',
     drupal_render($form['add']['mandatory']),
+    drupal_render($form['add']['email']),
     drupal_render($form['add']['cid']) . drupal_render($form['add']['pid']) . drupal_render($form['add']['weight']),
     array('colspan' => 3, 'data' => drupal_render($form['add']['add'])),
   );
@@ -154,6 +164,7 @@
       unset($form['components'][$cid]['mandatory']['#title']);
       unset($form['components'][$cid]['pid']['#title']);
       unset($form['components'][$cid]['weight']['#title']);
+      unset($form['components'][$cid]['email']['#title']);
 
       // Add special classes for weight and parent fields.
       $form['components'][$cid]['cid']['#attributes']['class'] = 'webform-cid';
@@ -172,6 +183,7 @@
         $component['type'],
         ($component['value'] == "") ? "-" : $component['value'],
         drupal_render($form['components'][$cid]['mandatory']),
+        drupal_render($form['components'][$cid]['email']),
         drupal_render($form['components'][$cid]['cid']) . drupal_render($form['components'][$cid]['pid']) . drupal_render($form['components'][$cid]['weight']),
         l(t('Edit'), 'node/'. $node->nid .'/edit/components/'. $cid),
         l(t('Clone'), 'node/'. $node->nid .'/edit/components/'. $cid .'/clone'),
@@ -216,9 +228,10 @@
 
   // Update all mandatory and weight values.
   foreach ($node->webform['components'] as $cid => $component) {
-    if ($component['weight'] != $form_values['components'][$cid]['weight'] || $component['mandatory'] != $form_values['components'][$cid]['mandatory']) {
+    if ($component['weight'] != $form_values['components'][$cid]['weight'] || $component['mandatory'] != $form_values['components'][$cid]['mandatory'] ||  $component['email'] != $form_values['components'][$cid]['email']) {
       $component['weight'] = $form_values['components'][$cid]['weight'];
       $component['mandatory'] = $form_values['components'][$cid]['mandatory'];
+      $component['email'] = $form_values['components'][$cid]['email'];
       $component['pid'] = $form_values['components'][$cid]['pid'];
       $component['nid'] = $node->nid;
       webform_component_update($component);
@@ -297,6 +310,13 @@
     '#description' => t('Check this option if the user must enter a value.'),
     '#weight' => 2,
   );
+  $form['email'] = array(
+    '#type' => 'checkbox',
+    '#title' => t("Include in E-mails"),
+    '#default_value' => ($component['email'] == '1' ? TRUE : FALSE),
+    '#description' => t('If checked, submitted values from this component will be included in e-mails.'),
+    '#weight' => 2,
+  );
 
   if (variable_get('webform_enable_fieldset', true) && is_array($node->webform['components'])) {
     $options = array('0' => t('Root'));
@@ -454,8 +474,8 @@
  */
 function webform_component_insert($component) {
   db_lock_table('webform_component');
-  $component['cid'] = db_result(db_query('SELECT MAX(cid) FROM {webform_component} WHERE nid = %d', $component['nid'])) + 1;
-  db_query("INSERT INTO {webform_component} (nid, cid, pid, form_key, name, type, value, extra, mandatory, weight) VALUES (%d, %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d)", $component['nid'], $component['cid'], $component['pid'], $component['form_key'], $component['name'], $component['type'], $component['value'], serialize($component['extra']), $component['mandatory'], $component['weight']);
+  $component['cid'] = isset($component['cid']) ? $component['cid'] : db_result(db_query('SELECT MAX(cid) FROM {webform_component} WHERE nid = %d', $component['nid'])) + 1;
+  db_query("INSERT INTO {webform_component} (nid, cid, pid, form_key, name, type, value, extra, mandatory, weight, email) VALUES (%d, %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d)", $component['nid'], $component['cid'], $component['pid'], $component['form_key'], $component['name'], $component['type'], $component['value'], serialize($component['extra']), $component['mandatory'], $component['weight'], $component['email']);
   db_unlock_tables('webform_component');
   return $component['cid'];
 }
@@ -468,7 +488,7 @@
  *   component form. Additional properties are stored in the extra array.
  */
 function webform_component_update($component) {
-  return db_query("UPDATE {webform_component} SET pid = %d, form_key = '%s', name = '%s', type = '%s', value = '%s', extra = '%s', mandatory = %d, weight = %d WHERE nid = %d AND cid = %d", $component['pid'], $component['form_key'], $component['name'], $component['type'], $component['value'], serialize($component['extra']), $component['mandatory'], $component['weight'], $component['nid'], $component['cid']);
+  return db_query("UPDATE {webform_component} SET pid = %d, form_key = '%s', name = '%s', type = '%s', value = '%s', extra = '%s', mandatory = %d, weight = %d, email = %d WHERE nid = %d AND cid = %d", $component['pid'], $component['form_key'], $component['name'], $component['type'], $component['value'], serialize($component['extra']), $component['mandatory'], $component['weight'], $component['email'], $component['nid'], $component['cid']);
 }
 
 function webform_component_delete($nid, $cid) {
