Project::checkCoherence

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. Project
  4. checkCoherence
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/processor/task/scheduler/relationmanager/project.php
  • Класс: BitrixTasksProcessorTaskSchedulerRelationManagerProject
  • Вызов: Project::checkCoherence
private function checkCoherence($id, $tasks, $result)
{
	$accessible = array();
	$queue = array($id);
	$limit = 0;
	$met = array();

	while(count($queue) && $limit < 10000)
	{
		$limit++;
		$nextId = array_shift($queue);
		if($met[$nextId])
		{
			//$result->addError('ILLEGAL_STRUCTURE.DEPTH', 'Oops, there is a structure loop ('.$nextId.' met twice)');
			//break;
			continue; // just do not go the same way twice
		}
		$met[$nextId] = true;

		if(is_array($tasks[$nextId]))
		{
			foreach($tasks[$nextId] as $nextSubId => $nextSub)
			{
				if($this->canModifyTask($nextSub))
				{
					$accessible[$nextSubId] = $nextSub;
					$queue[] = $nextSubId;
				}
			}
		}
	}

	if($limit == 10000)
	{
		$result->addError('ILLEGAL_STRUCTURE.DEPTH', 'Insane project tree depth faced');
	}

	return $accessible;
}

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