Problem/Motivation

No events are showing on calendar for any users other than admin.

This is because `CalendarEventsIndex` is checking if user has the permission to view events on the calendar:

      // Check if user has permission to view calendar data for this event type.
      if (!$this->currentUser->hasPermission('view calendar data for any ' . $type . ' event')) {
        continue;
      }

However, this will never be true because those view calendar data permissions do not exist and cannot be assigned to user roles:

In `EventPermissions`:

 public function permissions() {
    $permissions = [];

    if (isset($bundle_name)) {
      foreach (bat_event_get_types() as $bundle_name => $bundle_info) {

        if (!empty($bundle_name)) {
          $permissions['view calendar data for any ' . $bundle_name . ' event'] = [
            'title' => $this->t('View calendar data for any %bundle @entity_type', [
              '@entity_type' => 'events',
              '%bundle' => $bundle_info->label(),
            ]),
          ];
        };
      }
    }

    return $permissions + bat_entity_access_permissions('bat_event');
  }

`$bundle_name` is not set and never will be set, so these permissions will never be created and show on the permissions page.

It looks like this is a bug introduced in commit c96cc726f29c9a383030bf5b25d70679f28d297c in July 2023.

https://git.drupalcode.org/project/bat/-/commit/c96cc726f29c9a383030bf5b...

This will have been broken since `8.x-6.1`.

Steps to reproduce

Use any non-admin user (not user 1 and doesn't have the admistrator role) to view a calendar. You will not see any events.

Proposed resolution

I have a patch that I can attach.

Remaining tasks

Please review patch and commit.

Comments

dtarc created an issue. See original summary.

dtarc’s picture

Here's the patch.

dtarc’s picture

Status: Active » Needs review
afagioli’s picture

Thanks for the patch commited de27ff325d23609cf181ec7bea5ce8d533360256