|
@@ 451-473 (lines=23) @@
|
| 448 |
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException |
| 449 |
|
* @throws BadRequestException |
| 450 |
|
*/ |
| 451 |
|
public function assignLabel($cardId, $labelId) { |
| 452 |
|
|
| 453 |
|
if (is_numeric($cardId) === false) { |
| 454 |
|
throw new BadRequestException('card id must be a number'); |
| 455 |
|
} |
| 456 |
|
|
| 457 |
|
if (is_numeric($labelId) === false) { |
| 458 |
|
throw new BadRequestException('label id must be a number'); |
| 459 |
|
} |
| 460 |
|
|
| 461 |
|
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT); |
| 462 |
|
if ($this->boardService->isArchived($this->cardMapper, $cardId)) { |
| 463 |
|
throw new StatusException('Operation not allowed. This board is archived.'); |
| 464 |
|
} |
| 465 |
|
$card = $this->cardMapper->find($cardId); |
| 466 |
|
if ($card->getArchived()) { |
| 467 |
|
throw new StatusException('Operation not allowed. This card is archived.'); |
| 468 |
|
} |
| 469 |
|
$label = $this->labelMapper->find($labelId); |
| 470 |
|
$this->cardMapper->assignLabel($cardId, $labelId); |
| 471 |
|
$this->changeHelper->cardChanged($cardId, false); |
| 472 |
|
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_LABEL_ASSIGN, ['label' => $label]); |
| 473 |
|
} |
| 474 |
|
|
| 475 |
|
/** |
| 476 |
|
* @param $cardId |
|
@@ 484-506 (lines=23) @@
|
| 481 |
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException |
| 482 |
|
* @throws BadRequestException |
| 483 |
|
*/ |
| 484 |
|
public function removeLabel($cardId, $labelId) { |
| 485 |
|
|
| 486 |
|
if (is_numeric($cardId) === false) { |
| 487 |
|
throw new BadRequestException('card id must be a number'); |
| 488 |
|
} |
| 489 |
|
|
| 490 |
|
if (is_numeric($labelId) === false) { |
| 491 |
|
throw new BadRequestException('label id must be a number'); |
| 492 |
|
} |
| 493 |
|
|
| 494 |
|
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT); |
| 495 |
|
if ($this->boardService->isArchived($this->cardMapper, $cardId)) { |
| 496 |
|
throw new StatusException('Operation not allowed. This board is archived.'); |
| 497 |
|
} |
| 498 |
|
$card = $this->cardMapper->find($cardId); |
| 499 |
|
if ($card->getArchived()) { |
| 500 |
|
throw new StatusException('Operation not allowed. This card is archived.'); |
| 501 |
|
} |
| 502 |
|
$label = $this->labelMapper->find($labelId); |
| 503 |
|
$this->cardMapper->removeLabel($cardId, $labelId); |
| 504 |
|
$this->changeHelper->cardChanged($cardId, false); |
| 505 |
|
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_LABEL_UNASSING, ['label' => $label]); |
| 506 |
|
} |
| 507 |
|
|
| 508 |
|
/** |
| 509 |
|
* @param $cardId |