Add access to absence for parent

This commit is contained in:
mckmonster 2024-09-04 15:49:19 +02:00
parent e1078eb5ab
commit 3dc1aed82d
3 changed files with 28 additions and 7 deletions

View file

@ -50,17 +50,22 @@ class AbsencesAction extends YesWikiAction
$username = $userManager->getLoggedUsername(); $username = $userManager->getLoggedUsername();
$eleves = $elevemanager->getAll(); $eleves = $elevemanager->getAll();
foreach ($eleves as $eleve) { foreach ($eleves as $eleve) {
if ($eleve->getNom() == $username) { if ($eleve->getNom() == $username || $eleve->isParent($username)) {
$selectedEleve = $eleve; $selectedEleve = $eleve;
} }
} }
$identifier = $selectedEleve->getId();
// echo "<p>".var_dump($selectedEleve)."</p>";
$entries = $entryManager->search(['formsIds' => $formId, 'queries' => [ $eleveIdentifier => $identifier]]);
return $this->render('@meeo/eleve_absences.twig', [ if ($selectedEleve != null) {
"entries" => $entries, $identifier = $selectedEleve->getId();
]); // echo "<p>".var_dump($selectedEleve)."</p>";
$entries = $entryManager->search(['formsIds' => $formId, 'queries' => [ $eleveIdentifier => $identifier]]);
return $this->render('@meeo/eleve_absences.twig', [
"entries" => $entries,
]);
}
return "Utilisateur non connus : ". $username;
} }
} }
} }

View file

@ -67,4 +67,12 @@ class Eleve {
public function getData() { public function getData() {
return $this->data; return $this->data;
} }
public function isParent($username) {
foreach ($this->parents as $parent) {
if ($parent->getNom() == $username) {
return true;
}
}
}
} }

View file

@ -17,6 +17,14 @@ class ParentEleve {
// echo "<p>".var_dump($this)."</p>"; // echo "<p>".var_dump($this)."</p>";
} }
public function getNom() {
if (empty($this->user['bf_nom'])) {
return $this->user['bf_titre'];
} else {
return $this->user['bf_nom'];
}
}
public function getEmail() { public function getEmail() {
return $this->user['bf_mail']; return $this->user['bf_mail'];
} }