You are here

function _sheetnode_entity_load in Sheetnode 7.2

Same name and namespace in other branches
  1. 7 sheetnode.module \_sheetnode_entity_load()

Helper function to load a Drupal entity.

Also checks for access right.

2 calls to _sheetnode_entity_load()
_sheetnode_ajax_field in ./sheetnode.module
AJAX function to return a field value.
_sheetnode_ajax_token in ./sheetnode.module
AJAX function to return a token value.

File

./sheetnode.module, line 1213
Module file for the sheetnode module.

Code

function _sheetnode_entity_load($entity_type, $oid, $op = 'view', $account = NULL) {
  $entities = entity_load($entity_type, array(
    $oid,
  ));
  if (isset($entities[$oid])) {
    $entity = $entities[$oid];

    // Taken from entity.module/entity_access() - not included to reduce dependencies.
    // @see http://drupalcontrib.org/api/drupal/contributions!entity!entity.module/function/entity_access/7
    if (($info = entity_get_info()) && isset($info[$entity_type]['access callback'])) {
      return $info[$entity_type]['access callback']($op, $entity, $account, $entity_type) ? $entity : FALSE;
    }
    return $entity;
  }
  return FALSE;
}