• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/item.php
  • Класс: BitrixTasksItem
  • Вызов: Item::fetchBaseData
protected function fetchBaseData($fetchBase = true, $fetchUFs = false)
{
	if(!$fetchBase && !$fetchUFs)
	{
		return array();
	}

	$ac = $this->getAccessController();
	$dc = static::getDataSourceClass();

	if($this->canFetchData()) // formally ask access controller if we can read the item first. May be it would tell us with no query making
	{
		$filter = array('=ID' => $this->id); // todo: '=ID' may not be a correct condition for searching by primary

		$map = $this->getMap();

		$types = array();
		if($fetchBase)
		{
			$types[] = FieldScalar::SOURCE_TABLET;
		}
		if($fetchBase)
		{
			$types[] = FieldScalar::SOURCE_UF;
		}

		$allFields = array_diff($map->getFieldDBNamesBySourceType($types), array('ID'));
		$cachedFields = array_diff($map->getFieldDBNamesByNames($this->getCachedOffsetCodes()), array('ID'));

		// minus fields that where loaded already
		$select = array_unique(array_diff($allFields, $cachedFields));
		if(!count($select))
		{
			return array();
		}

		$queryParameters = array(
			'filter' => $filter,
			'select' => $select,
		);

		$transState = $this->getTransitionState();

		$result = $dc::getList($queryParameters)->fetch();
		if(!is_array($result))
		{
			$result = null; // access denied or not found
		}
	}
	else // else access denied, definitely
	{
		$result = null;
	}

	return $result;
}