Properly annotate exceptions thrown by services
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -40,6 +40,12 @@ class AssignedUsersMapper extends DeckMapper implements IPermissionMapper {
|
|||||||
$this->userManager = $userManager;
|
$this->userManager = $userManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FIXME: rename this since it returns multiple entities otherwise the naming is confusing with Entity::find
|
||||||
|
*
|
||||||
|
* @param $cardId
|
||||||
|
* @return array|Entity
|
||||||
|
*/
|
||||||
public function find($cardId) {
|
public function find($cardId) {
|
||||||
$sql = 'SELECT * FROM `*PREFIX*deck_assigned_users` ' .
|
$sql = 'SELECT * FROM `*PREFIX*deck_assigned_users` ' .
|
||||||
'WHERE `card_id` = ?';
|
'WHERE `card_id` = ?';
|
||||||
|
|||||||
@@ -39,6 +39,13 @@ class AttachmentMapper extends DeckMapper implements IPermissionMapper {
|
|||||||
private $userManager;
|
private $userManager;
|
||||||
private $qb;
|
private $qb;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AttachmentMapper constructor.
|
||||||
|
*
|
||||||
|
* @param IDBConnection $db
|
||||||
|
* @param CardMapper $cardMapper
|
||||||
|
* @param IUserManager $userManager
|
||||||
|
*/
|
||||||
public function __construct(IDBConnection $db, CardMapper $cardMapper, IUserManager $userManager) {
|
public function __construct(IDBConnection $db, CardMapper $cardMapper, IUserManager $userManager) {
|
||||||
parent::__construct($db, 'deck_attachment', Attachment::class);
|
parent::__construct($db, 'deck_attachment', Attachment::class);
|
||||||
$this->cardMapper = $cardMapper;
|
$this->cardMapper = $cardMapper;
|
||||||
@@ -60,7 +67,17 @@ class AttachmentMapper extends DeckMapper implements IPermissionMapper {
|
|||||||
|
|
||||||
$cursor = $qb->execute();
|
$cursor = $qb->execute();
|
||||||
$row = $cursor->fetch(PDO::FETCH_ASSOC);
|
$row = $cursor->fetch(PDO::FETCH_ASSOC);
|
||||||
|
if($row === false) {
|
||||||
|
$cursor->closeCursor();
|
||||||
|
throw new DoesNotExistException('Did expect one result but found none when executing' . $qb);
|
||||||
|
}
|
||||||
|
|
||||||
|
$row2 = $cursor->fetch();
|
||||||
$cursor->closeCursor();
|
$cursor->closeCursor();
|
||||||
|
if($row2 !== false ) {
|
||||||
|
throw new MultipleObjectsReturnedException('Did not expect more than one result when executing' . $query);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->mapRowToEntity($row);
|
return $this->mapRowToEntity($row);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,6 +104,11 @@ class AttachmentMapper extends DeckMapper implements IPermissionMapper {
|
|||||||
return $entities;
|
return $entities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param null $cardId
|
||||||
|
* @param bool $withOffset
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function findToDelete($cardId = null, $withOffset = true) {
|
public function findToDelete($cardId = null, $withOffset = true) {
|
||||||
// add buffer of 5 min
|
// add buffer of 5 min
|
||||||
$timeLimit = time() - (60 * 5);
|
$timeLimit = time() - (60 * 5);
|
||||||
|
|||||||
@@ -123,6 +123,10 @@ class AttachmentService {
|
|||||||
return $attachments;
|
return $attachments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $cardId
|
||||||
|
* @return int|mixed
|
||||||
|
*/
|
||||||
public function count($cardId) {
|
public function count($cardId) {
|
||||||
$count = $this->cache->get('card-' . $cardId);
|
$count = $this->cache->get('card-' . $cardId);
|
||||||
if (!$count) {
|
if (!$count) {
|
||||||
@@ -132,6 +136,14 @@ class AttachmentService {
|
|||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $cardId
|
||||||
|
* @param $type
|
||||||
|
* @param $data
|
||||||
|
* @return Attachment|\OCP\AppFramework\Db\Entity
|
||||||
|
* @throws NoPermissionException
|
||||||
|
* @throws StatusException
|
||||||
|
*/
|
||||||
public function create($cardId, $type, $data) {
|
public function create($cardId, $type, $data) {
|
||||||
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
|
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
|
||||||
|
|
||||||
@@ -172,7 +184,11 @@ class AttachmentService {
|
|||||||
* @param $cardId
|
* @param $cardId
|
||||||
* @param $attachmentId
|
* @param $attachmentId
|
||||||
* @return Response
|
* @return Response
|
||||||
|
* @throws \OCA\Deck\NotFoundException
|
||||||
|
* @throws NoPermissionException
|
||||||
* @throws NotFoundException
|
* @throws NotFoundException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
*/
|
*/
|
||||||
public function display($cardId, $attachmentId) {
|
public function display($cardId, $attachmentId) {
|
||||||
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_READ);
|
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_READ);
|
||||||
|
|||||||
@@ -75,6 +75,9 @@ class BoardService {
|
|||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function findAll() {
|
public function findAll() {
|
||||||
$userInfo = $this->getBoardPrerequisites();
|
$userInfo = $this->getBoardPrerequisites();
|
||||||
$userBoards = $this->boardMapper->findAllByUser($userInfo['user']);
|
$userBoards = $this->boardMapper->findAllByUser($userInfo['user']);
|
||||||
@@ -102,6 +105,13 @@ class BoardService {
|
|||||||
return array_values($result);
|
return array_values($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $boardId
|
||||||
|
* @return Board
|
||||||
|
* @throws DoesNotExistException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function find($boardId) {
|
public function find($boardId) {
|
||||||
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ);
|
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ);
|
||||||
/** @var Board $board */
|
/** @var Board $board */
|
||||||
@@ -124,6 +134,9 @@ class BoardService {
|
|||||||
return $board;
|
return $board;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
private function getBoardPrerequisites() {
|
private function getBoardPrerequisites() {
|
||||||
$groups = $this->groupManager->getUserGroupIds(
|
$groups = $this->groupManager->getUserGroupIds(
|
||||||
$this->userManager->get($this->userId)
|
$this->userManager->get($this->userId)
|
||||||
@@ -134,6 +147,14 @@ class BoardService {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $mapper
|
||||||
|
* @param $id
|
||||||
|
* @return bool
|
||||||
|
* @throws DoesNotExistException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function isArchived($mapper, $id) {
|
public function isArchived($mapper, $id) {
|
||||||
try {
|
try {
|
||||||
$boardId = $id;
|
$boardId = $id;
|
||||||
@@ -150,6 +171,14 @@ class BoardService {
|
|||||||
return $board->getArchived();
|
return $board->getArchived();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $mapper
|
||||||
|
* @param $id
|
||||||
|
* @return bool
|
||||||
|
* @throws DoesNotExistException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function isDeleted($mapper, $id) {
|
public function isDeleted($mapper, $id) {
|
||||||
try {
|
try {
|
||||||
$boardId = $id;
|
$boardId = $id;
|
||||||
@@ -167,7 +196,12 @@ class BoardService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $title
|
||||||
|
* @param $userId
|
||||||
|
* @param $color
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
*/
|
||||||
public function create($title, $userId, $color) {
|
public function create($title, $userId, $color) {
|
||||||
$board = new Board();
|
$board = new Board();
|
||||||
$board->setTitle($title);
|
$board->setTitle($title);
|
||||||
@@ -203,6 +237,13 @@ class BoardService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @return Board
|
||||||
|
* @throws DoesNotExistException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function delete($id) {
|
public function delete($id) {
|
||||||
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ);
|
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ);
|
||||||
$board = $this->find($id);
|
$board = $this->find($id);
|
||||||
@@ -211,6 +252,13 @@ class BoardService {
|
|||||||
return $board;
|
return $board;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws DoesNotExistException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function deleteUndo($id) {
|
public function deleteUndo($id) {
|
||||||
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ);
|
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ);
|
||||||
$board = $this->find($id);
|
$board = $this->find($id);
|
||||||
@@ -218,12 +266,29 @@ class BoardService {
|
|||||||
return $this->boardMapper->update($board);
|
return $this->boardMapper->update($board);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws DoesNotExistException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function deleteForce($id) {
|
public function deleteForce($id) {
|
||||||
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ);
|
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ);
|
||||||
$board = $this->find($id);
|
$board = $this->find($id);
|
||||||
return $this->boardMapper->delete($board);
|
return $this->boardMapper->delete($board);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @param $title
|
||||||
|
* @param $color
|
||||||
|
* @param $archived
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws DoesNotExistException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function update($id, $title, $color, $archived) {
|
public function update($id, $title, $color, $archived) {
|
||||||
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_MANAGE);
|
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_MANAGE);
|
||||||
$board = $this->find($id);
|
$board = $this->find($id);
|
||||||
@@ -235,6 +300,16 @@ class BoardService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $boardId
|
||||||
|
* @param $type
|
||||||
|
* @param $participant
|
||||||
|
* @param $edit
|
||||||
|
* @param $share
|
||||||
|
* @param $manage
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
*/
|
||||||
public function addAcl($boardId, $type, $participant, $edit, $share, $manage) {
|
public function addAcl($boardId, $type, $participant, $edit, $share, $manage) {
|
||||||
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_SHARE);
|
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_SHARE);
|
||||||
$acl = new Acl();
|
$acl = new Acl();
|
||||||
@@ -253,6 +328,16 @@ class BoardService {
|
|||||||
return $newAcl;
|
return $newAcl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @param $edit
|
||||||
|
* @param $share
|
||||||
|
* @param $manage
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws DoesNotExistException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function updateAcl($id, $edit, $share, $manage) {
|
public function updateAcl($id, $edit, $share, $manage) {
|
||||||
$this->permissionService->checkPermission($this->aclMapper, $id, Acl::PERMISSION_SHARE);
|
$this->permissionService->checkPermission($this->aclMapper, $id, Acl::PERMISSION_SHARE);
|
||||||
/** @var Acl $acl */
|
/** @var Acl $acl */
|
||||||
@@ -264,6 +349,13 @@ class BoardService {
|
|||||||
return $this->aclMapper->update($acl);
|
return $this->aclMapper->update($acl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws DoesNotExistException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function deleteAcl($id) {
|
public function deleteAcl($id) {
|
||||||
$this->permissionService->checkPermission($this->aclMapper, $id, Acl::PERMISSION_SHARE);
|
$this->permissionService->checkPermission($this->aclMapper, $id, Acl::PERMISSION_SHARE);
|
||||||
/** @var Acl $acl */
|
/** @var Acl $acl */
|
||||||
|
|||||||
@@ -89,6 +89,13 @@ class CardService {
|
|||||||
return $cards;
|
return $cards;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $cardId
|
||||||
|
* @return \OCA\Deck\Db\RelationalEntity
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function find($cardId) {
|
public function find($cardId) {
|
||||||
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_READ);
|
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_READ);
|
||||||
$card = $this->cardMapper->find($cardId);
|
$card = $this->cardMapper->find($cardId);
|
||||||
@@ -100,7 +107,16 @@ class CardService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param $title
|
||||||
|
* @param $stackId
|
||||||
|
* @param $type
|
||||||
* @param integer $order
|
* @param integer $order
|
||||||
|
* @param $owner
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws StatusException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
*/
|
*/
|
||||||
public function create($title, $stackId, $type, $order, $owner) {
|
public function create($title, $stackId, $type, $order, $owner) {
|
||||||
$this->permissionService->checkPermission($this->stackMapper, $stackId, Acl::PERMISSION_EDIT);
|
$this->permissionService->checkPermission($this->stackMapper, $stackId, Acl::PERMISSION_EDIT);
|
||||||
@@ -117,6 +133,14 @@ class CardService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws StatusException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function delete($id) {
|
public function delete($id) {
|
||||||
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
|
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
|
||||||
if ($this->boardService->isArchived($this->cardMapper, $id)) {
|
if ($this->boardService->isArchived($this->cardMapper, $id)) {
|
||||||
@@ -128,6 +152,21 @@ class CardService {
|
|||||||
return $card;
|
return $card;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @param $title
|
||||||
|
* @param $stackId
|
||||||
|
* @param $type
|
||||||
|
* @param $order
|
||||||
|
* @param $description
|
||||||
|
* @param $owner
|
||||||
|
* @param $duedate
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws StatusException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function update($id, $title, $stackId, $type, $order, $description, $owner, $duedate, $deletedAt) {
|
public function update($id, $title, $stackId, $type, $order, $description, $owner, $duedate, $deletedAt) {
|
||||||
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
|
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
|
||||||
if ($this->boardService->isArchived($this->cardMapper, $id)) {
|
if ($this->boardService->isArchived($this->cardMapper, $id)) {
|
||||||
@@ -148,6 +187,15 @@ class CardService {
|
|||||||
return $this->cardMapper->update($card);
|
return $this->cardMapper->update($card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @param $title
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws StatusException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function rename($id, $title) {
|
public function rename($id, $title) {
|
||||||
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
|
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
|
||||||
if ($this->boardService->isArchived($this->cardMapper, $id)) {
|
if ($this->boardService->isArchived($this->cardMapper, $id)) {
|
||||||
@@ -161,6 +209,16 @@ class CardService {
|
|||||||
return $this->cardMapper->update($card);
|
return $this->cardMapper->update($card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @param $stackId
|
||||||
|
* @param $order
|
||||||
|
* @return array
|
||||||
|
* @throws StatusException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function reorder($id, $stackId, $order) {
|
public function reorder($id, $stackId, $order) {
|
||||||
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
|
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
|
||||||
if ($this->boardService->isArchived($this->cardMapper, $id)) {
|
if ($this->boardService->isArchived($this->cardMapper, $id)) {
|
||||||
@@ -192,6 +250,14 @@ class CardService {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws StatusException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function archive($id) {
|
public function archive($id) {
|
||||||
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
|
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
|
||||||
if ($this->boardService->isArchived($this->cardMapper, $id)) {
|
if ($this->boardService->isArchived($this->cardMapper, $id)) {
|
||||||
@@ -202,6 +268,14 @@ class CardService {
|
|||||||
return $this->cardMapper->update($card);
|
return $this->cardMapper->update($card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws StatusException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function unarchive($id) {
|
public function unarchive($id) {
|
||||||
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
|
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
|
||||||
if ($this->boardService->isArchived($this->cardMapper, $id)) {
|
if ($this->boardService->isArchived($this->cardMapper, $id)) {
|
||||||
@@ -212,6 +286,14 @@ class CardService {
|
|||||||
return $this->cardMapper->update($card);
|
return $this->cardMapper->update($card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $cardId
|
||||||
|
* @param $labelId
|
||||||
|
* @throws StatusException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function assignLabel($cardId, $labelId) {
|
public function assignLabel($cardId, $labelId) {
|
||||||
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
|
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
|
||||||
if ($this->boardService->isArchived($this->cardMapper, $cardId)) {
|
if ($this->boardService->isArchived($this->cardMapper, $cardId)) {
|
||||||
@@ -224,6 +306,14 @@ class CardService {
|
|||||||
$this->cardMapper->assignLabel($cardId, $labelId);
|
$this->cardMapper->assignLabel($cardId, $labelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $cardId
|
||||||
|
* @param $labelId
|
||||||
|
* @throws StatusException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function removeLabel($cardId, $labelId) {
|
public function removeLabel($cardId, $labelId) {
|
||||||
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
|
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
|
||||||
if ($this->boardService->isArchived($this->cardMapper, $cardId)) {
|
if ($this->boardService->isArchived($this->cardMapper, $cardId)) {
|
||||||
@@ -236,6 +326,13 @@ class CardService {
|
|||||||
$this->cardMapper->removeLabel($cardId, $labelId);
|
$this->cardMapper->removeLabel($cardId, $labelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $cardId
|
||||||
|
* @param $userId
|
||||||
|
* @return bool|null|\OCP\AppFramework\Db\Entity
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function assignUser($cardId, $userId) {
|
public function assignUser($cardId, $userId) {
|
||||||
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
|
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
|
||||||
$assignments = $this->assignedUsersMapper->find($cardId);
|
$assignments = $this->assignedUsersMapper->find($cardId);
|
||||||
@@ -257,6 +354,14 @@ class CardService {
|
|||||||
return $this->assignedUsersMapper->insert($assignment);
|
return $this->assignedUsersMapper->insert($assignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $cardId
|
||||||
|
* @param $userId
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws NotFoundException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function unassignUser($cardId, $userId) {
|
public function unassignUser($cardId, $userId) {
|
||||||
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
|
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
|
||||||
$assignments = $this->assignedUsersMapper->find($cardId);
|
$assignments = $this->assignedUsersMapper->find($cardId);
|
||||||
|
|||||||
@@ -55,8 +55,14 @@ class DefaultBoardService {
|
|||||||
$this->boardMapper = $boardMapper;
|
$this->boardMapper = $boardMapper;
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkFirstRun($userId, $appName) {
|
/**
|
||||||
|
* @param $userId
|
||||||
|
* @param $appName
|
||||||
|
* @return bool
|
||||||
|
* @throws \OCP\PreConditionNotMetException
|
||||||
|
*/
|
||||||
|
public function checkFirstRun($userId, $appName) {
|
||||||
$firstRun = $this->config->getUserValue($userId, $appName, 'firstRun', 'yes');
|
$firstRun = $this->config->getUserValue($userId, $appName, 'firstRun', 'yes');
|
||||||
$userBoards = $this->boardMapper->findAllByUser($userId);
|
$userBoards = $this->boardMapper->findAllByUser($userId);
|
||||||
|
|
||||||
@@ -68,7 +74,17 @@ class DefaultBoardService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createDefaultBoard($title, $userId, $color) {
|
/**
|
||||||
|
* @param $title
|
||||||
|
* @param $userId
|
||||||
|
* @param $color
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCA\Deck\StatusException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
|
public function createDefaultBoard($title, $userId, $color) {
|
||||||
$defaultBoard = $this->boardService->create($title, $userId, $color);
|
$defaultBoard = $this->boardService->create($title, $userId, $color);
|
||||||
$defaultStacks = [];
|
$defaultStacks = [];
|
||||||
$defaultCards = [];
|
$defaultCards = [];
|
||||||
|
|||||||
@@ -142,6 +142,11 @@ class FileService implements IAttachmentService {
|
|||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Attachment $attachment
|
||||||
|
* @throws NotPermittedException
|
||||||
|
* @throws StatusException
|
||||||
|
*/
|
||||||
public function create(Attachment $attachment) {
|
public function create(Attachment $attachment) {
|
||||||
$file = $this->getUploadedFile();
|
$file = $this->getUploadedFile();
|
||||||
$folder = $this->getFolder($attachment);
|
$folder = $this->getFolder($attachment);
|
||||||
@@ -176,6 +181,10 @@ class FileService implements IAttachmentService {
|
|||||||
$attachment->setLastModified(time());
|
$attachment->setLastModified(time());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Attachment $attachment
|
||||||
|
* @throws NotPermittedException
|
||||||
|
*/
|
||||||
public function delete(Attachment $attachment) {
|
public function delete(Attachment $attachment) {
|
||||||
try {
|
try {
|
||||||
$file = $this->getFileForAttachment($attachment);
|
$file = $this->getFileForAttachment($attachment);
|
||||||
@@ -202,6 +211,11 @@ class FileService implements IAttachmentService {
|
|||||||
return $cardFolder->get($attachment->getData());
|
return $cardFolder->get($attachment->getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Attachment $attachment
|
||||||
|
* @return FileDisplayResponse|\OCP\AppFramework\Http\Response|StreamResponse
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
public function display(Attachment $attachment) {
|
public function display(Attachment $attachment) {
|
||||||
$file = $this->getFileFromRootFolder($attachment);
|
$file = $this->getFileFromRootFolder($attachment);
|
||||||
if (method_exists($file, 'fopen')) {
|
if (method_exists($file, 'fopen')) {
|
||||||
|
|||||||
@@ -44,11 +44,28 @@ class LabelService {
|
|||||||
$this->boardService = $boardService;
|
$this->boardService = $boardService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $labelId
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function find($labelId) {
|
public function find($labelId) {
|
||||||
$this->permissionService->checkPermission($this->labelMapper, $labelId, Acl::PERMISSION_READ);
|
$this->permissionService->checkPermission($this->labelMapper, $labelId, Acl::PERMISSION_READ);
|
||||||
return $this->labelMapper->find($labelId);
|
return $this->labelMapper->find($labelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $title
|
||||||
|
* @param $color
|
||||||
|
* @param $boardId
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws StatusException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function create($title, $color, $boardId) {
|
public function create($title, $color, $boardId) {
|
||||||
$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE);
|
$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE);
|
||||||
if ($this->boardService->isArchived(null, $boardId)) {
|
if ($this->boardService->isArchived(null, $boardId)) {
|
||||||
@@ -61,6 +78,14 @@ class LabelService {
|
|||||||
return $this->labelMapper->insert($label);
|
return $this->labelMapper->insert($label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws StatusException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function delete($id) {
|
public function delete($id) {
|
||||||
$this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE);
|
$this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE);
|
||||||
if ($this->boardService->isArchived($this->labelMapper, $id)) {
|
if ($this->boardService->isArchived($this->labelMapper, $id)) {
|
||||||
@@ -69,6 +94,16 @@ class LabelService {
|
|||||||
return $this->labelMapper->delete($this->find($id));
|
return $this->labelMapper->delete($this->find($id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @param $title
|
||||||
|
* @param $color
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws StatusException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function update($id, $title, $color) {
|
public function update($id, $title, $color) {
|
||||||
$this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE);
|
$this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE);
|
||||||
if ($this->boardService->isArchived($this->labelMapper, $id)) {
|
if ($this->boardService->isArchived($this->labelMapper, $id)) {
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ use OCA\Deck\Db\IPermissionMapper;
|
|||||||
use OCA\Deck\Db\User;
|
use OCA\Deck\Db\User;
|
||||||
use OCA\Deck\NoPermissionException;
|
use OCA\Deck\NoPermissionException;
|
||||||
use OCP\AppFramework\Db\DoesNotExistException;
|
use OCP\AppFramework\Db\DoesNotExistException;
|
||||||
|
use OCP\AppFramework\Db\Entity;
|
||||||
|
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||||
use OCP\IGroupManager;
|
use OCP\IGroupManager;
|
||||||
use OCP\ILogger;
|
use OCP\ILogger;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
@@ -114,41 +116,40 @@ class PermissionService {
|
|||||||
* @throws NoPermissionException
|
* @throws NoPermissionException
|
||||||
*/
|
*/
|
||||||
public function checkPermission($mapper, $id, $permission) {
|
public function checkPermission($mapper, $id, $permission) {
|
||||||
try {
|
$boardId = $id;
|
||||||
$boardId = $id;
|
if ($mapper instanceof IPermissionMapper) {
|
||||||
if ($mapper instanceof IPermissionMapper) {
|
$boardId = $mapper->findBoardId($id);
|
||||||
$boardId = $mapper->findBoardId($id);
|
}
|
||||||
}
|
if ($boardId === null) {
|
||||||
if ($boardId === null) {
|
|
||||||
// Throw NoPermission to not leak information about existing entries
|
|
||||||
throw new NoPermissionException('Permission denied');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->userIsBoardOwner($boardId)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
$acls = $this->aclMapper->findAll($boardId);
|
|
||||||
$result = $this->userCan($acls, $permission);
|
|
||||||
if ($result) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (DoesNotExistException $exception) {
|
|
||||||
// Throw NoPermission to not leak information about existing entries
|
// Throw NoPermission to not leak information about existing entries
|
||||||
throw new NoPermissionException('Permission denied');
|
throw new NoPermissionException('Permission denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new NoPermissionException('Permission denied.');
|
if ($this->userIsBoardOwner($boardId)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$acls = $this->aclMapper->findAll($boardId);
|
||||||
|
$result = $this->userCan($acls, $permission);
|
||||||
|
if ($result) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Throw NoPermission to not leak information about existing entries
|
||||||
|
throw new NoPermissionException('Permission denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $boardId
|
* @param $boardId
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
|
||||||
*/
|
*/
|
||||||
public function userIsBoardOwner($boardId) {
|
public function userIsBoardOwner($boardId) {
|
||||||
$board = $this->boardMapper->find($boardId);
|
try {
|
||||||
|
$board = $this->boardMapper->find($boardId);
|
||||||
|
} catch (DoesNotExistException $e) {
|
||||||
|
} catch (MultipleObjectsReturnedException $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return $board && $this->userId === $board->getOwner();
|
return $board && $this->userId === $board->getOwner();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,19 +193,34 @@ class PermissionService {
|
|||||||
$board = $this->boardMapper->find($boardId);
|
$board = $this->boardMapper->find($boardId);
|
||||||
} catch (DoesNotExistException $e) {
|
} catch (DoesNotExistException $e) {
|
||||||
return [];
|
return [];
|
||||||
|
} catch (MultipleObjectsReturnedException $e) {
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$owner = $this->userManager->get($board->getOwner());
|
$owner = $this->userManager->get($board->getOwner());
|
||||||
$users = [];
|
if ($owner === null) {
|
||||||
$users[$owner->getUID()] = new User($owner);
|
$this->logger->info('No owner found for board ' . $board->getId());
|
||||||
|
} else {
|
||||||
|
$users = [];
|
||||||
|
$users[$owner->getUID()] = new User($owner);
|
||||||
|
}
|
||||||
$acls = $this->aclMapper->findAll($boardId);
|
$acls = $this->aclMapper->findAll($boardId);
|
||||||
/** @var Acl $acl */
|
/** @var Acl $acl */
|
||||||
foreach ($acls as $acl) {
|
foreach ($acls as $acl) {
|
||||||
if ($acl->getType() === Acl::PERMISSION_TYPE_USER) {
|
if ($acl->getType() === Acl::PERMISSION_TYPE_USER) {
|
||||||
$user = $this->userManager->get($acl->getParticipant());
|
$user = $this->userManager->get($acl->getParticipant());
|
||||||
|
if ($user === null) {
|
||||||
|
$this->logger->info('No user found for acl rule ' . $acl->getId());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$users[$user->getUID()] = new User($user);
|
$users[$user->getUID()] = new User($user);
|
||||||
}
|
}
|
||||||
if ($acl->getType() === Acl::PERMISSION_TYPE_GROUP) {
|
if ($acl->getType() === Acl::PERMISSION_TYPE_GROUP) {
|
||||||
$group = $this->groupManager->get($acl->getParticipant());
|
$group = $this->groupManager->get($acl->getParticipant());
|
||||||
|
if ($group === null) {
|
||||||
|
$this->logger->info('No group found for acl rule ' . $acl->getId());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
foreach ($group->getUsers() as $user) {
|
foreach ($group->getUsers() as $user) {
|
||||||
$users[$user->getUID()] = new User($user);
|
$users[$user->getUID()] = new User($user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,21 +89,29 @@ class StackService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $stackId
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function find($stackId) {
|
public function find($stackId) {
|
||||||
$stack = $this->stackMapper->find($stackId);
|
$stack = $this->stackMapper->find($stackId);
|
||||||
$cards = $this->cardMapper->findAll($stackId);
|
$cards = $this->cardMapper->findAll($stackId);
|
||||||
foreach ($cards as $cardIndex => $card) {
|
foreach ($cards as $cardIndex => $card) {
|
||||||
$assignedUsers = $this->assignedUsersMapper->find($card->getId());
|
$assignedUsers = $this->assignedUsersMapper->find($card->getId());
|
||||||
$card->setAssignedUsers($assignedUsers);
|
$card->setAssignedUsers($assignedUsers);
|
||||||
if (array_key_exists($card->id, $labels)) {
|
|
||||||
$cards[$cardIndex]->setLabels($labels[$card->id]);
|
|
||||||
}
|
|
||||||
$card->setAttachmentCount($this->attachmentService->count($card->getId()));
|
$card->setAttachmentCount($this->attachmentService->count($card->getId()));
|
||||||
}
|
}
|
||||||
$stack->setCards($cards);
|
$stack->setCards($cards);
|
||||||
return $stack;
|
return $stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $boardId
|
||||||
|
* @return array
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
*/
|
||||||
public function findAll($boardId) {
|
public function findAll($boardId) {
|
||||||
$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_READ);
|
$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_READ);
|
||||||
$stacks = $this->stackMapper->findAll($boardId);
|
$stacks = $this->stackMapper->findAll($boardId);
|
||||||
@@ -118,6 +126,11 @@ class StackService {
|
|||||||
return $stacks;
|
return $stacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $boardId
|
||||||
|
* @return array
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
*/
|
||||||
public function findAllArchived($boardId) {
|
public function findAllArchived($boardId) {
|
||||||
$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_READ);
|
$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_READ);
|
||||||
$stacks = $this->stackMapper->findAll($boardId);
|
$stacks = $this->stackMapper->findAll($boardId);
|
||||||
@@ -135,7 +148,14 @@ class StackService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param $title
|
||||||
|
* @param $boardId
|
||||||
* @param integer $order
|
* @param integer $order
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws StatusException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
*/
|
*/
|
||||||
public function create($title, $boardId, $order) {
|
public function create($title, $boardId, $order) {
|
||||||
$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE);
|
$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE);
|
||||||
@@ -150,6 +170,13 @@ class StackService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function delete($id) {
|
public function delete($id) {
|
||||||
$this->permissionService->checkPermission($this->stackMapper, $id, Acl::PERMISSION_MANAGE);
|
$this->permissionService->checkPermission($this->stackMapper, $id, Acl::PERMISSION_MANAGE);
|
||||||
|
|
||||||
@@ -162,7 +189,18 @@ class StackService {
|
|||||||
return $stack;
|
return $stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @param $title
|
||||||
|
* @param $boardId
|
||||||
|
* @param $order
|
||||||
|
* @param $deletedAt
|
||||||
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
|
* @throws StatusException
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function update($id, $title, $boardId, $order, $deletedAt) {
|
public function update($id, $title, $boardId, $order, $deletedAt) {
|
||||||
$this->permissionService->checkPermission($this->stackMapper, $id, Acl::PERMISSION_MANAGE);
|
$this->permissionService->checkPermission($this->stackMapper, $id, Acl::PERMISSION_MANAGE);
|
||||||
if ($this->boardService->isArchived($this->stackMapper, $id)) {
|
if ($this->boardService->isArchived($this->stackMapper, $id)) {
|
||||||
@@ -176,6 +214,14 @@ class StackService {
|
|||||||
return $this->stackMapper->update($stack);
|
return $this->stackMapper->update($stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @param $order
|
||||||
|
* @return array
|
||||||
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
*/
|
||||||
public function reorder($id, $order) {
|
public function reorder($id, $order) {
|
||||||
$this->permissionService->checkPermission($this->stackMapper, $id, Acl::PERMISSION_EDIT);
|
$this->permissionService->checkPermission($this->stackMapper, $id, Acl::PERMISSION_EDIT);
|
||||||
$stackToSort = $this->stackMapper->find($id);
|
$stackToSort = $this->stackMapper->find($id);
|
||||||
|
|||||||
Reference in New Issue
Block a user