2024-07-27 12:14:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace YesWiki\Meeo\Eleve;
|
|
|
|
|
2024-09-04 13:25:23 +00:00
|
|
|
include 'tools/meeo/libs/eleves/parent.lib.php';
|
|
|
|
|
2024-07-27 12:14:54 +00:00
|
|
|
use YesWiki\Bazar\Service\EntryManager;
|
2024-09-04 13:25:23 +00:00
|
|
|
use YesWiki\Meeo\Eleve\ParentEleve;
|
2024-07-27 12:14:54 +00:00
|
|
|
|
|
|
|
class Eleve {
|
2024-07-27 13:22:09 +00:00
|
|
|
private $data;
|
|
|
|
private $user;
|
2024-09-04 13:25:23 +00:00
|
|
|
private $parents;
|
2024-07-27 12:14:54 +00:00
|
|
|
|
2024-09-06 09:54:14 +00:00
|
|
|
public function __construct(EntryManager $entryManager, $meeo_config, $data) {
|
2024-07-27 12:14:54 +00:00
|
|
|
$this->data = $data;
|
2024-07-27 13:22:09 +00:00
|
|
|
// echo "<p>".var_dump($data)."</p>";
|
2024-09-06 09:54:14 +00:00
|
|
|
$yunoshostFormId = $meeo_config['yunohostFormId'];
|
|
|
|
$parentsFormId = $meeo_config['parentsFormId'];
|
|
|
|
$elevesFormId = $meeo_config['elevesFormId'];
|
|
|
|
// echo "<p>Config : ".var_dump($meeo_config)."</p>";
|
2024-09-04 10:30:50 +00:00
|
|
|
$userId = $data['listefiche'.$yunoshostFormId.'bf_nom'];
|
2024-07-27 13:22:09 +00:00
|
|
|
$this->user = $entryManager->getOne($userId);
|
2024-09-04 13:25:23 +00:00
|
|
|
// echo "<p>".var_dump($userId)."</p>";
|
|
|
|
$this->parents = [];
|
2024-09-06 09:54:14 +00:00
|
|
|
$parents = $entryManager->search(['formsIds' => $parentsFormId, 'queries' => ['listefiche'.$elevesFormId.'bf_eleve' => $userId.'2']]);
|
|
|
|
// $parents = $entryManager->search(['formsIds' => $parentsFormId]);
|
|
|
|
// echo "<p>Parents : ".var_dump($parents)."</p>";
|
|
|
|
foreach ( $parents as $parent) {
|
2024-09-04 13:25:23 +00:00
|
|
|
array_push($this->parents, new ParentEleve($entryManager, $yunoshostFormId, $parent));
|
|
|
|
}
|
2024-09-04 14:26:29 +00:00
|
|
|
// echo "<p>".var_dump($this)."</p>";
|
2024-07-27 12:14:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getId() {
|
|
|
|
return $this->data['id_fiche'];
|
|
|
|
}
|
|
|
|
|
2024-08-05 17:02:45 +00:00
|
|
|
public function getUserId() {
|
|
|
|
return $this->user['bf_titre'];
|
|
|
|
}
|
|
|
|
|
2024-07-27 12:14:54 +00:00
|
|
|
public function getNom() {
|
|
|
|
if (empty($this->user['bf_nom'])) {
|
|
|
|
return $this->user['bf_titre'];
|
|
|
|
} else {
|
|
|
|
return $this->user['bf_nom'];
|
|
|
|
}
|
|
|
|
}
|
2024-07-27 13:22:09 +00:00
|
|
|
|
|
|
|
public function getClasse() {
|
|
|
|
if (empty($this->data['listeListeClassesbf_classe'])) {
|
|
|
|
return $this->data['bf_classe'];
|
|
|
|
}
|
|
|
|
return $this->data['listeListeClassesbf_classe'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setClasse(string $classe) {
|
|
|
|
$this->data['listeListeClassesbf_classe'] = $classe;
|
|
|
|
}
|
|
|
|
|
2024-07-29 16:58:52 +00:00
|
|
|
public function getEmail() {
|
|
|
|
return $this->user['bf_mail'];
|
|
|
|
}
|
|
|
|
|
2024-09-04 13:25:23 +00:00
|
|
|
public function getParentEmails() {
|
|
|
|
$emails = [];
|
|
|
|
foreach ($this->parents as $parent) {
|
|
|
|
array_push($emails, $parent->getEmail());
|
|
|
|
}
|
|
|
|
return $emails;
|
|
|
|
}
|
|
|
|
|
2024-07-27 13:22:09 +00:00
|
|
|
public function getData() {
|
|
|
|
return $this->data;
|
|
|
|
}
|
2024-09-04 13:49:19 +00:00
|
|
|
|
|
|
|
public function isParent($username) {
|
2024-09-04 14:19:03 +00:00
|
|
|
// echo "<p>username :".$username."</p>";
|
2024-09-04 13:49:19 +00:00
|
|
|
foreach ($this->parents as $parent) {
|
2024-09-04 14:26:29 +00:00
|
|
|
// echo "<p>parent :".$parent->getUserId()."</p>";
|
2024-09-04 14:19:03 +00:00
|
|
|
if ($parent->getUserId() == $username) {
|
2024-09-04 13:49:19 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-07-27 12:14:54 +00:00
|
|
|
}
|