Add SharingMiddleware for permission checks and small fixes

This commit is contained in:
Julius Haertl
2016-08-24 01:22:45 +02:00
parent 33e99b9e7c
commit 2deffacd98
21 changed files with 452 additions and 115 deletions

View File

@@ -28,7 +28,7 @@ use OCP\IDb;
use OCP\AppFramework\Db\Mapper;
class StackMapper extends Mapper {
class StackMapper extends Mapper implements IPermissionMapper {
private $cardMapper;
@@ -59,4 +59,16 @@ class StackMapper extends Mapper {
// FIXME: delete linked elements, because owncloud doesn't support foreign keys for apps
return parent::delete($entity);
}
public function isOwner($userId, $stackId) {
$sql = 'SELECT * FROM `*PREFIX*deck_boards` WHERE `id` IN (SELECT board_id FROM `*PREFIX*deck_stacks` WHERE id = ?)';
$stmt = $this->execute($sql, [$stackId]);
$row = $stmt->fetch();
return ($row['owner'] === $userId);
}
public function findBoardId($stackId) {
$entity = $this->find($stackId);
return $entity->getBoardId();
}
}