diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/User.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/User.php index 2006ebd8..e802e8b8 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/User.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/User.php @@ -347,6 +347,12 @@ class User implements UserInterface, \Serializable */ protected $messagesees; + /** + * @ORM\ManyToMany(targetEntity="Cadoles\PortalBundle\Entity\Alert", mappedBy="readers") + */ + protected $alertreaders; + + //== CODE A NE PAS REGENERER /** * @ORM\PostLoad @@ -1883,4 +1889,38 @@ class User implements UserInterface, \Serializable { return $this->niveau01other; } + + /** + * Add alertreader + * + * @param \Cadoles\PortalBundle\Entity\Alert $alertreader + * + * @return User + */ + public function addAlertreader(\Cadoles\PortalBundle\Entity\Alert $alertreader) + { + $this->alertreaders[] = $alertreader; + + return $this; + } + + /** + * Remove alertreader + * + * @param \Cadoles\PortalBundle\Entity\Alert $alertreader + */ + public function removeAlertreader(\Cadoles\PortalBundle\Entity\Alert $alertreader) + { + $this->alertreaders->removeElement($alertreader); + } + + /** + * Get alertreaders + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getAlertreaders() + { + return $this->alertreaders; + } } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/themes/transnum/look.png b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/themes/transnum/look.png index 26c736ac..55d7c216 100644 Binary files a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/themes/transnum/look.png and b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/themes/transnum/look.png differ diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/themes/transnum/transnum-logo.png b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/themes/transnum/transnum-logo.png index 26c736ac..55d7c216 100644 Binary files a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/themes/transnum/transnum-logo.png and b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/themes/transnum/transnum-logo.png differ diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/AlertController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/AlertController.php index 74c2800f..779d853b 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/AlertController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/AlertController.php @@ -126,6 +126,14 @@ class AlertController extends Controller $em = $this->getDoctrine()->getManager(); $data = $form->getData(); + // Si non masquable on s'assure qu'il n'y a pas de reader + if(!$data->getFghideable()) { + $readers=$data->getReaders(); + foreach($readers as $reader) { + $data->removeReader($reader); + } + } + // Sauvegarde $em->persist($data); $em->flush(); @@ -187,6 +195,27 @@ class AlertController extends Controller return $response; } + public function readAction(Request $request) { + $output=array(); + $id=$request->request->get('id'); + + $em = $this->getDoctrine()->getManager(); + $entity = $em->getRepository($this->labelentity)->find($id); + if (!$entity) { + throw $this->createNotFoundException('Unable to find entity.'); + } + + if(!$entity->getReaders()->contains($this->getUser())) { + $entity->addReader($this->getUser()); + $em->persist($entity); + $em->flush(); + } + + $response = new Response(json_encode($output)); + $response->headers->set('Content-Type', 'application/json'); + return $response; + } + protected function getDatas() { $em = $this->getDoctrine()->getManager(); diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php index 5cb7ee85..77b470ed 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php @@ -804,7 +804,7 @@ class PagewidgetController extends Controller } $alertsroles=$qb->getQuery()->getResult(); foreach($alertsroles as $alertrole) { - if(!$alerts->contains($alertrole)) $alerts->add($alertrole); + if(!$alerts->contains($alertrole)&&!$alertrole->getReaders()->contains($this->getUser())) $alerts->add($alertrole); } } @@ -826,8 +826,8 @@ class PagewidgetController extends Controller ->setParameter("alertcategory",$alertcategoryfilter); } $alertsniveau01s=$qb->getQuery()->getResult(); - foreach($alertsniveau01s as $alertsniveau01) { - if(!$alerts->contains($alertsniveau01s)) $alerts->add($alertsniveau01); + foreach($alertsniveau01s as $alertniveau01) { + if(!$alerts->contains($alertniveau01)&&!$alertniveau01->getReaders()->contains($this->getUser())) $alerts->add($alertniveau01); } // Récupération des alerts par group @@ -850,7 +850,7 @@ class PagewidgetController extends Controller } $alertsgroups=$qb->getQuery()->getResult(); foreach($alertsgroups as $alertgroup) { - if(!$alerts->contains($alertgroup)) $alerts->add($alertgroup); + if(!$alerts->contains($alertgroup)&&!$alertgroup->getReaders()->contains($this->getUser())) $alerts->add($alertgroup); } } diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Alert.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Alert.php index fef762ef..f34d4863 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Alert.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Alert.php @@ -60,6 +60,11 @@ class Alert */ protected $unpublishedat; + /** + * @ORM\Column(name="fghideable", type="boolean") + */ + private $fghideable; + /** * @var string * @@ -90,7 +95,15 @@ class Alert * ) */ protected $niveau01s; - + + /** + * @ORM\ManyToMany(targetEntity="Cadoles\CoreBundle\Entity\User", inversedBy="alertreaders", cascade={"persist"}) + * @ORM\JoinTable(name="alertuserread", + * joinColumns={@ORM\JoinColumn(name="alert", referencedColumnName="id")}, + * inverseJoinColumns={@ORM\JoinColumn(name="user", referencedColumnName="id")} + * ) + */ + protected $readers; // Is Online public function isOnline() @@ -390,4 +403,62 @@ class Alert { return $this->niveau01s; } + + /** + * Set fghideable + * + * @param boolean $fghideable + * + * @return Alert + */ + public function setFghideable($fghideable) + { + $this->fghideable = $fghideable; + + return $this; + } + + /** + * Get fghideable + * + * @return boolean + */ + public function getFghideable() + { + return $this->fghideable; + } + + /** + * Add reader + * + * @param \Cadoles\CoreBundle\Entity\User $reader + * + * @return Alert + */ + public function addReader(\Cadoles\CoreBundle\Entity\User $reader) + { + $this->readers[] = $reader; + + return $this; + } + + /** + * Remove reader + * + * @param \Cadoles\CoreBundle\Entity\User $reader + */ + public function removeReader(\Cadoles\CoreBundle\Entity\User $reader) + { + $this->readers->removeElement($reader); + } + + /** + * Get readers + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getReaders() + { + return $this->readers; + } } diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Form/AlertType.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Form/AlertType.php index 30fb1c57..8cf68ba1 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Form/AlertType.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Form/AlertType.php @@ -36,6 +36,11 @@ class AlertType extends AbstractType "config" => array("height" => "500px") ]) + ->add("fghideable",ChoiceType::class,[ + "label" =>"Permettre aux utilisateurs de masquer l'annonce", + "choices" => ["non"=>"0","oui"=>"1"] + ]) + ->add('alertcategory', EntityType::class, [ 'label' => 'Catégorie', 'class' => 'CadolesPortalBundle:Alertcategory', diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/config/routing.yml b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/config/routing.yml index 187670a7..d51f87ff 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/config/routing.yml +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/config/routing.yml @@ -163,6 +163,9 @@ cadoles_portal_config_ajax_alert_seleclist: path: /config/alert/ajax/selectlist defaults: { _controller: CadolesPortalBundle:Alert:ajaxseleclist } +cadoles_portal_user_alert_read: + path: /user/alert/read + defaults: { _controller: CadolesPortalBundle:Alert:read } #== ALERT CATEGORY ======================================================================================================================================= diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Alert/edit.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Alert/edit.html.twig index 676478c3..c836ef1c 100755 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Alert/edit.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Alert/edit.html.twig @@ -46,6 +46,7 @@
{{ form_row(form.title) }} + {{ form_row(form.fghideable) }}
{{ form_row(form.alertcategory) }} diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Page/viewwidget.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Page/viewwidget.html.twig index 8b7735f7..6bd17d2b 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Page/viewwidget.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Page/viewwidget.html.twig @@ -547,7 +547,7 @@ var grid = $('.grid').masonry(optiongrid); } - // Place un message en leur + // Place un message en lu function hideMessage(id) { $.ajax({ method: "POST", @@ -566,4 +566,20 @@ } }); } + + // Place un message en lu + function hideAlert(id) { + $.ajax({ + method: "POST", + url: "{{ path('cadoles_portal_user_alert_read') }}", + data: { + id:id + }, + success: function() { + $("#alert-"+id).remove(); + var grid = $('.grid').masonry(optiongrid); + } + }); + } + {% endblock %} diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewalert.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewalert.html.twig index 460f8d3f..bdeba3b6 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewalert.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewalert.html.twig @@ -32,7 +32,7 @@
{% for alert in alerts %} -
+
-
+
{{ alert.content|raw }}