Skip to content
Snippets Groups Projects
Commit 9441ef6d authored by Pierre Fleutot's avatar Pierre Fleutot
Browse files

Notifs : modif modèle de donénes, création demande amitié

parent 93ad24e8
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@
namespace App\Controller;
use App\Entity\Entry;
use App\Entity\InvitationRequest;
use App\Entity\Notification;
use App\Entity\User;
use App\Form\UserAddFriendType;
......@@ -40,20 +41,18 @@ class FriendController extends AbstractController
*/
public function index(Request $request): Response
{
$newNotificationsSent = $this->doctrine->getManager()->getRepository(Notification::class)->findBy([
$invitationRequestsSent = $this->doctrine->getManager()->getRepository(InvitationRequest::class)->findBy([
'sender' => $this->getUser(),
// 'status' => Notification::STATUS_NEW,
], ['id' => 'DESC']);
$newNotificationsReceived = $this->doctrine->getManager()->getRepository(Notification::class)->findBy([
$invitationRequestsReceived = $this->doctrine->getManager()->getRepository(InvitationRequest::class)->findBy([
'recipient' => $this->getUser(),
// 'status' => Notification::STATUS_NEW,
], ['id' => 'DESC']);
return $this->render('user/showFriends.html.twig', [
'user' => $this->getUser(),
'newNotificationsSent' => $newNotificationsSent,
'newNotificationsReceived' => $newNotificationsReceived,
'invitationRequestsSent' => $invitationRequestsSent,
'invitationRequestsReceived' => $invitationRequestsReceived,
]);
}
......@@ -66,15 +65,21 @@ class FriendController extends AbstractController
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$notification = new Notification(Notification::CATEGORY_FRIEND_INVITATION);
$invitationRequest = new InvitationRequest(InvitationRequest::CATEGORY_FRIEND_INVITATION);
$this->doctrine->getManager()->persist($invitationRequest);
$invitationRequest->setCreatedBy($this->getUser());
$invitationRequest->setSender($this->getUser());
$invitationRequest->setRecipient($form->get('friend')->getData());
$notification = new Notification();
$this->doctrine->getManager()->persist($notification);
$notification->setCreatedBy($this->getUser());
$notification->setSender($this->getUser());
$notification->setRecipient($form->get('friend')->getData());
// $this->getUser()->addMyFriend($form->get('friend')->getData());
$notification->setUser($invitationRequest->getRecipient());
$notification->setContent("Invitation amitié");
$notification->setInvitationRequest($invitationRequest);
$this->doctrine->getManager()->flush();
$this->addFlash('success', "Une notification a été envoyée à l'utilisateur");
$this->addFlash('success', "Une invitation a été envoyée à l'utilisateur");
return $this->redirectToRoute('app_friend_index');
}
......@@ -101,37 +106,46 @@ class FriendController extends AbstractController
}
/**
* @Route("/{id}/remove-friendship-notification", name="app_friend_remove_friendship_notification")
* @Route("/{id}/remove-friendship-invitationRequest", name="app_friend_remove_friendship_invitationRequest")
*/
public function removeFriendshipNotification(Request $request, Notification $notification): Response
public function removeFriendshipInvitationRequest(Request $request, InvitationRequest $invitationRequest): Response
{
$this->doctrine->getManager()->remove($notification);
$this->doctrine->getManager()->remove($invitationRequest);
$this->doctrine->getManager()->flush();
return $this->redirectToRoute('app_friend_index');
}
/**
* @Route("/{id}/deny-friendship-notification", name="app_friend_deny_friendship_notification")
* @Route("/{id}/deny-friendship-invitationRequest", name="app_friend_deny_friendship_invitationRequest")
*/
public function denyFriendshipNotification(Request $request, Notification $notification): Response
public function denyFriendshipInvitationRequest(Request $request, InvitationRequest $invitationRequest): Response
{
$notification->setStatus(Notification::STATUS_READ);
$notification->setAcceptedFriendRequest(false);
$invitationRequest->setStatus(InvitationRequest::STATUS_DENIED);
$notification = new Notification();
$notification->setUser($invitationRequest->getSender());
$notification->setContent("Invitation refusée");
$notification->setInvitationRequest($invitationRequest);
$this->doctrine->getManager()->persist($notification);
$this->doctrine->getManager()->flush();
return $this->redirectToRoute('app_friend_index');
}
/**
* @Route("/{id}/accept-friendship-notification", name="app_friend_accept_friendship_notification")
* @Route("/{id}/accept-friendship-invitationRequest", name="app_friend_accept_friendship_invitationRequest")
*/
public function acceptFriendshipNotification(Request $request, Notification $notification): Response
public function acceptFriendshipInvitationRequest(Request $request, InvitationRequest $invitationRequest): Response
{
$notification->setStatus(Notification::STATUS_READ);
$notification->setAcceptedFriendRequest(true);
$this->getUser()->addMyFriend($notification->getSender());
$invitationRequest->setStatus(InvitationRequest::STATUS_ACCEPTED);
$this->getUser()->addMyFriend($invitationRequest->getSender());
$notification = new Notification();
$notification->setUser($invitationRequest->getSender());
$notification->setContent("Invitation acceptée");
$notification->setInvitationRequest($invitationRequest);
$this->doctrine->getManager()->persist($notification);
$this->doctrine->getManager()->flush();
......
......@@ -64,9 +64,9 @@ class Group
private $labels;
/**
* @ORM\OneToMany(targetEntity=Notification::class, mappedBy="group", cascade={"remove", "persist"})
* @ORM\OneToMany(targetEntity=InvitationRequest::class, mappedBy="group", cascade={"remove", "persist"})
*/
private $notificationsSent;
private $invitationRequestsSent;
public function __toString()
{
......@@ -88,6 +88,7 @@ class Group
$this->addGroupMembership($groupMembership);
$this->labels = new ArrayCollection();
$this->notificationsSent = new ArrayCollection();
$this->invitationRequestsSent = new ArrayCollection();
}
......@@ -285,29 +286,29 @@ class Group
}
/**
* @return Collection<int, Notification>
* @return Collection<int, InvitationRequest>
*/
public function getNotificationsSent(): Collection
public function getInvitationRequestsSent(): Collection
{
return $this->notificationsSent;
return $this->invitationRequestsSent;
}
public function addNotificationsSent(Notification $notificationsSent): self
public function addInvitationRequestsSent(InvitationRequest $invitationRequestsSent): self
{
if (!$this->notificationsSent->contains($notificationsSent)) {
$this->notificationsSent[] = $notificationsSent;
$notificationsSent->setGroup($this);
if (!$this->invitationRequestsSent->contains($invitationRequestsSent)) {
$this->invitationRequestsSent[] = $invitationRequestsSent;
$invitationRequestsSent->setGroup($this);
}
return $this;
}
public function removeNotificationsSent(Notification $notificationsSent): self
public function removeInvitationRequestsSent(InvitationRequest $invitationRequestsSent): self
{
if ($this->notificationsSent->removeElement($notificationsSent)) {
if ($this->invitationRequestsSent->removeElement($invitationRequestsSent)) {
// set the owning side to null (unless already changed)
if ($notificationsSent->getGroup() === $this) {
$notificationsSent->setGroup(null);
if ($invitationRequestsSent->getGroup() === $this) {
$invitationRequestsSent->setGroup(null);
}
}
......
<?php
namespace App\Entity;
use App\Repository\LabelRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use App\Repository\InvitationRequestRepository;
/**
* @ORM\Entity(repositoryClass=InvitationRequestRepository::class)
* @ORM\HasLifecycleCallbacks
*/
class InvitationRequest
{
const STATUS_NEW = "new";
const STATUS_ACCEPTED = "accepted";
const STATUS_DENIED = "denied";
const CATEGORY_FRIEND_INVITATION = 'friend_invitation';
const CATEGORY_GROUP_INVITATION = 'group_invitation';
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=80)
* @Groups({"invitationRequest:read"})
*/
private $category;
/**
* @ORM\Column(type="string", length=80)
* @Groups({"invitationRequest:read"})
*/
private $status;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private $updatedAt;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @Groups({"invitationRequest:read"})
*/
private $createdBy;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="invitationRequestsReceived")
* @Groups({"invitationRequest:read"})
*/
private $recipient;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="invitationRequestsSent")
* @Groups({"invitationRequest:read"})
*/
private $sender;
/**
* @ORM\ManyToOne(targetEntity=Group::class, inversedBy="invitationRequestsSent")
* @Groups({"invitationRequest:read"})
*/
private $group;
/**
* @ORM\OneToMany(targetEntity=Notification::class, mappedBy="invitationRequest")
*/
private $notifications;
public function isAccepted()
{
return $this->getStatus() === self::STATUS_ACCEPTED;
}
public function isDenied()
{
return $this->getStatus() === self::STATUS_DENIED;
}
public function isNew()
{
return $this->getStatus() === self::STATUS_NEW;
}
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function updateTimestamps(): void
{
$this->setUpdatedAt(new \DateTimeImmutable('now'));
if ($this->getCreatedAt() === null) {
$this->setCreatedAt(new \DateTimeImmutable('now'));
}
}
public function __construct($category)
{
$this->status = self::STATUS_NEW;
$this->setCategory($category);
$this->notifications = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCategory(): ?string
{
return $this->category;
}
public function setCategory(string $category): self
{
$this->category = $category;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getCreatedBy(): ?User
{
return $this->createdBy;
}
public function setCreatedBy(?User $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getRecipient(): ?User
{
return $this->recipient;
}
public function setRecipient(?User $recipient): self
{
$this->recipient = $recipient;
return $this;
}
public function getSender(): ?User
{
return $this->sender;
}
public function setSender(?User $sender): self
{
$this->sender = $sender;
return $this;
}
public function getGroup(): ?Group
{
return $this->group;
}
public function setGroup(?Group $group): self
{
$this->group = $group;
return $this;
}
/**
* @return Collection<int, Notification>
*/
public function getNotifications(): Collection
{
return $this->notifications;
}
public function addNotification(Notification $notification): self
{
if (!$this->notifications->contains($notification)) {
$this->notifications[] = $notification;
$notification->setInvitationRequest($this);
}
return $this;
}
public function removeNotification(Notification $notification): self
{
if ($this->notifications->removeElement($notification)) {
// set the owning side to null (unless already changed)
if ($notification->getInvitationRequest() === $this) {
$notification->setInvitationRequest(null);
}
}
return $this;
}
}
......@@ -18,22 +18,6 @@ class Notification
const STATUS_NEW = "new";
const STATUS_READ = "read";
const CATEGORY_UPDATE_REQUEST = 'update_request';
const CATEGORY_FRIEND_INVITATION = 'friend_invitation';
// const CATEGORY_FRIEND_ACCEPT = 'friend_accept';
// const CATEGORY_FRIEND_DENY = 'friend_deny';
const CATEGORY_GROUP_INVITATION = 'group_invitation';
// const CATEGORY_GROUP_ACCEPT = 'group_accept';
// const CATEGORY_GROUP_DENY = 'group_deny';
const CATEGORY_OTHER = 'other';
// const CATEGORY_LIST = [
// self::CATEGORY_UPDATE_REQUEST => self::CATEGORY_UPDATE_REQUEST,
// self::CATEGORY_FRIEND_INVITATION => self::CATEGORY_FRIEND_INVITATION,
// self::CATEGORY_GROUP_INVITATION => self::CATEGORY_GROUP_INVITATION,
// self::CATEGORY_OTHER => self::CATEGORY_OTHER,
// ];
/**
* @ORM\Id
* @ORM\GeneratedValue
......@@ -41,12 +25,6 @@ class Notification
*/
private $id;
/**
* @ORM\Column(type="string", length=80)
* @Groups({"notification:read"})
*/
private $category;
/**
* @ORM\Column(type="string", length=80)
* @Groups({"notification:read"})
......@@ -70,28 +48,10 @@ class Notification
private $updatedAt;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="notifications")
* @Groups({"notification:read"})
*/
private $createdBy;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="notificationsReceived")
* @Groups({"notification:read"})
*/
private $recipient;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="notificationsSent")
* @Groups({"notification:read"})
*/
private $sender;
/**
* @ORM\ManyToOne(targetEntity=Group::class, inversedBy="notificationsSent")
* @Groups({"notification:read"})
*/
private $group;
private $user;
/**
* @ORM\ManyToOne(targetEntity=UpdateRequest::class, inversedBy="notifications")
......@@ -100,24 +60,30 @@ class Notification
private $updateRequest;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $acceptedDuplicate;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $acceptedMerge;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $acceptedFriendRequest;
/**
* @ORM\Column(type="boolean", nullable=true)
* @ORM\ManyToOne(targetEntity=InvitationRequest::class, inversedBy="notifications")
* @Groups({"notification:read"})
*/
private $acceptedGroupInvitation;
private $invitationRequest;
// /**
// * @ORM\Column(type="boolean", nullable=true)
// */
// private $acceptedDuplicate;
//
// /**
// * @ORM\Column(type="boolean", nullable=true)
// */
// private $acceptedMerge;
//
// /**
// * @ORM\Column(type="boolean", nullable=true)
// */
// private $acceptedFriendRequest;
//
// /**
// * @ORM\Column(type="boolean", nullable=true)
// */
// private $acceptedGroupInvitation;
public function isRead()
{
......@@ -136,9 +102,8 @@ class Notification
}
}
public function __construct($category)
public function __construct()
{
$this->setCategory($category);
$this->status = self::STATUS_NEW;
}
......@@ -147,26 +112,26 @@ class Notification
return $this->id;
}
public function getCategory(): ?string
public function getStatus(): ?string
{
return $this->category;
return $this->status;
}
public function setCategory(string $category): self
public function setStatus(string $status): self
{
$this->category = $category;
$this->status = $status;
return $this;
}
public function getStatus(): ?string
public function getContent(): ?string
{
return $this->status;
return $this->content;
}
public function setStatus(string $status): self
public function setContent(?string $content): self
{
$this->status = $status;
$this->content = $content;
return $this;
}
......@@ -195,98 +160,14 @@ class Notification
return $this;
}
public function isAcceptedDuplicate(): ?bool
{
return $this->acceptedDuplicate;
}
public function setAcceptedDuplicate(?bool $acceptedDuplicate): self
{
$this->acceptedDuplicate = $acceptedDuplicate;
return $this;
}
public function isAcceptedMerge(): ?bool
{
return $this->acceptedMerge;
}
public function setAcceptedMerge(?bool $acceptedMerge): self
{
$this->acceptedMerge = $acceptedMerge;
return $this;
}
public function isAcceptedFriendRequest(): ?bool
public function getUser(): ?User
{
return $this->acceptedFriendRequest;
return $this->user;
}
public function setAcceptedFriendRequest(?bool $acceptedFriendRequest): self
public function setUser(?User $user): self
{
$this->acceptedFriendRequest = $acceptedFriendRequest;
return $this;
}
public function isAcceptedGroupInvitation(): ?bool
{
return $this->acceptedGroupInvitation;
}
public function setAcceptedGroupInvitation(?bool $acceptedGroupInvitation): self
{
$this->acceptedGroupInvitation = $acceptedGroupInvitation;
return $this;
}
public function getCreatedBy(): ?User
{
return $this->createdBy;
}
public function setCreatedBy(?User $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getRecipient(): ?User
{
return $this->recipient;
}
public function setRecipient(?User $recipient): self
{
$this->recipient = $recipient;
return $this;
}
public function getSender(): ?User
{
return $this->sender;
}
public function setSender(?User $sender): self
{
$this->sender = $sender;
return $this;
}
public function getGroup(): ?Group
{
return $this->group;
}
public function setGroup(?Group $group): self
{
$this->group = $group;
$this->user = $user;
return $this;
}
......@@ -303,14 +184,14 @@ class Notification
return $this;
}
public function getContent(): ?string
public function getInvitationRequest(): ?InvitationRequest
{
return $this->content;
return $this->invitationRequest;
}
public function setContent(string $content): self
public function setInvitationRequest(?InvitationRequest $invitationRequest): self
{
$this->content = $content;
$this->invitationRequest = $invitationRequest;
return $this;
}
......
......@@ -238,14 +238,19 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
private $chatMessages;
/**
* @ORM\OneToMany(targetEntity=Notification::class, mappedBy="sender", cascade={"remove", "persist"})
* @ORM\OneToMany(targetEntity=Notification::class, mappedBy="user", cascade={"remove", "persist"})
*/
private $notificationsSent;
private $notifications;
/**
* @ORM\OneToMany(targetEntity=Notification::class, mappedBy="sender", cascade={"remove", "persist"})
* @ORM\OneToMany(targetEntity=InvitationRequest::class, mappedBy="recipient", cascade={"remove", "persist"})
*/
private $notificationsReceived;
private $invitationRequestsReceived;
/**
* @ORM\OneToMany(targetEntity=InvitationRequest::class, mappedBy="sender", cascade={"remove", "persist"})
*/
private $invitationRequestsSent;
public function __toString()
{
......@@ -276,8 +281,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
$this->entries = new ArrayCollection();
$this->headwordUserInfos = new ArrayCollection();
$this->chatMessages = new ArrayCollection();
$this->notificationsSent = new ArrayCollection();
$this->notificationsReceived = new ArrayCollection();
$this->notifications = new ArrayCollection();
$this->invitationRequestsReceived = new ArrayCollection();
$this->invitationRequestsSent = new ArrayCollection();
}
public function getInitials()
......@@ -1158,27 +1164,27 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
/**
* @return Collection<int, Notification>
*/
public function getNotificationsSent(): Collection
public function getNotifications(): Collection
{
return $this->notificationsSent;
return $this->notifications;
}
public function addNotificationsSent(Notification $notificationsSent): self
public function addNotification(Notification $notification): self
{
if (!$this->notificationsSent->contains($notificationsSent)) {
$this->notificationsSent[] = $notificationsSent;
$notificationsSent->setSender($this);
if (!$this->notifications->contains($notification)) {
$this->notifications[] = $notification;
$notification->setUser($this);
}
return $this;
}
public function removeNotificationsSent(Notification $notificationsSent): self
public function removeNotification(Notification $notification): self
{
if ($this->notificationsSent->removeElement($notificationsSent)) {
if ($this->notifications->removeElement($notification)) {
// set the owning side to null (unless already changed)
if ($notificationsSent->getSender() === $this) {
$notificationsSent->setSender(null);
if ($notification->getUser() === $this) {
$notification->setUser(null);
}
}
......@@ -1186,32 +1192,63 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
}
/**
* @return Collection<int, Notification>
* @return Collection<int, InvitationRequest>
*/
public function getInvitationRequestsReceived(): Collection
{
return $this->invitationRequestsReceived;
}
public function addInvitationRequestsReceived(InvitationRequest $invitationRequestsReceived): self
{
if (!$this->invitationRequestsReceived->contains($invitationRequestsReceived)) {
$this->invitationRequestsReceived[] = $invitationRequestsReceived;
$invitationRequestsReceived->setRecipient($this);
}
return $this;
}
public function removeInvitationRequestsReceived(InvitationRequest $invitationRequestsReceived): self
{
if ($this->invitationRequestsReceived->removeElement($invitationRequestsReceived)) {
// set the owning side to null (unless already changed)
if ($invitationRequestsReceived->getRecipient() === $this) {
$invitationRequestsReceived->setRecipient(null);
}
}
return $this;
}
/**
* @return Collection<int, InvitationRequest>
*/
public function getNotificationsReceived(): Collection
public function getInvitationRequestsSent(): Collection
{
return $this->notificationsReceived;
return $this->invitationRequestsSent;
}
public function addNotificationsReceived(Notification $notificationsReceived): self
public function addInvitationRequestsSent(InvitationRequest $invitationRequestsSent): self
{
if (!$this->notificationsReceived->contains($notificationsReceived)) {
$this->notificationsReceived[] = $notificationsReceived;
$notificationsReceived->setSender($this);
if (!$this->invitationRequestsSent->contains($invitationRequestsSent)) {
$this->invitationRequestsSent[] = $invitationRequestsSent;
$invitationRequestsSent->setSender($this);
}
return $this;
}
public function removeNotificationsReceived(Notification $notificationsReceived): self
public function removeInvitationRequestsSent(InvitationRequest $invitationRequestsSent): self
{
if ($this->notificationsReceived->removeElement($notificationsReceived)) {
if ($this->invitationRequestsSent->removeElement($invitationRequestsSent)) {
// set the owning side to null (unless already changed)
if ($notificationsReceived->getSender() === $this) {
$notificationsReceived->setSender(null);
if ($invitationRequestsSent->getSender() === $this) {
$invitationRequestsSent->setSender(null);
}
}
return $this;
}
}
<?php
namespace App\Repository;
use App\Entity\InvitationRequest;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<InvitationRequest>
*
* @method InvitationRequest|null find($id, $lockMode = null, $lockVersion = null)
* @method InvitationRequest|null findOneBy(array $criteria, array $orderBy = null)
* @method InvitationRequest[] findAll()
* @method InvitationRequest[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class InvitationRequestRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, InvitationRequest::class);
}
public function add(InvitationRequest $entity, bool $flush = false): void
{
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function remove(InvitationRequest $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
// /**
// * @return InvitationRequest[] Returns an array of InvitationRequest objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('l')
// ->andWhere('l.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('l.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?InvitationRequest
// {
// return $this->createQueryBuilder('l')
// ->andWhere('l.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}
......@@ -28,4 +28,11 @@
</div>
{#{% macro actions(notification) %}#}
{#{% endmacro %}#}
\ No newline at end of file
{#{% endmacro %}#}
{#{% if invitationRequest.read %}#}
{# <button class="btn btn-dark btn-xs"><i class="fa fa-envelope-open"></i></button>#}
{#{% else %}#}
{# <a title="{{ "Marquer comme lu"|trans }}" href="{{ path('app_invitationRequest_mark_as_read', {id: invitationRequest.id}) }}" class="btn btn-xs btn-success"><i class="fa fa-envelope"></i></a>#}
{#{% endif %}#}
\ No newline at end of file
......@@ -28,31 +28,26 @@
</div>
</div>
{% if newNotificationsSent %}
{% if invitationRequestsSent %}
<h3 class="mt-3">{{ "Demandes envoyées"|trans }}</h3>
<div class="card mt-3">
<div class="card-body">
<table class="table table-borderless">
{% for notification in newNotificationsSent %}
{% for invitationRequest in invitationRequestsSent %}
<tr>
<td>{{ notification.createdAt|date('d/m/Y') }}</td>
<td>{{ invitationRequest.createdAt|date('d/m/Y') }}</td>
<td>
<span class="badge bg-secondary"> {{ "Demande envoyée à "|trans }}{{ notification.recipient }}</span>
{% if notification.acceptedFriendRequest is same as true %}
<span class="badge bg-secondary"> {{ "Demande envoyée à "|trans }}{{ invitationRequest.recipient }}</span>
{% if invitationRequest.accepted %}
<span class="badge bg-success">{{ "Acceptée"|trans }}</span>
{% elseif notification.acceptedFriendRequest is same as false %}
{% elseif invitationRequest.accepted %}
<span class="badge bg-success">{{ "Refusée"|trans }}</span>
{% endif %}
</td>
<td class="text-end">
{% if notification.acceptedFriendRequest is null %}
{% if invitationRequest.accepted is null %}
<a data-confirm="{{ "Confirmer la suppression ?"|trans }}" data-bs-toggle="modal" data-bs-target="#confirm-dialog"
data-href="{{ path('app_friend_remove_friendship_notification', {id: notification.id}) }}" class="btn btn-xs btn-danger"><i class="bi-x-circle"></i></a>
{% endif %}
{% if notification.read %}
<button class="btn btn-dark btn-xs"><i class="fa fa-envelope-open"></i></button>
{% else %}
<a title="{{ "Marquer comme lu"|trans }}" href="{{ path('app_notification_mark_as_read', {id: notification.id}) }}" class="btn btn-xs btn-success"><i class="fa fa-envelope"></i></a>
data-href="{{ path('app_friend_remove_friendship_invitationRequest', {id: invitationRequest.id}) }}" class="btn btn-xs btn-danger"><i class="bi-x-circle"></i></a>
{% endif %}
</td>
</tr>
......@@ -62,25 +57,25 @@
</div>
{% endif %}
{% if newNotificationsReceived %}
{% if invitationRequestsReceived %}
<h3 class="mt-3">{{ "Demandes reçues"|trans }}</h3>
<div class="card mt-3">
<div class="card-body">
<table class="table table-borderless">
{% for notification in newNotificationsReceived %}
{% for invitationRequest in invitationRequestsReceived %}
<tr>
<td>{{ notification.createdAt|date('d/m/Y') }}</td>
<td><span class="badge bg-secondary"> {{ "Demande envoyée par "|trans }}{{ notification.sender }}</span></td>
<td>{{ invitationRequest.createdAt|date('d/m/Y') }}</td>
<td><span class="badge bg-secondary"> {{ "Demande envoyée par "|trans }}{{ invitationRequest.sender }}</span></td>
<td class="text-end">
{% if notification.acceptedFriendRequest is null %}
<a href="{{ path('app_friend_accept_friendship_notification', {id: notification.id}) }}" class="btn btn-xs btn-success"><i class="fa fa-check"></i> {{ "Accepter"|trans }}</a>
{% if invitationRequest.new %}
<a href="{{ path('app_friend_accept_friendship_invitationRequest', {id: invitationRequest.id}) }}" class="btn btn-xs btn-success"><i class="fa fa-check"></i> {{ "Accepter"|trans }}</a>
<a data-confirm="{{ "Confirmer le refus ?"|trans }}" data-bs-toggle="modal" data-bs-target="#confirm-dialog"
data-href="{{ path('app_friend_deny_friendship_notification', {id: notification.id}) }}" class="btn btn-xs btn-danger">
data-href="{{ path('app_friend_deny_friendship_invitationRequest', {id: invitationRequest.id}) }}" class="btn btn-xs btn-danger">
<i class="bi-x-circle"></i> {{ "Refuser"|trans }}
</a>
{% elseif notification.acceptedFriendRequest is same as true %}
{% elseif invitationRequest.accepted %}
<span class="badge bg-success">{{ "Acceptée"|trans }}</span>
{% elseif notification.acceptedFriendRequest is same as false %}
{% elseif invitationRequest.denied %}
<span class="badge bg-success">{{ "Refusée"|trans }}</span>
{% endif %}
</td>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment