You are here

function entity_print_access in Entity Print 7

Validate that the current user has access.

We need to validate that the user is allowed to access this entity also the print version.

Parameters

string $entity_type: The entity type.

int $entity_id: The entity id.

Return value

bool TRUE if they have access otherwise FALSE.

1 string reference to 'entity_print_access'
entity_print_menu in ./entity_print.module
Implements hook_entity_print().

File

./entity_print.module, line 56
Print any entity.

Code

function entity_print_access($entity_type, $entity_id) {

  // Check for overall entity access permission.
  if (user_access('bypass entity print access')) {
    return entity_print_view_access($entity_type, $entity_id);
  }

  // Check for entity type access permission.
  if (user_access('entity print access type ' . $entity_type)) {
    return entity_print_view_access($entity_type, $entity_id);
  }

  // Check for entity bundle access permission.
  $entity = entity_load_single($entity_type, $entity_id);
  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
  if (user_access('entity print access bundle ' . $bundle)) {
    return entity_print_view_access($entity_type, $entity_id);
  }
  return FALSE;
}