Commit cc985ef0 authored by nicola85's avatar nicola85

Issue #3021914 by sonixax: Add permissions to manage availability for all nodes or own nodes

parent c76e8727
......@@ -39,9 +39,15 @@ class BeeAvailabilityAccessCheck implements AccessInterface {
$bee_settings = \Drupal::config('node.type.' . $node->bundle())->get('bee');
if (isset($bee_settings['bookable']) && $bee_settings['bookable']) {
if ($account->hasPermission('admin ' . $node->bundle() . ' bee availability')) {
if ($account->hasPermission('manage availability for all ' . $node->bundle() . ' nodes')) {
return AccessResult::allowed();
}
if ($account->hasPermission('manage availability for own ' . $node->bundle() . ' nodes')) {
if ($account->id() == $node->getOwnerId()) {
return AccessResult::allowed();
}
}
}
}
......
......@@ -42,8 +42,12 @@ class BeePermissions implements ContainerInjectionInterface {
$permissions = [];
foreach (entity_get_bundles('node') as $bundle_name => $bundle_info) {
$permissions['admin ' . $bundle_name . ' bee availability'] = [
'title' => t('Admin %bundle bee availability', ['%bundle' => $bundle_info['label']]),
$permissions['manage availability for all ' . $bundle_name . ' nodes'] = [
'title' => t('Manage availability for all %bundle nodes', ['%bundle' => $bundle_info['label']]),
];
$permissions['manage availability for own ' . $bundle_name . ' nodes'] = [
'title' => t('Manage availability for own %bundle nodes', ['%bundle' => $bundle_info['label']]),
];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment