-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.php
67 lines (51 loc) · 1.9 KB
/
menu.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/*
* MENU.PHP
* ========
* Shows the left menu of the textbook.
*/
require_once "mysqlStuff.php";
/**
* Shows menu items - names of lessons as links.
*/
function showMenuItems() {
$con = db_connect();
$resultSet = $con->query("SELECT *
FROM lesson
ORDER BY number, lessonid");
while($lesson = $resultSet->fetch_array()) {
$number = $lesson["number"];
$id = $lesson["lessonid"];
$name = $lesson["name"];
// if this lesson is selected, then show menu unit as selected
$selected = isset($_GET["lesson"]) && $_GET["lesson"] == $id // lessonid is in GET
||
// lessonid is not in GET, but there has been a lesson displayed before
! isset($_GET["lesson"]) && isset ($_SESSION["lastlesson"]) && $_SESSION["lastlesson"] == $id ?
" selectedLesson" : "";
if($lesson["public"]) { // lesson is public
echo "<div class=\"menuUnit$selected\">
<a href=\"index.php?page=lessons&lesson=$id\" class=\"$selected\">
$number. $name
</a>
</div>";
} elseif (isset ($_SESSION["isadmin"]) && $_SESSION["isadmin"] == true) { // lesson isn't public, but user is admin
echo "<div class=\"menuUnit disabledLesson\">
<a href=\"index.php?page=lessons&lesson=$id\">
$number. $name
</a>
</div>";
}
}
$resultSet->close();
$con->close();
}
showMenuItems();
if(isset($_SESSION["isadmin"]) && $_SESSION["isadmin"]) {
?>
<div class="menuUnit" style="background-color: lightsalmon; text-align: center">
<a href="index.php?page=admin§ion=lessons" style="color: black; text-decoration: underline">spravovat lekce</a>
</div>
<?php
}
?>