• Модуль: intranet
  • Путь к файлу: ~/bitrix/modules/intranet/lib/Site/Sections/AutomationSection.php
  • Класс: BitrixIntranetSiteSectionsAutomationSection
  • Вызов: AutomationSection::getScripts
static function getScripts(): array
{
	if (!Loader::includeModule('crm'))
	{
		return [];
	}

	$router = CrmServiceContainer::getInstance()->getRouter();
	$items = [];
	$elements = [
		CCrmOwnerType::Deal,
		CCrmOwnerType::SmartInvoice,
	];

	if (CrmSettingsLeadSettings::isEnabled())
	{
		$elements[] = CCrmOwnerType::Lead;
	}

	$typesMap = CrmServiceContainer::getInstance()->getDynamicTypesMap();
	$typesMap->load([
		'isLoadStages' => false,
		'isLoadCategories' => false,
	]);

	$currentUser = CurrentUser::get();
	$userPermissions = Container::getInstance()->getUserPermissions($currentUser->getId());
	foreach ($typesMap->getTypes() as $type)
	{
		if (
			$userPermissions->canReadType($type->getEntityTypeId())
			&& $type->getIsAutomationEnabled()
			&& CrmIntegrationIntranetManager::isEntityTypeInCustomSection($type->getEntityTypeId())
		)
		{
			$elements[] = $type->getEntityTypeId();
		}
	}

	$elements[] = CCrmOwnerType::Order;
	$elements[] = CCrmOwnerType::Contact;
	$elements[] = CCrmOwnerType::Company;

	foreach ($elements as $elementTypeId)
	{
		if (CrmAutomationFactory::isScriptAvailable($elementTypeId))
		{
			$items[] = [
				'TEXT' => CCrmOwnerType::GetCategoryCaption($elementTypeId),
				'URL' => $router->getItemListUrlInCurrentView($elementTypeId) . '#scripts',
			];
		}
	}

	return [
		'id' => 'bizproc_script',
		'title' => Loc::getMessage('AUTOMATION_SECTION_SCRIPT_TITLE'),
		'available' => true,
		// 'url' => SITE_DIR,
		'iconClass' => 'ui-icon intranet-automation-rpa-icon',
		'menuData' => [
			'menu_item_id' => 'menu_bizproc_script',
			'top_menu_id' => 'top_menu_id_bizproc_script',
			'sub_menu' => $items,
		],
	];
}