mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
some data in msgraph synchro and answer on calendar invite
This commit is contained in:
@@ -26,6 +26,7 @@ use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use LogicException;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
@@ -212,7 +213,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
public function addUser(User $user): self
|
||||
{
|
||||
if (!$this->getUsers()->contains($user)) {
|
||||
if (!$this->getUsers()->contains($user) && $this->getMainUser() !== $user) {
|
||||
$this->addInvite((new Invite())->setUser($user));
|
||||
}
|
||||
|
||||
@@ -263,6 +264,21 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getInviteForUser(User $user): ?Invite
|
||||
{
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('user', $user));
|
||||
|
||||
$matchings = $this->invites
|
||||
->matching($criteria);
|
||||
|
||||
if (1 === $matchings->count()) {
|
||||
return $matchings->first();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Invite[]
|
||||
*/
|
||||
@@ -365,6 +381,18 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
||||
return null !== $this->calendarRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* return true if the user is invited.
|
||||
*/
|
||||
public function isInvited(User $user): bool
|
||||
{
|
||||
if ($this->getMainUser() === $user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getUsers()->contains($user);
|
||||
}
|
||||
|
||||
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||
{
|
||||
$metadata->addPropertyConstraint('startDate', new NotBlank());
|
||||
@@ -485,6 +513,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
||||
}
|
||||
|
||||
$this->mainUser = $mainUser;
|
||||
$this->removeUser($mainUser);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
Reference in New Issue
Block a user