- Модуль: lists
- Путь к файлу: ~/bitrix/modules/lists/classes/general/lists.php
- Класс: CLists
- Вызов: CLists::getIblockAttachedCrm
static function getIblockAttachedCrm($entityType)
{
if (
(!self::isFeatureEnabled("lists")) &&
(!self::isFeatureEnabled("lists_processes"))
)
{
return [];
}
$cacheTime = defined('BX_COMP_MANAGED_CACHE') ? 3153600 : 3600*4;
$cacheId = 'lists-crm-attached-'.mb_strtolower($entityType);
$cacheDir = '/lists/crm/attached/'.mb_strtolower($entityType).'/';
$cache = new CPHPCache;
if($cache->initCache($cacheTime, $cacheId, $cacheDir))
{
$listIblock = $cache->getVars();
}
else
{
$cache->startDataCache();
$listIblock = array();
$listProperty = array();
$propertyObject = BitrixIblockPropertyTable::getList(array(
'select' => array('ID', 'IBLOCK_ID', 'USER_TYPE_SETTINGS'),
'filter' => array(
'=ACTIVE' => 'Y',
'=USER_TYPE' => 'ECrm',
)
));
while($property = $propertyObject->fetch())
{
$property['USER_TYPE_SETTINGS'] = unserialize(
$property['USER_TYPE_SETTINGS'],
['allowed_classes' => false]
);
if(empty($property['USER_TYPE_SETTINGS']['VISIBLE']))
$property['USER_TYPE_SETTINGS']['VISIBLE'] = 'Y';
if($property['USER_TYPE_SETTINGS']['VISIBLE'] == 'Y'
&& !empty($property['USER_TYPE_SETTINGS'][$entityType]))
{
if($property['USER_TYPE_SETTINGS'][$entityType] == 'Y')
{
$listProperty[$property['IBLOCK_ID']][] = $property['ID'];
}
}
}
$isListsFeatureEnabled = self::isFeatureEnabled("lists");
$isProcessesFeatureEnabled = self::isFeatureEnabled("lists_processes");
foreach ($listProperty as $iblockId => $listPropertyId)
{
$iblockObject = BitrixIblockIblockTable::getList(array(
'select' => array('ID', 'NAME', 'IBLOCK_TYPE_ID'),
'filter' => array('=ACTIVE' => 'Y', '=ID' => $iblockId)
));
if ($iblock = $iblockObject->fetch())
{
switch ($iblock['IBLOCK_TYPE_ID'])
{
case "CRM_PRODUCT_CATALOG":
{
continue 2;
}
case "bitrix_processes":
{
if (!$isProcessesFeatureEnabled)
{
continue 2;
}
break;
}
default:
if (!$isListsFeatureEnabled)
{
continue 2;
}
}
$listIblock[$iblockId] = $iblock['NAME'];
}
}
$cache->endDataCache($listIblock);
}
return $listIblock;
}