diff options
author | Minteck <contact@minteck.org> | 2022-08-21 17:31:56 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-08-21 17:31:56 +0200 |
commit | a2df9a69dcc14cb70118cda2ded499055e7ee358 (patch) | |
tree | 6dd283e4e9452d38bce81ddaaae49b5335755842 /includes/travelling.php | |
parent | 84dd0735820b16b60f600284d35183d76547a71f (diff) | |
download | pluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.tar.gz pluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.tar.bz2 pluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.zip |
m. update
Diffstat (limited to 'includes/travelling.php')
-rw-r--r-- | includes/travelling.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/includes/travelling.php b/includes/travelling.php new file mode 100644 index 0000000..bb24172 --- /dev/null +++ b/includes/travelling.php @@ -0,0 +1,40 @@ +<?php + +$travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling.json"), true); +$members = [...array_map(function ($i) { + $i["_system"] = "ynmuc"; + return $i; +}, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true)), ...array_map(function ($i) { + $i["_system"] = "gdapd"; + return $i; +}, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true))]; + +foreach ($members as $member) { + if (!isset($travelling[$member["id"]])) { + $travelling[$member["id"]] = [ + "travelling" => 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 !$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 $travelling[$i['id']]['travelling']; + }) + ]; +} + +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling.json", json_encode($travelling, JSON_PRETTY_PRINT));
\ No newline at end of file |