summaryrefslogtreecommitdiff
path: root/pages/edit-private.php
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-09-21 22:42:33 +0200
committerMinteck <contact@minteck.org>2022-09-21 22:42:33 +0200
commite95b208af90cc386a7d8d1bcab426727cf4f0121 (patch)
treeb293e0c644513fbeb6e9ad29be97fa6347a55e9f /pages/edit-private.php
parentb5f589c323f415bb42ea7069cb4d1a8a2233dd69 (diff)
downloadpluralconnect-e95b208af90cc386a7d8d1bcab426727cf4f0121.tar.gz
pluralconnect-e95b208af90cc386a7d8d1bcab426727cf4f0121.tar.bz2
pluralconnect-e95b208af90cc386a7d8d1bcab426727cf4f0121.zip
Update time
Diffstat (limited to 'pages/edit-private.php')
-rw-r--r--pages/edit-private.php68
1 files changed, 68 insertions, 0 deletions
diff --git a/pages/edit-private.php b/pages/edit-private.php
new file mode 100644
index 0000000..ac93e06
--- /dev/null
+++ b/pages/edit-private.php
@@ -0,0 +1,68 @@
+<?php
+
+function getSubsystemByID(string $id) {
+ global $subsystems;
+ $subsystem = null;
+
+ foreach ($subsystems as $ss) {
+ if ($ss["source"] === $id) {
+ $subsystem = $ss;
+ }
+ }
+
+ return $subsystem;
+}
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.php"; global $title; global $isLoggedIn;
+
+if (!isset($_GET['_']) || trim($_GET['_']) === "") header("Location: /?error=Invalid request") and die();
+
+$parts = explode("/", $_GET['_']);
+array_shift($parts);
+array_shift($parts);
+$system = $parts[0];
+$member = ($parts[1] ?? null) === "" ? null : $parts[1];
+
+if ($system !== "cloudburst" && $system !== "raindrops") header("Location: /?error=Invalid system name: " . $system) and die();
+$systemCommonName = $system === "cloudburst" ? "Cloudburst System" : "Raindrops System";
+$systemID = $system === "cloudburst" ? "ynmuc" : "gdapd";
+
+$subsystems = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-subsystems.json"), true) ?? [];
+
+if ($member === null) {
+ header("Location: /?error=Unsupported target: system") and die();
+} else {
+ $isSubsystem = false;
+ $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "-members.json"), true);
+ $memberData = null;
+ $memberCommonName = null;
+ $memberID = null;
+
+ foreach ($members as $m) {
+ if ($m['name'] === $member) {
+ $memberData = $m;
+ $memberCommonName = $m['display_name'] ?? $m['name'];
+ $memberID = $m['id'];
+ }
+ }
+
+ if ($memberData === null) {
+ if (in_array($member, array_map(function ($i) {
+ return $i["source"];
+ }, $subsystems))) {
+ $isSubsystem = true;
+ $subsystemID = $member;
+ $subsystem = getSubsystemByID($subsystemID);
+ $subsystemData = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-subsystem-$subsystem[source].json"), true);
+ $subsystemCommonName = $subsystemData["name"] ?? $subsystemID;
+
+ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/subsysedit.php';
+ } else {
+ header("Location: /?error=System member or subsystem not found") and die();
+ }
+ }
+
+ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/edit-private.php';
+}
+
+exit; \ No newline at end of file