new user right system

This commit is contained in:
Tower committed 2026-03-15 17:40:59 +01:00
1 parent 4b30f00872
commit 236fe1fd7f
2 files changed
+29 -24

No files matched your search

+3 -3
View File
@@ -231,7 +231,7 @@ $Berufsschulberichte = [
];
$Stundenplan = [
"MO" => ["table" => "Fach", "key" => "ID", "value" => "Fach"],
"MO" => ["table" => "Fach", "key" => "ID", "value" => "Fach"],
"DI" => ["table" => "Fach", "key" => "ID", "value" => "Fach"],
"MI" => ["table" => "Fach", "key" => "ID", "value" => "Fach"],
"DO" => ["table" => "Fach", "key" => "ID", "value" => "Fach"],
@@ -239,6 +239,6 @@ $Stundenplan = [
];
$Berechtigungen = [
"BENUTZER_ID" => ["table" => "Benutzer", "key" => "ID", "value" => "ID"],
"BERECHTIGUNGEN_ID" => ["table" => "Berechtigungen", "key" => "ID", "value" => "ID"]
"BENUTZER_ID" => ["table" => "Benutzer", "key" => "ID", "value" => "NAME"],
"SEITEN_ID" => ["table" => "Backend_Seiten", "key" => "ID", "value" => "DATEINAME"]
];
+26 -21
View File
@@ -25,6 +25,22 @@ include_once 'controller/UserController.php';
include_once 'modules/ConsoleLog.php';
// include 'controller/RoutesController.php';
$user_id = DatabaseShow(
"Benutzer",
"ID",
"NAME = ?",
$_SESSION['username'],
);
$rightsArray = DatabaseShowWithFK(
"Benutzer_Berechtigungen",
$Berechtigungen,
"SEITEN_ID",
"BENUTZER_ID = ?",
$user_id[0]['ID'],
);
$userRights = array_map('trim', array_column($rightsArray['rows'], 'SEITEN_ID'));
$selectedService = null;
@@ -36,7 +52,6 @@ if (
$selectedService = $_GET['service'];
}
// 2. Default-Service
if (!$selectedService &&
isset($defaultService) &&
isset($services[$defaultService]) &&
@@ -45,7 +60,6 @@ if (!$selectedService &&
$selectedService = $defaultService;
}
// 3. Fallback: erster aktiver Service
if (!$selectedService) {
foreach ($services as $key => $service) {
if ($service['active']) {
@@ -54,6 +68,11 @@ if (!$selectedService) {
}
}
}
if ($selectedService && !in_array($selectedService, $userRights, true)) {
$selectedService = null;
}
$isAdmin = isset($_SESSION['is_admin']) && $_SESSION['is_admin'] === true;
if ((new getSpecificData())->getWebsite() != "backend.blackpi.ipv64.net") {
@@ -86,33 +105,19 @@ if ((new getSpecificData())->getWebsite() != "backend.blackpi.ipv64.net") {
$visibleServices = [];
foreach ($group['services'] as $serviceKey) {
if (!isset($services[$serviceKey])) continue;
if (!$services[$serviceKey]['active']) continue;
if (!empty($services[$serviceKey]['adminOnly']) && !$isAdmin) {
continue;
}
if (!empty($services[$serviceKey]['adminOnly']) && !$isAdmin) continue;
if (!in_array($serviceKey, $userRights, true)) continue;
$visibleServices[] = $serviceKey;
}
if (empty($visibleServices)) {
continue;
}
if (empty($visibleServices)) continue;
$isOpen = false;
if (!empty($group['defaultOpen'])) {
$isOpen = true;
}
if (in_array($selectedService, $visibleServices, true)) {
$isOpen = true;
}
$isOpen = !empty($group['defaultOpen']) || in_array($selectedService, $visibleServices, true);
?>
<div class="service-group <?= $isOpen ? 'open' : '' ?>" data-group="<?= $groupKey ?>">
<div class="group-title">
<?= htmlspecialchars($group['label']) ?>
<span class="arrow">▸</span>