function opigno_module_entity_access in Opigno module 8
Same name and namespace in other branches
- 3.x opigno_module.module \opigno_module_entity_access()
Implements hook_entity_access().
File
- ./
opigno_module.module, line 1143 - Contains opigno_module.module.
Code
function opigno_module_entity_access(EntityInterface $entity, $operation, AccountInterface $account) {
if ($entity
->getEntityTypeId() == 'file' && $operation == 'download') {
$user_is_manager = LearningPathAccess::memberHasRole('user_manager', $account);
if ($user_is_manager || $account
->id() == $entity
->get('uid')
->getString()) {
return AccessResult::allowed();
}
}
if ($entity
->getEntityTypeId() == 'user_module_status') {
if ($entity
->getOwnerId() == $account
->id()) {
return AccessResultAllowed::allowedIf((int) $account
->id() === 0)
->mergeCacheMaxAge(0);
}
}
}