dont show pages you dont have permission to in the navigation

This commit is contained in:
Bruno Rybársky 2024-02-01 10:14:49 +01:00
parent f2e3ac6bcd
commit 60bf24ec77

@ -35,8 +35,8 @@ function generateNavigation(): string
}
$navpages = "";
foreach ($pages_dir as $page_dir) {
$page_dir = explode(".", $page_dir)[0];
foreach ($pages_dir as $page_file) {
$page_dir = explode(".", $page_file)[0];
$page_class = "class=\"navpage_link\"";
if ($routerRequest["subdomain"] == $site_dir && $routerRequest["page_name"] == $page_dir) {
$page_class = "class=\"navpage_link active\"";
@ -47,11 +47,25 @@ function generateNavigation(): string
$page_name = str_replace("_", " ", $page_dir);
$page_name = explode(".", $page_name)[0];
$page_name = ucfirst($page_name);
$page_file = $routerConfig["page_dir"] . $site_dir . "/" . $page_file ;
$page_tmp = file_get_contents($page_file);
$pageMetadata = parsePageTag($page_tmp);
if(!empty($pageMetadata["parameters"]["minimal_permission_level"])){
$page_required_permission = intval($pageMetadata["parameters"]["minimal_permission_level"]);
}
else{
$page_required_permission = $routerConfig["default_page_permission_level"];
}
if($page_required_permission <= $_SESSION["privilegelevel"]) {
$navpages .= "<li class='navpage_item'><a href='$page_location' $page_class>$page_name</a></li>";
}
}
if(!empty($navpages)){
$nav_out .= "<li class='navsite_item'><a href='$site_location' $site_class>$site_name</a><ul class='navpage_list'>$navpages</ul></li>";
}
}
return $nav_out;
}