summaryrefslogtreecommitdiff
path: root/pages/travelling.inc
diff options
context:
space:
mode:
Diffstat (limited to 'pages/travelling.inc')
-rw-r--r--pages/travelling.inc112
1 files changed, 68 insertions, 44 deletions
diff --git a/pages/travelling.inc b/pages/travelling.inc
index b7b772b..a38ea87 100644
--- a/pages/travelling.inc
+++ b/pages/travelling.inc
@@ -1,6 +1,6 @@
<?php
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn;
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages;
$travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json"), true);
$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
@@ -9,6 +9,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.inc";
if (isset($_GET['toggleTravel'])) {
if (isset($travelling[$_GET['member']])) {
$id = $_GET['member'];
+ $equestria = isset($_GET['member']);
$member = getSystemMember(getMemberSystem($id), $id);
$system = getMemberSystem($id);
$metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$id.json"), true));
@@ -43,51 +44,55 @@ if (isset($_GET['toggleTravel'])) {
}
} else {
$travelling[$_GET['member']]["travelling"] = true;
+ $travelling[$_GET['member']]["equestria"] = $equestria;
$travelling[$_GET['member']]["pluralkit"] = null;
$travelling[$_GET['member']]["history"][] = [
"start" => date("c"),
- "end" => null
+ "end" => null,
+ "equestria" => $equestria
];
- // Insert code here to run after a travelling member is ADDED.
- // $id is the member ID (e.g. rirgf)
- // $member is the member
- // $system is the system the member comes from
- // $metadata is the ponies.equestria.horse metadata
- // $travellingMember is unset here
- // Store the travelling member ID in $travelling[$id]['pluralkit']
- $reqOptions = [
- 'http' => [
- 'method' => "POST",
- 'header' => "Authorization: " . $app["pluralkit"][$travellingSystem === "gdapd" ? "raindrops" : "cloudburst"] . "\r\n" .
- "Content-Type: application/json",
- 'content' => json_encode([
- 'name' => "$member[name]-travelling",
- 'display_name' => $member["display_name"],
- 'color' => $member["color"],
- 'birthday' => $member["birthday"],
- 'created' => $member["created"],
- 'pronouns' => $member["pronouns"],
- 'avatar_url' => $member["avatar_url"],
- 'banner' => $member["banner"],
- 'description' => "**This pony is visiting this system from the " . ($system === "gdapd" ? "Raindrops System" : "Cloudburst System") . ". They are not a permanent member of this system**\n\n$member[description]",
- 'proxy_tags' => array_map(function ($i) {
- $i["prefix"] = "+" . $i['prefix'];
- return $i;
- }, $member["proxy_tags"]),
- 'privacy' => $member["privacy"]
- ])
- ]
- ];
+ if (!$equestria) {
+ // Insert code here to run after a travelling member is ADDED.
+ // $id is the member ID (e.g. rirgf)
+ // $member is the member
+ // $system is the system the member comes from
+ // $metadata is the ponies.equestria.horse metadata
+ // $travellingMember is unset here
+ // Store the travelling member ID in $travelling[$id]['pluralkit']
+ $reqOptions = [
+ 'http' => [
+ 'method' => "POST",
+ 'header' => "Authorization: " . $app["pluralkit"][$travellingSystem === "gdapd" ? "raindrops" : "cloudburst"] . "\r\n" .
+ "Content-Type: application/json",
+ 'content' => json_encode([
+ 'name' => "$member[name]-travelling",
+ 'display_name' => $member["display_name"],
+ 'color' => $member["color"],
+ 'birthday' => $member["birthday"],
+ 'created' => $member["created"],
+ 'pronouns' => $member["pronouns"],
+ 'avatar_url' => $member["avatar_url"],
+ 'banner' => $member["banner"],
+ 'description' => "**This pony is visiting this system from the " . ($system === "gdapd" ? "Raindrops System" : "Cloudburst System") . ". They are not a permanent member of this system**\n\n$member[description]",
+ 'proxy_tags' => array_map(function ($i) {
+ $i["prefix"] = "+" . $i['prefix'];
+ return $i;
+ }, $member["proxy_tags"]),
+ 'privacy' => $member["privacy"]
+ ])
+ ]
+ ];
- $reqContext = stream_context_create($reqOptions);
+ $reqContext = stream_context_create($reqOptions);
- sleep(1);
- $member = json_decode(file_get_contents("https://api.pluralkit.me/v2/members", false, $reqContext), true);
+ sleep(1);
+ $member = json_decode(file_get_contents("https://api.pluralkit.me/v2/members", false, $reqContext), true);
- // Member exists?
- if (isset($member)) {
- $travelling[$id]['pluralkit'] = $member["id"];
+ // Member exists?
+ if (isset($member)) {
+ $travelling[$id]['pluralkit'] = $member["id"];
+ }
}
}
}
@@ -120,9 +125,9 @@ global $travelling;
...array_values(array_filter(scoreOrderGlobal(), function ($i) use ($travelling) {
return $travelling[$i['id']]["travelling"];
})),
- ...array_values(array_filter(scoreOrderGlobal(), function ($i) use ($travelling) {
- return !$travelling[$i['id']]["travelling"];
- }))
+ ...array_values(array_filter(scoreOrderGlobal(), function ($i) use ($travelling) {
+ return !$travelling[$i['id']]["travelling"];
+ }))
] as $member): ?>
<div class="relation" style="background-color:rgba(255, 255, 255, .1);margin-bottom:10px;padding:10px;border-radius:10px;display:grid;grid-template-columns: 1fr 2fr max-content;">
<a class="relation-intro" style="background-color:rgba(255, 255, 255, .05);border-right:1px solid rgba(255, 255, 255, .1);margin:-10px;padding:10px;border-top-left-radius:10px;border-bottom-left-radius:10px;color: white;display:flex;align-items:center;text-decoration: none;" href="/<?= $member["name"] ?>">
@@ -131,9 +136,13 @@ global $travelling;
<div class="relation-item" style="display:flex;align-items:center;margin-left:10px;padding:0 20px;">
<div>
- <b style="padding-right:5px;">Current system:</b><span class="list-separator-mobile"><br></span>
+ <b style="padding-right:5px;">Current location:</b><span class="list-separator-mobile"><br></span>
<?php $system = $member['_system'] === "gdapd" ? ($travelling[$member['id']]["travelling"] ? "ynmuc" : "gdapd") : ($travelling[$member['id']]["travelling"] ? "gdapd" : "ynmuc"); ?>
+ <?php if ($travelling[$member['id']]["travelling"] && $travelling[$member['id']]["equestria"]): ?>
+ <img style="width:24px;" src="/assets/logo/equestria.png"> Equestria
+ <?php else: ?>
<a class="member-link" href="/<?= $system === "gdapd" ? "raindrops" : "cloudburst" ?>"><img style="width:24px;border-radius:5px;" src="/assets/uploads/<?= $system === "gdapd" ? "raindrops" : "cloudburst" ?>.png"> <?= $system === "gdapd" ? "Raindrops" : "Cloudburst" ?> System</a>
+ <?php endif; ?>
<?php if ($travelling[$member['id']]["travelling"]): ?>
<span class="text-muted">(<?= timeAgo($travelling[$member['id']]["history"][count($travelling[$member['id']]["history"]) - 1]["start"]) ?>)</span>
<?php endif; ?>
@@ -142,9 +151,24 @@ global $travelling;
<div>
<?php if ($travelling[$member['id']]["travelling"]): ?>
- <a href="?toggleTravel&member=<?= $member['id'] ?>" class="btn btn-outline-danger">Stop travelling</a>
+ <div class="dropdown">
+ <button type="button" class="btn btn-outline-danger dropdown-toggle" data-bs-toggle="dropdown">
+ Stop travelling
+ </button>
+ <ul class="dropdown-menu">
+ <li><a class="dropdown-item" href="?toggleTravel&member=<?= $member['id'] ?>">Stop travelling</a></li>
+ </ul>
+ </div>
<?php else: ?>
- <a href="?toggleTravel&member=<?= $member['id'] ?>" class="btn btn-outline-success">Start travelling</a>
+ <div class="dropdown">
+ <button type="button" class="btn btn-outline-success dropdown-toggle" data-bs-toggle="dropdown">
+ Start travelling
+ </button>
+ <ul class="dropdown-menu">
+ <li><a class="dropdown-item" href="?toggleTravel&member=<?= $member['id'] ?>"><img style="width:24px;border-radius:5px;" src="/assets/uploads/<?= $system === "gdapd" ? "cloudburst" : "raindrops" ?>.png"> <?= $system === "gdapd" ? "Cloudburst" : "Raindrops" ?> System</a></li>
+ <li><a class="dropdown-item" href="?toggleTravel&equestria&member=<?= $member['id'] ?>"><img style="width:24px;" src="/assets/logo/equestria.png"> Equestria</a></li>
+ </ul>
+ </div>
<?php endif; ?>
</div>
</div>