diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PageController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PageController.php index a106066a..5a09780f 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PageController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PageController.php @@ -478,7 +478,7 @@ class PageController extends Controller } // On marque tt les messages comme lu par l'utilisateur - + /* Se fait à présent sur le controleur message au moment meme où l'on affiche l'ensemble des messages if($usage=="group") { // On calcule le nombre de message non lu pour le groupe $group=$em->getRepository("CadolesCoreBundle:Group")->find($groupid); @@ -513,6 +513,7 @@ class PageController extends Controller } } } + */ // Type Calendrier diff --git a/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Controller/ChatController.php b/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Controller/ChatController.php index c4407118..ef63a8ab 100644 --- a/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Controller/ChatController.php +++ b/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Controller/ChatController.php @@ -57,6 +57,16 @@ class ChatController extends Controller // Récupération des message du groupe $messages=$em->getRepository("CadolesWebsocketBundle:Message")->findBy(["group"=>$group],["submitdate"=>"DESC"],100); + foreach($messages as $message) { + $haveread = ($message->getReaders()->contains($user)); + $message->setHaveread($haveread); + + if(!$haveread) { + $message->addReader($this->getUser()); + $em->persist($message); + $em->flush(); + } + } // Création du formulaire $form = $this->createForm(ChatType::class,null,[]); diff --git a/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Entity/Message.php b/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Entity/Message.php index 5b15d9b0..55ac5444 100644 --- a/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Entity/Message.php +++ b/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Entity/Message.php @@ -58,6 +58,18 @@ class Message */ protected $sees; + + /* champs calculé non stocké en base */ + private $haveread; + public function getHaveread() + { + return $this->haveread; + } + public function setHaveread($haveread) { + $this->haveread = $haveread; + + return $this; + } /** * Constructor diff --git a/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Resources/views/Chat/client.html.twig b/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Resources/views/Chat/client.html.twig index 48ac77ff..4b1b9d92 100644 --- a/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Resources/views/Chat/client.html.twig +++ b/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Resources/views/Chat/client.html.twig @@ -23,6 +23,10 @@ background-color: #{{ colorbodyback }}; color: #{{ colorbodyfont }}; } + .message-toread { + font-weight:bold; + } + .msgavatar { float:left; height:40px; @@ -65,7 +69,11 @@