Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHS-6048: "Preparer" Role for creating draft content #1769

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/default/content_access.settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ content_access_roles_gids:
stanford_student: 8
author: 9
intranet_viewer: 10
preparer: 11
content_access_node_type:
hs_private_page: 'a:3:{s:4:"view";a:4:{i:0;s:11:"contributor";i:1;s:12:"site_manager";i:2;s:15:"intranet_viewer";i:3;s:13:"administrator";}s:8:"per_node";i:1;s:8:"view_own";a:4:{i:0;s:11:"contributor";i:1;s:12:"site_manager";i:2;s:15:"intranet_viewer";i:3;s:13:"administrator";}}'
1 change: 1 addition & 0 deletions config/default/core.extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ module:
hs_config_readonly: 0
hs_courses: 0
hs_courses_importer: 0
hs_editorial: 0
hs_entities: 0
hs_event_series: 0
hs_event_series_display: 0
Expand Down
2 changes: 1 addition & 1 deletion config/default/google_analytics.settings.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
account: ''
premium: false
domain_mode: 0
cross_domains: ''
visibility:
Expand Down Expand Up @@ -36,3 +35,4 @@ codesnippet:
translation_set: false
cache: false
debug: false
premium: false
2 changes: 1 addition & 1 deletion config/default/layout_builder_modal.settings.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
_core:
default_config_hash: gDNTgrmF0Aaxbr5-YV7aptP4mI8w_CboEJo2rPoQ49c
modal_width: 768
modal_width: '768'
modal_height: auto
modal_autoresize: true
theme_display: gin
1 change: 1 addition & 0 deletions config/default/samlauth.authentication.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ map_users_roles:
author: author
contributor: contributor
intranet_viewer: intranet_viewer
preparer: preparer
reviewer: reviewer
site_manager: site_manager
stanford_faculty: stanford_faculty
Expand Down
12 changes: 6 additions & 6 deletions config/default/stanford_basic.settings.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
_core:
default_config_hash: aglyNR8QctoQp4_qGIZAUkUuENNlv1Sto5HQuug59jA
favicon:
use_default: true
features:
favicon: true
browser_sync:
enabled: false
host: localhost
Expand All @@ -7,9 +13,3 @@ ie_enabled: false
ie_enabled_versions:
ie8: false
ie9: false
features:
favicon: true
favicon:
use_default: true
_core:
default_config_hash: aglyNR8QctoQp4_qGIZAUkUuENNlv1Sto5HQuug59jA
14 changes: 14 additions & 0 deletions config/default/system.action.user_add_role_action.preparer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
uuid: 3b627728-6379-44f4-bda0-1a4fae4460d2
langcode: en
status: true
dependencies:
config:
- user.role.preparer
module:
- user
id: user_add_role_action.preparer
label: 'Add the Preparer role to the selected user(s)'
type: user
plugin: user_add_role_action
configuration:
rid: preparer
14 changes: 14 additions & 0 deletions config/default/system.action.user_remove_role_action.preparer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
uuid: 16d7d1da-79de-44a3-a20f-8c4e118ed4df
langcode: en
status: true
dependencies:
config:
- user.role.preparer
module:
- user
id: user_remove_role_action.preparer
label: 'Remove the Preparer role from the selected user(s)'
type: user
plugin: user_remove_role_action
configuration:
rid: preparer
85 changes: 85 additions & 0 deletions config/default/user.role.preparer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
uuid: 1d441765-e453-4e47-955e-6ee1f61756bd
langcode: en
status: true
dependencies:
config:
- filter.format.basic_html
- filter.format.minimal_html
- filter.format.minimal_html_with_styles
- media.type.file
- media.type.image
- media.type.video
- node.type.hs_basic_page
- node.type.hs_event
- node.type.hs_event_series
- node.type.hs_news
- node.type.hs_person
- node.type.hs_publications
- node.type.hs_research
module:
- contextual
- editoria11y
- filter
- help
- hs_entities
- media
- node
- pathauto
- system
- toolbar
- view_unpublished
_core:
default_config_hash: IFWd-K7HmSVSUoYqKXCKFhRY61sQLjMAt4C6WU7sVek
id: preparer
label: Preparer
weight: 1
is_admin: null
permissions:
- 'access administration pages'
- 'access content overview'
- 'access contextual links'
- 'access help pages'
- 'access media overview'
- 'access toolbar'
- 'create file media'
- 'create hs_basic_page content'
- 'create hs_event content'
- 'create hs_event_series content'
- 'create hs_news content'
- 'create hs_person content'
- 'create hs_publications content'
- 'create hs_research content'
- 'create humsci entity'
- 'create image media'
- 'create media'
- 'create video media'
- 'edit any file media'
- 'edit any image media'
- 'edit any video media'
- 'edit humsci entity'
- 'edit own file media'
- 'edit own hs_basic_page content'
- 'edit own hs_event content'
- 'edit own hs_event_series content'
- 'edit own hs_news content'
- 'edit own hs_person content'
- 'edit own hs_publications content'
- 'edit own hs_research content'
- 'edit own image media'
- 'edit own video media'
- 'notify of path changes'
- 'update any media'
- 'update media'
- 'use text format basic_html'
- 'use text format minimal_html'
- 'use text format minimal_html_with_styles'
- 'view any unpublished hs_basic_page content'
- 'view any unpublished hs_event content'
- 'view any unpublished hs_event_series content'
- 'view any unpublished hs_news content'
- 'view any unpublished hs_person content'
- 'view any unpublished hs_publications content'
- 'view any unpublished hs_research content'
- 'view editoria11y checker'
- 'view own unpublished content'
- 'view own unpublished media'
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
langcode: en
status: true
dependencies:
config:
- filter.format.basic_html
- filter.format.minimal_html
- filter.format.minimal_html_with_styles
- media.type.file
- media.type.image
- media.type.video
- node.type.hs_basic_page
- node.type.hs_event
- node.type.hs_event_series
- node.type.hs_news
- node.type.hs_person
- node.type.hs_publications
- node.type.hs_research
module:
- contextual
- editoria11y
- filter
- help
- hs_entities
- media
- node
- pathauto
- system
- toolbar
- view_unpublished
id: preparer
label: 'Preparer'
permissions:
- 'access administration pages'
- 'access content overview'
- 'access contextual links'
- 'access help pages'
- 'access media overview'
- 'access toolbar'
- 'create file media'
- 'create hs_basic_page content'
- 'create hs_event content'
- 'create hs_event_series content'
- 'create hs_news content'
- 'create hs_person content'
- 'create hs_publications content'
- 'create hs_research content'
- 'create humsci entity'
- 'create image media'
- 'create media'
- 'create video media'
- 'edit any file media'
- 'edit any image media'
- 'edit any video media'
- 'edit humsci entity'
- 'edit own file media'
- 'edit own hs_basic_page content'
- 'edit own hs_event content'
- 'edit own hs_event_series content'
- 'edit own hs_news content'
- 'edit own hs_person content'
- 'edit own hs_publications content'
- 'edit own hs_research content'
- 'edit own image media'
- 'edit own video media'
- 'notify of path changes'
- 'update any media'
- 'update media'
- 'use text format basic_html'
- 'use text format minimal_html'
- 'use text format minimal_html_with_styles'
- 'view any unpublished hs_basic_page content'
- 'view any unpublished hs_event content'
- 'view any unpublished hs_event_series content'
- 'view any unpublished hs_news content'
- 'view any unpublished hs_person content'
- 'view any unpublished hs_publications content'
- 'view any unpublished hs_research content'
- 'view editoria11y checker'
- 'view own unpublished content'
- 'view own unpublished media'
18 changes: 18 additions & 0 deletions docroot/modules/humsci/hs_editorial/hs_editorial.info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'H&S Editorial'
type: module
description: 'Enhances content editorial roles and tools.'
core_version_requirement: ^10.3 || ^11
version: "1.0"
package: 'Humanities & Sciences'
dependencies:
- contextual:contextual
- editoria11y:editoria11y
- filter:filter
- help:help
- hs_entities:hs_entities
- media:media
- node:node
- pathauto:pathauto
- system:system
- toolbar:toolbar
- view_unpublished:view_unpublished
20 changes: 20 additions & 0 deletions docroot/modules/humsci/hs_editorial/hs_editorial.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/**
* @file
* Install, update and uninstall functions for the hs_editorial module.
*/

