|
@@ 511-537 (lines=27) @@
|
| 508 |
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException |
| 509 |
|
* @throws BadRequestException |
| 510 |
|
*/ |
| 511 |
|
public function assignLabel($cardId, $labelId) { |
| 512 |
|
|
| 513 |
|
if (is_numeric($cardId) === false) { |
| 514 |
|
throw new BadRequestException('card id must be a number'); |
| 515 |
|
} |
| 516 |
|
|
| 517 |
|
if (is_numeric($labelId) === false) { |
| 518 |
|
throw new BadRequestException('label id must be a number'); |
| 519 |
|
} |
| 520 |
|
|
| 521 |
|
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT); |
| 522 |
|
if ($this->boardService->isArchived($this->cardMapper, $cardId)) { |
| 523 |
|
throw new StatusException('Operation not allowed. This board is archived.'); |
| 524 |
|
} |
| 525 |
|
$card = $this->cardMapper->find($cardId); |
| 526 |
|
if ($card->getArchived()) { |
| 527 |
|
throw new StatusException('Operation not allowed. This card is archived.'); |
| 528 |
|
} |
| 529 |
|
$label = $this->labelMapper->find($labelId); |
| 530 |
|
$this->cardMapper->assignLabel($cardId, $labelId); |
| 531 |
|
$this->changeHelper->cardChanged($cardId, false); |
| 532 |
|
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_LABEL_ASSIGN, ['label' => $label]); |
| 533 |
|
|
| 534 |
|
$this->eventDispatcher->dispatch( |
| 535 |
|
'\OCA\Deck\Card::onUpdate', new GenericEvent(null, ['id' => $cardId, 'card' => $card]) |
| 536 |
|
); |
| 537 |
|
} |
| 538 |
|
|
| 539 |
|
/** |
| 540 |
|
* @param $cardId |
|
@@ 548-574 (lines=27) @@
|
| 545 |
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException |
| 546 |
|
* @throws BadRequestException |
| 547 |
|
*/ |
| 548 |
|
public function removeLabel($cardId, $labelId) { |
| 549 |
|
|
| 550 |
|
if (is_numeric($cardId) === false) { |
| 551 |
|
throw new BadRequestException('card id must be a number'); |
| 552 |
|
} |
| 553 |
|
|
| 554 |
|
if (is_numeric($labelId) === false) { |
| 555 |
|
throw new BadRequestException('label id must be a number'); |
| 556 |
|
} |
| 557 |
|
|
| 558 |
|
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT); |
| 559 |
|
if ($this->boardService->isArchived($this->cardMapper, $cardId)) { |
| 560 |
|
throw new StatusException('Operation not allowed. This board is archived.'); |
| 561 |
|
} |
| 562 |
|
$card = $this->cardMapper->find($cardId); |
| 563 |
|
if ($card->getArchived()) { |
| 564 |
|
throw new StatusException('Operation not allowed. This card is archived.'); |
| 565 |
|
} |
| 566 |
|
$label = $this->labelMapper->find($labelId); |
| 567 |
|
$this->cardMapper->removeLabel($cardId, $labelId); |
| 568 |
|
$this->changeHelper->cardChanged($cardId, false); |
| 569 |
|
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_LABEL_UNASSING, ['label' => $label]); |
| 570 |
|
|
| 571 |
|
$this->eventDispatcher->dispatch( |
| 572 |
|
'\OCA\Deck\Card::onUpdate', new GenericEvent(null, ['id' => $cardId, 'card' => $card]) |
| 573 |
|
); |
| 574 |
|
} |
| 575 |
|
|
| 576 |
|
/** |
| 577 |
|
* @param $cardId |