You are here

function ctools_entity_bundle_ctools_access_check in Chaos Tool Suite (ctools) 7

Check for access.

1 string reference to 'ctools_entity_bundle_ctools_access_check'
entity_bundle.inc in plugins/access/entity_bundle.inc
Plugin to provide access control based upon entity bundle.

File

plugins/access/entity_bundle.inc, line 77
Plugin to provide access control based upon entity bundle.

Code

function ctools_entity_bundle_ctools_access_check($conf, $context, $plugin) {
  list($plugin_name, $entity_type) = explode(':', $plugin['name']);
  if (!$entity_type) {
    return FALSE;
  }
  $entity = entity_get_info($entity_type);

  // As far as I know there should always be a context at this point, but this
  // is safe.
  if (empty($context) || empty($context->data) || empty($context->data->{$entity['entity keys']['bundle']})) {
    return FALSE;
  }
  if (array_filter($conf['type']) && empty($conf['type'][$context->data->{$entity['entity keys']['bundle']}])) {
    return FALSE;
  }
  return TRUE;
}