function eck__entity_access in Entity Construction Kit (ECK) 7.2
Default access callback for ECK entities.
This is used as the default behavior when entity_access() is called to check access on an entity provided by ECK. Note that in addition to calls from within this own module, entity_access() is also called by other modules such as Rules, Entity Reference, etc. (although it is not consistently called throughout Drupal).
Parameters
string $op: The operation being performed. One of 'view', 'update', 'create' or 'delete'.
mixed $entity_or_bundle: Normally, an entity to check access for. If this is NULL, we are checking access for all entities of the given type. If this is a string (representing the bundle to check access for; see parallel example in node_access()) we are checking access for all entities of the given type and bundle.
object $account: The user to check access for. If this is NULL, access will be checked for the current user.
string $entity_type_name: A string representing the type of entity to check access for.
Return value
bool TRUE if access is granted, FALSE otherwise.
See also
1 string reference to 'eck__entity_access'
- eck__entity_type__info in ./
eck.entity_type.inc - Generate the entity info for a specific entity.
File
- ./
eck.module, line 831
Code
function eck__entity_access($op, $entity_or_bundle, $account, $entity_type_name) {
// @todo This module uses different CRUD terminology than is normally used in
// Drupal, so we need to convert what entity_access() sent us back to
// something this module will understand.
$crud_map = array(
'create' => 'add',
'update' => 'edit',
);
if (isset($crud_map[$op])) {
$op = $crud_map[$op];
}
// Check the relevant permissions. If an entity or bundle is provided, use
// that to get the bundle-specific permissions and check those too.
$permissions = array(
'eck administer entities',
"eck {$op} entities",
);
if (isset($entity_or_bundle)) {
if (is_object($entity_or_bundle)) {
list(, , $bundle_name) = entity_extract_ids($entity_type_name, $entity_or_bundle);
}
else {
$bundle_name = $entity_or_bundle;
}
$permissions[] = "eck administer {$entity_type_name} {$bundle_name} entities";
$permissions[] = "eck {$op} {$entity_type_name} {$bundle_name} entities";
}
// @todo should auto-load entity author here.
return eck__multiple_access_check($permissions, FALSE, $account);
}