| @@ 247-270 (lines=24) @@ | ||
| 244 | * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException |
|
| 245 | * @throws BadRequestException |
|
| 246 | */ |
|
| 247 | public function delete($id) { |
|
| 248 | ||
| 249 | if (is_numeric($id) === false) { |
|
| 250 | throw new BadRequestException('stack id must be a number'); |
|
| 251 | } |
|
| 252 | ||
| 253 | $this->permissionService->checkPermission($this->stackMapper, $id, Acl::PERMISSION_MANAGE); |
|
| 254 | ||
| 255 | $stack = $this->stackMapper->find($id); |
|
| 256 | $stack->setDeletedAt(time()); |
|
| 257 | $stack = $this->stackMapper->update($stack); |
|
| 258 | ||
| 259 | $this->activityManager->triggerEvent( |
|
| 260 | ActivityManager::DECK_OBJECT_BOARD, $stack, ActivityManager::SUBJECT_STACK_DELETE |
|
| 261 | ); |
|
| 262 | $this->changeHelper->boardChanged($stack->getBoardId()); |
|
| 263 | $this->enrichStackWithCards($stack); |
|
| 264 | ||
| 265 | $this->eventDispatcher->dispatch( |
|
| 266 | '\OCA\Deck\Stack::onDelete', new GenericEvent(null, ['id' => $id, 'stack' => $stack]) |
|
| 267 | ); |
|
| 268 | ||
| 269 | return $stack; |
|
| 270 | } |
|
| 271 | ||
| 272 | /** |
|
| 273 | * @param $id |
|
| @@ 366-384 (lines=19) @@ | ||
| 363 | * @throws \OCA\Deck\NoPermissionException |
|
| 364 | * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException |
|
| 365 | */ |
|
| 366 | public function deleteUndo($id) { |
|
| 367 | ||
| 368 | if (is_numeric($id) === false) { |
|
| 369 | throw new BadRequestException('board id must be a number'); |
|
| 370 | } |
|
| 371 | ||
| 372 | $this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ); |
|
| 373 | $board = $this->find($id); |
|
| 374 | $board->setDeletedAt(0); |
|
| 375 | $board = $this->boardMapper->update($board); |
|
| 376 | $this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $board, ActivityManager::SUBJECT_BOARD_RESTORE); |
|
| 377 | $this->changeHelper->boardChanged($board->getId()); |
|
| 378 | ||
| 379 | $this->eventDispatcher->dispatch( |
|
| 380 | '\OCA\Deck\Board::onUpdate', new GenericEvent(null, ['id' => $id, 'board' => $board]) |
|
| 381 | ); |
|
| 382 | ||
| 383 | return $board; |
|
| 384 | } |
|
| 385 | ||
| 386 | /** |
|
| 387 | * @param $id |
|