Skip to content

Commit

Permalink
Merge pull request #1029 from UN-OCHA/RW-1180
Browse files Browse the repository at this point in the history
[RW-1180] Add role to edit topics
  • Loading branch information
orakili authored Mar 4, 2025
2 parents 9272ae9 + 80d342d commit f001900
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
14 changes: 14 additions & 0 deletions config/system.action.user_add_role_action.topic_editor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
uuid: 4f0355db-bb6f-4b9c-a206-907ce07510b1
langcode: en
status: true
dependencies:
config:
- user.role.topic_editor
module:
- user
id: user_add_role_action.topic_editor
label: 'Add the Topic editor role to the selected user(s)'
type: user
plugin: user_add_role_action
configuration:
rid: topic_editor
14 changes: 14 additions & 0 deletions config/system.action.user_remove_role_action.topic_editor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
uuid: 7bb10b57-3148-4053-831f-b69d2fdfff32
langcode: en
status: true
dependencies:
config:
- user.role.topic_editor
module:
- user
id: user_remove_role_action.topic_editor
label: 'Remove the Topic editor role from the selected user(s)'
type: user
plugin: user_remove_role_action
configuration:
rid: topic_editor
23 changes: 23 additions & 0 deletions config/user.role.topic_editor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
uuid: 9e4f7f13-f094-44af-9621-56340de4577d
langcode: en
status: true
dependencies:
config:
- filter.format.markdown
- media.type.image_topic
- node.type.topic
module:
- filter
- media
- node
id: topic_editor
label: 'Topic editor'
weight: 11
is_admin: null
permissions:
- 'create image_topic media'
- 'create topic content'
- 'delete any image_topic media'
- 'edit any image_topic media'
- 'edit any topic content'
- 'use text format markdown'
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,10 @@ public function getEntityFormSubmitButtons($status, EntityModeratedInterface $en
* {@inheritdoc}
*/
public function entityAccess(EntityModeratedInterface $entity, $operation = 'view', ?AccountInterface $account = NULL) {
// Trello #y0B0wxLi: allow beta tester to view unpublished topics.
if ($operation === 'view' && UserHelper::userHasRoles(['beta_tester'], $account)) {
// RW-1180: allow topic editors to view unpublished topics.
// @todo Check if we can introduce granular permissions to view unpublished
// content types.
if ($operation === 'view' && UserHelper::userHasRoles(['topic_editor'], $account)) {
return AccessResult::allowed();
}
return parent::entityAccess($entity, $operation, $account);
Expand Down

0 comments on commit f001900

Please sign in to comment.