aboutsummaryrefslogtreecommitdiff
path: root/controllers/list.php
diff options
context:
space:
mode:
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();
+}