• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/control/task.php
  • Класс: BitrixTasksControlTask
  • Вызов: Task::deleteRelations
private function deleteRelations()
{
	$taskData = $this->getFullTaskData();
	if (!$taskData)
	{
		return;
	}

	CTaskMembers::DeleteAllByTaskID($this->taskId);
	CTaskDependence::DeleteByTaskID($this->taskId);
	CTaskDependence::DeleteByDependsOnID($this->taskId);
	CTaskReminders::DeleteByTaskID($this->taskId);

	$tableResult = ProjectDependenceTable::getList([
		"select" => ['TASK_ID'],
		"filter" => [
			"=TASK_ID" => $this->taskId,
			"DEPENDS_ON_ID" => $this->taskId
		]
	]);

	if (ProjectDependenceTable::checkItemLinked($this->taskId) || $tableResult->fetch())
	{
		ProjectDependenceTable::deleteLink($this->taskId, $this->taskId);
	}

	$children = BitrixTasksInternalsHelperTaskDependence::getSubTree($this->taskId)
		->find(['__PARENT_ID' => $this->taskId])
		->getData();
	BitrixTasksInternalsHelperTaskDependence::delete($this->taskId);

	if (
		$taskData['PARENT_ID']
		&& !empty($children)
	)
	{
		foreach ($children as $child)
		{
			BitrixTasksInternalsHelperTaskDependence::attach($child['__ID'], $taskData['PARENT_ID']);
		}
	}

	if (
		$taskData['PARENT_ID']
		&& $taskData['START_DATE_PLAN']
		&& $taskData['END_DATE_PLAN']
	)
	{
		// we need to scan for parent bracket tasks change...
		$scheduler = BitrixTasksProcessorTaskScheduler::getInstance($this->userId);
		// we could use MODE => DETACH here, but there we can act in more effective way by
		// re-calculating tree of PARENT_ID after removing link between ID and PARENT_ID
		// we also do not need to calculate detached tree
		// it is like DETACH_AFTER
		$shiftResult = $scheduler->processEntity($taskData['PARENT_ID']);
		if ($shiftResult->isSuccess())
		{
			$shiftResult->save();
		}
	}

	if (Loader::includeModule("search"))
	{
		CSearch::DeleteIndex("tasks", $this->taskId);
	}
}