function rolereference_field_prepare_view in Role Reference 7
Implements hook_field_prepare_view().
File
- ./
rolereference.module, line 108
Code
function rolereference_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) {
$referenceable_roles = rolereference_potential_references($field['settings']['referenceable_roles'], $field['field_name']);
// Extract nids to check.
$ids = array();
foreach ($items as $id => $entity_items) {
foreach ($entity_items as $delta => $item) {
if (is_array($item)) {
// Default to 'not accessible'.
$items[$id][$delta]['access'] = FALSE;
if (!empty($item['rid']) && is_numeric($item['rid'])) {
$ids[$item['rid']] = $item['rid'];
}
}
}
}
if ($ids) {
foreach ($items as $id => $entity_items) {
foreach ($entity_items as $delta => $item) {
if (is_array($item) && !empty($item['rid']) && isset($referenceable_roles[$item['rid']])) {
$items[$id][$delta]['role'] = $referenceable_roles[$item['rid']];
$items[$id][$delta]['access'] = TRUE;
}
}
}
}
}