• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/classes/general/tasktemplates.php
  • Класс: CTaskTemplates
  • Вызов: CTaskTemplates::Update
function Update($id, $arFields, $arParams = [])
{
	$id = (int) $id;
	if ($id < 1)
	{
		return false;
	}

	if (isset($arParams['USER_ID']))
	{
		$userId = (int) $arParams['USER_ID'];
	}
	else
	{
		$userId = BitrixTasksUtilUser::getId();
		if(!$userId)
		{
			$userId = BitrixTasksUtilUser::getAdminId(); // compatibility
		}
	}

	$manager = new BitrixTasksControlTemplate($userId);

	if (isset($arParams['SKIP_AGENT_PROCESSING']))
	{
		$manager->withSkipAgent();
	}
	if (
		isset($arParams['CHECK_RIGHTS_ON_FILES'])
		&& (
			($arParams['CHECK_RIGHTS_ON_FILES'] === true)
			|| ($arParams['CHECK_RIGHTS_ON_FILES'] === 'Y')
		)
	)
	{
		$manager->withCheckFileRights();
	}

	try
	{
		$template = $manager->update($id, $arFields);
	}
	catch(BitrixTasksControlExceptionTemplateUpdateException $e)
	{
		$this->_errors[] = [
			'text' => $e->getMessage(),
			'id' => 'ERROR_TASKS_BAD_TEMPLATE_SYSTEM_ERROR'
		];

		return false;
	}
	catch (Exception $e)
	{
		$this->_errors[] = [
			'text' => $e->getMessage(),
			'id' => 'ERROR_TASKS_BAD_TEMPLATE_SYSTEM_ERROR'
		];

		return false;
	}

	return true;
}