You are here

function nodereference_uuid_node_features_export_alter in UUID Features Integration 6

Same name and namespace in other branches
  1. 7 includes/modules/nodereference.inc \nodereference_uuid_node_features_export_alter()

Implementation of hook_uuid_node_features_export_render().

File

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

Code

function nodereference_uuid_node_features_export_alter(&$export, &$pipe, $node) {
  $types = content_types();
  if (!empty($types[$node->type])) {

    // Find CCK nodereference fields.
    foreach ($types[$node->type]['fields'] as $field) {
      if ($field['module'] == 'nodereference') {
        $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['nid'])) {
              $uuid = uuid_get_uuid('node', 'nid', $data['nid']);

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