diff options
| author | Syndamia <kamen@syndamia.com> | 2025-02-02 10:54:23 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2025-02-02 10:54:23 +0200 |
| commit | 4bebfa04cf759d77c511541bdf30747c76a3b2e1 (patch) | |
| tree | 10eb1a2820fbbf3f49fdafb0a7821abc25e306e6 /controllers | |
| parent | b0fb3d9df06ab9aa77f95b3b60d60f414a9f5ebe (diff) | |
| download | nowayforward_human-4bebfa04cf759d77c511541bdf30747c76a3b2e1.tar nowayforward_human-4bebfa04cf759d77c511541bdf30747c76a3b2e1.tar.gz nowayforward_human-4bebfa04cf759d77c511541bdf30747c76a3b2e1.zip | |
feat(views/list): Fully implement list updating
Diffstat (limited to 'controllers')
| -rw-r--r-- | controllers/list.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/controllers/list.php b/controllers/list.php index 0561700..07db6c5 100644 --- a/controllers/list.php +++ b/controllers/list.php @@ -47,3 +47,36 @@ function on_patch() { header('Location: /list/' . $list->LID); exit(); } + +function on_put() { + 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 edit it!"; + return; + } + } + catch(Exception $e) { + $list_status = "Either your cookie is invalid or the author of this list has deleted their account!"; + return; + } + + $list->update($METHOD['name'], $METHOD['description']); + + header('Location: /list/' . $list->LID); + exit(); +} |
