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/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/IconController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/IconController.php index 3ef5ba5a..be8974f4 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/IconController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/IconController.php @@ -32,7 +32,7 @@ class IconController extends Controller return $this->render($this->labelentity.':list.html.twig',[ 'useheader' => !($inframe), 'usemenu' => false, - 'usesidebar' => ($access=="config"), + 'usesidebar' => ($access=="config"&&!$inframe), 'access' => $access, $this->labeldatas => $icons, 'inframe' => $inframe @@ -74,7 +74,7 @@ class IconController extends Controller return $this->render($this->labelentity.':edit.html.twig', [ 'useheader' => !($inframe), 'usemenu' => false, - 'usesidebar' => ($access=="config"), + 'usesidebar' => ($access=="config"&&!$inframe), 'access' => $access, $this->labeldata => $data, 'mode' => 'submit', @@ -119,7 +119,7 @@ class IconController extends Controller return $this->render($this->labelentity.':edit.html.twig', [ 'useheader' => !($inframe), 'usemenu' => false, - 'usesidebar' => ($access=="config"), + 'usesidebar' => ($access=="config"&&!$inframe), 'access' => $access, $this->labeldata => $data, 'mode' => 'update', 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/Entity/Icon.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Icon.php index a7a75e53..a06b708c 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Icon.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Icon.php @@ -27,6 +27,11 @@ class Icon */ private $label; + /** + * @ORM\Column(type="string", length=250, nullable=true) + */ + private $tags; + /** * @ORM\ManyToOne(targetEntity="Cadoles\CoreBundle\Entity\User", inversedBy="icons") * @ORM\JoinColumn(nullable=true) @@ -398,4 +403,28 @@ class Icon { return $this->groups; } + + /** + * Set tags + * + * @param string $tags + * + * @return Icon + */ + public function setTags($tags) + { + $this->tags = $tags; + + return $this; + } + + /** + * Get tags + * + * @return string + */ + public function getTags() + { + return $this->tags; + } } 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/Form/IconType.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Form/IconType.php index c20aba58..40846a03 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Form/IconType.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Form/IconType.php @@ -34,6 +34,11 @@ class IconType extends AbstractType "disabled" => ($options["mode"]=="delete"?true:false) ) ); + + $builder->add('tags', TextType::class, [ + 'label' => 'Tags', + 'required' => false + ]); } public function configureOptions(OptionsResolver $resolver) 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/Alertcategory/edit.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Alertcategory/edit.html.twig index 2a2f0045..a5f80c5d 100755 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Alertcategory/edit.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Alertcategory/edit.html.twig @@ -57,49 +57,31 @@
- {{ form_end(form) }} {% endblock %} {% block localjavascript %} - function selIcon(idicon) { + function selIcon(idicon,label) { $("#alertcategory_idicon").val(idicon); $("#diviconsel img").remove(); - $("#icon-"+idicon).clone().appendTo($("#diviconsel")); + url="/{{ alias }}/"+label; + $("#diviconsel").append(""); $("#diviconsel img").attr("height","100px"); - $('#selicon').modal('hide'); + $("#mymodal").modal("hide"); + } + + function selectIcon() { + $("#mymodal").find(".modal-title").html("SELECTIONNER UNE ICONE"); + var url="{{ path('cadoles_portal_config_icon_select') }}"; + $("#mymodal").find("#framemodal").attr("src",url); + $("#mymodal").modal("show"); } function delIcon() { diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Bookmark/edit.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Bookmark/edit.html.twig index be282445..b60f448f 100755 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Bookmark/edit.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Bookmark/edit.html.twig @@ -69,51 +69,11 @@
{{ form_row(form.idicon) }} - Selectionner une Icône + Selectionner une Icône Détacher l'Icône
- - {{ form_end(form) }} {% endblock %} @@ -126,13 +86,21 @@ showhide(); }); - function selIcon(idicon) { + function selIcon(idicon,label) { $("#bookmark_idicon").val(idicon); $("#diviconsel img").remove(); - $("#icon-"+idicon).clone().appendTo($("#diviconsel")); + url="/{{ alias }}/"+label; + $("#diviconsel").append(""); $("#diviconsel img").attr("height","100px"); - $('#selicon').modal('hide'); + $("#mymodal").modal("hide"); + } + + function selectIcon() { + $("#mymodal").find(".modal-title").html("SELECTIONNER UNE ICONE"); + var url="{{ path('cadoles_portal_user_icon_select') }}"; + $("#mymodal").find("#framemodal").attr("src",url); + $("#mymodal").modal("show"); } function delIcon() { diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Icon/edit.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Icon/edit.html.twig index 1a4fead2..b518cd5f 100755 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Icon/edit.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Icon/edit.html.twig @@ -53,6 +53,13 @@ {{ form_widget(form.label) }} Modifier + +
+ Privilégiez des images carrées de minimum 90px par 90px et avec un fond transparent +
+ + {{ form_row(form.tags) }} + {{ form_end(form) }} diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Icon/select.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Icon/select.html.twig index 3a5bbdcd..5b960048 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Icon/select.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Icon/select.html.twig @@ -2,31 +2,73 @@ {% block pagewrapper %}
+ +
Fermer {% if access=="user" %} Gérer mes Icônes + {% else %} + Gérer les Icônes {% endif %}
+ + + {% if iconsuser is not empty %}

Mes Icônes

- {% for icon in iconsuser %} - - - + {% for icon in iconsuser %} + {% set tag = "" %} + {% if icon.tags %} + {% set tag = icon.tags %} + {% endif %} + {% if icon.label starts with 'uploads/icon/icon_' %} + {% set tag = tag ~ icon.label|replace({'uploads/icon/icon_':'', '.png':''}) %} + {% endif %} + + {% endfor %}

Icônes Communs

{% endif %} {% for icon in icons %} - - - + {% set tag = "" %} + {% if icon.tags %} + {% set tag = icon.tags %} + {% endif %} + {% if icon.label starts with 'uploads/icon/icon_' %} + {% set tag = tag ~ icon.label|replace({'uploads/icon/icon_':'', '.png':''}) %} + {% endif %} + {% endfor %}
{% endblock %} +{% block localjavascript %} + $('document').ready(function(){ + $( "#icon_search" ).focus(); + }); + + $( "#icon_search" ).on("keyup", function() { + if($( "#icon_search" ).val()=="") + $(".grid-item-img").show(); + else { + tags=$( "#icon_search" ).val().toLowerCase().split(' '); + + $(".grid-item-img").hide(); + tags.forEach(function(tag){ + $(".grid-item-img").each(function(index) { + icontags=$( this ).attr("data"); + if (typeof icontags !== 'undefined') { + if(icontags.includes(tag)) $(this).show(); + } + }); + }); + } + }); +{% endblock %} + diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Item/edit.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Item/edit.html.twig index 29ad6d25..c09e4bfe 100755 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Item/edit.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Item/edit.html.twig @@ -71,37 +71,10 @@
{{ form_row(form.idicon) }} - Selectionner une Icône + Selectionner une Icône Détacher l'Icône
- - - {{ form_end(form) }} {% endblock %} @@ -115,15 +88,24 @@ showhide(); }); - function selIcon(idicon) { + function selIcon(idicon,label) { $("#item_idicon").val(idicon); $("#diviconsel img").remove(); - $("#icon-"+idicon).clone().appendTo($("#diviconsel")); + url="/{{ alias }}/"+label; + $("#diviconsel").append(""); $("#diviconsel img").attr("height","100px"); - $('#selicon').modal('hide'); + $("#mymodal").modal("hide"); } + function selectIcon() { + $("#mymodal").find(".modal-title").html("SELECTIONNER UNE ICONE"); + var url="{{ path('cadoles_portal_config_icon_select') }}"; + $("#mymodal").find("#framemodal").attr("src",url); + $("#mymodal").modal("show"); + } + + function delIcon() { $("#diviconsel img").remove(); $("#item_idicon").val(null); 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/edit.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/edit.html.twig index bae13ed4..606b7f14 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/edit.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/edit.html.twig @@ -61,7 +61,7 @@
{{ form_row(form.idicon) }} - Selectionner une Icône + Selectionner une Icône
@@ -88,46 +88,6 @@ {{ form_widget(form) }} - {{ form_end(form) }} {% endblock %} @@ -155,13 +115,22 @@ }); }); - function selIcon(idicon) { + function selIcon(idicon,label) { $("#pagewidget_idicon").val(idicon); $("#diviconsel img").remove(); - $("#icon-"+idicon).clone().appendTo($("#diviconsel")); + url="/{{ alias }}/"+label; + $("#diviconsel").append(""); $("#diviconsel img").attr("height","100px"); - $('#selicon').modal('hide'); - } + $("#mymodal").modal("hide"); + } + + function selectIcon() { + $("#mymodal").find(".modal-title").html("SELECTIONNER UNE ICONE"); + var url="{{ path('cadoles_portal_user_icon_select') }}"; + $("#mymodal").find("#framemodal").attr("src",url); + $("#mymodal").modal("show"); + } + {% endblock %} \ No newline at end of file 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 }}