diff --git a/.gitmodules b/.gitmodules index 58b232e..72740a4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,4 +3,4 @@ url = https://source.netsyms.com/Netsyms/Material-Color [submodule "static/easy-markdown-editor"] path = static/easy-markdown-editor - url = https://source.netsyms.com/Netsyms/easy-markdown-editor.git + url = https://source.netsyms.com/Netsyms/easy-markdown-editor.git \ No newline at end of file diff --git a/action.php b/action.php index ab4a272..c42ce82 100644 --- a/action.php +++ b/action.php @@ -90,4 +90,16 @@ switch ($VARS['action']) { $notes[] = Note::loadNote($n)->toArray(); } exit(json_encode($notes)); + case "setcolor": + if (empty($VARS['noteid'])) { + die($Strings->get("invalid parameters")); + } + $note = Note::loadNote($VARS['noteid']); + if (!$note->hasWriteAccess(new User($_SESSION['uid']))) { + die($Strings->get("invalid parameters")); + } + $note->setColor($VARS['color']); + $note->saveNote(); + returnToSender(""); + break; } \ No newline at end of file diff --git a/langs/en/notes.json b/langs/en/notes.json index 2140825..ee33272 100644 --- a/langs/en/notes.json +++ b/langs/en/notes.json @@ -5,5 +5,9 @@ "Edit": "Edit", "Delete": "Delete", "Download": "Download", - "Note deleted": "Note deleted" + "Note deleted": "Note deleted", + "Favorite": "Favorite", + "Set color": "Set color", + "Cancel": "Cancel", + "Save": "Save" } diff --git a/lib/Note.lib.php b/lib/Note.lib.php index 45743cf..a694ff6 100644 --- a/lib/Note.lib.php +++ b/lib/Note.lib.php @@ -239,6 +239,11 @@ class Note { * @param string $color "RRGGBB" */ public function setColor(string $color) { + $color = strtoupper($color); + // Make sure we have a valid RRGGBB hex + if (!preg_match("/[A-F0-9]{6}/", $color)) { + $color = "FFFFFF"; + } $this->color = $color; } diff --git a/pages/editnote.php b/pages/editnote.php index d3f5150..e0989c1 100644 --- a/pages/editnote.php +++ b/pages/editnote.php @@ -29,6 +29,6 @@ $note->saveNote();
\ No newline at end of file diff --git a/pages/home.php b/pages/home.php index 0c0f6ab..b66b2e5 100644 --- a/pages/home.php +++ b/pages/home.php @@ -14,6 +14,29 @@ foreach ($noteids as $n) { +