You are here

function og_features_pipe_alter in Organic groups 7.2

Implements hook_features_pipe_alter().

Prevent OG related fields from being piped in features, when a content type that has them is selected.

This if compatible with Features 1.x and 2.x

File

./og.module, line 3685
Enable users to create and manage groups with roles and permissions.

Code

function og_features_pipe_alter(&$pipe, $data, $export) {
  if (!variable_get('og_features_ignore_og_fields', FALSE)) {
    return;
  }
  if (empty($pipe['field']) && empty($pipe['field_base']) && empty($pipe['field_instance'])) {

    // The exported item is not a field.
    return;
  }
  if (!empty($pipe['field_instance'])) {
    $key = 'field_instance';
    $explode = TRUE;
  }
  elseif (!empty($pipe['field_base'])) {
    $key = 'field_base';
    $explode = FALSE;
  }
  else {
    $key = 'field';
    $explode = TRUE;
  }
  foreach ($pipe[$key] as $delta => $value) {
    if ($explode) {

      // Get the field name from the [entity-type]-[bundle]-[field-name].
      $args = explode('-', $value);
      $field_name = $args[2];
    }
    else {
      $field_name = $value;
    }
    if (og_fields_info($field_name) || og_is_group_audience_field($field_name)) {
      unset($pipe[$key][$delta]);
    }
  }
}