diff options
| author | Syndamia <kamen@syndamia.com> | 2025-01-26 22:19:25 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2025-01-26 22:24:48 +0200 |
| commit | cc16ebc3927fa19c86d970067bcb9a16be94e40a (patch) | |
| tree | 04740380dd81fe2a0ccb6bacef00c972563eaa4c /controllers/list.php | |
| parent | 32f3eadcc72a2c6ef3e732cecbc0706e7cbb267c (diff) | |
| download | nowayforward_human-cc16ebc3927fa19c86d970067bcb9a16be94e40a.tar nowayforward_human-cc16ebc3927fa19c86d970067bcb9a16be94e40a.tar.gz nowayforward_human-cc16ebc3927fa19c86d970067bcb9a16be94e40a.zip | |
feat(views): Implement adding a list item
Diffstat (limited to 'controllers/list.php')
| -rw-r--r-- | controllers/list.php | 29 |
1 files changed, 29 insertions, 0 deletions
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(); +} |
