should::add

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. should
  4. add
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/manager/task.php
  • Класс: Bitrix\Tasks\Manager\should
  • Вызов: should::add
static function add($userId, 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);
	}
	$parameters['ANALYTICS_DATA'] = static::getAnalyticsData($data);

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

		$task = static::doAdd($userId, $data, $parameters);

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

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

			if ($parameters[ 'RETURN_ENTITY' ])
			{
				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
	);
}

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