public function LearningPathContentController::getModuleRequiredActivitiesAccess in Opigno Learning path 8
Same name and namespace in other branches
- 3.x src/Controller/LearningPathContentController.php \Drupal\opigno_learning_path\Controller\LearningPathContentController::getModuleRequiredActivitiesAccess()
Returns Right access conditional activities with the module.
1 string reference to 'LearningPathContentController::getModuleRequiredActivitiesAccess'
File
- src/
Controller/ LearningPathContentController.php, line 363
Class
- LearningPathContentController
- Controller for all the actions of the Learning Path content.
Namespace
Drupal\opigno_learning_path\ControllerCode
public function getModuleRequiredActivitiesAccess($opigno_entity_type, $opigno_entity_id) {
// Check global roles.
$roles = $this->currentUser
->getRoles();
foreach ($roles as $role) {
if (in_array($role, [
'administrator',
'content_manager',
])) {
return AccessResult::allowed();
}
}
// Check group roles.
$group_id = OpignoGroupContext::getCurrentGroupId();
if (LearningPathAccess::memberHasRole('admin', $this->currentUser, $group_id) || LearningPathAccess::memberHasRole('content_manager', $this->currentUser, $group_id)) {
return AccessResult::allowed();
}
return AccessResult::allowedIfHasPermission($this->currentUser, 'bypass group access');
}