- Модуль: crmmobile
- Путь к файлу: ~/bitrix/modules/crmmobile/lib/Controller/Action/GetTabsAction.php
- Класс: BitrixCrmMobileControllerActionGetTabsAction
- Вызов: GetTabsAction::getCurrentCategoryId
private function getCurrentCategoryId(Factory $factory, UserPermissions $userPermissions): int
{
$defaultCategory = $factory->getDefaultCategory();
$defaultCategoryId = ($defaultCategory ? $defaultCategory->getId() : 0);
if (!$factory->isCategoriesEnabled())
{
return $defaultCategoryId;
}
if ($factory->getEntityName() === CCrmOwnerType::DealName)
{
$currentCategoryId = (int)CUserOptions::GetOption(
'crm',
'current_deal_category',
$defaultCategoryId
);
}
else if (CCrmOwnerType::isPossibleDynamicTypeId($factory->getEntityTypeId()))
{
$currentCategoryId = (int)CUserOptions::GetOption(
'crm',
'current_' . mb_strtolower($factory->getEntityName()) . '_category',
$defaultCategoryId
);
}
else
{
$currentCategoryId = $defaultCategoryId;
}
if (
$currentCategoryId !== null
&& !$userPermissions->canReadTypeInCategory($factory->getEntityTypeId(), $currentCategoryId)
)
{
$currentCategoryId = $this->getFirstAvailableCategory($factory, $userPermissions);
}
return ($currentCategoryId ?? $factory->getCategories()[0]->getId());
}