I think this code inside of cck_private_fields_nodeapi() is broken. If you enable private fields, set a field to "Hidden by default", and then later go and change the field to "Private by default" the information never gets updated in the {cck_private_fields} table.

The problem is hook_nodeapi('load') loads information from {cck_private_fields} in to the node object, then hook_nodeapi('update') deletes the information from the table and cascades in to 'insert' which then just saves the same information that was just deleted back to the table.

case 'update':
  if (!empty($node->cck_private_fields) && is_array($node->cck_private_fields)) {
    db_query("DELETE FROM {cck_private_fields} WHERE vid = %d", $node->vid);
  }
  // Fallback to 'insert' case is intentional.

case 'insert':
  if (!empty($node->cck_private_fields) && is_array($node->cck_private_fields)) {
    module_load_include('inc', 'cck_private_fields', 'includes/common');

    $private_fields = cck_private_fields_get_content_private_fields($node->type);
    foreach ($private_fields as $field_name => $privacy_status) {
      if ($private_fields[$field_name] !== FALSE) {
        db_query("INSERT INTO {cck_private_fields} (nid, vid, content_type, field_name, privacy_status) VALUES (%d, %d, '%s', '%s', %d)", array(
          $node->nid, $node->vid, $node->type, $field_name, $privacy_status
        ));
      }
    }
  }
  break;

Path to follow shortly.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

eojthebrave’s picture

This fixes the problem for me.

memoo’s picture

The patch did not work for me. I can change the privacy options, but they are no stored when saved; it jumps back to the initial option.

Is there another way to get this working?