diff --git a/api/actions/getnote.php b/api/actions/getnote.php new file mode 100644 index 0000000..e6a73bf --- /dev/null +++ b/api/actions/getnote.php @@ -0,0 +1,16 @@ +has('notes', ['AND' => ['noteid' => $VARS['id'], 'ownerid' => getRequestUser()->getUID()]])) { + sendJsonResp("No such note exists or you don't have permission to read it.", "ERROR"); +} + +$note = Note::loadNote($VARS['id'])->toArray(); + + +exitWithJson(["status" => "OK", "note" => $note]); \ No newline at end of file diff --git a/api/actions/getnotes.php b/api/actions/getnotes.php new file mode 100644 index 0000000..fe1620c --- /dev/null +++ b/api/actions/getnotes.php @@ -0,0 +1,15 @@ +select('notes', 'noteid', ['ownerid' => getRequestUser()->getUID()]); +$notes = []; +foreach ($noteids as $n) { + $notes[] = Note::loadNote($n)->toArray(); +} + +exitWithJson(["status" => "OK", "notes" => $notes]); \ No newline at end of file diff --git a/api/apisettings.php b/api/apisettings.php index a0f511b..abc251a 100644 --- a/api/apisettings.php +++ b/api/apisettings.php @@ -11,5 +11,16 @@ $APIS = [ "load" => "ping.php", "vars" => [ ] + ], + "getnotes" => [ + "load" => "getnotes.php", + "vars" => [ + ] + ], + "getnote" => [ + "load" => "getnote.php", + "vars" => [ + "id" => "numeric" + ] ] ]; diff --git a/lib/nextcloudnotes.php b/lib/nextcloudnotes.php index b7b952f..d6cda16 100644 --- a/lib/nextcloudnotes.php +++ b/lib/nextcloudnotes.php @@ -22,7 +22,7 @@ if (!isset($_SERVER['PHP_AUTH_USER'])) { } else { $user = User::byUsername($_SERVER['PHP_AUTH_USER']); if (!$user->checkPassword($_SERVER['PHP_AUTH_PW'])) { - header('HTTP/1.0 401 Unauthorized'); + header('HTTP/1.1 401 Unauthorized'); die($Strings->get("login incorrect")); } }