From 108525534c28013cfe1897c30e4565f9893f3766 Mon Sep 17 00:00:00 2001 From: Minteck Date: Mon, 10 Oct 2022 20:51:39 +0200 Subject: Update --- includes/travelling.inc | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 includes/travelling.inc (limited to 'includes/travelling.inc') diff --git a/includes/travelling.inc b/includes/travelling.inc new file mode 100644 index 0000000..edcb267 --- /dev/null +++ b/includes/travelling.inc @@ -0,0 +1,47 @@ + false, + "history" => [] + ]; + } +} + +function withTravelers(array $members, string $system): array { + global $travelling; + + return [ + ...array_map(function ($i) use ($system) { + $i['system'] = $system; + return $i; + }, array_filter($members, function ($i) use ($travelling) { + return !(isset($travelling[$i['id']]) && $travelling[$i['id']]['travelling']); + })), + ...array_filter(array_map(function ($i) use ($system) { + $i['system'] = $system === "gdapd" ? "ynmuc" : "gdapd"; + return $i; + }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($system === "gdapd" ? "ynmuc" : "gdapd") . "/members.json"), true)), function ($i) use ($travelling) { + return isset($travelling[$i['id']]) && $travelling[$i['id']]['travelling']; + }) + ]; +} + +@file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json", utf8_encode(json_encode($travelling, JSON_PRETTY_PRINT))); \ No newline at end of file -- cgit