Only those with "administer users" can link actor
This commit is contained in:
parent
48dabf1701
commit
09650469bf
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use Drupal\Core\Routing\RouteMatchInterface;
|
use Drupal\Core\Routing\RouteMatchInterface;
|
||||||
|
use Drupal\Core\Access\AccessResult;
|
||||||
use Drupal\opencase\EntityTypeRelationsWidget;
|
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.edit_form',
|
||||||
'entity.oc_activity.add_form'
|
'entity.oc_activity.add_form'
|
||||||
];
|
];
|
||||||
return \Drupal\Core\Access\AccessResult::forbiddenIf(!in_array($route_name, $routes_where_it_should_be_shown))
|
return AccessResult::forbiddenIf(!in_array($route_name, $routes_where_it_should_be_shown))->addCacheableDependency($block);
|
||||||
->addCacheableDependency($block);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// No opinion.
|
// 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;
|
$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();
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user