Current Path : /data/web/virtuals/51568/virtual/www/subdom/agenda/php/ |
Current File : /data/web/virtuals/51568/virtual/www/subdom/agenda/php/Login.php |
<?php class Login { public function menu(){ if (!isset($_SESSION["account"])) { return false; } $account = json_decode($_SESSION["account"]); $db = new DB(); $prava = $db->fetchAll('SELECT `pravaid` FROM `users_prava` WHERE `usersid` = :id', $account->id); $jeReditel = $db->fetchOne("SELECT `users`.`jereditel` FROM `users` WHERE `users`.`id`= :id", $account->id)->jereditel === '1'; $doucovani = ''; $jednani = ''; $cestaky = ''; $exkurze = ""; $akce = ''; if (($account->spravce == '1') || $prava){ $ucitele = ($account->spravce == '1') ? ' <li><a class="dropdown-item" href="#" onclick="ucitele()">Učitelé</a></li> <li><a class="dropdown-item" href="#">Třídy »</a> <ul class="submenu dropdown-menu"> <li><a class="dropdown-item" href="#" onclick="tridy()">Seznam tříd</a></li> <li><a class="dropdown-item" href="#" onclick="tridyHodiny(0)">Třídnické hodiny</a></li> </ul> </li> <li><a class="dropdown-item" href="#" onclick="importBakalari()">Import žáků z Bakalářů</a></li> ' : ''; $je7 = false; $je8 = false; forEach($prava as $pravo){ switch ($pravo->pravaid){ case 3: $jednani = '<li><a class="dropdown-item" href="#" onclick="jednaniZaznamy()">Deník pedagogů</a></li> <li><a class="dropdown-item" href="#" onclick="jednaniMeziKolegy()">Jednání mezi kolegy</a></li>'; break; case 4: $akce = '<li><a class="dropdown-item" href="#" onclick="akceZaznamy()">Přehled akcí</a></li>'; break; case 5: $doucovani = '<li><a class="dropdown-item" href="#" onclick="skupiny()">Skupiny doučování</a></li>'; break; case 6: $aktualni = $db->fetchOne("SELECT `jak_vyzvy`.`id` as idvyzvy, `jak_roky`.`id` as idrok FROM `jak_vyzvy` left join `jak_roky` on `jak_roky`.`idvyzvy`=`jak_vyzvy`.`id` WHERE `jak_roky`.`aktualni`='1'"); $jak = ' <li class="mt-2"><div id="id-opjak" class="py-1 dropdown-header border bg-secondary text-white fw-bold" data-idopjak="'.$aktualni->idvyzvy.'" data-idrok="'.$aktualni->idrok.'">OP JAK</div></li> <li><a class="dropdown-item" href="#" onclick="vyzvySeznam()">Výzvy</a></li> <li><a class="dropdown-item" href="#" onclick="DVPP()">DVPP</a></li> <li><a class="dropdown-item" href="#" onclick="inovativniSkupiny()">Inovativní vzdělávání</a></li>'; break; case 7: $cestaky = '<li><a class="dropdown-item" href="#" onclick="cestakySpravce()">Zpracování cesťáků</a></li>'; $je7 = true; break; case 8: $exkurze = '<li><a class="dropdown-item" href="#" onclick="exkurzeSpravce()">Zpracování exkurzí</a></li>'; $je8 = true; break; } } if ($jeReditel && (!$je7)){ $cestaky = '<li><a class="dropdown-item" href="#" onclick="cestakySpravce()">Zpracování cesťáků</a></li>'; } if ($jeReditel && (!$je8)){ $exkurze = '<li><a class="dropdown-item" href="#" onclick="exkurzeSpravce()">Zpracování exkurzí</a></li>'; } $spravce = <<<SPRAVCE <li class="nav-item dropdown" > <a class="nav-link top-menu text-white dropdown-toggle" href="#" id="navbarSpravce" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Správce </a> <ul class="dropdown-menu" aria-labelledby="navbarSpravce"> $doucovani $jednani $akce $cestaky $exkurze $ucitele $jak </ul> </li> SPRAVCE; } else { $spravce = ''; } $menu = <<<HTML <nav class="navbar navbar-expand-md bg-primary navbar-dark "> <div class="container-fluid"> <button class="navbar-toggler ms-auto " type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerEditace" aria-controls="navbarTogglerEditace" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarTogglerEditace"> <ul class="navbar-nav mb-2 mb-md-0"> <li class="border-end border-white"> <i class="fas fa-chalkboard-teacher text-white pt-2 pe-3 h4"></i> </li> <li class="nav-item"> <a class="nav-link top-menu text-white" aria-current="page" onclick="mojeSkupiny()" href="#">Doučování</a> </li> <li class="nav-item dropdown" > <a class="nav-link top-menu text-white dropdown-toggle" href="#" id="navbarJAK" role="button" data-bs-toggle="dropdown" aria-expanded="false"> OP JAK </a> <ul class="dropdown-menu" aria-labelledby="navbarJAK"> <li> <a class="dropdown-item" href="#" onclick="mojeInovativni()">Inovativní výuka</a> </li> <li> <a class="dropdown-item" href="#" onclick="mojeDVPP()">DVPP</a> </li> </ul> </li> <li class="nav-item dropdown" > <a class="nav-link top-menu text-white dropdown-toggle" href="#" id="navbarZapisy" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Zápisy z jednání </a> <ul class="dropdown-menu" aria-labelledby="navbarZapisy"> <li><a class="dropdown-item" onclick="mojeJednani()" href="#">Deník pedagoga</a></li> <li><a class="dropdown-item" onclick="jednaniKolega()" href="#">Jednání s kolegou</a></li> </ul> </li> <li class="nav-item"> <a class="nav-link top-menu text-white" aria-current="page" onclick="mojeCestaky()" href="#">Cesťáky</a> </li> <li class="nav-item"> <a class="nav-link top-menu text-white" aria-current="page" onclick="mojeExkurze()" href="#">Exkurze</a> </li> <li class="nav-item"> <a class="nav-link top-menu text-white" aria-current="page" onclick="mojeAkce()" href="#">Organizování akcí</a> </li> <li class="nav-item"> <a class="nav-link top-menu text-white" aria-current="page" onclick="mojeTH()" href="#">Zápisy TH</a> </li> $spravce <li class="nav-item" > <a class="nav-link top-menu text-white" aria-current="page" onclick="logout()" href="#">Odhlásit ($account->login)</a> </li> </ul> </div> </div> </nav> HTML; return $menu; } public function prihlaseni(){ $dlg = <<<HTML <div class="row justify-content-center mt-3"> <div id="dialog-login" class="card px-0 rounded-0 shadow"> <div class="card-header bg-primary text-white rounded-0 d-flex"> <div class="pt-1"> Přihlášení do agendy učitele ZŠ Republiky Znojmo </div> <div class="ms-auto h5"><i class="fas fa-chalkboard-teacher"></i></div> </div> <div class="card-body"> <div class="form-group"> <label for="email">Email</label> <input type="text" class="form-control rounded-0" name="email" id="email" required autofocus minlength="8" > </div> <div class="form-group mt-2 row"> <label for="pass">Heslo</label> <div class="input-group"> <input type="password" class="form-control rounded-0" name="password" id="password" required minlength="8" value="" > <span class="input-group-text" id="passVisible" pass-visible="0" style="cursor: pointer" onclick="passwordVisibility()"> <i class="far fa-eye"></i> </span> </div> </div> <!--div class="form-group mt-1"> <div> <div class="form-check"> <input class="form-check-input rounded-0" type="checkbox" name="rememberme" id="rememberme" value=""> <label class="form-check-label" for="rememberme">zapamatuj si mě</label> </div> </div> </div--> <div id="error-message" class="alert alert-danger my-2 py-1 rounded-0 d-none"></div> </div> <div class="card-footer"> <div class="d-flex"> <button type="submit" class="btn btn-outline-primary rounded-0" onclick="zapomenuteHeslo()">Neznám heslo</button> <button type="submit" class="btn btn-primary rounded-0 ms-auto" onclick="prihlasit()">Přihlásit</button> </div> </div> </div> </div> HTML; return $dlg; } public function zapomenuteHeslo(){ $dlg = <<<HTML <div class="row justify-content-center mt-3"> <div id="dialog-login" class="card px-0 rounded-0 shadow"> <div class="card-header bg-primary text-white rounded-0">Přihlášení do agendy učitele:<span class="fw-bold"> zapomenuté heslo</span></div> <div class="card-body"> <div class="form-group"> <label for="email-zapomenute">Email</label> <input type="text" class="form-control rounded-0" name="email-zapomenute" id="email-zapomenute" autofocus minlength="8" > </div> <div id="error-message" class="alert alert-danger my-2 py-1 rounded-0 d-none"></div> <div id="success-message" class="alert alert-success my-2 py-1 rounded-0 d-none"></div> </div> <div class="card-footer"> <div class="d-flex"> <button type="submit" class="btn btn-outline-primary rounded-0" onclick="loginZpetPrihlaseni()">Zpět na přihlášení</button> <button type="submit" class="btn btn-primary rounded-0 ms-auto" onclick="loginHesloEmail()">Poslat heslo na email</button> </div> </div> </div> </div> HTML; return $dlg; } public function hesloZmena($data){ try { $db = new DB(); $hash = password_hash($data->password, PASSWORD_DEFAULT); $db->query('UPDATE `users` SET `password`=:password WHERE `id` = :id', $hash, $data->id); $db->query('DELETE FROM `users_verify` WHERE `ucitele_id` = :id', $data->id); } catch (exception $e) { //return $e; } } }