From 14ff4e959cca81800596a63ea0492085cd46d5ba Mon Sep 17 00:00:00 2001 From: Nikolay Lobachev <nikolay.lobachev@gmail.com> Date: Tue, 3 Oct 2023 00:42:17 +0200 Subject: [PATCH] Issue #3293317 by LOBsTerr: Users cannot see the name of the Group that they were invited --- ginvite.module | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ginvite.module b/ginvite.module index 922df26..0578079 100644 --- a/ginvite.module +++ b/ginvite.module @@ -6,9 +6,12 @@ */ use Drupal\Component\Utility\Html; +use Drupal\Core\Access\AccessResult; +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\BubbleableMetadata; use Drupal\Core\Routing\RouteMatchInterface; +use Drupal\Core\Session\AccountInterface; use Drupal\Core\Url; use Drupal\ginvite\Event\UserLoginWithInvitationEvent; use Drupal\ginvite\Event\UserRegisteredFromInvitationEvent; @@ -464,3 +467,23 @@ function ginvite_user_login(UserInterface $user) { $event_dispatcher->dispatch($event, UserLoginWithInvitationEvent::EVENT_NAME); } } + +/** + * Implements hook_ENTITY_TYPE_access(). + */ +function ginvite_group_access(EntityInterface $entity, $operation, AccountInterface $account) { + if ($operation == 'view' || $operation == 'view label') { + $properties = [ + 'entity_id' => $account->id(), + 'gid' => $entity->id(), + 'invitation_status' => GroupInvitation::INVITATION_PENDING, + ]; + + $invitations = \Drupal::service('ginvite.invitation_loader')->loadByProperties($properties); + if (!empty($invitations)) { + return AccessResult::allowed(); + } + } + + return AccessResult::neutral(); +} -- GitLab