Only those with "administer users" can link actor

This commit is contained in:
naomi 2018-07-18 12:06:22 +02:00
parent 48dabf1701
commit 09650469bf

View File

@ -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();
}