Add deletenote API (#9)

master
Skylar Ittner 5 years ago
parent 3e04746f57
commit 2ff2c173eb

@ -0,0 +1,24 @@
<?php
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/**
* Update a note. If the note doesn't exist, creates a new one and saves it.
*/
try {
$note = Note::loadNote($VARS['id']);
} catch (NoSuchNoteException $ex) {
sendJsonResp($Strings->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->deleteNote();
sendJsonResp($Strings->get("Note deleted", false), "OK", ["id" => $note->getID()]);

@ -20,7 +20,7 @@ $APIS = [
"getnote" => [
"load" => "getnote.php",
"vars" => [
"id" => "numeric"
"id" => "/^[0-9]+$/"
]
],
"savenote" => [
@ -33,5 +33,11 @@ $APIS = [
"favorite (optional)" => "/^[0-1]+$/",
"archived (optional)" => "/^[0-1]+$/"
]
]
],
"deletenote" => [
"load" => "deletenote.php",
"vars" => [
"id" => "/^[0-9]+$/"
]
],
];

@ -27,5 +27,6 @@
"Note Reminder": "Note Reminder",
"Open {app} to read more": "Open {app} to read more",
"You don't have permission to edit this note.": "You don't have permission to edit this note.",
"Note saved": "Note saved"
"Note saved": "Note saved",
"Note does not exist": "Note does not exist"
}

Loading…
Cancel
Save