notification sur chat creation/modification fichier+article+event+lien (fixes #4)

This commit is contained in:
afornerot 2019-08-19 14:09:46 +02:00
parent 0f01430d81
commit f93b2980b2
7 changed files with 86 additions and 12 deletions

View File

@ -1,26 +1,28 @@
<?php <?php
namespace Cadoles\CoreBundle\EventListener; namespace Cadoles\CoreBundle\EventListener;
use Doctrine\Common\Persistence\ObjectManager; use Doctrine\ORM\EntityManager;
use Oneup\UploaderBundle\Event\PostPersistEvent; use Oneup\UploaderBundle\Event\PostPersistEvent;
use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\File\File; use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\DependencyInjection\ContainerInterface as Container;
class uploadListener class uploadListener
{ {
/** private $em;
* @var ObjectManager
*/
private $om;
private $session; private $session;
private $token;
private $container;
public function __construct(ObjectManager $om, TokenStorageInterface $token_storage, Session $session) public function __construct(EntityManager $em, TokenStorageInterface $token_storage, Session $session, Container $container)
{ {
$this->om = $om; $this->em = $em;
$this->session = $session; $this->session = $session;
$this->token = $token_storage;
$this->container = $container;
} }
protected function getHeight($image) { protected function getHeight($image) {
@ -98,6 +100,8 @@ class uploadListener
// Déplacer le fichier dans la cible // Déplacer le fichier dans la cible
$request = $event->getRequest(); $request = $event->getRequest();
$directory = $request->get('directory'); $directory = $request->get('directory');
$fs = new Filesystem();
$fgexit=$fs->exists($pathname."/".$directory."/".$filename);
$file->move($pathname."/".$directory, $filename); $file->move($pathname."/".$directory, $filename);
// Création d'un thumb dans le cas d'un fichier de type imapge // Création d'un thumb dans le cas d'un fichier de type imapge
@ -111,10 +115,25 @@ class uploadListener
$this->resizeImage($pathname."/".$directory."/thumb/".$filename,$width,$height,$scale); $this->resizeImage($pathname."/".$directory."/thumb/".$filename,$width,$height,$scale);
} }
if (strpos($directory, 'widget') === 0) {
$tmp=explode("-",$directory);
$widgetid=$tmp[1];
$widget=$this->em->getRepository("CadolesPortalBundle:Pagewidget")->find($widgetid);
if($widget) {
foreach($widget->getPage()->getGroups() as $group) {
if($group->getFgcanshare()) {
if($fgexit) $message="Modification fichier<br>".$filename;
else $message="Création fichier<br>".$filename;
$key=$this->em->getRepository("CadolesCoreBundle:Usergroup")->findOneBy(["group"=>$group,"user"=>$this->token->getToken()->getUser()])->getKeyvalue();
$websocket = $this->container->get('cadoles.websocket.pushmessage')->send($key,$this->token->getToken()->getUser()->getId(),$group->getId(),$message);
}
}
}
}
$response = $event->getResponse(); $response = $event->getResponse();
$response['file'] = $filename; $response['file'] = $filename;
break; break;
case "blogarticle": case "blogarticle":

View File

@ -9,7 +9,7 @@ services:
cadoles.core.upload.listener: cadoles.core.upload.listener:
public: true public: true
class: Cadoles\CoreBundle\EventListener\uploadListener class: Cadoles\CoreBundle\EventListener\uploadListener
arguments: ["@doctrine.orm.entity_manager","@security.token_storage","@session"] arguments: ["@doctrine.orm.entity_manager","@security.token_storage","@session","@service_container"]
tags: tags:
- { name: kernel.event_listener, event: oneup_uploader.post_persist, method: onUpload } - { name: kernel.event_listener, event: oneup_uploader.post_persist, method: onUpload }

View File

@ -543,7 +543,6 @@ a.item-heart {
.widgetbody iframe { .widgetbody iframe {
width:100%; width:100%;
border:0px; border:0px;
height:100%;
} }
.frameitem { .frameitem {

View File

@ -10,6 +10,7 @@ use Symfony\Component\Filesystem\Filesystem;
use Cadoles\PortalBundle\Entity\Blogarticle; use Cadoles\PortalBundle\Entity\Blogarticle;
use Cadoles\PortalBundle\Form\BlogarticleType; use Cadoles\PortalBundle\Form\BlogarticleType;
use Cadoles\CoreBundle\Entity\Usergroup;
class BlogarticleController extends Controller class BlogarticleController extends Controller
{ {
@ -54,6 +55,15 @@ class BlogarticleController extends Controller
$em->persist($entity); $em->persist($entity);
$em->flush(); $em->flush();
foreach($entity->getBlog()->getGroups() as $group) {
if($group->getFgcanshare()) {
$url=$this->generateUrl('cadoles_portal_'.$access.'_blogarticle_view',["id"=>$entity->getId()]);
$message="Création article<br><a href='$url'>".$entity->getName()."</a>";
$key=$em->getRepository("CadolesCoreBundle:Usergroup")->findOneBy(["group"=>$group,"user"=>$this->getUser()])->getKeyvalue();
$websocket = $this->container->get('cadoles.websocket.pushmessage')->send($key,$this->getUser()->getId(),$group->getId(),$message);
}
}
return $this->redirect($this->generateUrl('cadoles_portal_'.$access.'_blogarticle_view',["id"=>$entity->getId()])); return $this->redirect($this->generateUrl('cadoles_portal_'.$access.'_blogarticle_view',["id"=>$entity->getId()]));
} }
@ -90,6 +100,15 @@ class BlogarticleController extends Controller
$em->persist($entity); $em->persist($entity);
$em->flush(); $em->flush();
foreach($entity->getBlog()->getGroups() as $group) {
if($group->getFgcanshare()) {
$url=$this->generateUrl('cadoles_portal_'.$access.'_blogarticle_view',["id"=>$entity->getId()]);
$message="Modification article<br><a href='$url'>".$entity->getName()."</a>";
$key=$em->getRepository("CadolesCoreBundle:Usergroup")->findOneBy(["group"=>$group,"user"=>$this->getUser()])->getKeyvalue();
$websocket = $this->container->get('cadoles.websocket.pushmessage')->send($key,$this->getUser()->getId(),$group->getId(),$message);
}
}
return $this->redirect($this->generateUrl('cadoles_portal_'.$access.'_blogarticle_view',["id"=>$entity->getId()])); return $this->redirect($this->generateUrl('cadoles_portal_'.$access.'_blogarticle_view',["id"=>$entity->getId()]));
} }

View File

@ -62,6 +62,16 @@ class BookmarkController extends Controller
$em->persist($data); $em->persist($data);
$em->flush(); $em->flush();
if($pagewidget) {
foreach($pagewidget->getPage()->getGroups() as $groupchat) {
if($groupchat->getFgcanshare()) {
$message="Création favoris<br><a href='".$data->getUrl()."' target='_blank'>".$data->getTitle()."</a>";
$key=$em->getRepository("CadolesCoreBundle:Usergroup")->findOneBy(["group"=>$groupchat,"user"=>$this->getUser()])->getKeyvalue();
$websocket = $this->container->get('cadoles.websocket.pushmessage')->send($key,$this->getUser()->getId(),$groupchat->getId(),$message);
}
}
}
// Retour à la page // Retour à la page
return $this->redirect($this->generateUrl('cadoles_portal_'.$access.'_page_view',["id"=>$idpage,"usage"=>$usage,"group"=>$group])); return $this->redirect($this->generateUrl('cadoles_portal_'.$access.'_page_view',["id"=>$idpage,"usage"=>$usage,"group"=>$group]));
} }
@ -139,6 +149,17 @@ class BookmarkController extends Controller
$em->persist($data); $em->persist($data);
$em->flush(); $em->flush();
$pagewidget=$data->getPagewidget();
if($pagewidget) {
foreach($pagewidget->getPage()->getGroups() as $groupchat) {
if($groupchat->getFgcanshare()) {
$message="Modification favoris<br><a href='".$data->getUrl()."' target='_blank'>".$data->getTitle()."</a>";
$key=$em->getRepository("CadolesCoreBundle:Usergroup")->findOneBy(["group"=>$groupchat,"user"=>$this->getUser()])->getKeyvalue();
$websocket = $this->container->get('cadoles.websocket.pushmessage')->send($key,$this->getUser()->getId(),$groupchat->getId(),$message);
}
}
}
// Retour à la page // Retour à la page
return $this->redirect($this->generateUrl('cadoles_portal_'.$access.'_page_view',["id"=>$idpage,"usage"=>$usage,"group"=>$group])); return $this->redirect($this->generateUrl('cadoles_portal_'.$access.'_page_view',["id"=>$idpage,"usage"=>$usage,"group"=>$group]));
} }

