You are here

function opigno_learning_path_opigno_module_access in Opigno Learning path 8

Same name and namespace in other branches
  1. 3.x opigno_learning_path.module \opigno_learning_path_opigno_module_access()

Restricts user access to Learning Path content.

Implements hook_ENTITY_TYPE_access().

File

./opigno_learning_path.module, line 1961
Contains opigno_learning_path.module.

Code

function opigno_learning_path_opigno_module_access(EntityInterface $entity, $operation, AccountInterface $account) {
  if ($account
    ->hasPermission('manage group content in any group')) {

    // Allow platform-level content managers
    // to view/edit/delete learning path modules.
    return AccessResult::allowed();
  }
  if (!LearningPathAccess::getGroupContentAccess($entity, $account)) {
    return AccessResult::forbidden();
  }
  return AccessResult::neutral();
}