|
@@ 389-408 (lines=20) @@
|
| 386 |
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException |
| 387 |
|
* @throws BadRequestException |
| 388 |
|
*/ |
| 389 |
|
public function assignLabel($cardId, $labelId) { |
| 390 |
|
|
| 391 |
|
if (is_numeric($cardId) === false) { |
| 392 |
|
throw new BadRequestException('card id must be a number'); |
| 393 |
|
} |
| 394 |
|
|
| 395 |
|
if (is_numeric($labelId) === false) { |
| 396 |
|
throw new BadRequestException('label id must be a number'); |
| 397 |
|
} |
| 398 |
|
|
| 399 |
|
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT); |
| 400 |
|
if ($this->boardService->isArchived($this->cardMapper, $cardId)) { |
| 401 |
|
throw new StatusException('Operation not allowed. This board is archived.'); |
| 402 |
|
} |
| 403 |
|
$card = $this->cardMapper->find($cardId); |
| 404 |
|
if ($card->getArchived()) { |
| 405 |
|
throw new StatusException('Operation not allowed. This card is archived.'); |
| 406 |
|
} |
| 407 |
|
$this->cardMapper->assignLabel($cardId, $labelId); |
| 408 |
|
} |
| 409 |
|
|
| 410 |
|
/** |
| 411 |
|
* @param $cardId |
|
@@ 419-438 (lines=20) @@
|
| 416 |
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException |
| 417 |
|
* @throws BadRequestException |
| 418 |
|
*/ |
| 419 |
|
public function removeLabel($cardId, $labelId) { |
| 420 |
|
|
| 421 |
|
if (is_numeric($cardId) === false) { |
| 422 |
|
throw new BadRequestException('card id must be a number'); |
| 423 |
|
} |
| 424 |
|
|
| 425 |
|
if (is_numeric($labelId) === false) { |
| 426 |
|
throw new BadRequestException('label id must be a number'); |
| 427 |
|
} |
| 428 |
|
|
| 429 |
|
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT); |
| 430 |
|
if ($this->boardService->isArchived($this->cardMapper, $cardId)) { |
| 431 |
|
throw new StatusException('Operation not allowed. This board is archived.'); |
| 432 |
|
} |
| 433 |
|
$card = $this->cardMapper->find($cardId); |
| 434 |
|
if ($card->getArchived()) { |
| 435 |
|
throw new StatusException('Operation not allowed. This card is archived.'); |
| 436 |
|
} |
| 437 |
|
$this->cardMapper->removeLabel($cardId, $labelId); |
| 438 |
|
} |
| 439 |
|
|
| 440 |
|
/** |
| 441 |
|
* @param $cardId |