Compare commits

...

2 commits

Author SHA1 Message Date
mckmonster
e2a83cd841 prepare to display eleve 2024-08-05 19:02:45 +02:00
mckmonster
e0371384b5 prepare to display eleve 2024-08-05 19:02:41 +02:00
4 changed files with 31 additions and 14 deletions

View file

@ -4,7 +4,7 @@ parameters:
absencesFormId: 7 absencesFormId: 7
notesFormId: 8 notesFormId: 8
yunohostFormId: 5 yunohostFormId: 5
groupeEE: 'EquipeEducative' groupeEE: 'equipeeducative'
redirect: redirect:
eleveUpdate: '?Eleves' eleveUpdate: '?Eleves'
controle: '?Bulletin' controle: '?Bulletin'

View file

@ -21,6 +21,10 @@ class Eleve {
return $this->data['id_fiche']; return $this->data['id_fiche'];
} }
public function getUserId() {
return $this->user['bf_titre'];
}
public function getNom() { public function getNom() {
if (empty($this->user['bf_nom'])) { if (empty($this->user['bf_nom'])) {
return $this->user['bf_titre']; return $this->user['bf_titre'];

View file

@ -44,7 +44,6 @@ class EleveManager {
$eleves = []; $eleves = [];
foreach ($this->entryManager->search(['formsIds' => $this->formId]) as $data) foreach ($this->entryManager->search(['formsIds' => $this->formId]) as $data)
{ {
$eleve = new Eleve($this->entryManager, $this->yunoshostFormId, $data); $eleve = new Eleve($this->entryManager, $this->yunoshostFormId, $data);
// echo "<p>".var_dump($eleve)."</p>"; // echo "<p>".var_dump($eleve)."</p>";
$eleves[] = $eleve; $eleves[] = $eleve;
@ -57,7 +56,12 @@ class EleveManager {
} }
public function getCurrentEleve(string $username) { public function getCurrentEleve(string $username) {
return $this->entryManager->getOne(str_replace(".","", $username)); $all = $this->getAll();
foreach ($all as $eleve) {
echo "<p>".var_dump($eleve)."</p>";
if ($eleve->getUserId() == $username)
return $eleve;
}
} }
public function view() { public function view() {

View file

@ -5,6 +5,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use YesWiki\Bazar\Service\EntryManager; use YesWiki\Bazar\Service\EntryManager;
use YesWiki\Bazar\Service\ListManager; use YesWiki\Bazar\Service\ListManager;
use YesWiki\Core\Controller\AuthController; use YesWiki\Core\Controller\AuthController;
use YesWiki\Core\Service\UserManager;
use YesWiki\Wiki; use YesWiki\Wiki;
use YesWiki\Meeo\Bulletin\Bulletin; use YesWiki\Meeo\Bulletin\Bulletin;
use YesWiki\Meeo\Service\EleveManager; use YesWiki\Meeo\Service\EleveManager;
@ -16,31 +17,35 @@ class NoteManager {
protected $listManager; protected $listManager;
protected $formId; protected $formId;
protected $eleveFormId; protected $eleveFormId;
protected $eeGroup;
protected $authController; 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->wiki = $wiki;
$this->params = $params; $this->params = $params;
$this->entryManager = $entryManager; $this->entryManager = $entryManager;
$this->listManager = $listManager; $this->listManager = $listManager;
$this->authController = $authController; $this->authController = $authController;
$this->userManager = $userManager;
$meeo_config = $this->params->get('meeo'); $meeo_config = $this->params->get('meeo');
$this->formId = $meeo_config['notesFormId']; $this->formId = $meeo_config['notesFormId'];
$this->eleveFormId = $meeo_config['elevesFormId']; $this->eleveFormId = $meeo_config['elevesFormId'];
$this->eeGroup = $meeo_config['groupeEE'];
} }
public function viewBulletins() { public function viewBulletins() {
$eleveManager = $this->wiki->services->get(EleveManager::class); $eleveManager = $this->wiki->services->get(EleveManager::class);
$username = $this->authController->getLoggedUserName();
// echo "<p>".$username."</p>"; // echo "<p>".$username."</p>";
include 'tools/meeo/libs/bulletin/Bulletin.lib.php'; include 'tools/meeo/libs/bulletin/Bulletin.lib.php';
$currentEleve = $eleveManager->getCurrentEleve($username); $loggedUser = $this->authController->getLoggedUser();
// echo "<p>".var_dump($currentEleve)."</p>"; echo "<p>".var_dump($loggedUser)."</p>";
// if ($currentEleve == null) { if ($this->userManager->isInGroup($this->eeGroup, $loggedUser['name'], false)) {
$eleves = $eleveManager->getAll(); $eleves = $eleveManager->getAll();
$bulletins = []; $bulletins = [];
@ -53,12 +58,16 @@ class NoteManager {
return $this->wiki->render('@meeo/edu_notes.twig', [ return $this->wiki->render('@meeo/edu_notes.twig', [
"bulletins" => $bulletins, "bulletins" => $bulletins,
]); ]);
// } else { } else {
// $bulletin = new Bulletin($this->wiki, $currentEleve); echo "Eleve";
// return $this->wiki->render('@meeo/eleve_notes.twig', [ $currentEleve = $eleveManager->getCurrentEleve($loggedUser['name']);
// "bulletin" => $bulletin, if ($currentEleve != null) {
// ]); $bulletin = new Bulletin($this->wiki, $currentEleve);
// } return $this->wiki->render('@meeo/eleve_notes.twig', [
"bulletin" => $bulletin,
]);
}
}
} }
public function viewControle() { public function viewControle() {