diff --git a/config/install/filter.format.plain_text.yml b/config/install/filter.format.plain_text.yml index 903de4829f78e98ad47788e6dc4c85d365de4068..cfe726a132bb5bb68f83a9fd5be5e9a70745d23b 100644 --- a/config/install/filter.format.plain_text.yml +++ b/config/install/filter.format.plain_text.yml @@ -2,7 +2,7 @@ langcode: en status: true dependencies: module: - - media + - media_embed_extra name: 'Plain text' format: plain_text weight: 10 @@ -28,7 +28,7 @@ filters: settings: { } media_embed: id: media_embed - provider: media + provider: media_embed_extra status: false weight: 100 settings: diff --git a/config/install/filter.format.uw_tf_basic.yml b/config/install/filter.format.uw_tf_basic.yml index e6f5deb76d38a1b7634cb71999a19169f63ed173..cca5adab579f7143d1b2692c9cf0c4197edd1181 100644 --- a/config/install/filter.format.uw_tf_basic.yml +++ b/config/install/filter.format.uw_tf_basic.yml @@ -4,7 +4,7 @@ dependencies: module: - editor - linkit - - media + - media_embed_extra name: Basic format: uw_tf_basic weight: -4 @@ -76,10 +76,10 @@ filters: title: true media_embed: id: media_embed - provider: media + provider: media_embed_extra status: false weight: -40 settings: default_view_mode: default - allowed_media_types: { } allowed_view_modes: { } + allowed_media_types: { } diff --git a/config/install/filter.format.uw_tf_full_html.yml b/config/install/filter.format.uw_tf_full_html.yml index 76282801529ad099d69cfd74e8ede32f40e34887..5f1b510679a1d2b5d25307fecf9fccdf08670202 100644 --- a/config/install/filter.format.uw_tf_full_html.yml +++ b/config/install/filter.format.uw_tf_full_html.yml @@ -4,7 +4,7 @@ dependencies: module: - editor - linkit - - media + - media_embed_extra name: 'Full HTML' format: uw_tf_full_html weight: -6 @@ -26,13 +26,13 @@ filters: filter_html_nofollow: false media_embed: id: media_embed - provider: media + provider: media_embed_extra status: true weight: -48 settings: default_view_mode: uw_vm_standard_image - allowed_media_types: { } allowed_view_modes: { } + allowed_media_types: { } editor_file_reference: id: editor_file_reference provider: editor diff --git a/config/install/filter.format.uw_tf_standard.yml b/config/install/filter.format.uw_tf_standard.yml index 622db72a58813b9eff8be0c6ede193dab6f96edd..c96aa8dbb4c9b4dc1eaccac75488ae888e50a2c6 100644 --- a/config/install/filter.format.uw_tf_standard.yml +++ b/config/install/filter.format.uw_tf_standard.yml @@ -74,10 +74,10 @@ filters: weight: -45 settings: default_view_mode: uw_vm_standard_image + allowed_view_modes: { } allowed_media_types: uw_mt_file: uw_mt_file uw_mt_image: uw_mt_image - allowed_view_modes: { } linkit: id: linkit provider: linkit diff --git a/config/install/metatag.metatag_defaults.global.yml b/config/install/metatag.metatag_defaults.global.yml index 17353465ffd1a2b699f1b3f2382d1c20f3113cd3..ab314a9d014f2865f404352c00dadcd7500e8971 100644 --- a/config/install/metatag.metatag_defaults.global.yml +++ b/config/install/metatag.metatag_defaults.global.yml @@ -1,8 +1,6 @@ langcode: en status: true dependencies: { } -_core: - default_config_hash: O8nAew41iO4Q4Le9GodNgm-QcHjCnDobmdu6bCpCfG4 id: global label: Global tags: diff --git a/config/install/pathauto.pattern.uw_path_custom_block.yml b/config/install/pathauto.pattern.uw_path_custom_block.yml index 00936ceb272ba5c9a25405d7e1074a1d526b2252..8bde6c6490dc7b50bbf7a29b4dbbfd8650a418e4 100644 --- a/config/install/pathauto.pattern.uw_path_custom_block.yml +++ b/config/install/pathauto.pattern.uw_path_custom_block.yml @@ -1,8 +1,6 @@ langcode: en status: true -dependencies: - module: - - block_content +dependencies: { } id: uw_path_custom_block label: 'Custom block path pattern' type: 'canonical_entities:block_content' diff --git a/drush.services.yml b/drush.services.yml new file mode 100644 index 0000000000000000000000000000000000000000..4d67a5865d2dc9cf649462e935b075d86a02ee21 --- /dev/null +++ b/drush.services.yml @@ -0,0 +1,6 @@ +services: + uw_cfg_common.commands: + class: Drupal\uw_cfg_common\Commands\UwDrushCommands + arguments: ['@entity_type.manager'] + tags: + - { name: drush.command } diff --git a/src/Commands/UwDrushCommands.php b/src/Commands/UwDrushCommands.php new file mode 100644 index 0000000000000000000000000000000000000000..46122f2b46c2306efc64e17ababada2fd39f60e3 --- /dev/null +++ b/src/Commands/UwDrushCommands.php @@ -0,0 +1,59 @@ +<?php + +namespace Drupal\uw_cfg_common\Commands; + +use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\uw_cfg_common\UwRoles\UwRoles; +use Drush\Commands\DrushCommands; + +/** + * Drush commands for uw_cfg_common module. + * + * @package Drupal\uw_cfg_common\Commands + */ +class UwDrushCommands extends DrushCommands { + + /** + * Entity type manager. + * + * @var \Drupal\Core\Entity\EntityTypeManagerInterface + */ + protected $entityTypeManager; + + /** + * {@inheritDoc} + */ + public function __construct(EntityTypeManagerInterface $entityTypeManager) { + $this->entityTypeManager = $entityTypeManager; + } + + /** + * Drush command to update permissions. + * + * @command uwcfgcommon:catalog + * @aliases uwperm + * @usage uwperm + */ + public function updatePermissions() { + + // Get all the role ids in the system. + $rids = UwRoles::getAllRoles(); + + // Step through each rid and set the permissions. + foreach ($rids as $rid) { + + // Get the info about the role. + $uw_role = UwRoles::getUwRole($rid); + + // Set the permissions for the role. + UwRoles::setUwPermissions($uw_role); + + // Set message for specific role setting permissions. + $this->logger()->success('Permissions set for ' . $uw_role['label'] . '.'); + } + + // Set message for command completed. + $this->logger()->success('All permissions set.'); + } + +} diff --git a/src/UwRoles/UwRoles.php b/src/UwRoles/UwRoles.php new file mode 100644 index 0000000000000000000000000000000000000000..68035e029f441a5a6ee5c8592df0e7a1b8d3ff10 --- /dev/null +++ b/src/UwRoles/UwRoles.php @@ -0,0 +1,159 @@ +<?php + +namespace Drupal\uw_cfg_common\UwRoles; + +use Drupal\user\Entity\Role; +use Drupal\Component\Serialization\Yaml; + +/** + * Class UwRoles. + * + * UW Specific roles permissions. + */ +class UwRoles { + + /** + * Gets an array of data about a UW role. + * + * @param string $rid + * The role id. + * + * @return array + * An array of data for a UW role. + */ + public static function getUwRole(string $rid): array { + + return [ + 'label' => UwRoles::getUwRoleLabel($rid), + 'object' => Role::load($rid), + 'permissions' => UwRoles::getUwPermissions($rid), + ]; + } + + /** + * Gets the list of ids for UW roles. + * + * @return string[] + * An array of ids for the UW roles + */ + public static function getUwRoleIds(): array { + return [ + 'uw_role_site_owner', + 'uw_role_site_manager', + 'uw_role_content_author', + 'uw_role_content_editor', + 'uw_role_form_editor', + 'uw_role_form_results_access', + ]; + } + + /** + * Get the role id for Drupal roles. + * + * @return array + * Array of role ids for Drupal roles. + */ + public static function getDrupalRoleIds(): array { + + return [ + 'anonymous', + 'authenticated', + ]; + } + + /** + * Gets all the role ids in the system, UW and Drupal. + * + * @return array + * Array of all role ids. + */ + public static function getAllRoles(): array { + + // Get the UW roles. + $roles = UwRoles::getUwRoleIds(); + + // Append the Drupal roles. + $roles = array_merge($roles, UwRoles::getDrupalRoleIds()); + + // Return all the roles. + return $roles; + } + + /** + * Gets the label for a UW role. + * + * @param string $rid + * The role id. + * + * @return string + * The label. + */ + public static function getUwRoleLabel(string $rid): string { + + switch ($rid) { + case 'uw_role_site_owner': + return 'Site owner'; + + case 'uw_role_site_manager': + return 'Site manager'; + + case 'uw_role_content_author': + return 'Content Author'; + + case 'uw_role_content_editor': + return 'Content editor'; + + case 'uw_role_form_editor': + return 'Form editor'; + + case 'uw_role_form_results_access': + return 'Form results access'; + + case 'anonymous': + return 'Anonymous'; + + case 'authenticated': + return 'Authenticated'; + + default: + return ''; + } + } + + /** + * Get the permissions for a specific role. + * + * @param string $rid + * The role id. + * + * @return array + * An array of permissions for a specific role. + */ + public static function getUwPermissions(string $rid): array { + + // Get the file to the user role permissions yml file. + $file = __DIR__ . '/user.role.' . $rid . '.yml'; + + // Parse the yml file to get the permissions. + $permissions = Yaml::decode(file_get_contents($file)); + + // Return the permissions for the specific user. + return $permissions['permissions']; + } + + /** + * Set the list of permissions inside the uw_role array. + * + * @param array $uw_role + * The uw_role array from function getRole. + */ + public static function setUwPermissions(array $uw_role): void { + + foreach ($uw_role['permissions'] as $permission) { + $uw_role['object']->grantPermission($permission); + } + + $uw_role['object']->save(); + } + +} diff --git a/config/install/user.role.anonymous.yml b/src/UwRoles/user.role.anonymous.yml similarity index 88% rename from config/install/user.role.anonymous.yml rename to src/UwRoles/user.role.anonymous.yml index 8a05b52b741a8a3f2b5456e4a50bda8da14a2ced..cf482b6394bd53cae66fd4cb403ddba3d5c11dfb 100644 --- a/config/install/user.role.anonymous.yml +++ b/src/UwRoles/user.role.anonymous.yml @@ -1,10 +1,3 @@ -langcode: en -status: true -dependencies: { } -id: anonymous -label: 'Anonymous user' -weight: -10 -is_admin: false permissions: - 'access comments' - 'access content' diff --git a/config/install/user.role.authenticated.yml b/src/UwRoles/user.role.authenticated.yml similarity index 89% rename from config/install/user.role.authenticated.yml rename to src/UwRoles/user.role.authenticated.yml index ce87b4f158e6d0f3980af7743d71e9c0c4e60f12..e3b4120e8e187118cdc49e84d8bef70c3677e9b0 100644 --- a/config/install/user.role.authenticated.yml +++ b/src/UwRoles/user.role.authenticated.yml @@ -1,10 +1,3 @@ -langcode: en -status: true -dependencies: { } -id: authenticated -label: 'Authenticated user' -weight: -9 -is_admin: false permissions: - 'access comments' - 'access content' diff --git a/config/install/user.role.uw_role_content_editor.yml b/src/UwRoles/user.role.uw_role_content_author.yml similarity index 69% rename from config/install/user.role.uw_role_content_editor.yml rename to src/UwRoles/user.role.uw_role_content_author.yml index 21c8f055d72e5949043e2bd73169b03e42dca6df..877e3b8cd3ad8da05d42bc7f626f1dbe68fb6914 100644 --- a/config/install/user.role.uw_role_content_editor.yml +++ b/src/UwRoles/user.role.uw_role_content_author.yml @@ -1,17 +1,8 @@ -langcode: en -status: true -dependencies: { } -id: uw_role_content_editor -label: 'Content editor' -weight: -5 -is_admin: null permissions: - 'access administration pages' - 'access content overview' - 'access contextual links' - - 'access draggableviews' - 'access files overview' - - 'access in-place editing' - 'access media overview' - 'access media_entity_browser entity browser pages' - 'access media_entity_browser_modal entity browser pages' @@ -45,20 +36,11 @@ permissions: - 'access shortcuts' - 'access taxonomy overview' - 'access user profiles' - - 'access uw_ebr_image entity browser pages' - 'administer main menu items' - 'administer uw-menu-audience-menu menu items' - 'can override my_dashboard dashboard' - 'can view my_dashboard dashboard' - 'cancel smart date recur instances' - - 'clone uw_ct_blog content' - - 'clone uw_ct_catalog_item content' - - 'clone uw_ct_contact content' - - 'clone uw_ct_event content' - - 'clone uw_ct_news_item content' - - 'clone uw_ct_profile content' - - 'clone uw_ct_sidebar content' - - 'clone uw_ct_web_page content' - 'configure editable uw_ct_blog node layout overrides' - 'configure editable uw_ct_catalog_item node layout overrides' - 'configure editable uw_ct_contact node layout overrides' @@ -82,23 +64,7 @@ permissions: - 'create paragraph content uw_para_local_video_banner' - 'create paragraph content uw_para_timeline' - 'create paragraph content uw_para_vimeo_video_banner' - - 'create terms in uw_tax_event_tags' - - 'create terms in uw_tax_event_type' - - 'create terms in uw_vocab_audience' - - 'create terms in uw_vocab_blog_tags' - - 'create terms in uw_vocab_catalog_categories' - - 'create terms in uw_vocab_catalogs' - - 'create terms in uw_vocab_news_tags' - 'create url aliases' - - 'create uw_ct_blog content' - - 'create uw_ct_catalog_item content' - - 'create uw_ct_event content' - - 'create uw_ct_news_item content' - - 'create uw_ct_sidebar content' - - 'create uw_ct_site_footer content' - - 'create uw_ct_web_page content' - - 'create uw_news_item content' - - 'delete own uw_news_item content' - 'delete paragraph content uw_para_call_to_action' - 'delete paragraph content uw_para_call_to_action_text' - 'delete paragraph content uw_para_ec_item' @@ -111,28 +77,6 @@ permissions: - 'delete paragraph content uw_para_local_video_banner' - 'delete paragraph content uw_para_timeline' - 'delete paragraph content uw_para_vimeo_video_banner' - - 'edit any uw_ct_blog content' - - 'edit any uw_ct_catalog_item content' - - 'edit any uw_ct_event content' - - 'edit any uw_ct_news_item content' - - 'edit any uw_ct_sidebar content' - - 'edit any uw_ct_site_footer content' - - 'edit any uw_ct_web_page content' - - 'edit own uw_ct_blog content' - - 'edit own uw_ct_catalog_item content' - - 'edit own uw_ct_event content' - - 'edit own uw_ct_news_item content' - - 'edit own uw_ct_sidebar content' - - 'edit own uw_ct_site_footer content' - - 'edit own uw_ct_web_page content' - - 'edit own uw_news_item content' - - 'edit terms in uw_tax_event_tags' - - 'edit terms in uw_tax_event_type' - - 'edit terms in uw_vocab_audience' - - 'edit terms in uw_vocab_blog_tags' - - 'edit terms in uw_vocab_catalog_categories' - - 'edit terms in uw_vocab_catalogs' - - 'edit terms in uw_vocab_news_tags' - 'enter uw_ct_blog revision log entry' - 'enter uw_ct_catalog_item revision log entry' - 'enter uw_ct_contact revision log entry' @@ -162,14 +106,6 @@ permissions: - 'override uw_ct_web_page published option' - 'override uw_ct_web_page revision option' - 'reschedule smart date recur instances' - - 'revert uw_ct_blog revisions' - - 'revert uw_ct_catalog_item revisions' - - 'revert uw_ct_event revisions' - - 'revert uw_ct_news_item revisions' - - 'revert uw_ct_sidebar revisions' - - 'revert uw_ct_site_footer revisions' - - 'revert uw_ct_web_page revisions' - - 'revert uw_news_item revisions' - 'update any media' - 'update paragraph content uw_para_call_to_action' - 'update paragraph content uw_para_call_to_action_text' @@ -183,10 +119,7 @@ permissions: - 'update paragraph content uw_para_local_video_banner' - 'update paragraph content uw_para_timeline' - 'update paragraph content uw_para_vimeo_video_banner' - - 'use uw_workflow transition archived' - - 'use uw_workflow transition draft' - 'use uw_workflow transition needs_review' - - 'use uw_workflow transition published' - 'use workbench access' - 'view all media revisions' - 'view all revisions' @@ -195,11 +128,3 @@ permissions: - 'view own unpublished content' - 'view own unpublished media' - 'view unpublished paragraphs' - - 'view uw_ct_blog revisions' - - 'view uw_ct_catalog_item revisions' - - 'view uw_ct_event revisions' - - 'view uw_ct_news_item revisions' - - 'view uw_ct_sidebar revisions' - - 'view uw_ct_site_footer revisions' - - 'view uw_ct_web_page revisions' - - 'view uw_news_item revisions' diff --git a/config/install/user.role.uw_role_site_manager.yml b/src/UwRoles/user.role.uw_role_content_editor.yml similarity index 56% rename from config/install/user.role.uw_role_site_manager.yml rename to src/UwRoles/user.role.uw_role_content_editor.yml index 15ba01c7db5a0e8159ed60659c382e74834838e7..e841a53715e4b8d9f48880008c464afdc37fcbb0 100644 --- a/config/install/user.role.uw_role_site_manager.yml +++ b/src/UwRoles/user.role.uw_role_content_editor.yml @@ -1,15 +1,7 @@ -langcode: en -status: true -dependencies: { } -id: uw_role_site_manager -label: 'Site manager' -weight: -6 -is_admin: null permissions: - 'access administration pages' - 'access content overview' - 'access contextual links' - - 'access draggableviews' - 'access files overview' - 'access in-place editing' - 'access media overview' @@ -45,23 +37,11 @@ permissions: - 'access shortcuts' - 'access taxonomy overview' - 'access user profiles' - - 'access uw_ebr_cta entity browser pages' - - 'access uw_ebr_image entity browser pages' - 'administer main menu items' - - 'administer redirects' - - 'administer special alert' - 'administer uw-menu-audience-menu menu items' - 'can override my_dashboard dashboard' - 'can view my_dashboard dashboard' - 'cancel smart date recur instances' - - 'clone uw_ct_blog content' - - 'clone uw_ct_catalog_item content' - - 'clone uw_ct_contact content' - - 'clone uw_ct_event content' - - 'clone uw_ct_news_item content' - - 'clone uw_ct_profile content' - - 'clone uw_ct_sidebar content' - - 'clone uw_ct_web_page content' - 'configure editable uw_ct_blog node layout overrides' - 'configure editable uw_ct_catalog_item node layout overrides' - 'configure editable uw_ct_contact node layout overrides' @@ -85,83 +65,7 @@ permissions: - 'create paragraph content uw_para_local_video_banner' - 'create paragraph content uw_para_timeline' - 'create paragraph content uw_para_vimeo_video_banner' - - 'create terms in uw_tax_event_tags' - - 'create terms in uw_tax_event_type' - - 'create terms in uw_vocab_audience' - - 'create terms in uw_vocab_blog_tags' - - 'create terms in uw_vocab_catalog_categories' - - 'create terms in uw_vocab_catalogs' - - 'create terms in uw_vocab_news_tags' - 'create url aliases' - - 'create uw_ct_blog content' - - 'create uw_ct_catalog_item content' - - 'create uw_ct_event content' - - 'create uw_ct_news_item content' - - 'create uw_ct_sidebar content' - - 'create uw_ct_site_footer content' - - 'create uw_ct_web_page content' - - 'create uw_news_item content' - - 'delete all revisions' - - 'delete any media' - - 'delete any uw_ct_blog content' - - 'delete any uw_ct_catalog_item content' - - 'delete any uw_ct_event content' - - 'delete any uw_ct_news_item content' - - 'delete any uw_ct_sidebar content' - - 'delete any uw_ct_site_footer content' - - 'delete any uw_ct_web_page content' - - 'delete any uw_news_item content' - - 'delete own uw_ct_blog content' - - 'delete own uw_ct_catalog_item content' - - 'delete own uw_ct_event content' - - 'delete own uw_ct_news_item content' - - 'delete own uw_ct_sidebar content' - - 'delete own uw_ct_site_footer content' - - 'delete own uw_ct_web_page content' - - 'delete own uw_news_item content' - - 'delete paragraph content uw_para_call_to_action' - - 'delete paragraph content uw_para_call_to_action_text' - - 'delete paragraph content uw_para_ec_item' - - 'delete paragraph content uw_para_fact_figure' - - 'delete paragraph content uw_para_fact_point' - - 'delete paragraph content uw_para_fact_text' - - 'delete paragraph content uw_para_facts_and_figures' - - 'delete paragraph content uw_para_ff' - - 'delete paragraph content uw_para_image_banner' - - 'delete paragraph content uw_para_local_video_banner' - - 'delete paragraph content uw_para_timeline' - - 'delete paragraph content uw_para_vimeo_video_banner' - - 'delete terms in uw_tax_event_tags' - - 'delete terms in uw_tax_event_type' - - 'delete terms in uw_vocab_audience' - - 'delete terms in uw_vocab_blog_tags' - - 'delete terms in uw_vocab_catalog_categories' - - 'delete terms in uw_vocab_catalogs' - - 'delete terms in uw_vocab_news_tags' - - 'delete uw_news_item revisions' - - 'edit any uw_ct_blog content' - - 'edit any uw_ct_catalog_item content' - - 'edit any uw_ct_event content' - - 'edit any uw_ct_news_item content' - - 'edit any uw_ct_sidebar content' - - 'edit any uw_ct_site_footer content' - - 'edit any uw_ct_web_page content' - - 'edit any uw_news_item content' - - 'edit own uw_ct_blog content' - - 'edit own uw_ct_catalog_item content' - - 'edit own uw_ct_event content' - - 'edit own uw_ct_news_item content' - - 'edit own uw_ct_sidebar content' - - 'edit own uw_ct_site_footer content' - - 'edit own uw_ct_web_page content' - - 'edit own uw_news_item content' - - 'edit terms in uw_tax_event_tags' - - 'edit terms in uw_tax_event_type' - - 'edit terms in uw_vocab_audience' - - 'edit terms in uw_vocab_blog_tags' - - 'edit terms in uw_vocab_catalog_categories' - - 'edit terms in uw_vocab_catalogs' - - 'edit terms in uw_vocab_news_tags' - 'enter uw_ct_blog revision log entry' - 'enter uw_ct_catalog_item revision log entry' - 'enter uw_ct_contact revision log entry' @@ -190,18 +94,7 @@ permissions: - 'override uw_ct_profile revision option' - 'override uw_ct_web_page published option' - 'override uw_ct_web_page revision option' - - 'rearrange contacts' - - 'rearrange profiles' - 'reschedule smart date recur instances' - - 'revert all revisions' - - 'revert uw_ct_blog revisions' - - 'revert uw_ct_catalog_item revisions' - - 'revert uw_ct_event revisions' - - 'revert uw_ct_news_item revisions' - - 'revert uw_ct_sidebar revisions' - - 'revert uw_ct_site_footer revisions' - - 'revert uw_ct_web_page revisions' - - 'revert uw_news_item revisions' - 'update any media' - 'update paragraph content uw_para_call_to_action' - 'update paragraph content uw_para_call_to_action_text' @@ -227,11 +120,3 @@ permissions: - 'view own unpublished content' - 'view own unpublished media' - 'view unpublished paragraphs' - - 'view uw_ct_blog revisions' - - 'view uw_ct_catalog_item revisions' - - 'view uw_ct_event revisions' - - 'view uw_ct_news_item revisions' - - 'view uw_ct_sidebar revisions' - - 'view uw_ct_site_footer revisions' - - 'view uw_ct_web_page revisions' - - 'view uw_news_item revisions' diff --git a/config/install/user.role.uw_role_form_editor.yml b/src/UwRoles/user.role.uw_role_form_editor.yml similarity index 92% rename from config/install/user.role.uw_role_form_editor.yml rename to src/UwRoles/user.role.uw_role_form_editor.yml index 0ca6fe5d559bcd9cbe0e59c3ea3746f3f6add0fe..17cef7c3dfb87ba5cea23720eb14d203452cfb0b 100644 --- a/config/install/user.role.uw_role_form_editor.yml +++ b/src/UwRoles/user.role.uw_role_form_editor.yml @@ -1,13 +1,5 @@ -langcode: en -status: true -dependencies: { } -id: uw_role_form_editor -label: 'Form editor' -weight: -3 -is_admin: null permissions: - 'access any webform configuration' - - 'access draggableviews' - 'access metatag advanced__image_src' - 'access metatag advanced__original_source' - 'access metatag advanced__robots' diff --git a/config/install/user.role.uw_role_form_results_access.yml b/src/UwRoles/user.role.uw_role_form_results_access.yml similarity index 67% rename from config/install/user.role.uw_role_form_results_access.yml rename to src/UwRoles/user.role.uw_role_form_results_access.yml index 673e8e6629b59206355714e31e783519039cbd96..aef7b5a3b18ecf22d3796194cb8f6045a027ed98 100644 --- a/config/install/user.role.uw_role_form_results_access.yml +++ b/src/UwRoles/user.role.uw_role_form_results_access.yml @@ -1,12 +1,4 @@ -langcode: en -status: true -dependencies: { } -id: uw_role_form_results_access -label: 'Form results access' -weight: -2 -is_admin: null permissions: - - 'access draggableviews' - 'access user profiles' - 'access webform overview' - 'access webform submission user' diff --git a/config/install/user.role.uw_role_content_author.yml b/src/UwRoles/user.role.uw_role_site_manager.yml similarity index 71% rename from config/install/user.role.uw_role_content_author.yml rename to src/UwRoles/user.role.uw_role_site_manager.yml index d0ed331138ba574f4b9f7c1ca8a6260b5327097a..8eade4a9c03ea10840e59ecb22969a55849bfc15 100644 --- a/config/install/user.role.uw_role_content_author.yml +++ b/src/UwRoles/user.role.uw_role_site_manager.yml @@ -1,16 +1,9 @@ -langcode: en -status: true -dependencies: { } -id: uw_role_content_author -label: 'Content author' -weight: -4 -is_admin: null permissions: - 'access administration pages' - 'access content overview' - 'access contextual links' - - 'access draggableviews' - 'access files overview' + - 'access in-place editing' - 'access media overview' - 'access media_entity_browser entity browser pages' - 'access media_entity_browser_modal entity browser pages' @@ -44,20 +37,15 @@ permissions: - 'access shortcuts' - 'access taxonomy overview' - 'access user profiles' + - 'access uw_ebr_cta entity browser pages' - 'access uw_ebr_image entity browser pages' - 'administer main menu items' + - 'administer redirects' + - 'administer special alert' - 'administer uw-menu-audience-menu menu items' - 'can override my_dashboard dashboard' - 'can view my_dashboard dashboard' - 'cancel smart date recur instances' - - 'clone uw_ct_blog content' - - 'clone uw_ct_catalog_item content' - - 'clone uw_ct_contact content' - - 'clone uw_ct_event content' - - 'clone uw_ct_news_item content' - - 'clone uw_ct_profile content' - - 'clone uw_ct_sidebar content' - - 'clone uw_ct_web_page content' - 'configure editable uw_ct_blog node layout overrides' - 'configure editable uw_ct_catalog_item node layout overrides' - 'configure editable uw_ct_contact node layout overrides' @@ -81,23 +69,9 @@ permissions: - 'create paragraph content uw_para_local_video_banner' - 'create paragraph content uw_para_timeline' - 'create paragraph content uw_para_vimeo_video_banner' - - 'create terms in uw_tax_event_tags' - - 'create terms in uw_tax_event_type' - - 'create terms in uw_vocab_audience' - - 'create terms in uw_vocab_blog_tags' - - 'create terms in uw_vocab_catalog_categories' - - 'create terms in uw_vocab_catalogs' - - 'create terms in uw_vocab_news_tags' - 'create url aliases' - - 'create uw_ct_blog content' - - 'create uw_ct_catalog_item content' - - 'create uw_ct_event content' - - 'create uw_ct_news_item content' - - 'create uw_ct_sidebar content' - - 'create uw_ct_site_footer content' - - 'create uw_ct_web_page content' - - 'create uw_news_item content' - - 'delete own uw_news_item content' + - 'delete all revisions' + - 'delete any media' - 'delete paragraph content uw_para_call_to_action' - 'delete paragraph content uw_para_call_to_action_text' - 'delete paragraph content uw_para_ec_item' @@ -110,28 +84,6 @@ permissions: - 'delete paragraph content uw_para_local_video_banner' - 'delete paragraph content uw_para_timeline' - 'delete paragraph content uw_para_vimeo_video_banner' - - 'edit any uw_ct_blog content' - - 'edit any uw_ct_catalog_item content' - - 'edit any uw_ct_event content' - - 'edit any uw_ct_news_item content' - - 'edit any uw_ct_sidebar content' - - 'edit any uw_ct_site_footer content' - - 'edit any uw_ct_web_page content' - - 'edit own uw_ct_blog content' - - 'edit own uw_ct_catalog_item content' - - 'edit own uw_ct_event content' - - 'edit own uw_ct_news_item content' - - 'edit own uw_ct_sidebar content' - - 'edit own uw_ct_site_footer content' - - 'edit own uw_ct_web_page content' - - 'edit own uw_news_item content' - - 'edit terms in uw_tax_event_tags' - - 'edit terms in uw_tax_event_type' - - 'edit terms in uw_vocab_audience' - - 'edit terms in uw_vocab_blog_tags' - - 'edit terms in uw_vocab_catalog_categories' - - 'edit terms in uw_vocab_catalogs' - - 'edit terms in uw_vocab_news_tags' - 'enter uw_ct_blog revision log entry' - 'enter uw_ct_catalog_item revision log entry' - 'enter uw_ct_contact revision log entry' @@ -160,14 +112,9 @@ permissions: - 'override uw_ct_profile revision option' - 'override uw_ct_web_page published option' - 'override uw_ct_web_page revision option' + - 'rearrange contacts' + - 'rearrange profiles' - 'reschedule smart date recur instances' - - 'revert uw_ct_blog revisions' - - 'revert uw_ct_catalog_item revisions' - - 'revert uw_ct_event revisions' - - 'revert uw_ct_news_item revisions' - - 'revert uw_ct_sidebar revisions' - - 'revert uw_ct_site_footer revisions' - - 'revert uw_ct_web_page revisions' - 'update any media' - 'update paragraph content uw_para_call_to_action' - 'update paragraph content uw_para_call_to_action_text' @@ -181,7 +128,10 @@ permissions: - 'update paragraph content uw_para_local_video_banner' - 'update paragraph content uw_para_timeline' - 'update paragraph content uw_para_vimeo_video_banner' + - 'use uw_workflow transition archived' + - 'use uw_workflow transition draft' - 'use uw_workflow transition needs_review' + - 'use uw_workflow transition published' - 'use workbench access' - 'view all media revisions' - 'view all revisions' @@ -190,10 +140,3 @@ permissions: - 'view own unpublished content' - 'view own unpublished media' - 'view unpublished paragraphs' - - 'view uw_ct_blog revisions' - - 'view uw_ct_catalog_item revisions' - - 'view uw_ct_event revisions' - - 'view uw_ct_news_item revisions' - - 'view uw_ct_sidebar revisions' - - 'view uw_ct_site_footer revisions' - - 'view uw_ct_web_page revisions' diff --git a/config/install/user.role.uw_role_site_owner.yml b/src/UwRoles/user.role.uw_role_site_owner.yml similarity index 93% rename from config/install/user.role.uw_role_site_owner.yml rename to src/UwRoles/user.role.uw_role_site_owner.yml index 17915066c700b6c5714a649006568844cbdfbe54..d5b04e823b031cf070aa2948b53d18733627cc79 100644 --- a/config/install/user.role.uw_role_site_owner.yml +++ b/src/UwRoles/user.role.uw_role_site_owner.yml @@ -1,16 +1,8 @@ -langcode: en -status: true -dependencies: { } -id: uw_role_site_owner -label: 'Site owner' -weight: -7 -is_admin: null permissions: - 'access administration pages' - 'access content access form' - 'access content overview' - 'access contextual links' - - 'access draggableviews' - 'access files overview' - 'access metatag advanced__image_src' - 'access metatag advanced__original_source' diff --git a/uw_cfg_common.install b/uw_cfg_common.install index b98753dbfe7365e5ca492369f99e9c07862d8693..5f00d8b93680c2325767d52cedb2cde483993c7b 100644 --- a/uw_cfg_common.install +++ b/uw_cfg_common.install @@ -10,11 +10,50 @@ use Drupal\node\Entity\Node; use Drupal\uw_cfg_common\UwPermissions\UwPermissions; use Drupal\user\Entity\Role; use Drupal\Core\Config\FileStorage; +use Drupal\uw_cfg_common\UwRoles\UwRoles; /** * Implements hook_install(). */ function uw_cfg_common_install() { + + // Get the role ids for UW roles. + $uw_rids = UwRoles::getUwRoleIds(); + + // Step through each of the rids and create + // role and set permissions. + foreach ($uw_rids as $uw_rid) { + + // Create the role. + $role = Role::create( + [ + 'id' => $uw_rid, + 'label' => UwRoles::getUwRoleLabel($uw_rid), + ] + ); + $role->save(); + + // Get the info about the role. + $uw_role = UwRoles::getUwRole($uw_rid); + + // Set the permissions for the role. + UwRoles::setUwPermissions($uw_role); + } + + // Get the role ids for Drupal roles. + $drupal_rids = UwRoles::getDrupalRoleIds(); + + // Step through each of the Drupal roles and + // set the permissions. + foreach ($drupal_rids as $drupal_rid) { + + // Get the info about the role. + $uw_role = UwRoles::getUwRole($drupal_rid); + + // Set the permissions for the role. + UwRoles::setUwPermissions($uw_role); + } + $permissions_to_process = [ 'Blog' => [ 'Use content type' => [