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