--- webform.components.inc.orig	2011-05-18 23:07:35.000000000 +0200
+++ webform.components.inc	2011-06-09 07:35:25.879379000 +0200
@@ -71,6 +71,10 @@ function webform_components_form($form_s
       '#default_value' => $component['mandatory'],
       '#access' => webform_component_feature($component['type'], 'required'),
     );
+    $form['components'][$cid]['extra']['private'] = array(
+      '#type' => 'hidden',
+      '#default_value' => $component['extra']['private'],
+    );
     if (!isset($max_weight) || $component['weight'] > $max_weight) {
       $max_weight = $component['weight'];
     }
@@ -90,6 +94,7 @@ function webform_components_form($form_s
   $form['add']['mandatory'] = array(
     '#type' => 'checkbox',
   );
+
   $form['add']['cid'] = array(
     '#type' => 'hidden',
     '#default_value' => '',
@@ -302,6 +307,7 @@ function webform_components_form_submit(
     if ($component['pid'] != $form_state['values']['components'][$cid]['pid'] || $component['weight'] != $form_state['values']['components'][$cid]['weight'] || $component['mandatory'] != $form_state['values']['components'][$cid]['mandatory']) {
       $component['weight'] = $form_state['values']['components'][$cid]['weight'];
       $component['mandatory'] = $form_state['values']['components'][$cid]['mandatory'];
+      $component['extra']['private'] = $form_state['values']['components'][$cid]['extra']['private'];
       $component['pid'] = $form_state['values']['components'][$cid]['pid'];
       $component['nid'] = $node->nid;
       webform_component_update($component);
@@ -316,7 +322,7 @@ function webform_components_form_submit(
   }
   elseif (isset($_POST['op']) && $_POST['op'] == t('Add')) {
     $component = $form_state['values']['add'];
-    $form_state['redirect'] = array('node/' . $node->nid . '/webform/components/new/' . $component['type'], 'name=' . urlencode($component['name']) . '&mandatory=' . $component['mandatory'] . '&pid=' . $component['pid'] . '&weight=' . $component['weight']);
+    $form_state['redirect'] = array('node/' . $node->nid . '/webform/components/new/' . $component['type'], 'name=' . urlencode($component['name']) . '&mandatory=' . $component['mandatory'] . '&private=' . $component['extra']['private']  . '&pid=' . $component['pid'] . '&weight=' . $component['weight']);
   }
   else {
     drupal_set_message(t('The component positions and mandatory values have been updated.'));
@@ -413,6 +419,18 @@ function webform_component_edit_form(&$f
         '#description' => t('Do not display the label of this component.'),
       );
     }
+
+    // may user mark fields as Private?
+    $form['display']['private'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Private'),
+      '#default_value' => ($component['extra']['private'] == '1' ? TRUE : FALSE),
+      '#description' => t('Private fields are shown only to users with results access.'),
+      '#weight' => 45,
+      '#parents' => array('extra', 'private'),
+      '#disabled' => !webform_results_access($node)
+    );
+
     $form['display']['title_display']['#weight'] = 8;
     $form['display']['title_display']['#parents'] = array('extra', 'title_display');
   }
@@ -705,6 +723,7 @@ function webform_component_insert(&$comp
     $component['cid'] = isset($component['cid']) ? $component['cid'] : db_result(db_query('SELECT MAX(cid) FROM {webform_component} WHERE nid = %d', $component['nid'])) + 1;
     $component['value'] = isset($component['value']) ? $component['value'] : NULL;
     $component['mandatory'] = isset($component['mandatory']) ? $component['mandatory'] : 0;
+    $component['extra']['private'] = isset($component['extra']['private']) ? $component['extra']['private'] : 0;
     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']);
     lock_release('webform_component_insert_' . $component['nid']);
   }
@@ -735,6 +754,7 @@ function webform_component_update($compo
 
   $component['value'] = isset($component['value']) ? $component['value'] : NULL;
   $component['mandatory'] = isset($component['mandatory']) ? $component['mandatory'] : 0;
+  $component['extra']['private'] = isset($component['extra']['private']) ? $component['extra']['private'] : 0;
   $success = 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']);
 
   // Post-update actions.
@@ -815,6 +835,7 @@ function webform_component_feature($type
     'spam_analysis' => FALSE,
     'group' => FALSE,
     'attachment' => FALSE,
+    'private' => TRUE,
   );
   return isset($components[$type]['features'][$feature]) ? $components[$type]['features'][$feature] : !empty($defaults[$feature]);
 }
@@ -985,3 +1006,4 @@ function webform_validate_unique($elemen
     }
   }
 }
+
