Stages::moveScrumTask

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. Stages
  4. moveScrumTask
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/dispatcher/publicaction/task/stages.php
  • Класс: BitrixTasksDispatcherPublicActionTaskStages
  • Вызов: Stages::moveScrumTask
private function moveScrumTask(int $taskId, int $groupId, array $stage): bool
{
	$itemService = new ItemService();
	$entityService = new EntityService();

	$scrumItem = $itemService->getItemBySourceId($taskId);
	if ($itemService->getErrors() || $scrumItem->isEmpty())
	{
		return false;
	}

	$entity = $entityService->getEntityById($scrumItem->getEntityId());
	if ($entityService->getErrors() || $entity->isEmpty())
	{
		return false;
	}

	if ($entity->getEntityType() === EntityForm::BACKLOG_TYPE)
	{
		return false;
	}

	$featurePerms = CSocNetFeaturesPerms::currentUserCanPerformOperation(
		SONET_ENTITY_GROUP,
		[$groupId],
		'tasks',
		'sort'
	);
	$isAccess = (is_array($featurePerms) && isset($featurePerms[$groupId]) && $featurePerms[$groupId]);
	if (!$isAccess)
	{
		$this->errors->add(
			'ACCESS_DENIED_MOVE',
			Loc::getMessage('STAGES_ERROR_ACCESS_DENIED_MOVE')
		);

		return false;
	}

	$taskObject = new CTasks;

	$queryObject = TaskStageTable::getList([
		'filter' => [
			'TASK_ID' => $taskId,
			'=STAGE.ENTITY_TYPE' => StagesTable::WORK_MODE_ACTIVE_SPRINT,
			'STAGE.ENTITY_ID' => $entity->getId()
		]
	]);
	if ($taskStage = $queryObject->fetch())
	{
		TaskStageTable::update($taskStage['ID'], [
			'STAGE_ID' => $stage['ID'],
		]);

		$taskObject->update($taskId, ['STAGE_ID' => $stage['ID']]);
	}

	// todo maybe need add push here

	if ($stage['SYSTEM_TYPE'] === StagesTable::SYS_TYPE_FINISH)
	{
		$this->completeTask($taskId);
	}
	else
	{
		$this->renewTask($taskId);
	}

	return true;
}

Добавить комментарий