Index: fields.action.inc
===================================================================
--- fields.action.inc	(revision 2056)
+++ fields.action.inc	(revision 2389)
@@ -36,70 +36,88 @@
   }
   $form['fields'] = array('#type' => 'value', '#value' => array());
   foreach ($fields as $field) {
-    $field['required'] = FALSE;
-    $node[$field['field_name']] = NULL;
-
-    // The field info and widget.
-    if (isset($field['field_def'])) { // is it our hacked definition?
-      $form += (array)$field['field_def'];
-    }
-    else { // no, it's CCK
-      $form += (array)content_field_form($form, $form_state, $field);
-    }
-    if (!isset($form[$field['field_name']])) { // some field was not rendered
-      continue;
-    }
-    $form['#field_info'][$field['field_name']] = $field;
-    $form['fields']['#value'][] = $field['field_name'];
-    $form[$field['field_name']] += array('#weight' => $weight++, '#prefix' => '<div class="fields-action-togglable">', '#suffix' => '</div>');
-
-    // Checkbox to enable/disable this field.
-    $form[$field['field_name'] . '_check'] = array('#type' => 'checkbox', '#attributes' => array('class' => 'fields-action-toggler'));
-
-    // PHP code to program the value.
-    if (isset($field['field_def'])) {
-      $sample = 'return value;';
-    }
-    else {
-      $db_info = content_database_info($field);
-      $columns = array_keys($db_info['columns']);
-      foreach ($columns as $key => $column) {
-        $columns[$key] = t("'@column' => value for @column", array('@column' => $column));
+    if (!module_exists('content_permissions') || user_access('edit '.$field['field_name'])) {
+    
+      $field['required'] = FALSE;
+      $node[$field['field_name']] = NULL;
+  
+      // The field info and widget.
+      if (isset($field['field_def'])) { // is it our hacked definition?
+        $form += (array)$field['field_def'];
       }
-      $sample = t("return array(\n  0 => array(@columns),\n  // You'll usually want to stop here. Provide more values\n  // if you want your 'default value' to be multi-valued:\n  1 => array(@columns),\n  2 => ...\n);", array('@columns' => implode(', ', $columns)));
+      else { // no, it's CCK
+        $form += (array)content_field_form($form, $form_state, $field);
+      }
+      if (!isset($form[$field['field_name']])) { // some field was not rendered
+        continue;
+      }
+      $form['#field_info'][$field['field_name']] = $field;
+      $form['fields']['#value'][] = $field['field_name'];
+      $form[$field['field_name']] += array('#weight' => $weight++, '#prefix' => '<div class="fields-action-togglable">', '#suffix' => '</div>');
+  
+      // Checkbox to enable/disable this field.
+      $form[$field['field_name'] . '_check'] = array('#type' => 'checkbox', '#attributes' => array('class' => 'fields-action-toggler'));
+  
+      // PHP code to program the value.
+      if (isset($field['field_def'])) {
+        $sample = 'return value;';
+      }
+      else {
+        $db_info = content_database_info($field);
+        $columns = array_keys($db_info['columns']);
+        foreach ($columns as $key => $column) {
+          $columns[$key] = t("'@column' => value for @column", array('@column' => $column));
+        }
+        $sample = t("return array(\n  0 => array(@columns),\n  // You'll usually want to stop here. Provide more values\n  // if you want your 'default value' to be multi-valued:\n  1 => array(@columns),\n  2 => ...\n);", array('@columns' => implode(', ', $columns)));
+      }
+      if (user_access('Use PHP input for field settings (dangerous - grant with care)')) {
+        $form[$field['field_name'] . '_code'] = array(
+          '#type' => 'textarea',
+          '#default_value' => '',
+          '#rows' => 6,
+          '#description' => t('Expected format: <pre>!sample</pre>', array(
+            '!sample' => $sample,
+          )),
+          '#prefix' => '<div class="fields-action-togglable">',
+          '#suffix' => '</div>',
+        );
+      }
     }
-    $form[$field['field_name'] . '_code'] = array(
-      '#type' => 'textarea',
-      '#default_value' => '',
-      '#rows' => 6,
-      '#description' => t('Expected format: <pre>!sample</pre>', array(
-        '!sample' => $sample,
-      )),
-      '#prefix' => '<div class="fields-action-togglable">',
-      '#suffix' => '</div>',
-    );
   }
   $form['#node'] = (object)$node;
   return $form;
 }
 
 function theme_views_bulk_operations_fields_action_form(&$form) {
+  
   drupal_add_js(drupal_get_path('module', 'views_bulk_operations').'/fields.action.js');
-  $header = array(theme('table_select_header_cell'), t('Field'), t('Code'));
+  $header = array(theme('table_select_header_cell'), t('Field'));
+  if (user_access('Use PHP input for field settings (dangerous - grant with care)')) {
+    $header[] = t('Code');
+  }
   $rows = array();
   foreach ($form['fields']['#value'] as $field_name) {
-    $rows[] = array(
-      drupal_render($form[$field_name . '_check']),
-      drupal_render($form[$field_name]),
-      drupal_render($form[$field_name . '_code']),
-    );
+    // don't display the edit row if the user doesn't have permission to edit the field
+    if (!module_exists('content_permissions') || user_access('edit '.$field_name)) {
+      $row = array(
+        drupal_render($form[$field_name . '_check']),
+        drupal_render($form[$field_name]),
+      );
+      // don't show the code if the user does not have execute PHP permission in cck
+      if (user_access('Use PHP input for field settings (dangerous - grant with care)')) {
+        $row[] = drupal_render($form[$field_name . '_code']);
+      }
+      $rows[] = $row;
+    }
   }
-  $output  = t('<h4>Using the Code column</h4>
-                <ul>
-                <li>Will override the value specified in the field widget.</li>
-                <li>Should not include &lt;?php ?&gt; delimiters.</li>
-                <li>If in doubt, refer to <a target="_blank" href="@link_devel">devel.module</a> \'Dev load\' tab on a content page to figure out the expected format.</li>
-                </ul>', array('@link_devel' => 'http://www.drupal.org/project/devel'));
+  if (user_access('Use PHP input for field settings (dangerous - grant with care)')) {
+    $output  = t('<h4>Using the Code column</h4>
+                  <ul>
+                  <li>Will override the value specified in the field widget.</li>
+                  <li>Should not include &lt;?php ?&gt; delimiters.</li>
+                  <li>If in doubt, refer to <a target="_blank" href="@link_devel">devel.module</a> \'Dev load\' tab on a content page to figure out the expected format.</li>
+                  </ul>', array('@link_devel' => 'http://www.drupal.org/project/devel'));
+  }
   $output .= theme('table', $header, $rows); 
   return $output;
 }
