You are here

function filefield_uuid_node_features_export_alter in UUID Features Integration 7

Same name and namespace in other branches
  1. 6 includes/modules/filefield.inc \filefield_uuid_node_features_export_alter()

Implements hook_uuid_node_features_export_alter().

File

includes/modules/filefield.inc, line 10
uuid_node hooks on behalf of the filefield module.

Code

function filefield_uuid_node_features_export_alter(&$export, $node) {

  // Access / modify the pipe.
  $pipe =& $export['__drupal_alter_by_ref']['pipe'];
  $types = content_types();
  if (!empty($types[$node->type])) {

    // Find CCK filefields.
    foreach ($types[$node->type]['fields'] as $field) {
      if ($field['module'] == 'filefield') {
        $field_name = $field['field_name'];

        // If the content type has changed since the last export, this field
        // may not exist.
        if (isset($node->{$field_name})) {

          // Loop through all values of the field.
          foreach ($node->{$field_name} as $delta => $data) {
            if (!empty($data['fid'])) {
              $uuid = uuid_get_uuid('files', 'fid', $data['fid']);

              // If the referenced file doesn't have a uuid, take this
              // opportunity to create one.
              if (empty($uuid)) {
                $uuid = uuid_set_uuid('files', 'fid', $data['fid']);
              }
              $pipe['uuid_file'][$uuid] = $uuid;
            }
          }
        }
      }
    }
  }
}