You are here

function workbench_access_get_assigned_fields in Workbench Access 7

Finds fields associated with a content type.

Parameters

$type: The content type machine name.

$all: Boolean flag to return all possible fields for this content type. If set to FALSE, then only configured access fields are returned.

Return value

An array of field data that matches the current access scheme.

See also

workbench_access_get_available_fields().

6 calls to workbench_access_get_assigned_fields()
workbench_access_check_access_fields in ./workbench_access.module
Tests content types for proper field configuration.
workbench_access_find_form_elements in ./workbench_access.module
Find form elements that control access.
workbench_access_get_available_fields in ./workbench_access.module
Finds fields that may be associated with a content type.
workbench_access_is_active_autocomplete in ./workbench_access.module
Determines is the current path is an autocomplete request.
workbench_access_prepare_field_save in ./workbench_access.module
Prepares a node for saving in the event we did not come from a form.

... See full list

File

./workbench_access.module, line 2077
Workbench Access module file.

Code

function workbench_access_get_assigned_fields($type, $all = FALSE) {
  $matches = array();
  $fields = field_info_instances('node', $type);
  $scheme = variable_get('workbench_access');
  $settings = variable_get('workbench_access_' . $scheme, array());
  foreach ($fields as $field => $info) {
    $data = field_info_field($field);
    if ($data['module'] == $scheme) {
      foreach ($data['settings']['allowed_values'] as $key => $value) {

        // Currently, only works for taxonomy.
        $instance = field_info_instance('node', $field, $type);
        if (!empty($settings[$value['vocabulary']]) && ($all || !empty($instance['workbench_access_field']))) {
          $data['instance_info'] = $info;
          $matches[$field] = $data;
        }
      }
    }
  }
  return $matches;
}