iwa-panda1

Manage Weather Data by International Weather Agency (Version 1)
Log | Files | Refs

backup (3954B)


      1 <?php
      2 session_start();
      3 
      4 // Check if user is logged in and has permission level set
      5 if(!isset($_SESSION['email'])) {
      6     // Redirect to login page if permission level is not set
      7     header('Location: login.php');
      8     exit;
      9 }
     10 // Get the permission level of the user
     11 $permission_levels= $_SESSION['permissions'];
     12 
     13 // Assume $permission_levels is an array containing the user's permission levels
     14 
     15 $links = array();
     16 
     17 // Define the links for each type of employee
     18 if (in_array(1, $permission_levels)) {
     19     // Admin links
     20     $admin_links = array(
     21         array('url' => '/crud_user.php', 'title' => 'User toevoegen'),
     22         array('url' => 'admin_page_2.php', 'title' => 'Admin Page 2'),
     23         array('url' => 'admin_page_3.php', 'title' => 'Admin Page 3')
     24     );
     25     $links[] = array('name' => 'Admin', 'links' => $admin_links);
     26 }
     27 
     28 if (in_array(2, $permission_levels)) {
     29     // Administrative employee links
     30     $admin_employee_links = array(
     31         array('url' => 'admin_employee_page_1.php', 'title' => 'Admin Employee Page 1'),
     32         array('url' => 'admin_employee_page_2.php', 'title' => 'Admin Employee Page 2'),
     33         array('url' => 'admin_employee_page_3.php', 'title' => 'Admin Employee Page 3')
     34     );
     35     $links[] = array('name' => 'Administrative Employee', 'links' => $admin_employee_links);
     36 }
     37 
     38 if (in_array(3, $permission_levels)) {
     39     // Scientific employee links
     40     $scientific_employee_links = array(
     41         array('url' => 'scientific_employee_page_1.php', 'title' => 'Scientific Employee Page 1'),
     42         array('url' => 'scientific_employee_page_2.php', 'title' => 'Scientific Employee Page 2'),
     43         array('url' => 'scientific_employee_page_3.php', 'title' => 'Scientific Employee Page 3')
     44     );
     45     $links[] = array('name' => 'Scientific Employee', 'links' => $scientific_employee_links);
     46 }
     47 
     48 if (empty($links)) {
     49     // Guest links
     50     $guest_links = array(
     51         array('url' => 'guest_page_1.php', 'title' => 'Guest Page 1')
     52     );
     53     $links[] = array('name' => 'Guest', 'links' => $guest_links);
     54 }
     55 ?>
     56 <!DOCTYPE html>
     57 <html>
     58 <head>
     59     <title>Dashboard</title>
     60     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
     61 </head>
     62 <body>
     63     <nav class="navbar navbar-expand-lg navbar-light bg-light">
     64         <a class="navbar-brand" href="#">Dashboard</a>
     65         <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
     66             <span class="navbar-toggler-icon"></span>
     67         </button>
     68         <div class="collapse navbar-collapse" id="navbarNavDropdown">
     69             <ul class="navbar-nav">
     70                 <?php foreach($links as $employee_links) { ?>
     71                     <li class="nav-item dropdown">
     72                         <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink<?php echo $employee_links['name']; ?>" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
     73                             <?php echo $employee_links['name']; ?>
     74                         </a>
     75                         <ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink<?php echo $employee_links['name']; ?>">
     76                             <?php foreach ($employee_links['links'] as $link) { ?>
     77                                 <li><a class="dropdown-item" href="<?php echo $link['url']; ?>"><?php echo $link['title']; ?></a></li>
     78                             <?php } ?>
     79                         </ul>
     80                     </li>
     81                 <?php } ?>
     82             </ul>
     83         </div>
     84     </nav>
     85     <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
     86     <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script>
     87     <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
     88 </body>
     89 </html>
     90 
     91