• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/dispatcher/publicaction/task/template.php
  • Класс: BitrixTasksDispatcherPublicActionTaskTemplate
  • Вызов: Template::toggleReplication
private function toggleReplication($id, $way)
{
	$result = array();

	if(!($id = $this->checkId($id)))
	{
		return $result;
	}
	$result['ID'] = $id;

	// access check inside
	$template = new ItemTaskTemplate($id);
	$template['REPLICATE'] = $way ? 'Y' : 'N';

	if($way)
	{
		$template['TPARAM_REPLICATION_COUNT'] = 0;
	}

	$taskId = intval($template['TASK_ID']);

	$saveResult = $template->save();
	$this->errors->load($saveResult->getErrors());

	if($saveResult->isSuccess())
	{
		// update related task
		if($taskId)
		{
			$task = new ItemTask($taskId);
			if($task->canUpdate())
			{
				$task['REPLICATE'] = $way ? 'Y' : 'N';
				$saveResult = $task->save(); // todo: DO NOT remove template in case of REPLICATE falls to N
				$this->errors->load($saveResult->getErrors()->transform(array(
																			'CODE' => 'TASK.#CODE#',
																			'TYPE' => UtilError::TYPE_WARNING
																		)));
			}
		}
	}

	return $result;
}