Commit cdc575fe authored by Lily Yan's avatar Lily Yan
Browse files

Merge branch 'feature/ISTWCMS-4916-ibiki-node-overrides' into '1.0.x'

ISTWCMS-4916 Adding module dependency and update hook with logic to grant...

See merge request !48
parents 159032da 14196d85
......@@ -161,6 +161,7 @@ dependencies:
- drupal:webform_ui
- drupal:workbench_access
- drupal:workflows
- override_node_options:override_node_options
- uw_ckeditor_plugins:uw_ckeditor_plugins
- uw_ws_ofis:uw_ws_ofis
libraries:
......
......@@ -5,6 +5,8 @@
* Install, update and uninstall for UW Sites all.
*/
use Drupal\user\Entity\Role;
/**
* Implements hook_install().
*/
......@@ -83,3 +85,62 @@ function uw_sites_all_update_8103() {
$config = \Drupal::service('config.factory')->getEditable('webform.settings');
$config->set('third_party_settings.honeypot.honeypot', TRUE)->save();
}
/**
* Enable Override Node Options module and assigns permissions to roles.
*/
function uw_sites_all_update_8104() {
\Drupal::service('module_installer')->install(['override_node_options']);
// List of permissions needed to be applied to roles.
$permissions = [
'enter uw_ct_blog revision log entry',
'enter uw_ct_catalog_item revision log entry',
'enter uw_ct_contact revision log entry',
'enter uw_ct_event revision log entry',
'enter uw_ct_news_item revision log entry',
'enter uw_ct_profile revision log entry',
'enter uw_ct_web_page revision log entry',
'override uw_ct_blog promote to front page option',
'override uw_ct_blog published option',
'override uw_ct_blog revision option',
'override uw_ct_blog sticky option',
'override uw_ct_catalog_item published option',
'override uw_ct_catalog_item revision option',
'override uw_ct_contact published option',
'override uw_ct_contact revision option',
'override uw_ct_event promote to front page option',
'override uw_ct_event published option',
'override uw_ct_event revision option',
'override uw_ct_event sticky option',
'override uw_ct_news_item promote to front page option',
'override uw_ct_news_item published option',
'override uw_ct_news_item revision option',
'override uw_ct_news_item sticky option',
'override uw_ct_profile published option',
'override uw_ct_profile revision option',
'override uw_ct_web_page published option',
'override uw_ct_web_page revision option',
];
// 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);
}
// Save role with new permissions.
$roles['uw_role_site_manager']->save();
$roles['uw_role_content_editor']->save();
$roles['uw_role_content_author']->save();
}
Markdown is supported
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