• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/classes/general/taskitem.php
  • Класс: CTaskItem
  • Вызов: CTaskItem::getChildTemplateData
static function getChildTemplateData($templateId)
{
	$templateId = (int) $templateId;
	if ( ! $templateId )
		return array();	// template id not set

	$subTasksToCreate = array();

	// todo: use Item here!!!
	$userId = BitrixTasksUtilUser::getAdminId(); // todo: deprecated
	$ufc = new BitrixTasksUtilUserFieldTask(); // todo: deprecated
	$scheme = array();
	if($ufc)
	{
		$scheme = $ufc->getScheme();
	}

	$res = CTaskTemplates::GetList(array('BASE_TEMPLATE_ID' => 'asc'), array('BASE_TEMPLATE_ID' => $templateId), false, array('INCLUDE_TEMPLATE_SUBTREE' => true), array('*', 'UF_*', 'BASE_TEMPLATE_ID'));
	while($item = $res->fetch())
	{
		if($item['ID'] == $templateId)
			continue;

		// also, try to set default uf values
		foreach($scheme as $field => $desc)
		{
			if(!array_key_exists($field, $item))
			{
				$default = $ufc->getDefaultValue($field, $userId);
				if($default !== null)
				{
					$item[$field] = $default;
				}
			}
		}

		$subTasksToCreate[$item['ID']] = $item;
	}

	// get check lists
	$res = BitrixTasksInternalsTaskTemplateCheckListTable::getListByTemplateDependency($templateId, array(
		'order' => array('SORT' => 'ASC'),
		'select' => array('ID', 'TEMPLATE_ID', 'IS_COMPLETE', 'SORT_INDEX', 'TITLE')
	));
	while($item = $res->fetch())
	{
		if(isset($subTasksToCreate[$item['TEMPLATE_ID']]))
		{
			$clId = $item['ID'];
			$tmpId = $item['TEMPLATE_ID'];
			unset($item['ID']);
			unset($item['TEMPLATE_ID']);
			$subTasksToCreate[$tmpId]['CHECK_LIST'][$clId] = $item;
		}
	}

	return $subTasksToCreate;
}