diff --git a/controller/notecontroller.php b/controller/notecontroller.php index 0b9534f..d142e74 100644 --- a/controller/notecontroller.php +++ b/controller/notecontroller.php @@ -44,7 +44,17 @@ class NoteController extends Controller { public function index() { $notes = $this->notemapper->findAll($this->userId); foreach($notes as $note) { - $note->setIsShared(false); + $note->setIsShared(false); + $sharedWith = $this->notesharemapper->getSharesForNote($note->getId()); + if(count($sharedWith) > 0) { + $shareList = array(); + foreach($sharedWith as $share) { + $shareList[] = $share->getSharedUser(); + } + $note->setSharedWith(implode(", ", $shareList)); + } else { + $note->setSharedWith(null); + } } $shareEntries = $this->notesharemapper->findForUser($this->userId); $shares = array(); diff --git a/css/style.css b/css/style.css index d32cf1a..a55ba50 100644 --- a/css/style.css +++ b/css/style.css @@ -54,12 +54,16 @@ overflow: hidden; } -#div-content .shared-title { +#div-content .shared-title, #div-content .shared-title-owner { float: right; margin: 2px; opacity: 0.5; } +#div-content .shared-title-owner { + margin-right: 25px; +} + .noselect { -webkit-touch-callout: none; /* iOS Safari */ -webkit-user-select: none; /* Chrome/Safari/Opera */ diff --git a/db/note.php b/db/note.php index 1021775..a96095a 100644 --- a/db/note.php +++ b/db/note.php @@ -12,6 +12,7 @@ class Note extends Entity implements JsonSerializable { protected $timestamp; protected $colorId; protected $userId; + protected $sharedWith; protected $isShared; protected $color; @@ -29,6 +30,7 @@ class Note extends Entity implements JsonSerializable { 'colorid' => $this->colorId, 'color' => $this->color, 'userid' => $this->userId, + 'sharedwith' => $this->sharedWith, 'isshared' => $this->isShared ]; } diff --git a/db/notesharemapper.php b/db/notesharemapper.php index 3b98571..0796420 100644 --- a/db/notesharemapper.php +++ b/db/notesharemapper.php @@ -26,6 +26,11 @@ class NoteShareMapper extends Mapper { return $this->findEntities($sql, [$groupId]); } + public function getSharesForNote($noteId) { + $sql = 'SELECT * FROM *PREFIX*quicknotes_shares WHERE note_id = ?'; + return $this->findEntities($sql, [$noteId]); + } + public function deleteByNoteId($noteId) { $sql = 'DELETE FROM *PREFIX*quicknotes_shares WHERE note_id = ?'; $this->execute($sql, [$noteId]); diff --git a/templates/part.note.php b/templates/part.note.php index 98b7cd2..a1d10d9 100644 --- a/templates/part.note.php +++ b/templates/part.note.php @@ -4,6 +4,9 @@