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.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mkindred created an issue. See original summary.

mkindred’s picture

Fork created, changing:

if ($this->accessManager->checkNamedRoute('node.add', ['node_type' => 'article'])) {

to:

if ($this->accessManager->checkNamedRoute('node.add', ['node_type' => $settings['bundle_type']])) {
mkindred’s picture

Title: Can't add new event with double-click without article permission » Can't add new event via double-click without article permission

mandclu made their first commit to this issue’s fork.

  • mandclu committed 08501c78 on 3.0.x
    Issue #3533971 by mkindred, mandclu: Can't add new event via double-...
mandclu’s picture

Status: Active » Fixed

Thanks for identifying this, and for providing a fix. Merged in.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.