Add change database helper
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -57,6 +57,8 @@ class AttachmentService {
|
||||
private $l10n;
|
||||
/** @var ActivityManager */
|
||||
private $activityManager;
|
||||
/** @var ChangeHelper */
|
||||
private $changeHelper;
|
||||
|
||||
/**
|
||||
* AttachmentService constructor.
|
||||
@@ -219,12 +221,11 @@ class AttachmentService {
|
||||
* @param $cardId
|
||||
* @param $attachmentId
|
||||
* @return Response
|
||||
* @throws \OCA\Deck\NotFoundException
|
||||
* @throws BadRequestException
|
||||
* @throws NoPermissionException
|
||||
* @throws NotFoundException
|
||||
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||
* @throws \OCP\AppFramework\Db\
|
||||
* @throws BadRequestException
|
||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
*/
|
||||
public function display($cardId, $attachmentId) {
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ use OCA\Deck\Activity\ChangeSet;
|
||||
use OCA\Deck\Db\Acl;
|
||||
use OCA\Deck\Db\AclMapper;
|
||||
use OCA\Deck\Db\AssignedUsersMapper;
|
||||
use OCA\Deck\Db\ChangeHelper;
|
||||
use OCA\Deck\Db\IPermissionMapper;
|
||||
use OCA\Deck\Db\Label;
|
||||
use OCA\Deck\Notification\NotificationHelper;
|
||||
@@ -54,6 +55,7 @@ class BoardService {
|
||||
private $groupManager;
|
||||
private $userId;
|
||||
private $activityManager;
|
||||
private $changeHelper;
|
||||
|
||||
public function __construct(
|
||||
BoardMapper $boardMapper,
|
||||
@@ -66,6 +68,7 @@ class BoardService {
|
||||
IUserManager $userManager,
|
||||
IGroupManager $groupManager,
|
||||
ActivityManager $activityManager,
|
||||
ChangeHelper $changeHelper,
|
||||
$userId
|
||||
) {
|
||||
$this->boardMapper = $boardMapper;
|
||||
@@ -78,6 +81,7 @@ class BoardService {
|
||||
$this->userManager = $userManager;
|
||||
$this->groupManager = $groupManager;
|
||||
$this->activityManager = $activityManager;
|
||||
$this->changeHelper = $changeHelper;
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
@@ -276,6 +280,7 @@ class BoardService {
|
||||
'PERMISSION_SHARE' => $permissions[Acl::PERMISSION_SHARE]
|
||||
]);
|
||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $new_board, ActivityManager::SUBJECT_BOARD_CREATE);
|
||||
$this->changeHelper->boardChanged($new_board->getId());
|
||||
return $new_board;
|
||||
|
||||
}
|
||||
@@ -299,6 +304,7 @@ class BoardService {
|
||||
$board->setDeletedAt(time());
|
||||
$board = $this->boardMapper->update($board);
|
||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $board, ActivityManager::SUBJECT_BOARD_DELETE);
|
||||
$this->changeHelper->boardChanged($board->getId());
|
||||
return $board;
|
||||
}
|
||||
|
||||
@@ -320,6 +326,7 @@ class BoardService {
|
||||
$board->setDeletedAt(0);
|
||||
$board = $this->boardMapper->update($board);
|
||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $board, ActivityManager::SUBJECT_BOARD_RESTORE);
|
||||
$this->changeHelper->boardChanged($board->getId());
|
||||
return $board;
|
||||
}
|
||||
|
||||
@@ -380,6 +387,7 @@ class BoardService {
|
||||
$this->boardMapper->update($board); // operate on clone so we can check for updated fields
|
||||
$this->boardMapper->mapOwner($board);
|
||||
$this->activityManager->triggerUpdateEvents(ActivityManager::DECK_OBJECT_BOARD, $changes, ActivityManager::SUBJECT_BOARD_UPDATE);
|
||||
$this->changeHelper->boardChanged($board->getId());
|
||||
return $board;
|
||||
}
|
||||
|
||||
@@ -392,8 +400,8 @@ class BoardService {
|
||||
* @param $share
|
||||
* @param $manage
|
||||
* @return \OCP\AppFramework\Db\Entity
|
||||
* @throws \OCA\Deck\
|
||||
* @throws BadRequestException
|
||||
* @throws \OCA\Deck\NoPermissionException
|
||||
*/
|
||||
public function addAcl($boardId, $type, $participant, $edit, $share, $manage) {
|
||||
|
||||
@@ -436,6 +444,7 @@ class BoardService {
|
||||
$newAcl = $this->aclMapper->insert($acl);
|
||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $newAcl, ActivityManager::SUBJECT_BOARD_SHARE);
|
||||
$this->boardMapper->mapAcl($newAcl);
|
||||
$this->changeHelper->boardChanged($boardId);
|
||||
return $newAcl;
|
||||
}
|
||||
|
||||
@@ -475,7 +484,9 @@ class BoardService {
|
||||
$acl->setPermissionShare($share);
|
||||
$acl->setPermissionManage($manage);
|
||||
$this->boardMapper->mapAcl($acl);
|
||||
return $this->aclMapper->update($acl);
|
||||
$board = $this->aclMapper->update($acl);
|
||||
$this->changeHelper->boardChanged($acl->getBoardId());
|
||||
return $board;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -503,6 +514,7 @@ class BoardService {
|
||||
}
|
||||
}
|
||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $acl, ActivityManager::SUBJECT_BOARD_UNSHARE);
|
||||
$this->changeHelper->boardChanged($acl->getBoardId());
|
||||
return $this->aclMapper->delete($acl);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ class CardService {
|
||||
private $activityManager;
|
||||
private $commentsManager;
|
||||
private $changeHelper;
|
||||
private $userManager;
|
||||
|
||||
public function __construct(
|
||||
CardMapper $cardMapper,
|
||||
@@ -485,9 +486,10 @@ class CardService {
|
||||
* @param $cardId
|
||||
* @param $userId
|
||||
* @return bool|null|\OCP\AppFramework\Db\Entity
|
||||
* @throws BadRequestException
|
||||
* @throws \OCA\Deck\NoPermissionException
|
||||
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws BadRequestException
|
||||
*/
|
||||
public function assignUser($cardId, $userId) {
|
||||
|
||||
@@ -526,10 +528,11 @@ class CardService {
|
||||
* @param $cardId
|
||||
* @param $userId
|
||||
* @return \OCP\AppFramework\Db\Entity
|
||||
* @throws BadRequestException
|
||||
* @throws NotFoundException
|
||||
* @throws \OCA\Deck\NoPermissionException
|
||||
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws BadRequestException
|
||||
*/
|
||||
public function unassignUser($cardId, $userId) {
|
||||
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
|
||||
|
||||
@@ -5,24 +5,25 @@
|
||||
* @author Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Deck\Service;
|
||||
|
||||
use OCA\Deck\Db\ChangeHelper;
|
||||
use OCA\Deck\Db\Label;
|
||||
use OCA\Deck\Db\Acl;
|
||||
use OCA\Deck\Db\LabelMapper;
|
||||
@@ -38,11 +39,14 @@ class LabelService {
|
||||
private $permissionService;
|
||||
/** @var BoardService */
|
||||
private $boardService;
|
||||
/** @var ChangeHelper */
|
||||
private $changeHelper;
|
||||
|
||||
public function __construct(LabelMapper $labelMapper, PermissionService $permissionService, BoardService $boardService) {
|
||||
public function __construct(LabelMapper $labelMapper, PermissionService $permissionService, BoardService $boardService, ChangeHelper $changeHelper) {
|
||||
$this->labelMapper = $labelMapper;
|
||||
$this->permissionService = $permissionService;
|
||||
$this->boardService = $boardService;
|
||||
$this->changeHelper = $changeHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,6 +98,7 @@ class LabelService {
|
||||
$label->setTitle($title);
|
||||
$label->setColor($color);
|
||||
$label->setBoardId($boardId);
|
||||
$this->changeHelper->boardChanged($boardId);
|
||||
return $this->labelMapper->insert($label);
|
||||
}
|
||||
|
||||
@@ -116,7 +121,9 @@ class LabelService {
|
||||
if ($this->boardService->isArchived($this->labelMapper, $id)) {
|
||||
throw new StatusException('Operation not allowed. This board is archived.');
|
||||
}
|
||||
return $this->labelMapper->delete($this->find($id));
|
||||
$label = $this->labelMapper->delete($this->find($id));
|
||||
$this->changeHelper->boardChanged($label->getBoardId());
|
||||
return $label;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,7 +158,8 @@ class LabelService {
|
||||
$label = $this->find($id);
|
||||
$label->setTitle($title);
|
||||
$label->setColor($color);
|
||||
$this->changeHelper->boardChanged($label->getBoardId());
|
||||
return $this->labelMapper->update($label);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use OCA\Deck\Activity\ChangeSet;
|
||||
use OCA\Deck\Db\Acl;
|
||||
use OCA\Deck\Db\CardMapper;
|
||||
use OCA\Deck\Db\BoardMapper;
|
||||
use OCA\Deck\Db\ChangeHelper;
|
||||
use OCA\Deck\Db\LabelMapper;
|
||||
use OCA\Deck\Db\AssignedUsersMapper;
|
||||
use OCA\Deck\Db\Stack;
|
||||
@@ -49,6 +50,7 @@ class StackService {
|
||||
private $assignedUsersMapper;
|
||||
private $attachmentService;
|
||||
private $activityManager;
|
||||
private $changeHelper;
|
||||
|
||||
public function __construct(
|
||||
StackMapper $stackMapper,
|
||||
@@ -60,7 +62,8 @@ class StackService {
|
||||
CardService $cardService,
|
||||
AssignedUsersMapper $assignedUsersMapper,
|
||||
AttachmentService $attachmentService,
|
||||
ActivityManager $activityManager
|
||||
ActivityManager $activityManager,
|
||||
ChangeHelper $changeHelper
|
||||
) {
|
||||
$this->stackMapper = $stackMapper;
|
||||
$this->boardMapper = $boardMapper;
|
||||
@@ -72,6 +75,7 @@ class StackService {
|
||||
$this->assignedUsersMapper = $assignedUsersMapper;
|
||||
$this->attachmentService = $attachmentService;
|
||||
$this->activityManager = $activityManager;
|
||||
$this->changeHelper = $changeHelper;
|
||||
}
|
||||
|
||||
private function enrichStackWithCards($stack, $since = -1) {
|
||||
@@ -203,6 +207,7 @@ class StackService {
|
||||
$stack->setOrder($order);
|
||||
$stack = $this->stackMapper->insert($stack);
|
||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $stack, ActivityManager::SUBJECT_STACK_CREATE);
|
||||
$this->changeHelper->boardChanged($boardId);
|
||||
return $stack;
|
||||
}
|
||||
|
||||
@@ -227,7 +232,7 @@ class StackService {
|
||||
$stack = $this->stackMapper->update($stack);
|
||||
|
||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $stack, ActivityManager::SUBJECT_STACK_DELETE);
|
||||
|
||||
$this->changeHelper->boardChanged($stack->getBoardId());
|
||||
$this->enrichStackWithCards($stack);
|
||||
return $stack;
|
||||
}
|
||||
@@ -276,6 +281,7 @@ class StackService {
|
||||
$changes->setAfter($stack);
|
||||
$stack = $this->stackMapper->update($stack);
|
||||
$this->activityManager->triggerUpdateEvents(ActivityManager::DECK_OBJECT_BOARD, $changes, ActivityManager::SUBJECT_STACK_UPDATE);
|
||||
$this->changeHelper->boardChanged($stack->getBoardId());
|
||||
return $stack;
|
||||
}
|
||||
|
||||
@@ -318,7 +324,7 @@ class StackService {
|
||||
$this->stackMapper->update($stack);
|
||||
$result[$stack->getOrder()] = $stack;
|
||||
}
|
||||
|
||||
$this->changeHelper->boardChanged($stackToSort->getBoardId());
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user