blob: 7bbb7399e7fce98a8f24dae08fb793a817d8501c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
<?php
namespace Controller;
use Database;
use Exception;
function on_post() {
global $TOKEN;
global $list_status;
$list_status = "";
try {
$uid = Database\Cookie::fromDB($TOKEN)->UID;
Database\ArchiveList::create($uid, $_POST["name"], $_POST["description"]);
}
catch(Exception $e) {
$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();
}
|