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à !")