boardMapper = $boardMapper; $this->labelMapper = $labelMapper; $this->aclMapper = $aclMapper; $this->logger = $logger; $this->l10n = $l10n; } public function findAll($userId) { return $this->boardMapper->findAll($userId); } public function find($userId, $boardId) { $board = $this->boardMapper->find($boardId); if ($board->getOwner() === $userId) return $board; else return null; // FIXME: [share] Check for user permissions } public function create($title, $userId, $color) { $board = new Board(); $board->setTitle($title); $board->setOwner($userId); $board->setColor($color); $new_board = $this->boardMapper->insert($board); // create new labels $default_labels = [ '31CC7C' => $this->l10n->t('Finished'), '317CCC' => $this->l10n->t('To review'), 'FF7A66' => $this->l10n->t('Action needed'), 'F1DB50' => $this->l10n->t('Maybe')]; $labels = []; foreach ($default_labels as $color=>$title) { $label = new Label(); $label->setColor($color); $label->setTitle($title); $label->setBoardId($new_board->getId()); $labels[] = $this->labelMapper->insert($label); } $new_board->setLabels($labels); return $new_board; } public function delete($userId, $id) { return $this->boardMapper->delete($this->find($userId, $id)); } public function update($id, $title, $userId, $color) { $board = $this->find($userId, $id); $board->setTitle($title); $board->setColor($color); return $this->boardMapper->update($board); } public function addAcl($boardId, $type, $participant, $write, $invite, $manage) { $acl = new Acl(); $acl->setBoardId($boardId); $acl->setType($type); $acl->setParticipant($participant); $acl->setPermissionWrite($write); $acl->setPermissionInvite($invite); $acl->setPermissionManage($manage); return $this->aclMapper->insert($acl); } public function updateAcl($id, $write, $invite, $manage) { $acl = $this->aclMapper->find($id); $acl->setPermissionWrite($write); $acl->setPermissionInvite($invite); $acl->setPermissionManage($manage); return $this->aclMapper->update($acl); } public function deleteAcl($id) { $acl = $this->aclMapper->find($id); return $this->aclMapper->delete($acl); } }