From 54ffb73121d5202407fe46970caa1ba07bac8c34 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 10 Jul 2020 11:07:42 +0200 Subject: [PATCH] systeme de script en moulinette sur reconfigure --- src/nineskeletor-1.0/scripts/reconfigure.sh | 7 +- .../src/Command/DumpBddCommand.php | 2 +- .../src/Command/ScriptCommand.php | 89 +++++++++++++++++++ .../src/Command/SynchroUsersCommand.php | 37 ++++++-- .../src/Controller/GroupController.php | 9 ++ src/nineskeletor-1.0/src/Entity/Script.php | 50 +++++++++++ .../src/Repository/.gitignore | 0 .../src/Repository/ScriptRepository.php | 15 ++++ 8 files changed, 202 insertions(+), 7 deletions(-) create mode 100644 src/nineskeletor-1.0/src/Command/ScriptCommand.php create mode 100644 src/nineskeletor-1.0/src/Entity/Script.php delete mode 100644 src/nineskeletor-1.0/src/Repository/.gitignore create mode 100644 src/nineskeletor-1.0/src/Repository/ScriptRepository.php diff --git a/src/nineskeletor-1.0/scripts/reconfigure.sh b/src/nineskeletor-1.0/scripts/reconfigure.sh index 9d3ec8a..adc5160 100755 --- a/src/nineskeletor-1.0/scripts/reconfigure.sh +++ b/src/nineskeletor-1.0/scripts/reconfigure.sh @@ -15,10 +15,15 @@ if [ ! -f $DIR/.env ]; then fi # Installation des dépendances composer -composer install +echo COMPOSER = Install +composer install --quiet php bin/console app:AppInit --env=prod php bin/console app:CronInit --env=prod +php bin/console app:Script --env=prod # Permissions +echo PERMISSIONS ./scripts/perm.sh www-data + +echo \ No newline at end of file diff --git a/src/nineskeletor-1.0/src/Command/DumpBddCommand.php b/src/nineskeletor-1.0/src/Command/DumpBddCommand.php index ab75e01..f172d3c 100644 --- a/src/nineskeletor-1.0/src/Command/DumpBddCommand.php +++ b/src/nineskeletor-1.0/src/Command/DumpBddCommand.php @@ -64,7 +64,7 @@ class DumpBddCommand extends Command $result = $this->runCommand($cmd); if($result['exit_status'] == 0) { - $this->filesystem->dumpFile($this->rootlog.$alias.".sql", $result['output']); + $this->filesystem->dumpFile($this->rootlog.$alias.".sql", implode('', $result['output'])); } $this->writeln(''); diff --git a/src/nineskeletor-1.0/src/Command/ScriptCommand.php b/src/nineskeletor-1.0/src/Command/ScriptCommand.php new file mode 100644 index 0000000..43227f0 --- /dev/null +++ b/src/nineskeletor-1.0/src/Command/ScriptCommand.php @@ -0,0 +1,89 @@ +container = $container; + $this->em = $em; + } + + + protected function configure() + { + $this + ->setName('app:Script') + ->setDescription('Script to call') + ->setHelp('Script to call') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->output = $output; + $this->filesystem = new Filesystem(); + $this->rootlog = $this->container->get('kernel')->getLogDir()."/"; + + $output->writeln('APP = Scripts'); + + //$this->callscript("test"); + + $output->writeln(''); + + + return 1; + } + + + private function callscript($name) { + $script=$this->em->getRepository("App:Script")->findOneBy(["name"=>$name]); + if(!$script) { + $this->writelnred("== SCRIPT = ".$name); + $this->$name(); + + $script=new Script(); + $script->setName($name); + $this->em->persist($script); + $this->em->flush(); + $this->writeln(""); + } + } + + private function test() { + $this->writeln("TEST"); + } + + + + private function writelnred($string) { + $this->output->writeln(''.$string.''); + $this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n"); + } + private function writeln($string) { + $this->output->writeln($string); + $this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n"); + } +} diff --git a/src/nineskeletor-1.0/src/Command/SynchroUsersCommand.php b/src/nineskeletor-1.0/src/Command/SynchroUsersCommand.php index fdeb535..ae2efce 100644 --- a/src/nineskeletor-1.0/src/Command/SynchroUsersCommand.php +++ b/src/nineskeletor-1.0/src/Command/SynchroUsersCommand.php @@ -36,8 +36,8 @@ class SynchroUsersCommand extends Command { $this ->setName('app:synchroUsers') - ->setDescription('Synchronisation des Utilisateurs via un annuaire scribe') - ->setHelp('Synchronisation des Utilisateurs via un annuaire scribe') + ->setDescription('Synchronisation des Utilisateurs') + ->setHelp('Synchronisation des Utilisateurs') ->addArgument('simulate', InputArgument::OPTIONAL, 'true to simulate / false to run') ->addArgument('cronid', InputArgument::OPTIONAL, 'ID Cron Job') ->addArgument('lastchance', InputArgument::OPTIONAL, 'Lastchance to run the cron') @@ -106,6 +106,33 @@ class SynchroUsersCommand extends Command $this->writeln(''); $this->writeln('== SCRIBE ==========================================='); + $this->writeln(''); + $this->writeln('== PROFILS =========================================='); + + // Eleves + $ldapfilter="(&(uid=*)(ENTPersonProfils=eleve))"; + $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"; + $this->writeln(" - $label"); + if(!$simulate) $this->addmodGroup($label,$ldapfilter,true); + + // Responsables + $ldapfilter="(&(uid=*)(ENTPersonProfils=responsable))"; + $label="PROFIL - Responsables"; + $this->writeln(" - $label"); + if(!$simulate) $this->addmodGroup($label,$ldapfilter,false); + + // Administratifs + $ldapfilter="(&(uid=*)(ENTPersonProfils=administratif))"; + $label="PROFIL - Administratifs"; + $this->writeln(" - $label"); + if(!$simulate) $this->addmodGroup($label,$ldapfilter,true); + // Classes $this->writeln(''); $this->writeln('== CLASSES =========================================='); @@ -114,7 +141,7 @@ class SynchroUsersCommand 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); } @@ -127,7 +154,7 @@ class SynchroUsersCommand extends Command foreach($results as $result) { $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); } @@ -148,7 +175,7 @@ class SynchroUsersCommand extends Command $cn=$result["cn"]; $ldapfilter="(&(&".$ldap_filtergroup.")(cn=$cn))"; - $label="GROUPE = ".$result["cn"]; + $label="GROUPE - ".$result["cn"]; $this->writeln(" - $label"); if(!$simulate) $this->addmodGroup($label,$ldapfilter,true); } diff --git a/src/nineskeletor-1.0/src/Controller/GroupController.php b/src/nineskeletor-1.0/src/Controller/GroupController.php index 984a925..ec749f9 100755 --- a/src/nineskeletor-1.0/src/Controller/GroupController.php +++ b/src/nineskeletor-1.0/src/Controller/GroupController.php @@ -164,6 +164,15 @@ class GroupController extends AbstractController if ($form->get('submit')->isClicked() && $mode=="submit") { } + if ($form->get('submit')->isClicked() && ($mode=="submit" || $mode=="update")) { + // On s'assure que le label ne contient pas des caractères speciaux + $string = preg_replace('~[^ éèêôöàïî\'@a-zA-Z0-9._-]~', '', $data->getName()); + if($string!=$data->getName()) + { + $form->addError(new FormError('Caractères interdit dans ce label')); + } + } + if ($form->get('submit')->isClicked() && !$form->isValid()) { $this->get('session')->getFlashBag()->clear(); diff --git a/src/nineskeletor-1.0/src/Entity/Script.php b/src/nineskeletor-1.0/src/Entity/Script.php new file mode 100644 index 0000000..ac9885c --- /dev/null +++ b/src/nineskeletor-1.0/src/Entity/Script.php @@ -0,0 +1,50 @@ +id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): self + { + $this->name = $name; + + return $this; + } +} diff --git a/src/nineskeletor-1.0/src/Repository/.gitignore b/src/nineskeletor-1.0/src/Repository/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/src/nineskeletor-1.0/src/Repository/ScriptRepository.php b/src/nineskeletor-1.0/src/Repository/ScriptRepository.php new file mode 100644 index 0000000..977a640 --- /dev/null +++ b/src/nineskeletor-1.0/src/Repository/ScriptRepository.php @@ -0,0 +1,15 @@ +