function opigno_learning_path_install in Opigno Learning path 3.x
Same name and namespace in other branches
- 8 opigno_learning_path.install \opigno_learning_path_install()
Implements hook_install().
File
- ./
opigno_learning_path.install, line 23 - Install, update and uninstall functions for the module.
Code
function opigno_learning_path_install() {
// Create database tables for Learning Path.
LearningPathAccess::createUserStatusTable();
_opigno_learning_path_create_achievements_table();
_opigno_learning_path_create_step_achievements_table();
_opigno_learning_path_create_lp_module_availability_table();
_opigno_learning_path_create_user_lp_status_table();
_opigno_learning_path_create_user_lp_status_expire_table();
// Grant additional users permissions.
$roles = [
'content_manager' => [
'access contextual links',
'bypass group access',
],
'user_manager' => [
'access contextual links',
],
RoleInterface::AUTHENTICATED_ID => [
'dropzone upload files',
],
];
foreach ($roles as $role => $permissions) {
$role = Role::load($role);
if (!$role instanceof RoleInterface) {
continue;
}
foreach ($permissions as $permission) {
$role
->grantPermission($permission);
}
try {
$role
->save();
} catch (EntityStorageException $e) {
watchdog_exception('opigno_learning_path_exception', $e);
}
}
}