diff --git a/opencase.module b/opencase.module index ffe8880..f858259 100644 --- a/opencase.module +++ b/opencase.module @@ -6,6 +6,7 @@ */ use Drupal\Core\Routing\RouteMatchInterface; +use Drupal\Core\Access\AccessResult; use Drupal\opencase\EntityTypeRelationsWidget; @@ -30,12 +31,11 @@ function opencase_block_access(\Drupal\block\Entity\Block $block, $operation, \D 'entity.oc_activity.edit_form', 'entity.oc_activity.add_form' ]; - return \Drupal\Core\Access\AccessResult::forbiddenIf(!in_array($route_name, $routes_where_it_should_be_shown)) - ->addCacheableDependency($block); + return AccessResult::forbiddenIf(!in_array($route_name, $routes_where_it_should_be_shown))->addCacheableDependency($block); } // No opinion. - return \Drupal\Core\Access\AccessResult::neutral(); + return AccessResult::neutral(); } @@ -155,3 +155,13 @@ function opencase_views_pre_render($view) { $view->exposed_widgets = NULL; } } + + +function opencase_entity_field_access($operation, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $account, $items = NULL) { + if ($field_definition->getName() == 'field_linked_opencase_actor' + && $operation == 'edit' + && !$account->hasPermission('administer users')) { + return AccessResult::forbidden(); + } + return AccessResult::neutral(); +}