From cc16ebc3927fa19c86d970067bcb9a16be94e40a Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 26 Jan 2025 22:19:25 +0200 Subject: feat(views): Implement adding a list item --- controllers/list.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'controllers/list.php') diff --git a/controllers/list.php b/controllers/list.php index 2dea9ec..7bbb739 100644 --- a/controllers/list.php +++ b/controllers/list.php @@ -16,3 +16,32 @@ function on_post() { $list_status = $e; } } + +function on_patch() { + global $TOKEN; + global $METHOD; + + try { + $user = Database\Cookie::fromDB($TOKEN); + } + catch(Exception $e) { + return; + } + + $list = null; + try { + $list = Database\ArchiveList::fromDB($METHOD['lid']); + } + catch(Exception $e) { + return; + } + + switch ($METHOD['type']) { + case 'add': $list->addItem($METHOD['wid']); break; + + default: throw new Exception('Unknown type ' . $METHOD['type']); + } + + header('Location: /list/' . $list->LID); + exit(); +} -- cgit v1.2.3