|
@@ 216-237 (lines=22) @@
|
| 213 |
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException |
| 214 |
|
* @throws BadRequestException |
| 215 |
|
*/ |
| 216 |
|
public function delete($id) { |
| 217 |
|
|
| 218 |
|
if (is_numeric($id) === false) { |
| 219 |
|
throw new BadRequestException('card id must be a number'); |
| 220 |
|
} |
| 221 |
|
|
| 222 |
|
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); |
| 223 |
|
if ($this->boardService->isArchived($this->cardMapper, $id)) { |
| 224 |
|
throw new StatusException('Operation not allowed. This board is archived.'); |
| 225 |
|
} |
| 226 |
|
$card = $this->cardMapper->find($id); |
| 227 |
|
$card->setDeletedAt(time()); |
| 228 |
|
$this->cardMapper->update($card); |
| 229 |
|
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_CARD_DELETE); |
| 230 |
|
$this->changeHelper->cardChanged($card->getId(), false); |
| 231 |
|
|
| 232 |
|
$this->eventDispatcher->dispatch( |
| 233 |
|
'\OCA\Deck\Card::onDelete', new GenericEvent(null, ['id' => $id, 'card' => $card]) |
| 234 |
|
); |
| 235 |
|
|
| 236 |
|
return $card; |
| 237 |
|
} |
| 238 |
|
|
| 239 |
|
/** |
| 240 |
|
* @param $id |
|
@@ 446-468 (lines=23) @@
|
| 443 |
|
* @throws \OCP\AppFramework\Db\ |
| 444 |
|
* @throws BadRequestException |
| 445 |
|
*/ |
| 446 |
|
public function archive($id) { |
| 447 |
|
|
| 448 |
|
if (is_numeric($id) === false) { |
| 449 |
|
throw new BadRequestException('id must be a number'); |
| 450 |
|
} |
| 451 |
|
|
| 452 |
|
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); |
| 453 |
|
if ($this->boardService->isArchived($this->cardMapper, $id)) { |
| 454 |
|
throw new StatusException('Operation not allowed. This board is archived.'); |
| 455 |
|
} |
| 456 |
|
$card = $this->cardMapper->find($id); |
| 457 |
|
$card->setArchived(true); |
| 458 |
|
$newCard = $this->cardMapper->update($card); |
| 459 |
|
$this->notificationHelper->markDuedateAsRead($card); |
| 460 |
|
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $newCard, ActivityManager::SUBJECT_CARD_UPDATE_ARCHIVE); |
| 461 |
|
$this->changeHelper->cardChanged($id, false); |
| 462 |
|
|
| 463 |
|
$this->eventDispatcher->dispatch( |
| 464 |
|
'\OCA\Deck\Card::onUpdate', new GenericEvent(null, ['id' => $id, 'card' => $card]) |
| 465 |
|
); |
| 466 |
|
|
| 467 |
|
return $newCard; |
| 468 |
|
} |
| 469 |
|
|
| 470 |
|
/** |
| 471 |
|
* @param $id |
|
@@ 479-500 (lines=22) @@
|
| 476 |
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException |
| 477 |
|
* @throws BadRequestException |
| 478 |
|
*/ |
| 479 |
|
public function unarchive($id) { |
| 480 |
|
|
| 481 |
|
if (is_numeric($id) === false) { |
| 482 |
|
throw new BadRequestException('id must be a number'); |
| 483 |
|
} |
| 484 |
|
|
| 485 |
|
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); |
| 486 |
|
if ($this->boardService->isArchived($this->cardMapper, $id)) { |
| 487 |
|
throw new StatusException('Operation not allowed. This board is archived.'); |
| 488 |
|
} |
| 489 |
|
$card = $this->cardMapper->find($id); |
| 490 |
|
$card->setArchived(false); |
| 491 |
|
$newCard = $this->cardMapper->update($card); |
| 492 |
|
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $newCard, ActivityManager::SUBJECT_CARD_UPDATE_UNARCHIVE); |
| 493 |
|
$this->changeHelper->cardChanged($id, false); |
| 494 |
|
|
| 495 |
|
$this->eventDispatcher->dispatch( |
| 496 |
|
'\OCA\Deck\Card::onUpdate', new GenericEvent(null, ['id' => $id, 'card' => $card]) |
| 497 |
|
); |
| 498 |
|
|
| 499 |
|
return $newCard; |
| 500 |
|
} |
| 501 |
|
|
| 502 |
|
/** |
| 503 |
|
* @param $cardId |