From e471355637c1d021a1fc25e8c08ab51dfd078f3a Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Wed, 23 Jan 2019 18:23:13 -0700 Subject: [PATCH] Update note modified date when favorite status changes, fix API bug preventing notes from being unfavorited --- action.php | 1 + api/actions/favoritenote.php | 4 +++- api/actions/savenote.php | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/action.php b/action.php index 3069b15..612bf3f 100644 --- a/action.php +++ b/action.php @@ -104,6 +104,7 @@ switch ($VARS['action']) { die($Strings->get("invalid parameters")); } $note->setFavorite(!$note->getFavorite()); + $note->setModified(date("Y-m-d H:i:s")); $note->saveNote(); returnToSender(""); break; diff --git a/api/actions/favoritenote.php b/api/actions/favoritenote.php index f9fea29..d293f9f 100644 --- a/api/actions/favoritenote.php +++ b/api/actions/favoritenote.php @@ -15,12 +15,14 @@ try { if (!$note->hasWriteAccess(getRequestUser())) { sendJsonResp($Strings->get("You don't have permission to edit this note.", false), "ERROR"); } -if (empty($VARS['favorite'])) { +if (!isset($VARS['favorite'])) { $note->setFavorite(!$note->getFavorite()); } else { $note->setFavorite($VARS['favorite'] == true); } +$note->setModified(date("Y-m-d H:i:s")); + $note->saveNote(); sendJsonResp($Strings->get("Note saved", false), "OK", ["note" => $note->toArray()]); \ No newline at end of file diff --git a/api/actions/savenote.php b/api/actions/savenote.php index bbb6001..5f6d248 100644 --- a/api/actions/savenote.php +++ b/api/actions/savenote.php @@ -47,7 +47,7 @@ if (empty($VARS['modified'])) { $note->setModified($VARS['modified']); } -if (!empty($VARS['favorite'])) { +if (isset($VARS['favorite'])) { $note->setFavorite($VARS['favorite'] == true); }