summaryrefslogtreecommitdiff
path: root/includes/components/navigation.inc
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-04-02 23:03:02 +0200
committerRaindropsSys <contact@minteck.org>2023-04-02 23:03:02 +0200
commit02eda3e4c9b4ba718f1fff70b7328ed8cdd5e63b (patch)
tree6d1dec61008998aadc6b69f7e750712794d99324 /includes/components/navigation.inc
parentf559308a1b42a9036135d764374a8c007b7d70a9 (diff)
downloadpluralconnect-02eda3e4c9b4ba718f1fff70b7328ed8cdd5e63b.tar.gz
pluralconnect-02eda3e4c9b4ba718f1fff70b7328ed8cdd5e63b.tar.bz2
pluralconnect-02eda3e4c9b4ba718f1fff70b7328ed8cdd5e63b.zip
Updated 35 files, added 11 files and deleted includes/components/search.inc (automated)
Diffstat (limited to 'includes/components/navigation.inc')
-rw-r--r--includes/components/navigation.inc148
1 files changed, 76 insertions, 72 deletions
diff --git a/includes/components/navigation.inc b/includes/components/navigation.inc
index bd4ea4b..29168ec 100644
--- a/includes/components/navigation.inc
+++ b/includes/components/navigation.inc
@@ -4,7 +4,78 @@ $pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pa
global $navigation;
global $toplevel;
-global $lang; global $pages; global $app; global $isLowerLoggedIn;
+global $lang; global $pages; global $app; global $isLowerLoggedIn; global $isLoggedIn;
+
+$cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/navigation.json"), true);
+
+if (!isset($cache["raindrops"])) $cache["raindrops"] = [];
+if (!isset($cache["cloudburst"])) $cache["cloudburst"] = [];
+if (!isset($cache["other"])) $cache["other"] = [];
+
+foreach ([
+ [
+ "name" => "raindrops",
+ "id" => "gdapd"
+ ],
+ [
+ "name" => "cloudburst",
+ "id" => "ynmuc"
+ ],
+ [
+ "name" => "other",
+ "id" => $app["other"]["id"]
+ ]
+] as $cacheSystem) {
+ if (!isset($cache[$cacheSystem["name"]]["public"])) {
+ $isLoggedInOldState = $isLoggedIn;
+ $isLowerLoggedInOldState = $isLowerLoggedIn;
+
+ $isLoggedIn = false;
+ $isLowerLoggedIn = false;
+
+ $cache[$cacheSystem["name"]]["public"] = array_map(function ($member) {
+ return [
+ "name" => $member['display_name'] ?? $member['name'],
+ "icon" => getAsset($member["system"], $member["id"], "heads"),
+ "invert" => false,
+ "link" => "/$member[name]",
+ "stepped" => null,
+ "private" => false
+ ];
+ }, array_filter(scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$cacheSystem[id]/members.json"), true), "$cacheSystem[id]"), "$cacheSystem[id]"), function ($member) {
+ return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new";
+ }));
+
+ $isLoggedIn = $isLoggedInOldState;
+ $isLowerLoggedIn = $isLowerLoggedInOldState;
+ }
+
+ if (!isset($cache[$cacheSystem["name"]]["private"])) {
+ $isLoggedInOldState = $isLoggedIn;
+ $isLowerLoggedInOldState = $isLowerLoggedIn;
+
+ $isLoggedIn = true;
+ $isLowerLoggedIn = false;
+
+ $cache[$cacheSystem["name"]]["private"] = array_map(function ($member) {
+ return [
+ "name" => $member['display_name'] ?? $member['name'],
+ "icon" => getAsset($member["system"], $member["id"], "heads"),
+ "invert" => false,
+ "link" => "/$member[name]",
+ "stepped" => null,
+ "private" => false
+ ];
+ }, array_filter(scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$cacheSystem[id]/members.json"), true), "$cacheSystem[id]"), "$cacheSystem[id]"), function ($member) {
+ return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new";
+ }));
+
+ $isLoggedIn = $isLoggedInOldState;
+ $isLowerLoggedIn = $isLowerLoggedInOldState;
+ }
+}
+
+file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/navigation.json", json_encode($cache));
$navigation_admin = [
"admin" => !$isLowerLoggedIn,
@@ -173,41 +244,7 @@ $navigation_admin = [
"private" => false
],
]
- ],
- /*"debug" => [
- "name" => $lang["navigation"]["debug"],
- "minimal" => false,
- "items" => [
- [
- "name" => $pages["debug"]["name"][$lang["_name"]],
- "icon" => "/assets/icons/debug.svg",
- "invert" => true,
- "link" => "/-/debug",
- "stepped" => null
- ],
- [
- "name" => $pages["bitset"]["name"][$lang["_name"]],
- "icon" => "/assets/icons/bitset.svg",
- "invert" => true,
- "link" => "/-/bitset",
- "stepped" => null
- ],
- [
- "name" => $pages["score"]["name"][$lang["_name"]],
- "icon" => "/assets/icons/score.svg",
- "invert" => true,
- "link" => "/-/score",
- "stepped" => null
- ],
- [
- "name" => $pages["logout"]["name"][$lang["_name"]],
- "icon" => "/assets/icons/logout.svg",
- "invert" => true,
- "link" => "/-/logout",
- "stepped" => null
- ]
- ]
- ]*/
+ ]
]
];
$navigation_global = [
@@ -287,18 +324,7 @@ $navigation_cloudburst = [
"members" => [
"name" => $lang["navigation"]["members"],
"minimal" => false,
- "items" => array_map(function ($member) {
- return [
- "name" => $member['display_name'] ?? $member['name'],
- "icon" => getAsset($member["system"], $member["id"], "heads"),
- "invert" => false,
- "link" => "/$member[name]",
- "stepped" => null,
- "private" => false
- ];
- }, array_filter(scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true), "ynmuc"), "ynmuc"), function ($member) {
- return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new";
- }))
+ "items" => $cache["cloudburst"][$isLoggedIn || $isLowerLoggedIn ? "private" : "public"]
]
]
];
@@ -341,18 +367,7 @@ $navigation_other = [
"members" => [
"name" => $lang["navigation"]["members"],
"minimal" => false,
- "items" => array_map(function ($member) {
- return [
- "name" => $member['display_name'] ?? $member['name'],
- "icon" => getAsset($member["system"], $member["id"], "heads"),
- "invert" => false,
- "link" => "/$member[name]",
- "stepped" => null,
- "private" => false
- ];
- }, array_filter(scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/members.json"), true), $app["other"]["id"]), function ($member) {
- return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new";
- }))
+ "items" => $cache["other"][$isLoggedIn || $isLowerLoggedIn ? "private" : "public"]
]
]
];
@@ -395,18 +410,7 @@ $navigation_raindrops = [
"members" => [
"name" => $lang["navigation"]["members"],
"minimal" => false,
- "items" => array_map(function ($member) {
- return [
- "name" => $member['display_name'] ?? $member['name'],
- "icon" => getAsset($member["system"], $member["id"], "heads"),
- "invert" => false,
- "link" => "/$member[name]",
- "stepped" => null,
- "private" => false
- ];
- }, array_filter(scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true), "gdapd"), "gdapd"), function ($member) {
- return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new";
- }))
+ "items" => $cache["raindrops"][$isLoggedIn || $isLowerLoggedIn ? "private" : "public"]
]
]
];