You are here

function blockreference_autocomplete_access in Block reference 7.2

Same name and namespace in other branches
  1. 7 blockreference.module \blockreference_autocomplete_access()

Menu access callback for the autocomplete path.

1 string reference to 'blockreference_autocomplete_access'
blockreference_menu in ./blockreference.module
Implements hook_menu().

File

./blockreference.module, line 26

Code

function blockreference_autocomplete_access($entity_type, $bundle, $field_name, $eid) {
  if ($eid == 0) {
    $entity_info = entity_get_info($entity_type);
    $entity_dummy = entity_create($entity_type, array(
      $entity_info['entity keys']['bundle'] => $bundle,
    ));
    $entity_access = entity_access('create', $entity_type, $entity_dummy);
  }
  else {
    $entity = entity_load($entity_type, array(
      $eid,
    ));
    $entity = reset($entity) ?: FALSE;
    $entity_access = entity_access('update', $entity_type, $entity);
  }
  return user_access('access content') && $entity_access;
}