You are here

function field_permissions_features_pipe_field_base_alter in Field Permissions 7

Implements hook_features_pipe_COMPONENT_alter().

Add field permissions to features when exporting a field_base.

File

./field_permissions.module, line 287
This is the main script for the Field Permissions module. It merely contains the implementation of hooks invoked by Drupal core and CCK. All common functions are externalized into several scripts that are included on demand to save memory consumption…

Code

function field_permissions_features_pipe_field_base_alter(&$pipe, $data, $export) {

  // Validate if there are field_base components that will be exported for this
  // feature.
  if (isset($export['features']['field_base'])) {
    module_load_include('inc', 'field_permissions', 'field_permissions.admin');

    // Iterate through the exported field_base components for this feature and
    // add the defined field permissions.
    foreach ($export['features']['field_base'] as $field_name) {
      $field = field_info_field($field_name);
      if (isset($field['field_permissions']['type']) && $field['field_permissions']['type'] == FIELD_PERMISSIONS_CUSTOM) {
        $perms = field_permissions_list_field_permissions($field, '');
        foreach ($perms as $perm => $info) {
          $pipe['user_permission'][] = $perm;
        }
      }
    }
  }
}