mirror of
https://github.com/JanGross/quicknotes.git
synced 2025-12-01 07:37:18 +01:00
add basich sharing functionality logic
This commit is contained in:
@@ -12,6 +12,7 @@ class Note extends Entity implements JsonSerializable {
|
||||
protected $timestamp;
|
||||
protected $colorId;
|
||||
protected $userId;
|
||||
protected $isShared;
|
||||
|
||||
protected $color;
|
||||
|
||||
@@ -26,7 +27,9 @@ class Note extends Entity implements JsonSerializable {
|
||||
'content' => $this->content,
|
||||
'timestamp' => $this->timestamp,
|
||||
'colorid' => $this->colorId,
|
||||
'color' => $this->color
|
||||
'color' => $this->color,
|
||||
'userid' => $this->userId,
|
||||
'isshared' => $this->isShared
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,11 @@ class NoteMapper extends Mapper {
|
||||
return $this->findEntity($sql, [$id, $userId]);
|
||||
}
|
||||
|
||||
public function findById($id) {
|
||||
$sql = 'SELECT * FROM *PREFIX*quicknotes_notes WHERE id = ?';
|
||||
return $this->findEntity($sql, [$id]);
|
||||
}
|
||||
|
||||
public function findAll($userId) {
|
||||
$sql = 'SELECT * FROM *PREFIX*quicknotes_notes WHERE user_id = ?';
|
||||
return $this->findEntities($sql, [$userId]);
|
||||
@@ -29,4 +34,4 @@ class NoteMapper extends Mapper {
|
||||
return $row['count'];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use JsonSerializable;
|
||||
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
|
||||
class Share extends Entity implements JsonSerializable {
|
||||
class NoteShare extends Entity implements JsonSerializable {
|
||||
|
||||
protected $noteId;
|
||||
protected $sharedUser;
|
||||
@@ -14,9 +14,9 @@ class Share extends Entity implements JsonSerializable {
|
||||
public function jsonSerialize() {
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'note' => $this->noteId,
|
||||
'user' => $this->sharedUser,
|
||||
'group' => $this->sharedGroup
|
||||
'noteid' => $this->noteId,
|
||||
'shareduser' => $this->sharedUser,
|
||||
'sharedgroup' => $this->sharedGroup
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,10 @@ use OCP\IDb;
|
||||
use OCP\AppFramework\Db\Mapper;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
|
||||
class ShareMapper extends Mapper {
|
||||
class NoteShareMapper extends Mapper {
|
||||
|
||||
public function __construct(IDb $db) {
|
||||
parent::__construct($db, 'quicknotes_notes', '\OCA\QuickNotes\Db\Share');
|
||||
parent::__construct($db, 'quicknotes_notes', '\OCA\QuickNotes\Db\NoteShare');
|
||||
}
|
||||
|
||||
/*public function find($id, $userId) {
|
||||
Reference in New Issue
Block a user