From 910350699d3d655f871bb8583083f0eacad8024f Mon Sep 17 00:00:00 2001 From: naomi Date: Mon, 9 Jul 2018 20:15:16 +0200 Subject: [PATCH] Added 'view label' access bypass to actors Was therefore able to get rid of the "view volunteer involvement in cases" stuff which was complicated --- .../opencase_entities.permissions.yml | 4 ---- .../src/OCActorAccessControlHandler.php | 12 ++++++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/modules/opencase_entities/opencase_entities.permissions.yml b/modules/opencase_entities/opencase_entities.permissions.yml index f07a6b8..101d899 100644 --- a/modules/opencase_entities/opencase_entities.permissions.yml +++ b/modules/opencase_entities/opencase_entities.permissions.yml @@ -33,10 +33,6 @@ delete all client revisions: title: 'Delete all Client revisions' description: 'Role requires permission to view Client revisions and delete rights for client entities in question or administer client entities.' -view volunteer involvement in cases: - title: 'View names of Volunteers involved in Cases' - description: "When viewing a case record, they can see the names of the volunteers involved, but cannot click through to volunteer's details." - add volunteer entities: title: 'Create new Volunteer entities' diff --git a/modules/opencase_entities/src/OCActorAccessControlHandler.php b/modules/opencase_entities/src/OCActorAccessControlHandler.php index cf1a8ae..622b7fc 100644 --- a/modules/opencase_entities/src/OCActorAccessControlHandler.php +++ b/modules/opencase_entities/src/OCActorAccessControlHandler.php @@ -14,6 +14,9 @@ use Drupal\Core\Access\AccessResult; */ class OCActorAccessControlHandler extends EntityAccessControlHandler { + + protected $viewLabelOperation = TRUE; + /** * {@inheritdoc} * Permissions are assigned by bundle. @@ -22,21 +25,18 @@ class OCActorAccessControlHandler extends EntityAccessControlHandler { protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { /** @var \Drupal\opencase_entities\Entity\OCActorInterface $entity */ $bundle = $entity->bundle(); - $route_name = \Drupal::routeMatch()->getRouteName(); - $case_routes = ['entity.oc_case.canonical', 'entity.oc_case.edit_form', 'view.cases.page_1', 'entity.oc_case.add_form']; - $is_case_context = in_array($route_name, $case_routes); - switch ($operation) { + case 'view label': + return AccessResult::allowed(); + case 'view': if (!$entity->isPublished()) { return AccessResult::allowedIf( $account->hasPermission("view unpublished $bundle entities") - or ($is_case_context && $account->hasPermission("view unpublished $bundle entities")) ); } return AccessResult::allowedIf( $account->hasPermission("view published $bundle entities") - or ($is_case_context && $account->hasPermission("view $bundle involvement in cases")) ); case "update":