aboutsummaryrefslogtreecommitdiff
path: root/controllers/list.php
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2025-02-02 11:06:04 +0200
committerSyndamia <kamen@syndamia.com>2025-02-02 11:06:04 +0200
commit0f54da2c648a5913f6ed282f39dc7d6a62ef37da (patch)
tree22c0dc0a3e6151c16b5fe0686035d783f96b36e9 /controllers/list.php
parent4bebfa04cf759d77c511541bdf30747c76a3b2e1 (diff)
downloadnowayforward_human-0f54da2c648a5913f6ed282f39dc7d6a62ef37da.tar
nowayforward_human-0f54da2c648a5913f6ed282f39dc7d6a62ef37da.tar.gz
nowayforward_human-0f54da2c648a5913f6ed282f39dc7d6a62ef37da.zip
feat(views/list): Fully implement list deletion
Diffstat (limited to 'controllers/list.php')
-rw-r--r--controllers/list.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/controllers/list.php b/controllers/list.php
index 07db6c5..c2e72a0 100644
--- a/controllers/list.php
+++ b/controllers/list.php
@@ -80,3 +80,36 @@ function on_put() {
header('Location: /list/' . $list->LID);
exit();
}
+
+function on_delete() {
+ global $TOKEN;
+ global $METHOD;
+ global $list_status;
+
+ $list = null;
+ try {
+ $list = Database\ArchiveList::fromDB($METHOD['lid']);
+ }
+ catch(Exception $e) {
+ $list_status = "This list doesn't exist!";
+ return;
+ }
+
+ try {
+ $user = Database\Cookie::fromDB($TOKEN);
+ $author = Database\User::fromDBuid($list->AuthorUID);
+ if ($author->UID !== $user->UID) {
+ $list_status = "You're not the owner of this list! You have no permission to delete it!";
+ return;
+ }
+ }
+ catch(Exception $e) {
+ $list_status = "Either your cookie is invalid or the author of this list has deleted their account!";
+ return;
+ }
+
+ $list->delete();
+
+ header('Location: /');
+ exit();
+}