You are here

function _field_permissions_field_view_access in Field Permissions 7

Same name and namespace in other branches
  1. 6 includes/field_access.inc \_field_permissions_field_view_access()

Implementation of hook_field_access('view').

1 call to _field_permissions_field_view_access()
field_permissions_field_access in ./field_permissions.module
Implementation of hook_field_access().

File

./field_permissions.module, line 213
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_field_view_access($field_name, $entity_type, $entity, $account) {

  // Check if user has access to view this field in any entity.
  if (user_access('view ' . $field_name, $account)) {
    return TRUE;
  }

  // If the user has permission to view entities that they own, return TRUE if
  // they own this entity or FALSE if they don't.
  if (user_access('view own ' . $field_name, $account)) {
    return _field_permissions_entity_is_owned_by_account($entity, $account);
  }
  return FALSE;
}