Allow for User with inviter_id (Member id) in selected context

@param User $user Currently authenticated User
@param MemberInvitation $memberInvitation MemberInvitation affected
@return boolean
543953
public function update(User $user, MemberInvitation $memberInvitation)
    {
        return $user->selected_context->id === $memberInvitation->inviter_id;
    }
827604
public function ReduceInviteCount($UserID, $ReduceBy = 1) {
      $CurrentCount = $this->GetInvitationCount($UserID);

      // Do not reduce if the user has unlimited invitations
      if ($CurrentCount == -1)
         return TRUE;

      // Do not reduce the count below zero.
      if ($ReduceBy > $CurrentCount)
         $ReduceBy = $CurrentCount;

      $this->SQL->Update($this->Name)
         ->Set('CountInvitations', 'CountInvitations - '.$ReduceBy, FALSE)
         ->Where('UserID', $UserID)
         ->Put();
   }
117271
public function bindUser(User $user, $binding)
    {
        return $this->bindUserID(intval($user->getUserID(), 10), $binding);
    }
959252
public function addInvitationsMenuItem(UserMenuCollectionEvent $event): void
    {
        // Get the menu from the event.
        $menu = $event->getMenu();

        // Lookup and count pending invitations.
        $repo = $this->em->getRepository(Invitation::class);
        $user = $this->token_storage->getToken()->getUser();
        $invitations = $repo->findPendingInvitations($user);

        // Create the pending invitations menu link.
        $invitations = $this->factory->createItem('menu_item.pending_invitations', [
            'route' => 'bkstg_invitation_index',
            'extras' => [
                'badge_count' => count($invitations),
                'translation_domain' => BkstgScheduleBundle::TRANSLATION_DOMAIN,
            ],
        ]);
        $menu->addChild($invitations);
    }
183782
def invite_user(self, user_id):
        
        try:
            self.client.api.invite_user(self.room_id, user_id)
            return True
        except MatrixRequestError:
            return False
1331320
public function view(User $user, Page $page)
    {

        if ($user->canDo('page.page.view')) {
            return true;
        }

        return $user->id == $page->user_id;
    }
1220066
def sendUserInvitationRevoked(self, context={}):
    
    organization, invited, invitator = context['invite'].organization, context['invite'].invited, context['invite'].invitator
    # invited user email
    self.__init__(organization, async_mail=self.async_mail, override_receiver=invited.email, locale=invited.locale)
    self.sendEmail('userInvitedRevoked-toUser', 'Your invitation to an organization has been revoked', context)

    if organization.owner == invitator:
      self.__init__(organization, async_mail=self.async_mail, override_receiver=organization.owner.email, locale=organization.owner.locale)
      self.sendEmail('userInvitedRevoked-toOwnerInviter', 'You have revoked an user invitation', context)
    else:
      self.__init__(organization, async_mail=self.async_mail, override_receiver=organization.owner.email, locale=organization.owner.locale)
      self.sendEmail('userInvitedRevoked-toOwner', 'An invitation to join your organization has been revoked', context)

      self.__init__(organization, async_mail=self.async_mail, override_receiver=invitator.email, locale=invitator.locale)
      self.sendEmail('userInvitedRevoked-toMemberInviter', 'You have revoked an user invitation', context)
556950
def get_user_invitation_by_id(self, id):
        """"""
        return self.db_adapter.get_object(self.UserInvitationClass, id=id)
1175585
def add_user_invitation(self, **kwargs):
        """"""
        user_invitation = self.UserInvitationClass(**kwargs)
        self.db_adapter.add_object(user_invitation)
        return user_invitation
552012
@Override
    public SendInvitation invitees(ApiBaseUser... users) {
        this.invitees.addAll(Arrays.asList(users));
        return this;
    }
476553
public function makeResponsible(Event $event, User $user)
    {
        $this->authorize('update', $event);
        $event->addResponsible($user);

        return redirect()->route('laralum::events.show', ['event' => $event->id])
            ->with('success', __('laralum_events::general.responsible_added', ['event_id' => $event->id, 'user_id' => $user->id]));
    }
