From 06d8eb8b8112d3ab98556c369d18ca738d86a0fd Mon Sep 17 00:00:00 2001 From: mckmonster Date: Wed, 17 Jul 2024 10:42:47 +0200 Subject: [PATCH] Add eleves liste --- commands/CreateFormsCommand.php | 8 +-- commands/UpdateElevesFromYunohostCommand.php | 72 ++++++++++++++++++++ config.yaml | 11 ++- 3 files changed, 80 insertions(+), 11 deletions(-) create mode 100644 commands/UpdateElevesFromYunohostCommand.php diff --git a/commands/CreateFormsCommand.php b/commands/CreateFormsCommand.php index 774e5d5..2d17ce5 100644 --- a/commands/CreateFormsCommand.php +++ b/commands/CreateFormsCommand.php @@ -62,7 +62,7 @@ class CreateFormsCommand extends Command private function absencesForm(FormManager $formManager, $meeo_config) { - $formId = $meeo_config['absences']['formId']; + $formId = $meeo_config['absencesFormId']; $data = [ "bn_id_nature" => $formId, "bn_label_nature" => "Absences", @@ -102,7 +102,7 @@ EOT, private function notesForm(FormManager $formManager, $meeo_config) { - $formId = $meeo_config['notes']['formId']; + $formId = $meeo_config['notesFormId']; $this->matiereList(); @@ -146,7 +146,7 @@ EOT, private function elevesForms(FormManager $formManager, $meeo_config) { - $formId = $meeo_config['eleves']['formId']; + $formId = $meeo_config['elevesFormId']; $this->classeList(); @@ -162,7 +162,7 @@ EOT, texte***bf_titre***Nom d'utilisateur*** *** *** *** ***text***1*** *** *** * *** * *** *** *** *** texte***bf_nom***Nom complet*** *** *** *** ***text***1*** *** *** * *** * *** *** *** *** champs_mail***bf_mail***Email*** *** % *** ***form*** ***1***0*** *** * *** % *** *** *** *** -liste***ListeClasse***Liste déroulante*** *** *** ***bf_classe*** ***1*** *** *** * *** * *** *** *** *** +liste***ListeClasses***Classe*** *** ***aucune***bf_classe*** ***1*** *** *** * *** * *** *** *** *** EOT, "bn_ce_i18n" => "fr-FR", "bn_only_one_entry" => "N", diff --git a/commands/UpdateElevesFromYunohostCommand.php b/commands/UpdateElevesFromYunohostCommand.php new file mode 100644 index 0000000..964d2c6 --- /dev/null +++ b/commands/UpdateElevesFromYunohostCommand.php @@ -0,0 +1,72 @@ +wiki = $wiki; + } + + protected function configure() { + $this + // the name of the command : ./yeswicli helloworld:hello" + ->setName('meeo:update') + // the short description shown while running "./yeswicli list" + ->setDescription('Update la liste des élèves depuis les utilisateurs Yunohost') + + // the full command description shown when running the command with + // the "--help" option + // ->setHelp("This command display the message \"Hello !\" with options for uppercase of add a username.\n" . + // "The argument \"username\" can be used to add a username. Example : \n" . + // "Command line'./yeswicli helloworld:hello \"John Smith\"' gives \"Hello John Smith !\"") + + // add argument for username + // second parameter could be InputArgument::OPTIONAL <=> null, InputArgument::REQUIRED, InputArgument::IS_ARRAY + // third parameter is the description + // forth parameter is default value + // ->addArgument('username', InputArgument::OPTIONAL, 'Username') + + // add option to display output as UPPERCASE + // second parameter null|string is shortcut + // third parameter null|int could be InputOption::VALUE_NONE <=> null, InputOption::VALUE_REQUIRED + // , InputOption::VALUE_OPTIONAL, InputOption::VALUE_IS_ARRAY, InputOption::VALUE_NEGATABLE + // forth parameter is the description + // ->addOption('uppercase', 'u', InputOption::VALUE_NONE, 'Display output in UPPERCASE') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) { + $entryManager = $this->wiki->services->get(EntryManager::class); + $params = $this->wiki->services->get(ParameterBagInterface::class); + $meeo_config = $params->get('meeo'); + $yunohostFormId = $meeo_config['yunohostFormId']; + $elevesFormId = $meeo_config['elevesFormId']; + + $yunohostEntries = $entryManager->search(['formsIds' => $yunohostFormId]); + foreach ($yunohostEntries as $yunohostEntry) { + $eleveEntry = $entryManager->search(['formsIds' => $elevesFormId, 'queries' => [ + 'bf_titre' => $yunohostEntry['bf_titre'] + ]]); + if ($eleveEntry == null) { + $entryManager->create($elevesFormId, [ + 'bf_titre' => $yunohostEntry['bf_titre'], + 'bf_nom' => $yunohostEntry['bf_nom'], + 'bf_mail' => $yunohostEntry['bf_mail'], + 'antispam' => 1 + ]); + } + } + + return Command::SUCCESS; + } +} \ No newline at end of file diff --git a/config.yaml b/config.yaml index 37bd821..cf44823 100644 --- a/config.yaml +++ b/config.yaml @@ -1,12 +1,9 @@ parameters: meeo: - eleves: - formId: 6 - absences: - formId: 7 - notes: - formId: 8 - elevesFormId: 5 + elevesFormId: 6 + absencesFormId: 7 + notesFormId: 8 + yunohostFormId: 5 groupeEE: 'EquipeEducative' services: _defaults: