|
@@ 179-194 (lines=16) @@
|
| 176 |
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException |
| 177 |
|
* @throws BadRequestException |
| 178 |
|
*/ |
| 179 |
|
public function delete($id) { |
| 180 |
|
|
| 181 |
|
if (is_numeric($id) === false) { |
| 182 |
|
throw new BadRequestException('card id must be a number'); |
| 183 |
|
} |
| 184 |
|
|
| 185 |
|
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); |
| 186 |
|
if ($this->boardService->isArchived($this->cardMapper, $id)) { |
| 187 |
|
throw new StatusException('Operation not allowed. This board is archived.'); |
| 188 |
|
} |
| 189 |
|
$card = $this->cardMapper->find($id); |
| 190 |
|
$card->setDeletedAt(time()); |
| 191 |
|
$this->cardMapper->update($card); |
| 192 |
|
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_CARD_DELETE); |
| 193 |
|
return $card; |
| 194 |
|
} |
| 195 |
|
|
| 196 |
|
/** |
| 197 |
|
* @param $id |
|
@@ 353-368 (lines=16) @@
|
| 350 |
|
* @throws \OCP\AppFramework\Db\ |
| 351 |
|
* @throws BadRequestException |
| 352 |
|
*/ |
| 353 |
|
public function archive($id) { |
| 354 |
|
|
| 355 |
|
if (is_numeric($id) === false) { |
| 356 |
|
throw new BadRequestException('id must be a number'); |
| 357 |
|
} |
| 358 |
|
|
| 359 |
|
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); |
| 360 |
|
if ($this->boardService->isArchived($this->cardMapper, $id)) { |
| 361 |
|
throw new StatusException('Operation not allowed. This board is archived.'); |
| 362 |
|
} |
| 363 |
|
$card = $this->cardMapper->find($id); |
| 364 |
|
$card->setArchived(true); |
| 365 |
|
$newCard = $this->cardMapper->update($card); |
| 366 |
|
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $newCard, ActivityManager::SUBJECT_CARD_UPDATE_ARCHIVE); |
| 367 |
|
return $newCard; |
| 368 |
|
} |
| 369 |
|
|
| 370 |
|
/** |
| 371 |
|
* @param $id |
|
@@ 379-394 (lines=16) @@
|
| 376 |
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException |
| 377 |
|
* @throws BadRequestException |
| 378 |
|
*/ |
| 379 |
|
public function unarchive($id) { |
| 380 |
|
|
| 381 |
|
if (is_numeric($id) === false) { |
| 382 |
|
throw new BadRequestException('id must be a number'); |
| 383 |
|
} |
| 384 |
|
|
| 385 |
|
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); |
| 386 |
|
if ($this->boardService->isArchived($this->cardMapper, $id)) { |
| 387 |
|
throw new StatusException('Operation not allowed. This board is archived.'); |
| 388 |
|
} |
| 389 |
|
$card = $this->cardMapper->find($id); |
| 390 |
|
$card->setArchived(false); |
| 391 |
|
$newCard = $this->cardMapper->update($card); |
| 392 |
|
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $newCard, ActivityManager::SUBJECT_CARD_UPDATE_UNARCHIVE); |
| 393 |
|
return $newCard; |
| 394 |
|
} |
| 395 |
|
|
| 396 |
|
/** |
| 397 |
|
* @param $cardId |