From 60bf24ec77fa90bad9054ed11aaca1a40055d3a6 Mon Sep 17 00:00:00 2001 From: bruno Date: Thu, 1 Feb 2024 10:14:49 +0100 Subject: [PATCH] dont show pages you dont have permission to in the navigation --- lib/navigation.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/navigation.php b/lib/navigation.php index fe32a71..8471012 100644 --- a/lib/navigation.php +++ b/lib/navigation.php @@ -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,10 +47,24 @@ 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); - $navpages .= ""; + $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 .= ""; + } + } + if(!empty($navpages)){ + $nav_out .= ""; } - $nav_out .= ""; } return $nav_out;