diff --git a/api/actions/favoritenote.php b/api/actions/favoritenote.php new file mode 100644 index 0000000..f9fea29 --- /dev/null +++ b/api/actions/favoritenote.php @@ -0,0 +1,26 @@ +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"); +} +if (empty($VARS['favorite'])) { + $note->setFavorite(!$note->getFavorite()); +} else { + $note->setFavorite($VARS['favorite'] == true); +} + +$note->saveNote(); + +sendJsonResp($Strings->get("Note saved", false), "OK", ["note" => $note->toArray()]); \ No newline at end of file diff --git a/api/apisettings.php b/api/apisettings.php index 2c1b2de..d776a1d 100644 --- a/api/apisettings.php +++ b/api/apisettings.php @@ -40,4 +40,11 @@ $APIS = [ "id" => "/^[0-9]+$/" ] ], + "favoritenote" => [ + "load" => "favoritenote.php", + "vars" => [ + "id" => "/^[0-9]+$/", + "favorite (optional)" => "/^[0-1]+$/" + ] + ] ];