diff --git a/lib/Db/AssignedUsersMapper.php b/lib/Db/AssignedUsersMapper.php index e9323811f..a7e0ea0b6 100644 --- a/lib/Db/AssignedUsersMapper.php +++ b/lib/Db/AssignedUsersMapper.php @@ -40,6 +40,12 @@ class AssignedUsersMapper extends DeckMapper implements IPermissionMapper { $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) { $sql = 'SELECT * FROM `*PREFIX*deck_assigned_users` ' . 'WHERE `card_id` = ?'; diff --git a/lib/Db/AttachmentMapper.php b/lib/Db/AttachmentMapper.php index 4ead87510..2ccae3be8 100644 --- a/lib/Db/AttachmentMapper.php +++ b/lib/Db/AttachmentMapper.php @@ -39,6 +39,13 @@ class AttachmentMapper extends DeckMapper implements IPermissionMapper { private $userManager; private $qb; + /** + * AttachmentMapper constructor. + * + * @param IDBConnection $db + * @param CardMapper $cardMapper + * @param IUserManager $userManager + */ public function __construct(IDBConnection $db, CardMapper $cardMapper, IUserManager $userManager) { parent::__construct($db, 'deck_attachment', Attachment::class); $this->cardMapper = $cardMapper; @@ -60,7 +67,17 @@ class AttachmentMapper extends DeckMapper implements IPermissionMapper { $cursor = $qb->execute(); $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(); + if($row2 !== false ) { + throw new MultipleObjectsReturnedException('Did not expect more than one result when executing' . $query); + } + return $this->mapRowToEntity($row); } @@ -87,6 +104,11 @@ class AttachmentMapper extends DeckMapper implements IPermissionMapper { return $entities; } + /** + * @param null $cardId + * @param bool $withOffset + * @return array + */ public function findToDelete($cardId = null, $withOffset = true) { // add buffer of 5 min $timeLimit = time() - (60 * 5); diff --git a/lib/Service/AttachmentService.php b/lib/Service/AttachmentService.php index a2bbcbc0a..53f89f518 100644 --- a/lib/Service/AttachmentService.php +++ b/lib/Service/AttachmentService.php @@ -123,6 +123,10 @@ class AttachmentService { return $attachments; } + /** + * @param $cardId + * @return int|mixed + */ public function count($cardId) { $count = $this->cache->get('card-' . $cardId); if (!$count) { @@ -132,6 +136,14 @@ class AttachmentService { return $count; } + /** + * @param $cardId + * @param $type + * @param $data + * @return Attachment|\OCP\AppFramework\Db\Entity + * @throws NoPermissionException + * @throws StatusException + */ public function create($cardId, $type, $data) { $this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT); @@ -172,7 +184,11 @@ class AttachmentService { * @param $cardId * @param $attachmentId * @return Response + * @throws \OCA\Deck\NotFoundException + * @throws NoPermissionException * @throws NotFoundException + * @throws \OCP\AppFramework\Db\DoesNotExistException + * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException */ public function display($cardId, $attachmentId) { $this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_READ); diff --git a/lib/Service/BoardService.php b/lib/Service/BoardService.php index 1ce4f546b..6b250fb4a 100644 --- a/lib/Service/BoardService.php +++ b/lib/Service/BoardService.php @@ -75,6 +75,9 @@ class BoardService { $this->userId = $userId; } + /** + * @return array + */ public function findAll() { $userInfo = $this->getBoardPrerequisites(); $userBoards = $this->boardMapper->findAllByUser($userInfo['user']); @@ -102,6 +105,13 @@ class BoardService { return array_values($result); } + /** + * @param $boardId + * @return Board + * @throws DoesNotExistException + * @throws \OCA\Deck\NoPermissionException + * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException + */ public function find($boardId) { $this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ); /** @var Board $board */ @@ -124,6 +134,9 @@ class BoardService { return $board; } + /** + * @return array + */ private function getBoardPrerequisites() { $groups = $this->groupManager->getUserGroupIds( $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) { try { $boardId = $id; @@ -150,6 +171,14 @@ class BoardService { 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) { try { $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) { $board = new Board(); $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) { $this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ); $board = $this->find($id); @@ -211,6 +252,13 @@ class BoardService { return $board; } + /** + * @param $id + * @return \OCP\AppFramework\Db\Entity + * @throws DoesNotExistException + * @throws \OCA\Deck\NoPermissionException + * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException + */ public function deleteUndo($id) { $this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ); $board = $this->find($id); @@ -218,12 +266,29 @@ class BoardService { 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) { $this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ); $board = $this->find($id); 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) { $this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_MANAGE); $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) { $this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_SHARE); $acl = new Acl(); @@ -253,6 +328,16 @@ class BoardService { 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) { $this->permissionService->checkPermission($this->aclMapper, $id, Acl::PERMISSION_SHARE); /** @var Acl $acl */ @@ -264,6 +349,13 @@ class BoardService { 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) { $this->permissionService->checkPermission($this->aclMapper, $id, Acl::PERMISSION_SHARE); /** @var Acl $acl */ diff --git a/lib/Service/CardService.php b/lib/Service/CardService.php index fcf691ecc..ad54f819d 100644 --- a/lib/Service/CardService.php +++ b/lib/Service/CardService.php @@ -89,6 +89,13 @@ class CardService { 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) { $this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_READ); $card = $this->cardMapper->find($cardId); @@ -100,7 +107,16 @@ class CardService { } /** + * @param $title + * @param $stackId + * @param $type * @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) { $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) { $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); if ($this->boardService->isArchived($this->cardMapper, $id)) { @@ -128,6 +152,21 @@ class CardService { 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) { $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); if ($this->boardService->isArchived($this->cardMapper, $id)) { @@ -148,6 +187,15 @@ class CardService { 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) { $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); if ($this->boardService->isArchived($this->cardMapper, $id)) { @@ -161,6 +209,16 @@ class CardService { 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) { $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); if ($this->boardService->isArchived($this->cardMapper, $id)) { @@ -192,6 +250,14 @@ class CardService { 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) { $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); if ($this->boardService->isArchived($this->cardMapper, $id)) { @@ -202,6 +268,14 @@ class CardService { 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) { $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); if ($this->boardService->isArchived($this->cardMapper, $id)) { @@ -212,6 +286,14 @@ class CardService { 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) { $this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT); if ($this->boardService->isArchived($this->cardMapper, $cardId)) { @@ -224,6 +306,14 @@ class CardService { $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) { $this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT); if ($this->boardService->isArchived($this->cardMapper, $cardId)) { @@ -236,6 +326,13 @@ class CardService { $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) { $this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT); $assignments = $this->assignedUsersMapper->find($cardId); @@ -257,6 +354,14 @@ class CardService { 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) { $this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT); $assignments = $this->assignedUsersMapper->find($cardId); diff --git a/lib/Service/DefaultBoardService.php b/lib/Service/DefaultBoardService.php index f79b8d24e..82fc02fa5 100644 --- a/lib/Service/DefaultBoardService.php +++ b/lib/Service/DefaultBoardService.php @@ -55,8 +55,14 @@ class DefaultBoardService { $this->boardMapper = $boardMapper; $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'); $userBoards = $this->boardMapper->findAllByUser($userId); @@ -68,7 +74,17 @@ class DefaultBoardService { 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); $defaultStacks = []; $defaultCards = []; diff --git a/lib/Service/FileService.php b/lib/Service/FileService.php index a122d76c5..543371bf2 100644 --- a/lib/Service/FileService.php +++ b/lib/Service/FileService.php @@ -142,6 +142,11 @@ class FileService implements IAttachmentService { return $file; } + /** + * @param Attachment $attachment + * @throws NotPermittedException + * @throws StatusException + */ public function create(Attachment $attachment) { $file = $this->getUploadedFile(); $folder = $this->getFolder($attachment); @@ -176,6 +181,10 @@ class FileService implements IAttachmentService { $attachment->setLastModified(time()); } + /** + * @param Attachment $attachment + * @throws NotPermittedException + */ public function delete(Attachment $attachment) { try { $file = $this->getFileForAttachment($attachment); @@ -202,6 +211,11 @@ class FileService implements IAttachmentService { return $cardFolder->get($attachment->getData()); } + /** + * @param Attachment $attachment + * @return FileDisplayResponse|\OCP\AppFramework\Http\Response|StreamResponse + * @throws \Exception + */ public function display(Attachment $attachment) { $file = $this->getFileFromRootFolder($attachment); if (method_exists($file, 'fopen')) { diff --git a/lib/Service/LabelService.php b/lib/Service/LabelService.php index 2bb910083..2b0a640be 100644 --- a/lib/Service/LabelService.php +++ b/lib/Service/LabelService.php @@ -44,11 +44,28 @@ class LabelService { $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) { $this->permissionService->checkPermission($this->labelMapper, $labelId, Acl::PERMISSION_READ); 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) { $this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE); if ($this->boardService->isArchived(null, $boardId)) { @@ -61,6 +78,14 @@ class LabelService { 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) { $this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE); if ($this->boardService->isArchived($this->labelMapper, $id)) { @@ -69,6 +94,16 @@ class LabelService { 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) { $this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE); if ($this->boardService->isArchived($this->labelMapper, $id)) { diff --git a/lib/Service/PermissionService.php b/lib/Service/PermissionService.php index 8b7e69d12..5dff31be8 100644 --- a/lib/Service/PermissionService.php +++ b/lib/Service/PermissionService.php @@ -31,6 +31,8 @@ use OCA\Deck\Db\IPermissionMapper; use OCA\Deck\Db\User; use OCA\Deck\NoPermissionException; use OCP\AppFramework\Db\DoesNotExistException; +use OCP\AppFramework\Db\Entity; +use OCP\AppFramework\Db\MultipleObjectsReturnedException; use OCP\IGroupManager; use OCP\ILogger; use OCP\IUserManager; @@ -114,41 +116,40 @@ class PermissionService { * @throws NoPermissionException */ public function checkPermission($mapper, $id, $permission) { - try { - $boardId = $id; - if ($mapper instanceof IPermissionMapper) { - $boardId = $mapper->findBoardId($id); - } - 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) { + $boardId = $id; + if ($mapper instanceof IPermissionMapper) { + $boardId = $mapper->findBoardId($id); + } + if ($boardId === null) { // Throw NoPermission to not leak information about existing entries 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 * @return bool - * @throws \OCP\AppFramework\Db\DoesNotExistException */ 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(); } @@ -192,19 +193,34 @@ class PermissionService { $board = $this->boardMapper->find($boardId); } catch (DoesNotExistException $e) { return []; + } catch (MultipleObjectsReturnedException $e) { + return []; } + $owner = $this->userManager->get($board->getOwner()); - $users = []; - $users[$owner->getUID()] = new User($owner); + if ($owner === null) { + $this->logger->info('No owner found for board ' . $board->getId()); + } else { + $users = []; + $users[$owner->getUID()] = new User($owner); + } $acls = $this->aclMapper->findAll($boardId); /** @var Acl $acl */ foreach ($acls as $acl) { if ($acl->getType() === Acl::PERMISSION_TYPE_USER) { $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); } if ($acl->getType() === Acl::PERMISSION_TYPE_GROUP) { $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) { $users[$user->getUID()] = new User($user); } diff --git a/lib/Service/StackService.php b/lib/Service/StackService.php index c5bdb7a8d..ae0850dae 100644 --- a/lib/Service/StackService.php +++ b/lib/Service/StackService.php @@ -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) { $stack = $this->stackMapper->find($stackId); $cards = $this->cardMapper->findAll($stackId); foreach ($cards as $cardIndex => $card) { $assignedUsers = $this->assignedUsersMapper->find($card->getId()); $card->setAssignedUsers($assignedUsers); - if (array_key_exists($card->id, $labels)) { - $cards[$cardIndex]->setLabels($labels[$card->id]); - } $card->setAttachmentCount($this->attachmentService->count($card->getId())); } $stack->setCards($cards); return $stack; } + /** + * @param $boardId + * @return array + * @throws \OCA\Deck\NoPermissionException + */ public function findAll($boardId) { $this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_READ); $stacks = $this->stackMapper->findAll($boardId); @@ -118,6 +126,11 @@ class StackService { return $stacks; } + /** + * @param $boardId + * @return array + * @throws \OCA\Deck\NoPermissionException + */ public function findAllArchived($boardId) { $this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_READ); $stacks = $this->stackMapper->findAll($boardId); @@ -135,7 +148,14 @@ class StackService { } /** + * @param $title + * @param $boardId * @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) { $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) { $this->permissionService->checkPermission($this->stackMapper, $id, Acl::PERMISSION_MANAGE); @@ -162,7 +189,18 @@ class StackService { 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) { $this->permissionService->checkPermission($this->stackMapper, $id, Acl::PERMISSION_MANAGE); if ($this->boardService->isArchived($this->stackMapper, $id)) { @@ -176,6 +214,14 @@ class StackService { 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) { $this->permissionService->checkPermission($this->stackMapper, $id, Acl::PERMISSION_EDIT); $stackToSort = $this->stackMapper->find($id);