Implement backend code to update shares with others

This commit is contained in:
Matias De lellis
2020-06-15 23:52:24 -03:00
parent c7a29e51f9
commit 8f88f88dcb
4 changed files with 63 additions and 21 deletions

View File

@@ -45,4 +45,14 @@ class NoteShareMapper extends Mapper {
$sql = 'DELETE FROM *PREFIX*quicknotes_shares WHERE note_id = ?';
$this->execute($sql, [$noteId]);
}
public function existsByNoteAndUser($noteId, $userId) {
$sql = 'SELECT * FROM *PREFIX*quicknotes_shares WHERE shared_user = ? AND note_id = ?';
try {
return $this->findEntities($sql, [$userId, $noteId]);
} catch (DoesNotExistException $e) {
return false;
}
return true;
}
}