SAE_web/views/header.php

70 lines
2.2 KiB
PHP
Raw Normal View History

<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/tools/dbConnect.php';
if (isset($_COOKIE['userData'])) {
$userDataEncoded = $_COOKIE['userData'];
$userData = json_decode($userDataEncoded, true); // 'true' pour obtenir un tableau associatif
$email = $userData['email'];
$name = $userData['name'];
$familyName = $userData['familyName'];
$role = $userData['role'];
}
?>
2024-05-28 15:40:57 +02:00
<nav class="menu-container">
<!-- burger menu -->
2024-05-28 15:40:57 +02:00
<input type="checkbox" aria-label="Toggle menu" />
2024-05-28 15:40:57 +02:00
<span></span>
<span></span>
<span></span>
<!-- logo -->
<a href="../../../" class="menu-logo">
2024-05-28 15:40:57 +02:00
<img src="https://i.imgur.com/RkmSo9Q.png" alt="Jeux Olympiques - Paris 2024" />
</a>
<!-- menu items -->
<div class="menu">
<ul>
<li><?php
if (isset($_COOKIE['userData'])) {
$role = $userData['role'];
if ($role == 'Administrateur') {
echo "<a href='/admin'>Panel d'administration</a>";
}
}
?></li>
2024-05-28 15:40:57 +02:00
<li>
<a href="/events">
Évènements
</a>
</li>
</ul>
<ul>
<li><?php
if (isset($_COOKIE['userData'])) {
echo "<a href='/tools/logout.php' title='Déconnexion'><i class='fas fa-sign-out-alt'></i></a>";
}
?></li>
2024-05-28 15:40:57 +02:00
<li>
<?php
if (isset($_COOKIE['userData'])) {
//echo "<a href='/account/profile'>Mon profil</a>";
$userName = "" . $userData['name'] . " " . $userData['familyName'] . "";
echo "<a href='/account/profile'><img class='avatar' src='https://cdn-icons-png.flaticon.com/64/4139/4139948.png' title=" . $userName . "></a>";
//echo "<br>" . $userData['name'] . " " . $userData['familyName'];
} else {
echo "<a href='/account/login'>Connexion</a>";
}
?>
2024-05-28 15:40:57 +02:00
</li>
2024-05-28 15:40:57 +02:00
</ul>
</div>
</nav>
<script src="https://kit.fontawesome.com/f16a36bad3.js" crossorigin="anonymous"></script>