SubTask::processTask

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. SubTask
  4. processTask
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/processor/task/scheduler/relationmanager/subtask.php
  • Класс: BitrixTasksProcessorTaskSchedulerRelationManagerSubTask
  • Вызов: SubTask::processTask
public function processTask($rootImpact, $result, array $settings = array())
{
	if(!$rootImpact)
	{
		return;
	}

	$id = $rootImpact->getId();
	$mode = $settings['MODE'];

	//_print_r('============== Process subtask with '.$id);

	// get tree to recalculate
	$parentTreeFragment = null;

	if($mode == 'BEFORE_ATTACH')
	{
		$newParentId = $rootImpact->getParentId();
		if($newParentId)
		{
			$parentTreeFragment = $this->getParentTree($newParentId);
			if($parentTreeFragment) // we have smth to recalculate
			{
				if($id)
				{
					$subTreeFragment = $this->getSubTree($id);
					$subTreeFragment->setParentFor($id, $newParentId);

					$parentTreeFragment->includeFragment($subTreeFragment);
				}
				else
				{
					// and add one "virtual" node to our tree fragment, and then do calculations as usual
					$parentTreeFragment->addNode(-1, $newParentId, array(
						'START_DATE_PLAN' => $rootImpact->getStartDatePlan(true),
						'END_DATE_PLAN' => $rootImpact->getEndDatePlan(),
						'PARENT_ID' => $newParentId,

						'MATCH_WORK_TIME' => 'N', // whatever, Y or N, does not make any sense here: task is already processed
						'INHERIT_DATES' => 'N', // whatever, Y or N, does not make any sense here: task is already processed
					));
				}
			}
		}
	}
	elseif($mode == 'BEFORE_DETACH')
	{
		$oldParentId = $rootImpact->getParentId();
		if($oldParentId)
		{
			$parentTreeFragment = $this->getParentTree($oldParentId);
			if($parentTreeFragment) // we have smth to recalculate
			{
				// remove subtree with root at $id, not to take it into account
				$parentTreeFragment->excludeSubTreeFragment($id);
			}
		}
	}
	else
	{
		if($id)
		{
			// if task already created (typically, we are called from inside update()), get its parent tree
			$parentTreeFragment = $this->getParentTree($id);
		}
	}

	if($parentTreeFragment)
	{
		$current = $parentTreeFragment->getNodeData($id ? $id : -1);
		if($current)
		{
			// MODIFY SUBTREE: if it is a "bracket" task, it will shift its subtree
			if($current['INHERIT_DATES'] == 'Y')
			{
				$this->shiftSubTree($rootImpact, $parentTreeFragment);
			}
		}

		// MODIFY PATH: for each task we need to calculate min and max dates of its sub-tasks
		$this->resizeBrackets($parentTreeFragment);
	}
}

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