Skip to content

Commit e48dd15

Browse files
committed
Support GET and PUT in API
1 parent c2638e1 commit e48dd15

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

controller/ownnoteapicontroller.php

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ public function index() {
4949
*/
5050
public function edit() {
5151
require_once 'ownnote/lib/backend.php';
52-
return editNote("Notes", $_GET["note"].".htm");
52+
if (isset($_GET["note"]))
53+
return editNote("Notes", $_GET["note"].".htm");
54+
elseif (isset($_POST["note"]))
55+
return editNote("Notes", $_POST["note"].".htm");
5356
}
5457

5558
/**
@@ -59,7 +62,10 @@ public function edit() {
5962
*/
6063
public function del() {
6164
require_once 'ownnote/lib/backend.php';
62-
return deleteNote("Notes", $_GET["note"].".htm");
65+
if (isset($_GET["note"]))
66+
return deleteNote("Notes", $_GET["note"].".htm");
67+
elseif (isset($_POST["note"]))
68+
return deleteNote("Notes", $_POST["note"].".htm");
6369
}
6470

6571
/**
@@ -69,7 +75,10 @@ public function del() {
6975
*/
7076
public function ren() {
7177
require_once 'ownnote/lib/backend.php';
72-
return renameNote("Notes", $_GET["note"], $_GET["newnote"]);
78+
if (isset($_GET["note"]) && isset($_GET["newnote"]))
79+
return renameNote("Notes", $_GET["note"], $_GET["newnote"]);
80+
elseif (isset($_POST["note"]) && isset($_POST["newnote"]))
81+
return renameNote("Notes", $_POST["note"], $_POST["newnote"]);
7382
}
7483

7584
/**
@@ -79,7 +88,10 @@ public function ren() {
7988
*/
8089
public function save() {
8190
require_once 'ownnote/lib/backend.php';
82-
return saveNote("Notes", $_GET["note"], $_GET["content"]);
91+
if (isset($_GET["note"]) && isset($_GET["content"]))
92+
return saveNote("Notes", $_GET["note"], $_GET["content"]);
93+
elseif (isset($_POST["note"]) && isset($_POST["content"]))
94+
return saveNote("Notes", $_POST["note"], $_POST["content"]);
8395
}
8496

8597
/**
@@ -89,7 +101,10 @@ public function save() {
89101
*/
90102
public function create() {
91103
require_once 'ownnote/lib/backend.php';
92-
return createNote("Notes", $_GET["note"]);
104+
if (isset($_GET["note"]))
105+
return createNote("Notes", $_GET["note"]);
106+
elseif (isset($_POST["note"]))
107+
return createNote("Notes", $_POST["note"]);
93108
}
94109

95110
/**
@@ -99,7 +114,10 @@ public function create() {
99114
*/
100115
public function delgroup() {
101116
require_once 'ownnote/lib/backend.php';
102-
return deleteGroup("Notes", $_GET["group"]);
117+
if (isset($_GET["group"]))
118+
return deleteGroup("Notes", $_GET["group"]);
119+
if (isset($_POST["group"]))
120+
return deleteGroup("Notes", $_POST["group"]);
103121
}
104122

105123
/**
@@ -109,6 +127,9 @@ public function delgroup() {
109127
*/
110128
public function rengroup() {
111129
require_once 'ownnote/lib/backend.php';
112-
return renameGroup("Notes", $_GET["group"], $_GET["newgroup"]);
130+
if (isset($_GET["group"]) && isset($_GET["newgroup"]))
131+
return renameGroup("Notes", $_GET["group"], $_GET["newgroup"]);
132+
elseif (isset($_POST["group"]) && isset($_POST["newgroup"]))
133+
return renameGroup("Notes", $_POST["group"], $_POST["newgroup"]);
113134
}
114135
}

0 commit comments

Comments
 (0)