Skip to content

Commit

Permalink
Allow some necessary blocks to be public on intranets
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Sep 11, 2023
1 parent 63a7df8 commit e33ffbc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions modules/stanford_intranet/stanford_intranet.module
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ function stanford_intranet_entity_access(EntityInterface $entity, $operation, Ac
\Drupal::state()->get('stanford_intranet', FALSE) &&
!($entity instanceof ParagraphInterface)
) {
if ($entity->getEntityTypeId() == 'block') {
$default = ['system_main_block', 'help', 'system_messages_block'];
$allowed_blocks = \Drupal::config('stanford_intranet.settings')
->get('public_blocks') ?: $default;

if (
in_array($entity->getPluginId(), $allowed_blocks) ||
in_array($entity->id(), $allowed_blocks)
) {
return AccessResult::neutral();
}
}
// Prevent all access to non-authenticated users.
return AccessResult::forbidden();
}
Expand Down

0 comments on commit e33ffbc

Please sign in to comment.