Skip to content

Commit

Permalink
Merge pull request #430 from localgovdrupal/fix/3.x/416-microsites-vi…
Browse files Browse the repository at this point in the history
…ew-access

Fix access to the microsites overview view
  • Loading branch information
finnlewis authored Oct 30, 2023
2 parents ec28b06 + 8b4aaca commit d78a23b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
33 changes: 33 additions & 0 deletions localgov_microsites_group.install
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,36 @@ function localgov_microsites_group_update_9002(&$sandbox) {
$my_invitations_view->save();
}
}

/**
* Fix access to the microsites overview view.
*/
function localgov_microsites_group_update_9003() {
$permission = 'access microsites overview';

// Add 'access microsites overview' permission to microsites controller role.
/** @var \Drupal\user\Entity\Role $controller_role */
$controller_role = \Drupal::entityTypeManager()
->getStorage('user_role')
->load('microsites_controller');
if (!$controller_role->hasPermission($permission)) {
$controller_role->grantPermission($permission);
$controller_role->save();
}

// Update access to the microsites overview view.
$microsites_view = \Drupal::entityTypeManager()
->getStorage('view')
->load('localgov_microsites_overview');
$displays = $microsites_view->get('display');
if (
isset($displays['default']['display_options']['access']['type']) &&
$displays['default']['display_options']['access']['type'] === 'perm' &&
isset($displays['default']['display_options']['access']['options']['perm']) &&
$displays['default']['display_options']['access']['options']['perm'] == 'bypass group access'
) {
$displays['default']['display_options']['access']['options']['perm'] = $permission;
$microsites_view->set('display', $displays);
$microsites_view->save();
}
}
2 changes: 1 addition & 1 deletion localgov_microsites_group.permissions.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
access microsites overview:
title: 'Access the Microcistes overview page'
title: 'Access the Microsites overview page'

0 comments on commit d78a23b

Please sign in to comment.