204842
private function checkEdit(TokenInterface $token, User $user)
    {
        //the user can edit himself too.
        //He just can add roles and stuff and this should be checked later
        if ($token->getUser() === $user) {
            return true;
        }

        return $this->isOrganizationManager($token, $user) ?
            VoterInterface::ACCESS_GRANTED : VoterInterface::ACCESS_DENIED;
    }
999470
public function detachMemberTagMember(User $user, Member $member)
    {
        return $user->selected_context->id === $member->id;
    }
1312122
public function byInvitationAction(Request $request, $userClass)
    {
        $invitationToken = $request->query->get('token');
        try {
            // we need to know if the invitation token given exists in
            // database, in case that it isn't, it throws 404.
            $user = $this->get('bengor_user.' . $userClass . '.by_invitation_token_query')->__invoke(
                new UserOfInvitationTokenQuery($invitationToken)
            );
        } catch (UserDoesNotExistException $exception) {
            return new JsonResponse(null, 404);
        } catch (UserTokenExpiredException $exception) {
            return new JsonResponse(null, 404);
        } catch (\InvalidArgumentException $exception) {
            return new JsonResponse(null, 404);
        }

        $form = $this->get('form.factory')->createNamedBuilder('', SignUpByInvitationType::class, null, [
            'roles'            => $this->getParameter('bengor_user.' . $userClass . '_default_roles'),
            'invitation_token' => $invitationToken,
            'csrf_protection'  => false,
        ])->getForm();

        $form->handleRequest($request);
        if ($form->isValid()) {
            $commandBus = $this->get('bengor_user.' . $userClass . '.api_command_bus');

            try {
                $commandBus->handle(
                    $form->getData()
                );
                $commandBus->handle(
                    new LogInUserCommand(
                        $user['email'],
                        $form->getData()->password()
                    )
                );
            } catch (UserDoesNotExistException $exception) {
                return new JsonResponse(null, 404);
            } catch (UserInactiveException $exception) {
                return new JsonResponse(null, 404);
            } catch (UserPasswordInvalidException $exception) {
                return new JsonResponse('Bad credentials', 400);
            } catch (UserAlreadyExistException $exception) {
                return new JsonResponse('Bad credentials', 400);
            }
            $token = $this->get('lexik_jwt_authentication.encoder.default')->encode(['email' => $user['email']]);

            return new JsonResponse(['token' => $token]);
        }

        return new JsonResponse(FormErrorSerializer::errors($form), 400);
    }
1223112
public function attachUser($user, $reload = true)
    {
        if ($this->hasUser($user)) return;

        event(new AttachingUserToRole($this, $user));
        $this->users()->attach($user);
        event(new AttachedUserToRole($this, $user));

        $this->loadUsers($reload);
    }
1275416
public function setClientUser($client_id, $user_id)
    {
        if ($this->getClientUser($client_id, $user_id)) {
            return true;
        } else {
            $created_at = date('Y-m-d H:i:s');
            $sql        = 'INSERT INTO %s (client_id, user_id, created_at) VALUES (:client_id, :user_id, :created_at)';
            $sql        = sprintf($sql, $this->config['client_user_table']);

            $params = array_map('trim', compact('client_id', 'user_id', 'created_at'));

            return $this->db->prepare($sql)->execute($params);
        }
    }
1198055
function(user) {
      if (!this._shouldAllowUser(user)) {
        return false;
      }
      user.leaveRoom();
      this.members.push(user);
      user.room = this;
      if (this.minRoomMembers !== null &&
          this.members.length >= this.minRoomMembers) {
        this._hasReachedMin = true;
      }
      this._emitEvent('newMember', this, user);
      this._serverMessageMembers(this.isLobby ? 'lobbyMemberJoined' : 'roomMemberJoined', _.pick(user, 'id', 'name'));
      user._serverMessage('joinedRoom', _.pick(this, 'name'));
      return true;
    }