set sharing layout

This commit is contained in:
Vinzenz Rosenkranz
2016-05-31 00:38:56 +02:00
parent 710bee7069
commit 45fa10394f
5 changed files with 88 additions and 3 deletions

22
db/share.php Normal file
View File

@@ -0,0 +1,22 @@
<?php
namespace OCA\QuickNotes\Db;
use JsonSerializable;
use OCP\AppFramework\Db\Entity;
class Share extends Entity implements JsonSerializable {
protected $noteId;
protected $sharedUser;
protected $sharedGroup;
public function jsonSerialize() {
return [
'id' => $this->id,
'note' => $this->noteId,
'user' => $this->sharedUser,
'group' => $this->sharedGroup
];
}
}

28
db/sharemapper.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
namespace OCA\QuickNotes\Db;
use OCP\IDb;
use OCP\AppFramework\Db\Mapper;
use OCP\AppFramework\Db\DoesNotExistException;
class ShareMapper extends Mapper {
public function __construct(IDb $db) {
parent::__construct($db, 'quicknotes_notes', '\OCA\QuickNotes\Db\Share');
}
/*public function find($id, $userId) {
$sql = 'SELECT * FROM *PREFIX*quicknotes_shares WHERE id = ? AND user_id = ?';
return $this->findEntity($sql, [$id, $userId]);
}*/
public function findForUser($userId) {
$sql = 'SELECT * FROM *PREFIX*quicknotes_shares WHERE shared_user = ?';
return $this->findEntities($sql, [$userId]);
}
public function findForGroup($groupId) {
$sql = 'SELECT * FROM *PREFIX*quicknotes_shares WHERE shared_group = ?';
return $this->findEntities($sql, [$groupId]);
}
}