View File

@ -125,6 +125,14 @@ class CalendareventController extends Controller
$em->persist($calendarevent); $em->persist($calendarevent);
$em->flush(); $em->flush();
foreach($calendarevent->getCalendar()->getGroups() as $group) {
if($group->getFgcanshare()) {
$message="Création évènement<br>".$calendarevent->getName()."<br>du ".$start->format("d/m/Y H:i")." au ".$end->sub(new \DateInterval('PT1M'))->format("d/m/Y H:i");
$key=$em->getRepository("CadolesCoreBundle:Usergroup")->findOneBy(["group"=>$group,"user"=>$this->getUser()])->getKeyvalue();
$websocket = $this->container->get('cadoles.websocket.pushmessage')->send($key,$this->getUser()->getId(),$group->getId(),$message);
}
}
$output["id"]=$calendarevent->getId(); $output["id"]=$calendarevent->getId();
$output["color"]="#".(is_null($calendar->getColor())?$this->get('session')->get('color')["main"]:$calendar->getColor()); $output["color"]="#".(is_null($calendar->getColor())?$this->get('session')->get('color')["main"]:$calendar->getColor());
@ -170,6 +178,14 @@ class CalendareventController extends Controller
$em->persist($calendarevent); $em->persist($calendarevent);
$em->flush(); $em->flush();
foreach($calendarevent->getCalendar()->getGroups() as $group) {
if($group->getFgcanshare()) {
$message="Modification évènement<br>".$calendarevent->getName()."<br>du ".$start->format("d/m/Y H:i")." au ".$end->sub(new \DateInterval('PT1M'))->format("d/m/Y H:i");
$key=$em->getRepository("CadolesCoreBundle:Usergroup")->findOneBy(["group"=>$group,"user"=>$this->getUser()])->getKeyvalue();
$websocket = $this->container->get('cadoles.websocket.pushmessage')->send($key,$this->getUser()->getId(),$group->getId(),$message);
}
}
$output["id"]=$calendarevent->getId(); $output["id"]=$calendarevent->getId();
$output["color"]="#".(is_null($calendar->getColor())?$this->get('session')->get('color')["main"]:$calendar->getColor()); $output["color"]="#".(is_null($calendar->getColor())?$this->get('session')->get('color')["main"]:$calendar->getColor());

