add basich sharing functionality logic

This commit is contained in:
Vinzenz
2016-05-31 14:16:43 +02:00
parent 9eede1756d
commit df3db489f4
9 changed files with 49 additions and 15 deletions

View File

@@ -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
];
}
}
}

View File

@@ -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'];
}
}
}

View File

@@ -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
];
}
}

View File

@@ -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) {