Task::update

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. Task
  4. update
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/manager/task.php
  • Класс: Bitrix\Tasks\Manager\Task
  • Вызов: Task::update
static function update($userId, $taskId, array $data, array $parameters = array('PUBLIC_MODE' => false, 'RETURN_ENTITY' => false))
{
	$errors = static::ensureHaveErrorCollection($parameters);

	$task = null;
	$can = array();

	if ($parameters[ 'PUBLIC_MODE' ])
	{
		$data = static::filterData($data, static::getFieldMap(), $errors);
	}

	if ($errors->checkNoFatals())
	{
		$cacheAFWasDisabled = \CTasks::disableCacheAutoClear();
		$notifADWasDisabled = \CTaskNotifications::disableAutoDeliver();

		$updateParams = [
			'TASK_ACTION_UPDATE_PARAMETERS' => [
				'THROTTLE_MESSAGES' => ($parameters['THROTTLE_MESSAGES'] ?? null),
			],
			'PUBLIC_MODE' => $parameters['PUBLIC_MODE'],
			'ERRORS' => $errors,
			'ANALYTICS_DATA' => static::getAnalyticsData($data),
		];

		$task = static::doUpdate($userId, $taskId, $data, $updateParams);

		if ($notifADWasDisabled)
		{
			\CTaskNotifications::enableAutoDeliver();
		}
		if ($cacheAFWasDisabled)
		{
			\CTasks::enableCacheAutoClear();
		}

		if ($errors->checkNoFatals())
		{
			$data = ['ID' => $task->getId()];

			if ($parameters['RETURN_ENTITY'] ?? null)
			{
				try
				{
					$data = $task->getData(false);
					$data[ static::ACT_KEY ] = $can = static::translateAllowedActionNames($task->getAllowedActions(true));
				}
				catch (\TasksException $e)
				{

				}
			}
		}
	}

	return array(
		'TASK' => $task,
		'ERRORS' => $errors,
		'DATA' => $data,
		'CAN' => $can
	);
}

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