|
@@ 197-213 (lines=17) @@
|
| 194 |
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException |
| 195 |
|
* @throws BadRequestException |
| 196 |
|
*/ |
| 197 |
|
public function delete($id) { |
| 198 |
|
|
| 199 |
|
if (is_numeric($id) === false) { |
| 200 |
|
throw new BadRequestException('card id must be a number'); |
| 201 |
|
} |
| 202 |
|
|
| 203 |
|
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); |
| 204 |
|
if ($this->boardService->isArchived($this->cardMapper, $id)) { |
| 205 |
|
throw new StatusException('Operation not allowed. This board is archived.'); |
| 206 |
|
} |
| 207 |
|
$card = $this->cardMapper->find($id); |
| 208 |
|
$card->setDeletedAt(time()); |
| 209 |
|
$this->cardMapper->update($card); |
| 210 |
|
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_CARD_DELETE); |
| 211 |
|
$this->changeHelper->cardChanged($card->getId(), false); |
| 212 |
|
return $card; |
| 213 |
|
} |
| 214 |
|
|
| 215 |
|
/** |
| 216 |
|
* @param $id |
|
@@ 397-413 (lines=17) @@
|
| 394 |
|
* @throws \OCP\AppFramework\Db\ |
| 395 |
|
* @throws BadRequestException |
| 396 |
|
*/ |
| 397 |
|
public function archive($id) { |
| 398 |
|
|
| 399 |
|
if (is_numeric($id) === false) { |
| 400 |
|
throw new BadRequestException('id must be a number'); |
| 401 |
|
} |
| 402 |
|
|
| 403 |
|
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); |
| 404 |
|
if ($this->boardService->isArchived($this->cardMapper, $id)) { |
| 405 |
|
throw new StatusException('Operation not allowed. This board is archived.'); |
| 406 |
|
} |
| 407 |
|
$card = $this->cardMapper->find($id); |
| 408 |
|
$card->setArchived(true); |
| 409 |
|
$newCard = $this->cardMapper->update($card); |
| 410 |
|
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $newCard, ActivityManager::SUBJECT_CARD_UPDATE_ARCHIVE); |
| 411 |
|
$this->changeHelper->cardChanged($id, false); |
| 412 |
|
return $newCard; |
| 413 |
|
} |
| 414 |
|
|
| 415 |
|
/** |
| 416 |
|
* @param $id |
|
@@ 424-440 (lines=17) @@
|
| 421 |
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException |
| 422 |
|
* @throws BadRequestException |
| 423 |
|
*/ |
| 424 |
|
public function unarchive($id) { |
| 425 |
|
|
| 426 |
|
if (is_numeric($id) === false) { |
| 427 |
|
throw new BadRequestException('id must be a number'); |
| 428 |
|
} |
| 429 |
|
|
| 430 |
|
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); |
| 431 |
|
if ($this->boardService->isArchived($this->cardMapper, $id)) { |
| 432 |
|
throw new StatusException('Operation not allowed. This board is archived.'); |
| 433 |
|
} |
| 434 |
|
$card = $this->cardMapper->find($id); |
| 435 |
|
$card->setArchived(false); |
| 436 |
|
$newCard = $this->cardMapper->update($card); |
| 437 |
|
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $newCard, ActivityManager::SUBJECT_CARD_UPDATE_UNARCHIVE); |
| 438 |
|
$this->changeHelper->cardChanged($id, false); |
| 439 |
|
return $newCard; |
| 440 |
|
} |
| 441 |
|
|
| 442 |
|
/** |
| 443 |
|
* @param $cardId |