Commit 7a94a97c authored by Eric Bremner's avatar Eric Bremner
Browse files

ISTWCMS-5204: updating update hook to include permissions for project

parent 47077b15
......@@ -558,4 +558,47 @@ function uw_sites_all_update_9107(&$sandbox) {
'uw_ct_project',
];
\Drupal::service('module_installer')->install($modules);
// List of permissions needed to be applied to roles.
$permissions = [
'create uw_ct_project content',
'create terms in uw_vocab_project_roles',
'create terms in uw_vocab_project_topics',
'edit own uw_ct_project content',
'edit any uw_ct_project content',
'edit terms in uw_vocab_project_roles',
'edit terms in uw_vocab_project_topics',
];
$only_site_manager_permissions = [
'delete uw_ct_project content',
'delete own uw_ct_project content',
'delete terms in uw_vocab_project_roles',
'delete terms in uw_vocab_project_topics',
];
// Roles that require updated permissions.
$role_ids = [
'uw_role_site_manager',
'uw_role_content_editor',
'uw_role_content_author',
];
$roles = Role::loadMultiple($role_ids);
// Grant all all roles.
foreach ($permissions as $permission) {
$roles['uw_role_site_manager']->grantPermission($permission);
$roles['uw_role_content_editor']->grantPermission($permission);
$roles['uw_role_content_author']->grantPermission($permission);
}
foreach ($only_site_manager_permissions as $only_site_manager_permission) {
$roles['uw_role_site_manager']->grantPermission($only_site_manager_permission);
}
// Save role with new permissions.
$roles['uw_role_site_manager']->save();
$roles['uw_role_content_editor']->save();
$roles['uw_role_content_author']->save();
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment