function tripal_entity_access
3.x tripal.entity.inc | tripal_entity_access($op, $entity = NULL, $account = NULL, $entity_type = NULL) |
Checks access permissions for a given entity.
This function is set for TripalEntity access checking in the tripal_entity_info() under the 'access callback' element.
Parameters
$op: The operation. One of: create, view, edit, delete.
$entity: The entity to check access for.
$account: The user account.
$entity_type: The type of entity (will always be TripalEntity).
1 call to tripal_entity_access()
- TripalContentService_v0_1::checkAccess in tripal_ws/
includes/ TripalWebService/ TripalContentService_v0_1.inc - Ensures that user's only have access to content they should see.
2 string references to 'tripal_entity_access'
- TripalEntityUIController::hook_menu in tripal/
includes/ TripalEntityUIController.inc - Overrides hook_menu() defaults. Main reason for doing this is that parent class hook_menu() is optimized for entity type administration.
- tripal_entity_info in tripal/
includes/ tripal.entity.inc - Implement hook_entity_info().
File
- tripal/
includes/ tripal.entity.inc, line 433
Code
function tripal_entity_access($op, $entity = NULL, $account = NULL, $entity_type = NULL) {
global $user;
if ($entity) {
$bundle_name = $entity->bundle;
}
else {
return FALSE;
}
if (!isset($account)) {
$account = $user;
}
if (!$entity_type) {
$entity_type = $entity->type;
}
// See if other modules want to adust permissions.
$results = module_invoke_all($entity_type . '_access', $entity, $op, $account);
if (in_array(TRUE, $results)) {
return TRUE;
}
switch ($op) {
case 'create':
return user_access('create ' . $bundle_name, $account);
case 'view':
return user_access('view ' . $bundle_name, $account);
case 'edit':
return user_access('edit ' . $bundle_name, $account);
case 'delete':
return user_access('delete ' . $bundle_name, $account);
}
return FALSE;
}