• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/rest/controllers/scrum/kanban.php
  • Класс: BitrixTasksRestControllersScrumKanban
  • Вызов: Kanban::addTaskAction
public function addTaskAction(int $sprintId, int $taskId, int $stageId): bool
{
	$sprintId = (int) $sprintId;
	if (!$sprintId)
	{
		$this->errorCollection->add([new Error('Sprint id not found')]);

		return false;
	}

	$taskId = (int) $taskId;
	if (!$taskId)
	{
		$this->errorCollection->add([new Error('Task id not found')]);

		return false;
	}

	$stageId = (int) $stageId;
	if (!$stageId)
	{
		$this->errorCollection->add([new Error('Stage id not found')]);

		return false;
	}

	$sprintService = new SprintService();

	$sprint = $sprintService->getSprintById($sprintId);

	if (!$sprint->getId())
	{
		$this->errorCollection->add([new Error('Sprint not found')]);

		return false;
	}

	if (!$this->checkAccess($sprint->getGroupId()))
	{
		$this->errorCollection->add([new Error('Access denied')]);

		return false;
	}

	$queryObject = StagesTable::getById($stageId);
	if (!$queryObject->fetch())
	{
		$this->errorCollection->add([new Error('Stage not found')]);

		return false;
	}

	$queryObject = CTasks::getList(
		['ID' => 'ASC'],
		[
			'ID' => $taskId,
			'GROUP_ID' => $sprint->getGroupId(),
			'CHECK_PERMISSIONS' => 'N',
		],
		['ID']
	);
	if (!$queryObject->fetch())
	{
		$this->errorCollection->add([new Error('Task not found. The task must be with GROUP_ID')]);

		return false;
	}

	$result = TaskStageTable::add([
		'TASK_ID' => $taskId,
		'STAGE_ID' => $stageId,
	]);

	if ($result->isSuccess())
	{
		return $result->getId();
	}
	else
	{
		$this->errorCollection->setError(new Error('System error'));

		return false;
	}
}