• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/controller/activity/todo.php
  • Класс: Bitrix\Crm\Controller\Activity\ToDo
  • Вызов: ToDo::updateAction
public function updateAction(
	int $ownerTypeId,
	int $ownerId,
	string $deadline,
	int $id = null,
	string $description = '',
	?int $responsibleId = null,
	?int $parentActivityId = null,
	array $fileTokens = [],
	array $settings = []
): ?array
{
	$todo = $this->loadEntity($ownerTypeId, $ownerId, $id);
	if (!$todo)
	{
		return null;
	}

	if ($todo->isCompleted())
	{
		$this->addError(new Error( Loc::getMessage('CRM_ACTIVITY_TODO_UPDATE_FILES_ERROR')));

		return null;
	}
	
	$prevResponsibleId = $todo->getResponsibleId();

	$todo = $this->getPreparedEntity($todo, $description, $deadline, $parentActivityId, $responsibleId);
	if (!$todo)
	{
		return null;
	}

	$currentStorageElementIds = $todo->getStorageElementIds() ?? [];
	if (!empty($fileTokens) || !empty($currentStorageElementIds))
	{
		$storageElementIds = $this->saveFilesToStorage(
			$ownerTypeId,
			$ownerId,
			$fileTokens,
			$id,
			$currentStorageElementIds
		);

		$todo->setStorageElementIds($storageElementIds);
	}

	$settingsManager = Manager::createFromEntity($todo);
	$todo = $settingsManager->getPreparedEntity($settings);
	$options = $settingsManager->getEntityOptions($settings);

	$result = $this->saveTodo($todo, $options);
	if ($result === null)
	{
		return null;
	}

	$this->tryNotifyWhenUpdate(
		$id,
		$ownerTypeId,
		$ownerId,
		$responsibleId,
		$prevResponsibleId
	);

	return $result;
}