View File

@ -46,7 +46,7 @@
<span class="title">{{ entity.name }}</span> <span class="title">{{ entity.name }}</span>
</div> </div>
<div class="widgetbody" style="{{ stylewidgetbodyframe }}"> <div class="widgetbody" style="{{ stylewidgetbodyframe }}; overflow-y:auto;">
{{ render(url('cadoles_websocket_chat',{'id':group,'framed':true,'border':entity.border,'colorbodybacklight':colorbodyback, 'colorbodyback':colorbodyback,'colorbodyfont':colorbodyfont})) }} {{ render(url('cadoles_websocket_chat',{'id':group,'framed':true,'border':entity.border,'colorbodybacklight':colorbodyback, 'colorbodyback':colorbodyback,'colorbodyfont':colorbodyfont})) }}
<!-- <!--
<iframe src="{{ path(tool,{'id':group,'framed':true,'border':entity.border,'colorbodybacklight':colorbodyback, 'colorbodyback':colorbodyback,'colorbodyfont':colorbodyfont}) }}" class="{% if entity.autoajust %}frameajust {% endif %}"></iframe> <iframe src="{{ path(tool,{'id':group,'framed':true,'border':entity.border,'colorbodybacklight':colorbodyback, 'colorbodyback':colorbodyback,'colorbodyfont':colorbodyfont}) }}" class="{% if entity.autoajust %}frameajust {% endif %}"></iframe>