controle d'unicité de rattachement à un groupe (ref #160)
This commit is contained in:
parent
9f6024049b
commit
fcbf0ab4ad
|
@ -46,6 +46,7 @@ class ScriptCommand extends Command
|
||||||
$this->filesystem = new Filesystem();
|
$this->filesystem = new Filesystem();
|
||||||
$this->rootlog = $this->container->get('kernel')->getRootDir()."/../var/logs/";
|
$this->rootlog = $this->container->get('kernel')->getRootDir()."/../var/logs/";
|
||||||
|
|
||||||
|
|
||||||
$script=$this->em->getRepository("CadolesCoreBundle:Script")->findOneBy(["name"=>"visibletrue"]);
|
$script=$this->em->getRepository("CadolesCoreBundle:Script")->findOneBy(["name"=>"visibletrue"]);
|
||||||
if(!$script) {
|
if(!$script) {
|
||||||
$this->writelnred("== SCRIPT = visibletrue");
|
$this->writelnred("== SCRIPT = visibletrue");
|
||||||
|
|
|
@ -593,9 +593,14 @@ class SynchroCommand extends Command
|
||||||
$attrs["cadolesMember"]=array();
|
$attrs["cadolesMember"]=array();
|
||||||
|
|
||||||
foreach($data->getUsers() as $usergroupe) {
|
foreach($data->getUsers() as $usergroupe) {
|
||||||
array_push($attrs["memberuid"],$usergroupe->getUser()->getUsername());
|
if(!in_array($usergroupe->getUser()->getUsername(), $attrs["memberuid"])) {
|
||||||
array_push($attrs["cadolesMember"],$this->ldap->getUserDN($usergroupe->getUser()));
|
array_push($attrs["memberuid"],$usergroupe->getUser()->getUsername());
|
||||||
$this->writeln(' > '.$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);
|
if(!$simulate) $this->ldap->ldapModify($dn, $attrs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -400,15 +400,17 @@ class UserController extends Controller
|
||||||
foreach($lstgroups as $idgroup) {
|
foreach($lstgroups as $idgroup) {
|
||||||
$group=$em->getRepository("CadolesCoreBundle:Group")->find($idgroup);
|
$group=$em->getRepository("CadolesCoreBundle:Group")->find($idgroup);
|
||||||
|
|
||||||
$key = Uuid::uuid4();
|
$usergroup=$em->getRepository('CadolesCoreBundle:UserGroup')->findBy(["user"=>$data,"group"=>$group]);
|
||||||
|
if(!$usergroup) {
|
||||||
$usergroup= new UserGroup();
|
$key = Uuid::uuid4();
|
||||||
$usergroup->setUser($data);
|
$usergroup= new UserGroup();
|
||||||
$datagroup = $group;
|
$usergroup->setUser($data);
|
||||||
$usergroup->setGroup($datagroup);
|
$datagroup = $group;
|
||||||
$usergroup->setKeyvalue($key);
|
$usergroup->setGroup($datagroup);
|
||||||
$em->persist($usergroup);
|
$usergroup->setKeyvalue($key);
|
||||||
$em->flush();
|
$em->persist($usergroup);
|
||||||
|
$em->flush();
|
||||||
|
}
|
||||||
|
|
||||||
// Notification message
|
// Notification message
|
||||||
$message="Inscription de l'utilisateur<br>".$data->getLastname()." ".$data->getFirstname()."<br>Par ".$this->getUser()->getLastname()." ".$this->getUser()->getFirstname();
|
$message="Inscription de l'utilisateur<br>".$data->getLastname()." ".$data->getFirstname()."<br>Par ".$this->getUser()->getLastname()." ".$this->getUser()->getFirstname();
|
||||||
|
@ -540,16 +542,19 @@ class UserController extends Controller
|
||||||
foreach($addgroups as $idgroup) {
|
foreach($addgroups as $idgroup) {
|
||||||
$group=$em->getRepository("CadolesCoreBundle:Group")->find($idgroup);
|
$group=$em->getRepository("CadolesCoreBundle:Group")->find($idgroup);
|
||||||
|
|
||||||
$key = Uuid::uuid4();
|
$usergroup=$em->getRepository('CadolesCoreBundle:UserGroup')->findBy(["user"=>$data,"group"=>$group]);
|
||||||
|
if(!$usergroup) {
|
||||||
$usergroup= new UserGroup();
|
$key = Uuid::uuid4();
|
||||||
$usergroup->setUser($data);
|
|
||||||
$datagroup = $group;
|
|
||||||
$usergroup->setGroup($datagroup);
|
|
||||||
$usergroup->setKeyvalue($key);
|
|
||||||
$em->persist($usergroup);
|
|
||||||
$em->flush();
|
|
||||||
|
|
||||||
|
$usergroup= new UserGroup();
|
||||||
|
$usergroup->setUser($data);
|
||||||
|
$datagroup = $group;
|
||||||
|
$usergroup->setGroup($datagroup);
|
||||||
|
$usergroup->setKeyvalue($key);
|
||||||
|
$em->persist($usergroup);
|
||||||
|
$em->flush();
|
||||||
|
}
|
||||||
|
|
||||||
// notification message
|
// notification message
|
||||||
$message="Inscription de l'utilisateur<br>".$data->getLastname()." ".$data->getFirstname()."<br>Par ".$this->getUser()->getLastname()." ".$this->getUser()->getFirstname();
|
$message="Inscription de l'utilisateur<br>".$data->getLastname()." ".$data->getFirstname()."<br>Par ".$this->getUser()->getLastname()." ".$this->getUser()->getFirstname();
|
||||||
$websocket = $this->container->get('cadoles.websocket.pushmessage')->send($key->toString(),$id,$idgroup,$message);
|
$websocket = $this->container->get('cadoles.websocket.pushmessage')->send($key->toString(),$id,$idgroup,$message);
|
||||||
|
|
|
@ -9,7 +9,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
* @ORM\Table(name="usergroupe")
|
* @ORM\Table(name="usergroupe",uniqueConstraints={@ORM\UniqueConstraint(columns={"user_id", "group_id"})})
|
||||||
* @ORM\HasLifecycleCallbacks()
|
* @ORM\HasLifecycleCallbacks()
|
||||||
*
|
*
|
||||||
* @UniqueEntity(fields={"user", "group"}, message="Cette liaison existe déjà !")
|
* @UniqueEntity(fields={"user", "group"}, message="Cette liaison existe déjà !")
|
||||||
|
|
Loading…
Reference in New Issue