use Drupal\user\Entity\Role;

/**
* Implements hook_uninstall().
*/
function hs_editorial_uninstall() {
// Remove the preparer role on module uninstall. Site admins will also want to
// rebuild configuration to clean up related configuration dependencies.
$role = Role::load('preparer');
if ($role) {
$role->delete();
}
}
37 changes: 37 additions & 0 deletions docroot/modules/humsci/hs_editorial/hs_editorial.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/**
* @file
* hs_editorial.module
*/

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Session\AccountInterface;
use Drupal\node\NodeInterface;

/**
* Implements hook_node_presave().
*/
function hs_editorial_node_presave(NodeInterface $node) {
// Users with the 'Preparer' role are not allowed to publish new content.
// Override the default publishing status set within the content types.
if ($node->isNew() && in_array('preparer', \Drupal::currentUser()->getRoles())) {
$node->setUnpublished();
}
}

/**
* Implements hook_node_access().
*/
function hs_editorial_node_access(NodeInterface $node, $op, AccountInterface $account) {
// Users with the 'Preparer' role are not allowed to edit published content.
// This closes a gap with the currently available permissions where edit does
// not differentiate between published and unpublished nodes.
if ($op === 'update'
&& $node->isPublished()
&& in_array('preparer', $account->getRoles())) {
return AccessResult::forbidden()->addCacheableDependency($node);
}
// Default response should return neutral, letting other access checks decide.
return AccessResult::neutral();
}
Loading