• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/manager/task.php
  • Класс: BitrixTasksManagershould
  • Вызов: should::getBasicData
static function getBasicData($userId, $taskId, array $parameters)
{
	$data = array();
	$denied = false;

	try
	{
		$task = static::getTask($userId, $taskId);
		$taskParameters = array();

		if ($task !== null)
		{
			$data = $task->getData((bool)($parameters['ESCAPE_DATA'] ?? null));
			$data[ static::ACT_KEY ] = static::translateAllowedActionNames($task->getAllowedActions(true));

			if (!isset($data['FORUM_ID']) || !is_numeric($data['FORUM_ID']))
			{
				$data['FORUM_ID'] = CTasksTools::getForumIdForIntranet();
			}
			$data['COMMENTS_COUNT'] = (int)($data['COMMENTS_COUNT'] ?? 0);

			// get task parameters
			$res = ParameterTable::getList(array('filter' => array('=TASK_ID' => $taskId)));
			while ($item = $res->fetch())
			{
				$taskParameters[] = $item;
			}
		}

		if ($parameters['DROP_PRIMARY'] ?? null)
		{
			unset($data[ 'ID' ]);
			$data[ static::ACT_KEY ] = static::getFullRights($userId);
		}

		$data[ 'SE_PARAMETER' ] = $taskParameters;
	}
	catch (TasksException $e) // todo: get rid of this annoying catch by making BitrixTasks*Exception classes inherited from TasksException (dont forget about code)
	{
		if ($e->checkOfType(TasksException::TE_TASK_NOT_FOUND_OR_NOT_ACCESSIBLE))
		{
			$denied = true;
		}
		else
		{
			throw $e; // let it log
		}
	}
	catch (BitrixTasksAccessDeniedException $e) // task not found or not accessible
	{
		$denied = true;
	}

	if ($denied)
	{
		$parameters[ 'ERRORS' ]->add('ACCESS_DENIED.NO_TASK', 'Task not found or not accessible');
	}

	return $data;
}