From dcaa0e1506f2ed43b5c876b713f8180d8eb3dd3b Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Thu, 27 Dec 2018 15:31:10 -0700 Subject: [PATCH] Add tolist API to convert a note to a checklist (#9) --- api/actions/tolist.php | 23 +++++++++++++++++++++++ api/apisettings.php | 6 ++++++ 2 files changed, 29 insertions(+) create mode 100644 api/actions/tolist.php diff --git a/api/actions/tolist.php b/api/actions/tolist.php new file mode 100644 index 0000000..8f2624d --- /dev/null +++ b/api/actions/tolist.php @@ -0,0 +1,23 @@ +get("Note does not exist", false), "ERROR"); +} + +if (!$note->hasWriteAccess(getRequestUser())) { + sendJsonResp($Strings->get("You don't have permission to edit this note.", false), "ERROR"); +} + +$note->toChecklist(); + +$note->saveNote(); + +sendJsonResp($Strings->get("Note saved", false), "OK", ["note" => $note->toArray()]); diff --git a/api/apisettings.php b/api/apisettings.php index d776a1d..985b449 100644 --- a/api/apisettings.php +++ b/api/apisettings.php @@ -46,5 +46,11 @@ $APIS = [ "id" => "/^[0-9]+$/", "favorite (optional)" => "/^[0-1]+$/" ] + ], + "tolist" => [ + "load" => "tolist.php", + "vars" => [ + "id" => "/^[0-9]+$/" + ] ] ];