• Модуль: crmmobile
  • Путь к файлу: ~/bitrix/modules/crmmobile/lib/Controller/Action/GetTabsAction.php
  • Класс: BitrixCrmMobileControllerActionGetTabsAction
  • Вызов: GetTabsAction::getTabs
private function getTabs(UserPermissions $userPermissions, ?int $customSectionId): array
{
	$result = [];
	$searchRestriction = RestrictionManager::getSearchLimitRestriction();
	$infoHelperId = $searchRestriction->getMobileInfoHelperId();

	foreach (FactoryProvider::getAvailableFactories() as $factory)
	{
		$entityTypeId = $factory->getEntityTypeId();
		$isPossibleDynamicTypeId = CCrmOwnerType::isPossibleDynamicTypeId($entityTypeId);
		if (
			$customSectionId === null
			&& $isPossibleDynamicTypeId
			&& IntranetManager::isEntityTypeInCustomSection($entityTypeId)
		)
		{
			continue;
		}

		if ($customSectionId !== null && !$isPossibleDynamicTypeId)
		{
			continue;
		}
		if ($customSectionId !== null && $isPossibleDynamicTypeId)
		{
			$customSection = IntranetManager::getCustomSectionByEntityTypeId($entityTypeId);
			if (!$customSection || $customSection->getId() !== $customSectionId)
			{
				continue;
			}
		}

		$entityTypeName = $factory->getEntityName();

		$hasRestrictions = BitrixCrmMobileEntityRestrictionManager::isEntityRestricted($entityTypeId);
		$counter = EntityCounterFactory::create($factory->getEntityTypeId(), EntityCounterType::ALL)->getValue();

		$isCategoriesSupported = ($factory->isCategoriesSupported() && $entityTypeId !== CCrmOwnerType::Contact);
		$categoryId = $isCategoriesSupported ? $this->getCurrentCategoryId($factory, $userPermissions) : 0;
		$permissions = $this->getPermissions($userPermissions, $entityTypeId, $categoryId);

		$isCategoriesEnabled = $factory->isCategoriesEnabled();
		$categories = $isCategoriesEnabled ? $factory->getCategories() : [];

		$filterOptions = $this->getFilterOptions($factory, $categoryId);

		$result[] = [
			'id' => $entityTypeId,
			'typeName' => $entityTypeName,
			'active' => false,
			'selectable' => !$hasRestrictions,
			'hasRestrictions' => $hasRestrictions,
			'link' => $this->getLinkToDesktop($entityTypeName, $categoryId),
			'title' => TruncateText($factory->getEntityDescription(),self::TITLE_MAX_LENGTH),
			'titleInPlural' => TruncateText($factory->getEntityDescriptionInPlural(), self::TITLE_MAX_LENGTH),
			'entityLink' => $this->getEntityLink($entityTypeName),
			'pageUrl' => null,
			'label' => $counter > 0 ? (string)$counter : '',
			'isClientEnabled' => $factory->isClientEnabled() || $factory->isMyCompanyEnabled(),
			'isStagesEnabled' => $factory->isStagesEnabled(),
			'isCategoriesSupported' => $isCategoriesSupported,
			'isCategoriesEnabled' => $isCategoriesEnabled,
			'isChatSupported' => ImChat::isEntitySupported($entityTypeId),
			'isLastActivityEnabled' => $factory->isLastActivityEnabled(),
			'isLinkWithProductsEnabled' => $factory->isLinkWithProductsEnabled(),
			'needSaveCurrentCategoryId' => (
				$entityTypeName === CCrmOwnerType::DealName
				|| (CCrmOwnerType::isPossibleDynamicTypeId($entityTypeId) && $isCategoriesEnabled)
			),
			'data' => [
				'currentCategoryId' => $categoryId,
				'categoriesCount' => $isCategoriesEnabled ? count($categories) : 1,
				'counters' => $this->getCounters($factory, $categoryId),
				'presetId' => $this->getCurrentFilterPresetId($filterOptions),
				'defaultFilterId' => $this->getDefaultFilterId($filterOptions),
				'sortType' => $this->getSortType($entityTypeName, $categoryId),
				'smartActivitySettings' => $this->getSmartActivitySettings($factory, $permissions),
			],
			'permissions' => $permissions,
			'restrictions' => [
				'search' => [
					'isExceeded' => $searchRestriction->isExceeded($entityTypeId),
					'infoHelperId' => $infoHelperId,
				],
				'conversion' => RestrictionManager::isConversionPermitted(),
			],
		];
	}
	CustomSectionsTabSorter::sort($result, $customSectionId);
	$this->prepareActiveTab($result);

	return $result;
}