You are here

function _ctools_entity_access in Chaos Tool Suite (ctools) 7

Core hack to include entity api-esque 'access callback' functions to core entities without needing to rely on entity api. Exception: We don't touch file entity. You must have entity API enabled to view files.

1 call to _ctools_entity_access()
ctools_content_autocomplete_entity in includes/content.menu.inc
Helper function for autocompletion of entity titles.

File

includes/entity-access.inc, line 16
Provides various callbacks for the whole core module integration. This is a copy of Entity API's functionality for use when Entity API isn't Enabled, and only works on view functions.

Code

function _ctools_entity_access(&$entity_info, $entity_type) {

  // If the access callback is already set, don't change anything.
  if (isset($entity_info['access callback'])) {
    return;
  }
  switch ($entity_type) {
    case 'node':

      // Sad panda, we don't use Entity API, lets manually add access callbacks.
      $entity_info['access callback'] = 'ctools_metadata_no_hook_node_access';
      break;
    case 'user':
      $entity_info['access callback'] = 'ctools_metadata_user_access';
      break;
    case 'comment':
      if (module_exists('comment')) {
        $entity_info['access callback'] = 'ctools_metadata_comment_access';
      }
      break;
    case 'taxonomy_term':
      if (module_exists('taxonomy')) {
        $entity_info['access callback'] = 'ctools_metadata_taxonomy_access';
      }
      break;
    case 'taxonomy_vocabulary':
      if (module_exists('taxonomy')) {
        $entity_info['access callback'] = 'ctools_metadata_taxonomy_access';
      }
      break;
  }
}