From 0203e6bd04a546d74b933bc2bd1a0dda08df83d5 Mon Sep 17 00:00:00 2001 From: afornerot Date: Thu, 5 Dec 2019 14:17:55 +0100 Subject: [PATCH] =?UTF-8?q?sur=20creation=20modification=20on=20ajoute=20l?= =?UTF-8?q?e=20propri=C3=A9taire=20dans=20le=20groupe=20en=20tant=20que=20?= =?UTF-8?q?manager=20(fixes=20#51)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CoreBundle/Command/data/core-init-01.sql | 2 +- .../CoreBundle/Controller/GroupController.php | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/data/core-init-01.sql b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/data/core-init-01.sql index d7b6a047..caefbf5f 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/data/core-init-01.sql +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/data/core-init-01.sql @@ -8,7 +8,7 @@ INSERT IGNORE INTO `niveau01` (`id`, `label`, `siren`) VALUES (-100, 'DRAAF', '130007107'); INSERT IGNORE INTO `user` (`id`, `niveau01_id`, `username`, `firstname`, `lastname`, `password`, `email`, `avatar`, `role`,`siren`,`authlevel`) VALUES -(-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}6eCBwLuPHx5ue7ysFHb+h5Sc/iazIb3t +(-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}6YNXtIHaQ6w62Z/IFo4Ux8oRFfg3LpIf ', 'admin@ldapbundle.ac-arno.fr', 'admin.jpg', 'ROLE_ADMIN', '130007107', 'simple'); diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/GroupController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/GroupController.php index 105c1e3b..248eeddf 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/GroupController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/GroupController.php @@ -18,6 +18,7 @@ use Cadoles\CoreBundle\Form\GroupType; use Cadoles\PortalBundle\Entity\Calendar; use Cadoles\PortalBundle\Entity\Blog; use Cadoles\WebsocketBundle\Entity\Message; +use Symfony\Component\Security\Core\User\User; class GroupController extends Controller { @@ -722,6 +723,9 @@ class GroupController extends Controller $em->flush(); } + // On s'assure que le propriétaire est bien membre du groupe + $this->ctrlOwner($data); + // On s'assure que le groupe de travail à bien page d'accueil / calendrier / blog associé // Sinon on les génère $this->ctrlFgcanshare($data,$access); @@ -791,6 +795,9 @@ class GroupController extends Controller $em->persist($data); $em->flush(); + // On s'assure que le propriétaire est bien membre du groupe + $this->ctrlOwner($data); + // On s'assure que le groupe de travail à bien page d'accueil / calendrier / blog associé // Sinon on les génère $this->ctrlFgcanshare($data,$access); @@ -918,6 +925,24 @@ class GroupController extends Controller ]); } + protected function ctrlOwner($group) { + $em = $this->getDoctrine()->getManager(); + if($group->getOwner()) { + $usergroup=$em->getRepository("CadolesCoreBundle:Usergroup")->findOneBy(["user"=>$group->getOwner()]); + if($usergroup) { + $key = Uuid::uuid4(); + $usergroup=new Usergroup; + $usergroup->setUser($group->getOwner()); + $usergroup->setGroup($group); + $usergroup->setKeyvalue($key); + } + $usergroup->setFgmanager(true); + $em->persist($usergroup); + $em->flush(); + + } + } + protected function ctrlFgcanshare($group,$access) { $em = $this->getDoctrine()->getManager();