From 9f6024049bf0d44997a46479550773f1c4cffbdc Mon Sep 17 00:00:00 2001 From: afornerot Date: Wed, 17 Jun 2020 11:44:47 +0200 Subject: [PATCH 1/4] =?UTF-8?q?r=C3=A9ponse=20sur=20commentaire=20d'articl?= =?UTF-8?q?e=20de=20blog=20(ref=20#157)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/BlogcommentController.php | 53 ++++++++++++++ .../PortalBundle/Entity/Blogcomment.php | 73 +++++++++++++++++++ .../PortalBundle/Resources/config/routing.yml | 8 ++ .../views/Blogarticle/view.html.twig | 39 +++++++--- 4 files changed, 164 insertions(+), 9 deletions(-) diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/BlogcommentController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/BlogcommentController.php index f0e044a3..d034eb18 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/BlogcommentController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/BlogcommentController.php @@ -83,6 +83,59 @@ class BlogcommentController extends Controller ]); } + public function replyAction(Request $request,$idarticle,$idcomment,$access="config") + { + $em = $this->getDoctrine()->getManager(); + + $entity = new Blogcomment(); + + // Recherche de l'article associé + $blogarticle=$em->getRepository("CadolesPortalBundle:Blogarticle")->find($idarticle); + if($blogarticle) $entity->setBlogarticle($blogarticle); + + // Recherche du commentaire parent + $parent=$em->getRepository("CadolesPortalBundle:Blogcomment")->find($idcomment); + if($parent) $entity->setParent($parent); + + $entity->setName("Réponse"); + + $form = $this->entityForm($entity,$access); + $form->handleRequest($request); + + if ($form->isValid()) { + $entity->setUser($this->getUser()); + $entity->setSubmit(new \Datetime()); + + $em->persist($entity); + $em->flush(); + + foreach($entity->getBlogarticle()->getBlog()->getGroups() as $group) { + if($group->getFgcanshare()) { + $url=$this->generateUrl('cadoles_core_redirect', ['route'=>'cadoles_portal_user_blogarticle_view','id'=>$entity->getBlogarticle()->getId()], UrlGeneratorInterface::ABSOLUTE_URL); + $message="Création commentaire article
".$entity->getName().""; + $usergroup=$em->getRepository("CadolesCoreBundle:Usergroup")->findOneBy(["group"=>$group,"user"=>$this->getUser()]); + if($usergroup) { + $key=$usergroup->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->getBlogarticle()->getId()])); + } + + return $this->render($this->labelentity.':edit.html.twig', [ + 'useheader' => ($access=="config"), + 'usemenu' => false, + 'usesidebar' => ($access=="config"), + 'maxwidth' => ($access=="user"), + 'entity' => $entity, + 'mode' => "submit", + 'access' => $access, + 'form' => $form->createView() + ]); + } + public function updateAction(Request $request, $id,$access="config") { $em = $this->getDoctrine()->getManager(); diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Blogcomment.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Blogcomment.php index 0280a481..84119154 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Blogcomment.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Blogcomment.php @@ -56,7 +56,15 @@ class Blogcomment */ private $blogarticle; + /** + * @ORM\ManyToOne(targetEntity="Cadoles\PortalBundle\Entity\Blogcomment", inversedBy="childs") + */ + private $parent; + /** + * @ORM\OneToMany(targetEntity="Cadoles\PortalBundle\Entity\Blogcomment", mappedBy="parent", cascade={"persist"}, orphanRemoval=true) + */ + protected $childs; /** * Get id @@ -188,4 +196,69 @@ class Blogcomment { return $this->blogarticle; } + /** + * Constructor + */ + public function __construct() + { + $this->childs = new \Doctrine\Common\Collections\ArrayCollection(); + } + + /** + * Set parent + * + * @param \Cadoles\PortalBundle\Entity\Blogcomment $parent + * + * @return Blogcomment + */ + public function setParent(\Cadoles\PortalBundle\Entity\Blogcomment $parent = null) + { + $this->parent = $parent; + + return $this; + } + + /** + * Get parent + * + * @return \Cadoles\PortalBundle\Entity\Blogcomment + */ + public function getParent() + { + return $this->parent; + } + + /** + * Add child + * + * @param \Cadoles\PortalBundle\Entity\Blogcomment $child + * + * @return Blogcomment + */ + public function addChild(\Cadoles\PortalBundle\Entity\Blogcomment $child) + { + $this->childs[] = $child; + + return $this; + } + + /** + * Remove child + * + * @param \Cadoles\PortalBundle\Entity\Blogcomment $child + */ + public function removeChild(\Cadoles\PortalBundle\Entity\Blogcomment $child) + { + $this->childs->removeElement($child); + } + + /** + * Get childs + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getChilds() + { + return $this->childs; + } } 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 b1f73f56..187670a7 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 @@ -566,6 +566,10 @@ cadoles_portal_config_blogcomment_submit: path: /config/blogcomment/submit/{idarticle} defaults: { _controller: CadolesPortalBundle:Blogcomment:submit, access: config} +cadoles_portal_config_blogcomment_reply: + path: /config/blogcomment/reply/{idarticle}/{idcomment} + defaults: { _controller: CadolesPortalBundle:Blogcomment:reply, access: config} + cadoles_portal_config_blogcomment_update: path: /config/blogcomment/update/{id} defaults: { _controller: CadolesPortalBundle:Blogcomment:update, access: config } @@ -583,6 +587,10 @@ cadoles_portal_user_blogcomment_submit: path: /user/blogcomment/submit/{idarticle} defaults: { _controller: CadolesPortalBundle:Blogcomment:submit, access: user } +cadoles_portal_user_blogcomment_reply: + path: /user/blogcomment/reply/{idarticle}/{idcomment} + defaults: { _controller: CadolesPortalBundle:Blogcomment:reply, access: user} + cadoles_portal_user_blogcomment_update: path: /user/blogcomment/update/{id} defaults: { _controller: CadolesPortalBundle:Blogcomment:update, access: user } diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Blogarticle/view.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Blogarticle/view.html.twig index 796d5b8e..5297d934 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Blogarticle/view.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Blogarticle/view.html.twig @@ -78,16 +78,37 @@ {% endif %} {% if not entity.blogcomments is empty %} {% for comment in entity.blogcomments|reverse %} -
-

