Commit 41048477 authored by Mingsong's avatar Mingsong Committed by Mingsong Hu

Issue #3018138 by Andrew211, Mingsong, jotwede: Permissions Issues - Add event...

Issue #3018138 by Andrew211, Mingsong, jotwede: Permissions Issues - Add event doesn't show on calendar front end despite giving user permissions to create events
parent a159a7aa
......@@ -52,8 +52,10 @@ function template_preprocess_views_view_fullcalendar(array &$variables) {
}
// Can the user add a new event?
$entity_manager = \Drupal::entityTypeManager();
$access_handler = $entity_manager->getAccessControlHandler($entity_type->id());
$dbl_click_to_create = FALSE;
if (!empty($user) && $user->hasPermission(strtolower("create $event_bundle_type " . $entity_type->getLabel()))) {
if ($access_handler->createAccess($event_bundle_type)) {
$dbl_click_to_create = TRUE;
}
// Pass entity type to twig template.
......
......@@ -220,23 +220,22 @@ class CalendarEventController extends ControllerBase {
* A event entity form render array
*/
public function addEvent(Request $request) {
$entity_id = $request->get('entity', '');
$type = $request->get('bundle', '');
$entity_type_id = $request->get('entity', '');
$bundle = $request->get('bundle', '');
$start_field = $request->get('start_field', '');
$end_field = $request->get('end_field', '');
$form = [];
if (!empty($type) && !empty($entity_id)) {
$entity_label = $this->entityTypeManager()->getDefinition($entity_id)->getLabel();
$user = $this->currentUser();
if (!empty($bundle) && !empty($entity_type_id)) {
$access_control_handler = $this->entityTypeManager()->getAccessControlHandler($entity_type_id);
// Check the user permission.
if (!empty($user) && $user->hasPermission(strtolower("create $type " . $entity_label))) {
if ($access_control_handler->createAccess($bundle)) {
$data = [
'type' => $type,
'type' => $bundle,
];
// Create a new event entity for this form.
$entity = $this->entityTypeManager()
->getStorage($entity_id)
->getStorage($entity_type_id)
->create($data);
if (!empty($entity)) {
......
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