Merge branch 'master' into dist/envole/6/master

This commit is contained in:
Arnaud Fornerot 2020-07-10 09:37:23 +02:00
commit 2392318922
2 changed files with 67 additions and 7 deletions

View File

@ -119,6 +119,19 @@ class ScriptCommand extends Command
$this->writeln("");
}
$script=$this->em->getRepository("CadolesCoreBundle:Script")->findOneBy(["name"=>"renamegroup"]);
if(!$script) {
$this->writelnred("== SCRIPT = renamegroup");
$this->renamegroup();
$script=new Script();
$script->setName("renamegroup");
$this->em->persist($script);
$this->em->flush();
$this->writeln("");
}
return 1;
}
@ -228,6 +241,53 @@ class ScriptCommand extends Command
}
private function renamegroup(){
$groups = $this->em->getRepository('CadolesCoreBundle:Group')->findAll();
foreach($groups as $group) {
// Si présence d'un = dans le label
if(stripos($group->getLabel(),"=")!==false) {
$newname=str_replace("=","-",$group->getLabel());
$this->writeln("Renommer groupe = ".$group->getLabel());
// Renommer les pages
$pages = $this->em->getRepository('CadolesPortalBundle:Page')->findBy(["name"=>$group->getLabel()]);
foreach($pages as $page) {
$page->setName($newname);
$this->em->persist($page);
$this->em->flush();
}
// Renommer calendrier
$calendars = $this->em->getRepository('CadolesPortalBundle:Calendar')->findBy(["name"=>$group->getLabel()]);
foreach($calendars as $calendar) {
$calendar->setName($newname);
$this->em->persist($calendar);
$this->em->flush();
}
// Renommer blog
$blogs = $this->em->getRepository('CadolesPortalBundle:Blog')->findBy(["name"=>$group->getLabel()]);
foreach($blogs as $blog) {
$blog->setName($newname);
$this->em->persist($blog);
$this->em->flush();
}
// Renommer projet
$projects = $this->em->getRepository('CadolesPortalBundle:Project')->findBy(["name"=>$group->getLabel()]);
foreach($projects as $project) {
$project->setName($newname);
$this->em->persist($project);
$this->em->flush();
}
$group->setLabel($newname);
$this->em->persist($group);
$this->em->flush();
}
}
}

View File

@ -111,25 +111,25 @@ class SynchroCommand extends Command
// Eleves
$ldapfilter="(&(uid=*)(ENTPersonProfils=eleve))";
$label="PROFIL = Elèves";
$label="PROFIL - Elèves";
$this->writeln(" - $label");
if(!$simulate) $this->addmodGroup($label,$ldapfilter,false);
// Enseignants
$ldapfilter="(|(&(uid=*)(ENTPersonProfils=enseignant))(&(uid=*)(typeadmin=0))(&(uid=*)(typeadmin=2)))";
$label="PROFIL = Enseignants";
$label="PROFIL - Enseignants";
$this->writeln(" - $label");
if(!$simulate) $this->addmodGroup($label,$ldapfilter,true);
// Responsables
$ldapfilter="(&(uid=*)(ENTPersonProfils=responsable))";
$label="PROFIL = Responsables";
$label="PROFIL - Responsables";
$this->writeln(" - $label");
if(!$simulate) $this->addmodGroup($label,$ldapfilter,false);
// Administratifs
$ldapfilter="(&(uid=*)(ENTPersonProfils=administratif))";
$label="PROFIL = Administratifs";
$label="PROFIL - Administratifs";
$this->writeln(" - $label");
if(!$simulate) $this->addmodGroup($label,$ldapfilter,true);
@ -141,7 +141,7 @@ class SynchroCommand extends Command
$cn=$result["cn"];
$ldapfilter="(|(&(type=Classe)(cn=$cn))(&(type=Equipe)(cn=profs-$cn))(&(ENTPersonProfils=Administratif)(divcod=$cn)))";
$label="CLASSE = ".$result["cn"];
$label="CLASSE - ".$result["cn"];
$this->writeln(" - $label");
if(!$simulate) $this->addmodGroup($label,$ldapfilter,true);
}
@ -154,7 +154,7 @@ class SynchroCommand extends Command
$cn=$result["cn"];
$ldapfilter="(|(&(type=Option)(cn=$cn))(&(type=Equipe)(cn=profs-$cn))(&(ENTPersonProfils=Administratif)(divcod=$cn)))";
$label="OPTION = ".$result["cn"];
$label="OPTION - ".$result["cn"];
$this->writeln(" - $label");
if(!$simulate) $this->addmodGroup($label,$ldapfilter,true);
}
@ -167,7 +167,7 @@ class SynchroCommand extends Command
$cn=$result["cn"];
$ldapfilter="(&(type=Groupe)(cn=$cn))";
$label="GROUPE = ".$result["cn"];
$label="GROUPE - ".$result["cn"];
$this->writeln(" - $label");
if(!$simulate) $this->addmodGroup($label,$ldapfilter,true);
}