From 00a4ad9784ce1728d6d7ce721a709bcfd59e9ef8 Mon Sep 17 00:00:00 2001 From: mckmonster Date: Mon, 29 Jul 2024 18:50:23 +0200 Subject: [PATCH 01/16] =?UTF-8?q?[Absence]=20Creation=20entr=C3=A9e=20baza?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/ApiController.php | 15 +++++++++++- services/AbsenceManager.php | 40 ++++++++++++++++++++++++++++++++ templates/edu_creer_absence.twig | 6 ++--- 3 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 services/AbsenceManager.php diff --git a/controllers/ApiController.php b/controllers/ApiController.php index d60637e..f2ff5bb 100644 --- a/controllers/ApiController.php +++ b/controllers/ApiController.php @@ -8,6 +8,7 @@ use Symfony\Component\Routing\Annotation\Route; use YesWiki\Core\ApiResponse; use YesWiki\Core\YesWikiController; use YesWiki\Meeo\Controle\Controle; +use YesWiki\Meeo\Service\AbsenceManager; use YesWiki\Meeo\Service\EleveManager; use YesWiki\Meeo\Service\NoteManager; @@ -71,10 +72,22 @@ class ApiController extends YesWikiController * @Route("/api/meeo/absence",methods={"POST"},options={"acl":{"public"}}) */ public function absence(Request $request) { - // $noteManager = $this->getService(NoteManager::class); $content = $request->getContent(); parse_str($content, $parameters); + // Créer l'absence dans bazar + $eleve = $this->getService(EleveManager::class)->getEleve($parameters['eleve']); + $absenceManager = $this->getService(AbsenceManager::class); + $absenceManager->create($eleve, $parameters['date_debut_absence'], $parameters['date_fin_absence'], $parameters['justification']); + + // Récupération de l'expéditeur + + // Récupération du destinataire + + // Génération du rendu du mail + + // Envoi de mail à la personne qui a été absente + return new ApiResponse($parameters); // return $this->wiki->redirect($this->redirectParams['absence'], 200); } diff --git a/services/AbsenceManager.php b/services/AbsenceManager.php new file mode 100644 index 0000000..863a37a --- /dev/null +++ b/services/AbsenceManager.php @@ -0,0 +1,40 @@ +wiki = $wiki; + $this->params = $params; + $this->entryManager = $entryManager; + + $this->formId = $params->get('meeo')['absencesFormId']; + $this->eleveFormId = $params->get('meeo')['elevesFormId']; + } + + public function create(Eleve $eleve, $debut, $fin, $justification) { + $data = [ + 'bf_titre' => 'Absence : '.$eleve->getId().' - '.$debut, + 'listefiche'.$this->eleveFormId.'bf_eleve' => $eleve->getId(), + 'bf_date_debut' => $debut, + 'bf_date_fin' => $fin, + 'bf_commentaire' => $justification, + 'antispam' => true + ]; + + // echo var_dump($data); + $this->entryManager->create($this->formId, $data); + } +} \ No newline at end of file diff --git a/templates/edu_creer_absence.twig b/templates/edu_creer_absence.twig index d42fe0e..1938416 100644 --- a/templates/edu_creer_absence.twig +++ b/templates/edu_creer_absence.twig @@ -21,10 +21,10 @@ -
- +
+
- +
From 4a4306f1c8aade32b6573d4cbc601b4e91584ac2 Mon Sep 17 00:00:00 2001 From: mckmonster Date: Mon, 29 Jul 2024 18:58:52 +0200 Subject: [PATCH 02/16] =?UTF-8?q?[Absence]=20Recup=C3=A9ration=20des=20ema?= =?UTF-8?q?ils=20expediteurs=20et=20destinataire.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/ApiController.php | 5 +++++ libs/eleves/eleve.lib.php | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/controllers/ApiController.php b/controllers/ApiController.php index f2ff5bb..c8a84e4 100644 --- a/controllers/ApiController.php +++ b/controllers/ApiController.php @@ -6,6 +6,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use YesWiki\Core\ApiResponse; +use YesWiki\Core\Controller\AuthController; use YesWiki\Core\YesWikiController; use YesWiki\Meeo\Controle\Controle; use YesWiki\Meeo\Service\AbsenceManager; @@ -81,8 +82,12 @@ class ApiController extends YesWikiController $absenceManager->create($eleve, $parameters['date_debut_absence'], $parameters['date_fin_absence'], $parameters['justification']); // Récupération de l'expéditeur + $expediteur = $this->getService(AuthController::class)->getLoggedUser()['email']; + // echo "Expediteur : ".$expediteur."\n"; // Récupération du destinataire + $destinataire = $eleve->getEmail(); + // echo "Envoyer à : ".$destinataire."\n"; // Génération du rendu du mail diff --git a/libs/eleves/eleve.lib.php b/libs/eleves/eleve.lib.php index 904f2af..e11471d 100644 --- a/libs/eleves/eleve.lib.php +++ b/libs/eleves/eleve.lib.php @@ -45,6 +45,10 @@ class Eleve { $this->data['listeListeClassesbf_classe'] = $classe; } + public function getEmail() { + return $this->user['bf_mail']; + } + public function getData() { return $this->data; } From d6c8fd2ba7856e631e11cacbb49166871addac88 Mon Sep 17 00:00:00 2001 From: mckmonster Date: Mon, 29 Jul 2024 19:07:12 +0200 Subject: [PATCH 03/16] [Absence] Debut de texte pour le message d'absence --- controllers/ApiController.php | 7 ++++++- services/AbsenceManager.php | 2 +- templates/eleve_creer_absence.twig | 7 +++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 templates/eleve_creer_absence.twig diff --git a/controllers/ApiController.php b/controllers/ApiController.php index c8a84e4..93d1ddd 100644 --- a/controllers/ApiController.php +++ b/controllers/ApiController.php @@ -79,7 +79,7 @@ class ApiController extends YesWikiController // Créer l'absence dans bazar $eleve = $this->getService(EleveManager::class)->getEleve($parameters['eleve']); $absenceManager = $this->getService(AbsenceManager::class); - $absenceManager->create($eleve, $parameters['date_debut_absence'], $parameters['date_fin_absence'], $parameters['justification']); + $absence = $absenceManager->create($eleve, $parameters['date_debut_absence'], $parameters['date_fin_absence'], $parameters['justification']); // Récupération de l'expéditeur $expediteur = $this->getService(AuthController::class)->getLoggedUser()['email']; @@ -90,6 +90,11 @@ class ApiController extends YesWikiController // echo "Envoyer à : ".$destinataire."\n"; // Génération du rendu du mail + $body = $this->render("@meeo/eleve_creer_absence.twig", [ + 'eleve' => $eleve, + 'absence' => $parameters + ]); + echo $body; // Envoi de mail à la personne qui a été absente diff --git a/services/AbsenceManager.php b/services/AbsenceManager.php index 863a37a..9650f77 100644 --- a/services/AbsenceManager.php +++ b/services/AbsenceManager.php @@ -35,6 +35,6 @@ class AbsenceManager { ]; // echo var_dump($data); - $this->entryManager->create($this->formId, $data); + return $this->entryManager->create($this->formId, $data); } } \ No newline at end of file diff --git a/templates/eleve_creer_absence.twig b/templates/eleve_creer_absence.twig new file mode 100644 index 0000000..f792534 --- /dev/null +++ b/templates/eleve_creer_absence.twig @@ -0,0 +1,7 @@ +Le message sera à voir avec l'équipe educative. + +Bonjour {{ eleve.getNom() }}, + +Nous vous signalons que votre enfant a été absent {{ absence['date_debut_absence']}}. + +Merci d'en prendre note. \ No newline at end of file From 09d87dee723e3763c5db206331b1a6ae652414fd Mon Sep 17 00:00:00 2001 From: mckmonster Date: Mon, 29 Jul 2024 19:28:09 +0200 Subject: [PATCH 04/16] [Absence] envoie de mail --- controllers/ApiController.php | 12 +++++++++--- templates/eleve_creer_absence.twig | 8 +++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/controllers/ApiController.php b/controllers/ApiController.php index 93d1ddd..4b638b1 100644 --- a/controllers/ApiController.php +++ b/controllers/ApiController.php @@ -1,6 +1,10 @@ create($eleve, $parameters['date_debut_absence'], $parameters['date_fin_absence'], $parameters['justification']); // Récupération de l'expéditeur - $expediteur = $this->getService(AuthController::class)->getLoggedUser()['email']; - // echo "Expediteur : ".$expediteur."\n"; + $expediteur = $this->getService(AuthController::class)->getLoggedUser(); + // echo "Expediteur : ".var_dump($expediteur)."\n"; // Récupération du destinataire $destinataire = $eleve->getEmail(); @@ -94,9 +98,11 @@ class ApiController extends YesWikiController 'eleve' => $eleve, 'absence' => $parameters ]); - echo $body; + // echo $body; // Envoi de mail à la personne qui a été absente + if (!send_mail($expediteur['email'], $expediteur['name'], $destinataire, "Absence", $body, $body)) + echo "Erreur d'envoie de mail"; return new ApiResponse($parameters); // return $this->wiki->redirect($this->redirectParams['absence'], 200); diff --git a/templates/eleve_creer_absence.twig b/templates/eleve_creer_absence.twig index f792534..de17e68 100644 --- a/templates/eleve_creer_absence.twig +++ b/templates/eleve_creer_absence.twig @@ -1,7 +1,9 @@ Le message sera à voir avec l'équipe educative. -Bonjour {{ eleve.getNom() }}, +
+

Bonjour {{ eleve.getNom() }},

-Nous vous signalons que votre enfant a été absent {{ absence['date_debut_absence']}}. +

Nous vous signalons que votre enfant a été absent {{ absence['date_debut_absence']}}.

-Merci d'en prendre note. \ No newline at end of file +

Merci d'en prendre note.

+
\ No newline at end of file From 852a962f6fb57765ad10ab8808c4de64072be476 Mon Sep 17 00:00:00 2001 From: mckmonster Date: Fri, 2 Aug 2024 18:06:52 +0200 Subject: [PATCH 05/16] Fix erreur to create form --- commands/CreateFormsCommand.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/commands/CreateFormsCommand.php b/commands/CreateFormsCommand.php index 4323bc9..67796e3 100644 --- a/commands/CreateFormsCommand.php +++ b/commands/CreateFormsCommand.php @@ -17,6 +17,7 @@ class CreateFormsCommand extends Command { protected $wiki; protected $eleveFormId; + protected $yunohostFormId; public function __construct(Wiki &$wiki) { @@ -25,6 +26,7 @@ class CreateFormsCommand extends Command $params = $this->wiki->services->get(ParameterBagInterface::class); $meeo_config = $params->get('meeo'); $this->eleveFormId = $meeo_config['elevesFormId']; + $this->yunohostFormId = $meeo_config['yunohostFormId']; } protected function configure() From 1ffa4363373559b6f38275d5d4c75f6eca3c5308 Mon Sep 17 00:00:00 2001 From: mckmonster Date: Fri, 2 Aug 2024 18:18:15 +0200 Subject: [PATCH 06/16] fix Create forms --- commands/CreateFormsCommand.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/commands/CreateFormsCommand.php b/commands/CreateFormsCommand.php index 67796e3..9ae6adf 100644 --- a/commands/CreateFormsCommand.php +++ b/commands/CreateFormsCommand.php @@ -16,6 +16,8 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class CreateFormsCommand extends Command { protected $wiki; + protected $absenceFormId; + protected $noteFormId; protected $eleveFormId; protected $yunohostFormId; @@ -25,6 +27,8 @@ class CreateFormsCommand extends Command $this->wiki = $wiki; $params = $this->wiki->services->get(ParameterBagInterface::class); $meeo_config = $params->get('meeo'); + $this->absenceFormId = $meeo_config['absencesFormId']; + $this->noteFormId = $meeo_config['notesFormId']; $this->eleveFormId = $meeo_config['elevesFormId']; $this->yunohostFormId = $meeo_config['yunohostFormId']; } @@ -68,9 +72,8 @@ class CreateFormsCommand extends Command private function absencesForm(FormManager $formManager, $meeo_config) { - $formId = $meeo_config['absencesFormId']; $data = [ - "bn_id_nature" => $formId, + "bn_id_nature" => $this->absenceFormId, "bn_label_nature" => "Absences", "bn_description" => "Absences des élèves", "bn_condition" => "", @@ -108,12 +111,10 @@ EOT, private function notesForm(FormManager $formManager, $meeo_config) { - $formId = $meeo_config['notesFormId']; - $this->matiereList(); $data = [ - "bn_id_nature" => $formId, + "bn_id_nature" => $this->noteFormId, "bn_label_nature" => "Notes", "bn_description" => "Notes des élèves", "bn_condition" => "", @@ -151,13 +152,10 @@ EOT, } private function elevesForms(FormManager $formManager, $meeo_config) { - - $formId = $meeo_config['elevesFormId']; - $this->classeList(); $data = [ - "bn_id_nature" => $formId, + "bn_id_nature" => $this->eleveFormId, "bn_label_nature" => "Eleves", "bn_description" => "Liste des élèves", "bn_condition" => "", From 8f754af0caab38e8e6e05f909c5c3db9f636e87e Mon Sep 17 00:00:00 2001 From: mckmonster Date: Fri, 2 Aug 2024 18:20:35 +0200 Subject: [PATCH 07/16] fix createforms --- commands/CreateFormsCommand.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/commands/CreateFormsCommand.php b/commands/CreateFormsCommand.php index 9ae6adf..9b71463 100644 --- a/commands/CreateFormsCommand.php +++ b/commands/CreateFormsCommand.php @@ -92,7 +92,7 @@ EOT, "bn_only_one_entry_message" => null ]; - $this->createOrUpdate($formManager, $formId, $data); + $this->createOrUpdate($formManager, $this->absenceFormId, $data); } private function matiereList() @@ -134,7 +134,7 @@ EOT, "bn_only_one_entry_message" => null ]; - $this->createOrUpdate($formManager, $formId, $data); + $this->createOrUpdate($formManager, $this->noteFormId, $data); } private function classeList() @@ -172,7 +172,7 @@ EOT, "bn_only_one_entry_message" => null ]; - $this->createOrUpdate($formManager, $formId, $data); + $this->createOrUpdate($formManager, $this->eleveFormId, $data); } protected function execute(InputInterface $input, OutputInterface $output) From eabc7168a954952935e7c1835e1c988f4d74f06d Mon Sep 17 00:00:00 2001 From: mckmonster Date: Fri, 2 Aug 2024 18:24:43 +0200 Subject: [PATCH 08/16] add log --- commands/CreateFormsCommand.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/commands/CreateFormsCommand.php b/commands/CreateFormsCommand.php index 9b71463..6797db6 100644 --- a/commands/CreateFormsCommand.php +++ b/commands/CreateFormsCommand.php @@ -17,7 +17,7 @@ class CreateFormsCommand extends Command { protected $wiki; protected $absenceFormId; - protected $noteFormId; + protected $notesFormId; protected $eleveFormId; protected $yunohostFormId; @@ -28,7 +28,7 @@ class CreateFormsCommand extends Command $params = $this->wiki->services->get(ParameterBagInterface::class); $meeo_config = $params->get('meeo'); $this->absenceFormId = $meeo_config['absencesFormId']; - $this->noteFormId = $meeo_config['notesFormId']; + $this->notesFormId = $meeo_config['notesFormId']; $this->eleveFormId = $meeo_config['elevesFormId']; $this->yunohostFormId = $meeo_config['yunohostFormId']; } @@ -63,6 +63,7 @@ class CreateFormsCommand extends Command } private function createOrUpdate($formManager, $formId, $data) { + echo $formId.": ".$data['bn_label_nature']; $existingForm = $formManager->getOne($formId); if ($existingForm) return $formManager->update($data); @@ -114,7 +115,7 @@ EOT, $this->matiereList(); $data = [ - "bn_id_nature" => $this->noteFormId, + "bn_id_nature" => $this->notesFormId, "bn_label_nature" => "Notes", "bn_description" => "Notes des élèves", "bn_condition" => "", @@ -134,7 +135,7 @@ EOT, "bn_only_one_entry_message" => null ]; - $this->createOrUpdate($formManager, $this->noteFormId, $data); + $this->createOrUpdate($formManager, $this->notesFormId, $data); } private function classeList() From 775b24f18499553129e3d67547b14e46db15833f Mon Sep 17 00:00:00 2001 From: mckmonster Date: Fri, 2 Aug 2024 18:53:08 +0200 Subject: [PATCH 09/16] Add an exception result --- actions/ElevesAction.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/actions/ElevesAction.php b/actions/ElevesAction.php index 2c8c739..3c869f3 100644 --- a/actions/ElevesAction.php +++ b/actions/ElevesAction.php @@ -14,7 +14,11 @@ class ElevesAction extends YesWikiAction public function run() { - $eleveManager = $this->getService(EleveManager::class); - return $eleveManager->view(); + try { + $eleveManager = $this->getService(EleveManager::class); + return $eleveManager->view(); + } catch (Exception $e) { + echo 'Exception reçue : '. $e->getMessage() ."\n"; + } } } \ No newline at end of file From 000d5ce1335600c92d64a88adffe3e068e5f4f6e Mon Sep 17 00:00:00 2001 From: mckmonster Date: Fri, 2 Aug 2024 19:00:18 +0200 Subject: [PATCH 10/16] try to fix EleveAction --- libs/eleves/eleve.lib.php | 9 ++------- services/EleveManager.php | 6 ++++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/libs/eleves/eleve.lib.php b/libs/eleves/eleve.lib.php index e11471d..6ca6c1d 100644 --- a/libs/eleves/eleve.lib.php +++ b/libs/eleves/eleve.lib.php @@ -8,15 +8,10 @@ class Eleve { private $data; private $user; - public function __construct(EntryManager $entryManager, $data) { + public function __construct(EntryManager $entryManager, $yunoshostFormId, $data) { $this->data = $data; // echo "

".var_dump($data)."

"; - //TODO récupérer le bon numéro de liste - - if (empty($data['listefiche5Listebf_nom'])) - $userId = $data['listefichebf_nom']; - else - $userId = $data['listefiche5Listebf_nom']; + $userId = $data['listefiche'.$yunoshostFormId.'Listebf_nom']; $this->user = $entryManager->getOne($userId); // echo "

".var_dump($this)."

"; diff --git a/services/EleveManager.php b/services/EleveManager.php index 8bcbaf8..6bbdee1 100644 --- a/services/EleveManager.php +++ b/services/EleveManager.php @@ -13,6 +13,7 @@ use YesWiki\Meeo\Eleve\Eleve; class EleveManager { private $formId; + private $yunoshostFormId; private $entryManager; private $listManager; private $wiki; @@ -22,6 +23,7 @@ class EleveManager { $meeo_config = $params->get('meeo'); $this->wiki = $wiki; $this->formId = $meeo_config['elevesFormId']; + $this->yunoshostFormId = $meeo_config['yunohostFormId']; $this->entryManager = $entryManager; $this->listManager = $listManager; } @@ -43,7 +45,7 @@ class EleveManager { foreach ($this->entryManager->search(['formsIds' => $this->formId]) as $data) { - $eleve = new Eleve($this->entryManager, $data); + $eleve = new Eleve($this->entryManager, $this->yunoshostFormId, $data); // echo "

".var_dump($eleve)."

"; $eleves[] = $eleve; } @@ -51,7 +53,7 @@ class EleveManager { } public function getEleve(string $id) { - return new Eleve($this->entryManager, $this->entryManager->getOne($id)); + return new Eleve($this->entryManager, $this->yunoshostFormId, $this->entryManager->getOne($id)); } public function getCurrentEleve(string $username) { From 12d9bff04421f3f8b42b66d7af6ed7f6561dc097 Mon Sep 17 00:00:00 2001 From: mckmonster Date: Fri, 2 Aug 2024 19:19:00 +0200 Subject: [PATCH 11/16] fix ElevesAction --- services/EleveManager.php | 2 +- templates/edu_eleves.twig | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/EleveManager.php b/services/EleveManager.php index 6bbdee1..aa73c9b 100644 --- a/services/EleveManager.php +++ b/services/EleveManager.php @@ -66,6 +66,6 @@ class EleveManager { $classes = $this->listManager->getOne('ListeClasses'); // echo "

".var_dump($classes)."

"; - return $this->wiki->render('@meeo/edu_eleves.twig', ['eleves' => $eleves, 'classes' => $classes['nodes']]); + return $this->wiki->render('@meeo/edu_eleves.twig', ['eleves' => $eleves, 'classes' => $classes['label']]); } } \ No newline at end of file diff --git a/templates/edu_eleves.twig b/templates/edu_eleves.twig index 1c1f751..ba3bd7a 100644 --- a/templates/edu_eleves.twig +++ b/templates/edu_eleves.twig @@ -10,8 +10,8 @@
{{ eleve.getNom() }}
From 60c79580665f2d0654749839f834328d1a72c682 Mon Sep 17 00:00:00 2001 From: mckmonster Date: Sat, 3 Aug 2024 11:56:26 +0200 Subject: [PATCH 12/16] Fix apiController --- controllers/ApiController.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/controllers/ApiController.php b/controllers/ApiController.php index 4b638b1..b71e7db 100644 --- a/controllers/ApiController.php +++ b/controllers/ApiController.php @@ -21,14 +21,17 @@ class ApiController extends YesWikiController { private $redirectParams; - public function __construct(ParameterBagInterface $params) { - $this->redirectParams = $params->get('meeo')['redirect']; + public function __construct() { + } /** * @Route("/api/meeo/eleves",methods={"POST"},options={"acl":{"public"}}) */ public function eleveUpdate(Request $request) { + $params = $this->getService(ParameterBagInterface::class); + $redirectParams = $params->get('meeo')['redirect']; + $eleveController = $this->getService(EleveManager::class); $content = $request->getContent(); @@ -49,13 +52,16 @@ class ApiController extends YesWikiController } } // return new ApiResponse($data); - return $this->wiki->redirect($this->redirectParams['eleveUpdate'], 200); + return $this->wiki->redirect($redirectParams['eleveUpdate'], 200); } /** * @Route("/api/meeo/controle",methods={"POST"},options={"acl":{"public"}}) */ public function controle(Request $request) { + $params = $this->getService(ParameterBagInterface::class); + $redirectParams = $params->get('meeo')['redirect']; + $noteManager = $this->getService(NoteManager::class); $content = $request->getContent(); @@ -70,13 +76,15 @@ class ApiController extends YesWikiController $controle = new Controle($parameters['intitule'], $parameters['matiere'], $parameters['coef'], $eleves); $controle->createNotes($noteManager); // return new ApiResponse($controle); - return $this->wiki->redirect($this->redirectParams['controle'], 200); + return $this->wiki->redirect($redirectParams['controle'], 200); } /** * @Route("/api/meeo/absence",methods={"POST"},options={"acl":{"public"}}) */ public function absence(Request $request) { + $params = $this->getService(ParameterBagInterface::class); + $redirectParams = $params->get('meeo')['redirect']; $content = $request->getContent(); parse_str($content, $parameters); @@ -104,7 +112,7 @@ class ApiController extends YesWikiController if (!send_mail($expediteur['email'], $expediteur['name'], $destinataire, "Absence", $body, $body)) echo "Erreur d'envoie de mail"; - return new ApiResponse($parameters); - // return $this->wiki->redirect($this->redirectParams['absence'], 200); + // return new ApiResponse($parameters); + return $this->wiki->redirect($redirectParams['absence'], 200); } } \ No newline at end of file From c00aac5b79ce26b946cb138410e2b1b1e82214e0 Mon Sep 17 00:00:00 2001 From: mckmonster Date: Sat, 3 Aug 2024 12:01:20 +0200 Subject: [PATCH 13/16] Fix controle --- services/NoteManager.php | 2 +- templates/edu_controle.twig | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/services/NoteManager.php b/services/NoteManager.php index 74407a7..b03b535 100644 --- a/services/NoteManager.php +++ b/services/NoteManager.php @@ -68,7 +68,7 @@ class NoteManager { // echo var_dump($matieres); $classes = $this->listManager->getOne('ListeClasses'); // echo var_dump($classes); - return $this->wiki->render('@meeo/edu_controle.twig', ['matieres' => $matieres['nodes'], 'classes' => $classes['nodes'], 'eleves' => $eleves]); + return $this->wiki->render('@meeo/edu_controle.twig', ['matieres' => $matieres['label'], 'classes' => $classes['label'], 'eleves' => $eleves]); } public function createNote($intitule, $eleve, $matiere, $note, $coef) { diff --git a/templates/edu_controle.twig b/templates/edu_controle.twig index 63d1db5..509f387 100644 --- a/templates/edu_controle.twig +++ b/templates/edu_controle.twig @@ -11,8 +11,8 @@
@@ -21,8 +21,8 @@
From 1c1196955460bf085e18f63dbd077c3efb46b20b Mon Sep 17 00:00:00 2001 From: mckmonster Date: Sat, 3 Aug 2024 12:07:23 +0200 Subject: [PATCH 14/16] Fix notes --- actions/NotesAction.php | 9 +++++++-- libs/bulletin/Bulletin.lib.php | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/actions/NotesAction.php b/actions/NotesAction.php index 68ff53d..5c9e437 100644 --- a/actions/NotesAction.php +++ b/actions/NotesAction.php @@ -14,7 +14,12 @@ class NotesAction extends YesWikiAction public function run() { - $noteManager = $this->getService(NoteManager::class); - return $noteManager->viewBulletins(); + try { + $noteManager = $this->getService(NoteManager::class); + return $noteManager->viewBulletins(); + } catch (Exception $e) { + return 'Exception reçue : '.$e->getMessage()."\n"; + } + } } diff --git a/libs/bulletin/Bulletin.lib.php b/libs/bulletin/Bulletin.lib.php index ae4c7fd..1b035bd 100644 --- a/libs/bulletin/Bulletin.lib.php +++ b/libs/bulletin/Bulletin.lib.php @@ -18,8 +18,9 @@ class Bulletin { $listManager = $wiki->services->get(ListManager::class); $matieres = $listManager->getOne('ListeMatiere'); // echo "

".var_dump($matieres)."

"; - foreach ($matieres['nodes'] as $matiere) { - $this->matieres[] = new Matiere($wiki, $this, $matiere["id"], $matiere["label"]); + foreach ($matieres['label'] as $id => $matiere) { + // echo "

".$id.""; + $this->matieres[] = new Matiere($wiki, $this, $id, $matiere); } } From e0371384b53df58a35f4ec9793d96d7bdf7d0d64 Mon Sep 17 00:00:00 2001 From: mckmonster Date: Mon, 5 Aug 2024 19:02:41 +0200 Subject: [PATCH 15/16] prepare to display eleve --- config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.yaml b/config.yaml index c383eb5..f1b0252 100644 --- a/config.yaml +++ b/config.yaml @@ -4,7 +4,7 @@ parameters: absencesFormId: 7 notesFormId: 8 yunohostFormId: 5 - groupeEE: 'EquipeEducative' + groupeEE: 'equipeeducative' redirect: eleveUpdate: '?Eleves' controle: '?Bulletin' From e2a83cd841d72f07de726d437ce488ab01639b9e Mon Sep 17 00:00:00 2001 From: mckmonster Date: Mon, 5 Aug 2024 19:02:45 +0200 Subject: [PATCH 16/16] prepare to display eleve --- libs/eleves/eleve.lib.php | 4 ++++ services/EleveManager.php | 8 ++++++-- services/NoteManager.php | 31 ++++++++++++++++++++----------- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/libs/eleves/eleve.lib.php b/libs/eleves/eleve.lib.php index 6ca6c1d..e3afe92 100644 --- a/libs/eleves/eleve.lib.php +++ b/libs/eleves/eleve.lib.php @@ -21,6 +21,10 @@ class Eleve { return $this->data['id_fiche']; } + public function getUserId() { + return $this->user['bf_titre']; + } + public function getNom() { if (empty($this->user['bf_nom'])) { return $this->user['bf_titre']; diff --git a/services/EleveManager.php b/services/EleveManager.php index aa73c9b..5dc4032 100644 --- a/services/EleveManager.php +++ b/services/EleveManager.php @@ -44,7 +44,6 @@ class EleveManager { $eleves = []; foreach ($this->entryManager->search(['formsIds' => $this->formId]) as $data) { - $eleve = new Eleve($this->entryManager, $this->yunoshostFormId, $data); // echo "

".var_dump($eleve)."

"; $eleves[] = $eleve; @@ -57,7 +56,12 @@ class EleveManager { } public function getCurrentEleve(string $username) { - return $this->entryManager->getOne(str_replace(".","", $username)); + $all = $this->getAll(); + foreach ($all as $eleve) { + echo "

".var_dump($eleve)."

"; + if ($eleve->getUserId() == $username) + return $eleve; + } } public function view() { diff --git a/services/NoteManager.php b/services/NoteManager.php index b03b535..f390823 100644 --- a/services/NoteManager.php +++ b/services/NoteManager.php @@ -5,6 +5,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use YesWiki\Bazar\Service\EntryManager; use YesWiki\Bazar\Service\ListManager; use YesWiki\Core\Controller\AuthController; +use YesWiki\Core\Service\UserManager; use YesWiki\Wiki; use YesWiki\Meeo\Bulletin\Bulletin; use YesWiki\Meeo\Service\EleveManager; @@ -16,31 +17,35 @@ class NoteManager { protected $listManager; protected $formId; protected $eleveFormId; + protected $eeGroup; protected $authController; + protected $userManager; - public function __construct( Wiki $wiki, ParameterBagInterface $params, EntryManager $entryManager, ListManager $listManager, AuthController $authController) + public function __construct( Wiki $wiki, ParameterBagInterface $params, EntryManager $entryManager, ListManager $listManager, AuthController $authController, UserManager $userManager) { $this->wiki = $wiki; $this->params = $params; $this->entryManager = $entryManager; $this->listManager = $listManager; $this->authController = $authController; + $this->userManager = $userManager; $meeo_config = $this->params->get('meeo'); $this->formId = $meeo_config['notesFormId']; $this->eleveFormId = $meeo_config['elevesFormId']; + $this->eeGroup = $meeo_config['groupeEE']; } public function viewBulletins() { $eleveManager = $this->wiki->services->get(EleveManager::class); - $username = $this->authController->getLoggedUserName(); + // echo "

".$username."

"; include 'tools/meeo/libs/bulletin/Bulletin.lib.php'; - $currentEleve = $eleveManager->getCurrentEleve($username); - // echo "

".var_dump($currentEleve)."

"; - // if ($currentEleve == null) { + $loggedUser = $this->authController->getLoggedUser(); + echo "

".var_dump($loggedUser)."

"; + if ($this->userManager->isInGroup($this->eeGroup, $loggedUser['name'], false)) { $eleves = $eleveManager->getAll(); $bulletins = []; @@ -53,12 +58,16 @@ class NoteManager { return $this->wiki->render('@meeo/edu_notes.twig', [ "bulletins" => $bulletins, ]); - // } else { - // $bulletin = new Bulletin($this->wiki, $currentEleve); - // return $this->wiki->render('@meeo/eleve_notes.twig', [ - // "bulletin" => $bulletin, - // ]); - // } + } else { + echo "Eleve"; + $currentEleve = $eleveManager->getCurrentEleve($loggedUser['name']); + if ($currentEleve != null) { + $bulletin = new Bulletin($this->wiki, $currentEleve); + return $this->wiki->render('@meeo/eleve_notes.twig', [ + "bulletin" => $bulletin, + ]); + } + } } public function viewControle() {