diff --git a/src/ebda6bd8-95b9-468b-a521-974205146018/README.md b/src/ebda6bd8-95b9-468b-a521-974205146018/README.md index 9797d9d..4ce8943 100644 --- a/src/ebda6bd8-95b9-468b-a521-974205146018/README.md +++ b/src/ebda6bd8-95b9-468b-a521-974205146018/README.md @@ -18,7 +18,7 @@ class Note << (F,LightGreen) >> #Green { + __construct(Load $load, Insert $insert, ...) + set(int $book, int $chapter, ...) : ?array + delete(string $note) : bool - - get(string $linker, int $book, ...) : ?array + - get(string $linker, int $book, ...) : ?object - create(string $linker, int $book, ...) : bool } @@ -58,7 +58,7 @@ note right of Note::get Get a note since: 2.0.1 - return: ?array + return: ?object arguments: string $linker diff --git a/src/ebda6bd8-95b9-468b-a521-974205146018/code.php b/src/ebda6bd8-95b9-468b-a521-974205146018/code.php index 16184ec..fb7abd7 100644 --- a/src/ebda6bd8-95b9-468b-a521-974205146018/code.php +++ b/src/ebda6bd8-95b9-468b-a521-974205146018/code.php @@ -108,7 +108,7 @@ final class Note ]; } - // get note if it exist + // get note if it exists if (($_note = $this->get($linker, $book, $chapter, $verse)) !== null) { // publish if not published @@ -120,7 +120,7 @@ final class Note } // update the note if needed - if ($_note->note !== $note && !$this->update->value($note, 'note', $_note->id, 'id', 'note')) + if ((!isset($_note->note) || $_note->note !== $note) && !$this->update->value($note, 'note', $_note->id, 'id', 'note')) { return [ 'error' => Text::_('COM_GETBIBLE_NOTE_ALREADY_EXIST_BUT_COULD_NOT_UPDATE_THE_NOTE_TEXT') @@ -176,7 +176,7 @@ final class Note * @param int $chapter The chapter in which the note is made * @param int $verse The verse where the note is made * - * @return array|null Array of the note values on success + * @return object|null Array of the note values on success * @since 2.0.1 **/ private function get( @@ -184,12 +184,12 @@ final class Note int $book, int $chapter, int $verse - ): ?array + ): ?object { // get note if it exist if (($note = $this->load->item([ 'linker' => $linker, - 'book' => $book, + 'book_nr' => $book, 'chapter' => $chapter, 'verse' => $verse ], 'note')) !== null) @@ -231,7 +231,7 @@ final class Note 'note' => $note ?? '', 'access' => 0, 'linker' => $linker, - 'book' => $book, + 'book_nr' => $book, 'chapter' => $chapter, 'verse' => $verse, 'guid' => $guid diff --git a/src/ebda6bd8-95b9-468b-a521-974205146018/code.power b/src/ebda6bd8-95b9-468b-a521-974205146018/code.power index 1f82f3f..a31a05b 100644 --- a/src/ebda6bd8-95b9-468b-a521-974205146018/code.power +++ b/src/ebda6bd8-95b9-468b-a521-974205146018/code.power @@ -79,7 +79,7 @@ ]; } - // get note if it exist + // get note if it exists if (($_note = $this->get($linker, $book, $chapter, $verse)) !== null) { // publish if not published @@ -91,7 +91,7 @@ } // update the note if needed - if ($_note->note !== $note && !$this->update->value($note, 'note', $_note->id, 'id', 'note')) + if ((!isset($_note->note) || $_note->note !== $note) && !$this->update->value($note, 'note', $_note->id, 'id', 'note')) { return [ 'error' => Text::_('Note already exist, but could not update the note text.') @@ -147,7 +147,7 @@ * @param int $chapter The chapter in which the note is made * @param int $verse The verse where the note is made * - * @return array|null Array of the note values on success + * @return object|null Array of the note values on success * @since 2.0.1 **/ private function get( @@ -155,12 +155,12 @@ int $book, int $chapter, int $verse - ): ?array + ): ?object { // get note if it exist if (($note = $this->load->item([ 'linker' => $linker, - 'book' => $book, + 'book_nr' => $book, 'chapter' => $chapter, 'verse' => $verse ], 'note')) !== null) @@ -202,7 +202,7 @@ 'note' => $note ?? '', 'access' => 0, 'linker' => $linker, - 'book' => $book, + 'book_nr' => $book, 'chapter' => $chapter, 'verse' => $verse, 'guid' => $guid