Skip to content

Commit 1389866

Browse files
committed
Replays: Restore edit function
Apparently that's why that was broken.
1 parent 3515fdd commit 1389866

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

replay.pokemonshowdown.com/replay-manage.php

-2
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ function userid($username) {
150150
$replay['private'] = intval($_POST['private']);
151151
$Replays->edit($replay);
152152
echo '<p>Edited.</p>';
153-
} else {
154-
echo '<p>Editing privacy to '.$_POST['private']. 'failed. ';
155153
}
156154
?>
157155
Change privacy: <form action="/<?= $replay['id'] ?>/manage" method="post" style="display: inline" data-target="replace">

replay.pokemonshowdown.com/replays.lib.php

+21
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,27 @@ function genPassword() {
5050
return $password;
5151
}
5252

53+
function edit($replay) {
54+
if ($replay['private'] === 3) {
55+
$replay['private'] = 3;
56+
$res = $this->db->prepare("UPDATE replays SET private = 3, password = NULL WHERE id = ? LIMIT 1");
57+
$res->execute([$replay['id']]);
58+
} else if ($replay['private'] === 2) {
59+
$replay['private'] = 1;
60+
$replay['password'] = NULL;
61+
$res = $this->db->prepare("UPDATE replays SET private = 1, password = NULL WHERE id = ? LIMIT 1");
62+
$res->execute([$replay['id']]);
63+
} else if ($replay['private']) {
64+
if (!$replay['password']) $replay['password'] = $this->genPassword();
65+
$res = $this->db->prepare("UPDATE replays SET private = 1, password = ? WHERE id = ? LIMIT 1");
66+
$res->execute([$replay['password'], $replay['id']]);
67+
} else {
68+
$res = $this->db->prepare("UPDATE replays SET private = 0, password = NULL WHERE id = ? LIMIT 1");
69+
$res->execute([$replay['id']]);
70+
}
71+
return;
72+
}
73+
5374
function get($id, $force = false) {
5475
if (!$this->db) {
5576
// if (!$force) return false;

0 commit comments

Comments
 (0)