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,10 +50,12 @@ class AbsencesAction extends YesWikiAction
$username = $userManager->getLoggedUsername();
$eleves = $elevemanager->getAll();
foreach ($eleves as $eleve) {
if ($eleve->getNom() == $username) {
if ($eleve->getNom() == $username || $eleve->isParent($username)) {
$selectedEleve = $eleve;
}
}
if ($selectedEleve != null) {
$identifier = $selectedEleve->getId();
// echo "<p>".var_dump($selectedEleve)."</p>";
$entries = $entryManager->search(['formsIds' => $formId, 'queries' => [ $eleveIdentifier => $identifier]]);
@ -62,5 +64,8 @@ class AbsencesAction extends YesWikiAction
"entries" => $entries,
]);
}
return "Utilisateur non connus : ". $username;
}
}
}

View file

@ -67,4 +67,12 @@ class Eleve {
public function getData() {
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>";
}
public function getNom() {
if (empty($this->user['bf_nom'])) {
return $this->user['bf_titre'];
} else {
return $this->user['bf_nom'];
}
}
public function getEmail() {
return $this->user['bf_mail'];
}