{{comment.name}}

- publié par {{ comment.user.username }} le {{ comment.submit|date("d/m/Y à H:i") }} - {% if canadd or app.user==comment.user%} - + {% if comment.parent is empty %} +
+

{{comment.name}}

+ publié par {{ comment.user.username }} le {{ comment.submit|date("d/m/Y à H:i") }} + {% if canadd or app.user==comment.user%} + + {% endif %} +
+
+ {{ comment.description | raw }} +
+ +
+ {% for reply in comment.childs|reverse %} +
+

{{reply.name}}

+ publié par {{ reply.user.username }} le {{ reply.submit|date("d/m/Y à H:i") }} + {% if canadd or app.user==reply.user%} + + {% endif %} +
+
+ {{ reply.description | raw }} +
+ {% endfor %} +
+ + {% if entity.fgcomment %} + Répondre {% endif %} -
-
- {{ comment.description | raw }} -
+ {% endif %} {% endfor %} {% endif %} From fcbf0ab4adae2928a6ebf4037ab6bd33ef0605c0 Mon Sep 17 00:00:00 2001 From: afornerot Date: Thu, 18 Jun 2020 09:57:05 +0200 Subject: [PATCH 2/4] =?UTF-8?q?controle=20d'unicit=C3=A9=20de=20rattacheme?= =?UTF-8?q?nt=20=C3=A0=20un=20groupe=20(ref=20#160)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CoreBundle/Command/ScriptCommand.php | 1 + .../CoreBundle/Command/SynchroCommand.php | 11 +++-- .../CoreBundle/Controller/UserController.php | 41 +++++++++++-------- .../Cadoles/CoreBundle/Entity/UserGroup.php | 2 +- 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/ScriptCommand.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/ScriptCommand.php index 9fbf3e7a..81d3d62e 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/ScriptCommand.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/ScriptCommand.php @@ -46,6 +46,7 @@ class ScriptCommand extends Command $this->filesystem = new Filesystem(); $this->rootlog = $this->container->get('kernel')->getRootDir()."/../var/logs/"; + $script=$this->em->getRepository("CadolesCoreBundle:Script")->findOneBy(["name"=>"visibletrue"]); if(!$script) { $this->writelnred("== SCRIPT = visibletrue"); diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/SynchroCommand.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/SynchroCommand.php index cfe0c451..b6e60644 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/SynchroCommand.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/SynchroCommand.php @@ -593,9 +593,14 @@ class SynchroCommand extends Command $attrs["cadolesMember"]=array(); foreach($data->getUsers() as $usergroupe) { - array_push($attrs["memberuid"],$usergroupe->getUser()->getUsername()); - array_push($attrs["cadolesMember"],$this->ldap->getUserDN($usergroupe->getUser())); - $this->writeln(' > '.$usergroupe->getUser()->getUsername()); + if(!in_array($usergroupe->getUser()->getUsername(), $attrs["memberuid"])) { + array_push($attrs["memberuid"],$usergroupe->getUser()->getUsername()); + array_push($attrs["cadolesMember"],$this->ldap->getUserDN($usergroupe->getUser())); + $this->writeln(' > '.$usergroupe->getUser()->getUsername()); + } + else { + $this->writelnred(' > EXIST'.$usergroupe->getUser()->getUsername()); + } } if(!$simulate) $this->ldap->ldapModify($dn, $attrs); } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/UserController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/UserController.php index a52ad713..fbbb416e 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/UserController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/UserController.php @@ -400,15 +400,17 @@ class UserController extends Controller foreach($lstgroups as $idgroup) { $group=$em->getRepository("CadolesCoreBundle:Group")->find($idgroup); - $key = Uuid::uuid4(); - - $usergroup= new UserGroup(); - $usergroup->setUser($data); - $datagroup = $group; - $usergroup->setGroup($datagroup); - $usergroup->setKeyvalue($key); - $em->persist($usergroup); - $em->flush(); + $usergroup=$em->getRepository('CadolesCoreBundle:UserGroup')->findBy(["user"=>$data,"group"=>$group]); + if(!$usergroup) { + $key = Uuid::uuid4(); + $usergroup= new UserGroup(); + $usergroup->setUser($data); + $datagroup = $group; + $usergroup->setGroup($datagroup); + $usergroup->setKeyvalue($key); + $em->persist($usergroup); + $em->flush(); + } // Notification message $message="Inscription de l'utilisateur
".$data->getLastname()." ".$data->getFirstname()."
Par ".$this->getUser()->getLastname()." ".$this->getUser()->getFirstname(); @@ -540,16 +542,19 @@ class UserController extends Controller foreach($addgroups as $idgroup) { $group=$em->getRepository("CadolesCoreBundle:Group")->find($idgroup); - $key = Uuid::uuid4(); - - $usergroup= new UserGroup(); - $usergroup->setUser($data); - $datagroup = $group; - $usergroup->setGroup($datagroup); - $usergroup->setKeyvalue($key); - $em->persist($usergroup); - $em->flush(); + $usergroup=$em->getRepository('CadolesCoreBundle:UserGroup')->findBy(["user"=>$data,"group"=>$group]); + if(!$usergroup) { + $key = Uuid::uuid4(); + $usergroup= new UserGroup(); + $usergroup->setUser($data); + $datagroup = $group; + $usergroup->setGroup($datagroup); + $usergroup->setKeyvalue($key); + $em->persist($usergroup); + $em->flush(); + } + // notification message $message="Inscription de l'utilisateur
".$data->getLastname()." ".$data->getFirstname()."
Par ".$this->getUser()->getLastname()." ".$this->getUser()->getFirstname(); $websocket = $this->container->get('cadoles.websocket.pushmessage')->send($key->toString(),$id,$idgroup,$message); diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/UserGroup.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/UserGroup.php index 27937767..792a4a85 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/UserGroup.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/UserGroup.php @@ -9,7 +9,7 @@ use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Entity - * @ORM\Table(name="usergroupe") + * @ORM\Table(name="usergroupe",uniqueConstraints={@ORM\UniqueConstraint(columns={"user_id", "group_id"})}) * @ORM\HasLifecycleCallbacks() * * @UniqueEntity(fields={"user", "group"}, message="Cette liaison existe déjà !") From d916b59f1c4971e1a1544083cbf0c8087bcd14bb Mon Sep 17 00:00:00 2001 From: afornerot Date: Thu, 18 Jun 2020 10:41:48 +0200 Subject: [PATCH 3/4] auto connexion sur onlyoffice (ref #89) --- src/ninegate-1.0/app/config/twig.yml | 3 +++ .../PortalBundle/Resources/views/Page/pages.html.twig | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/ninegate-1.0/app/config/twig.yml b/src/ninegate-1.0/app/config/twig.yml index 0dab5d2e..430f43cd 100644 --- a/src/ninegate-1.0/app/config/twig.yml +++ b/src/ninegate-1.0/app/config/twig.yml @@ -23,3 +23,6 @@ twig: labelsniveau02: %labelsniveau02% iconniveau02: %iconniveau02% keyterm: %keyterm% + + activate_widonlyoffice: %activate_widonlyoffice% + widonlyoffice_url: %widonlyoffice_url% diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Page/pages.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Page/pages.html.twig index 1d42fada..ccc94efd 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Page/pages.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Page/pages.html.twig @@ -134,6 +134,11 @@ {% block pagewrapper %}
+ + {% if activate_widonlyoffice %} + + {% endif %} +