Can't add new event with double-click without article permission

Created on 3 July 2025, 16 days ago

Problem/Motivation

I created a calendar using a new content type 'event'. If I give a role 'Create new content' permission for 'event', I can't double-click on a day to add a new event. Seems that accessManager permission check is hard-coded for node_type 'article' on line 328 of src/Plugin/views/style/FullCalendar.php:

// Drupal events.
$events = $this->prepareEvents();
if ($events) {
  $settings['options']['eventSources'][] = $events;
}
$settings['entityType'] = $this->view->getBaseEntityType()->id();
if (!empty($settings['bundle_type'])) {
  // Can the user add a new event?
  if ($settings['entityType'] === 'node') {
    if ($this->accessManager->checkNamedRoute('node.add', ['node_type' => 'article'])) {
      $settings['addLink'] = 'node/add/' . $settings['bundle_type'];
    }
  }
  else {
    $entity_type = $this->view->getBaseEntityType();
    $entity_links = $entity_type->get('links');
    if (isset($entity_links['add-form'])) {
      $settings['addLink'] = str_replace('{' . $entity_type->id() . '}', $settings['bundle_type'], $entity_links['add-form']);
    }
    elseif (isset($entity_links['add-page'])) {
      $settings['addLink'] = str_replace('{' . $entity_type->id() . '}', $settings['bundle_type'], $entity_links['add-page']);
    }
  }
}

Proposed resolution

Change the accessManager check to take into account other content types. I have a patch that works; I'll create a fork.

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mkindred

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024