- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/lib/ui/selector/entities.php
- Класс: BitrixMainUISelectorEntities
- Вызов: Entities::getData
static function getData($options = array(), $entityTypes = array(), $selectedItems = array())
{
$result = array(
'ENTITIES' => array(),
'SORT' => array()
);
$context = (!empty($options['context']) ? $options['context'] : false);
if (
empty($context)
|| empty($entityTypes)
)
{
return $result;
}
$filterParams = array(
"DEST_CONTEXT" => $context,
"ALLOW_EMAIL_INVITATION" => (
(isset($options["allowEmailInvitation"]) && $options["allowEmailInvitation"] == "Y")
|| (isset($options["allowSearchCrmEmailUsers"]) && $options["allowSearchCrmEmailUsers"] == "Y")
),
"CRM" => (isset($options["enableCrm"]) && $options["enableCrm"] == "Y")
);
if (!empty($options['contextCode']))
{
$filterParams["CODE_TYPE"] = $options['contextCode'];
}
$res = self::getLastSort($filterParams);
$destSortData = $res['DATA'];
$dataAdditional = $res['DATA_ADDITIONAL'];
$res = self::fillLastDestination(
$destSortData,
array(
"CRM" => (
isset($options["enableCrm"])
&& $options["enableCrm"] == 'Y'
? 'Y'
: 'N'
),
"EMAILS" => (
(
isset($options["allowAddUser"])
&& $options["allowAddUser"] == 'Y'
)
|| (
isset($options["allowSearchEmailUsers"])
&& $options["allowSearchEmailUsers"] == 'Y'
)
|| (
isset($options["allowEmailInvitation"])
&& $options["allowEmailInvitation"] == 'Y'
)
? 'Y'
: 'N'
),
"CRMEMAILS" => (
isset($options["allowSearchCrmEmailUsers"])
&& $options["allowSearchCrmEmailUsers"] == 'Y'
? 'Y'
: 'N'
),
"DATA_ADDITIONAL" => $dataAdditional,
"MULTI" => (
(
isset($options["returnMultiEmail"])
&& $options["returnMultiEmail"] == 'Y'
)
|| (
isset($options["returnMultiPhone"])
&& $options["returnMultiPhone"] == 'Y'
)
? 'Y'
: 'N'
)
)
);
$destSortData['UA'] = array(
'Y' => 9999999999,
'N' => 9999999999
);
$destSortData['EMPTY'] = array(
'Y' => 9999999998,
'N' => 9999999998
);
$lastItems = $res['LAST_DESTINATIONS'];
$result['SORT'] = $destSortData;
$result['TABS'] = array();
if (
!isset($options["disableLast"])
|| $options["disableLast"] != 'Y'
)
{
$result['TABS']['last'] = array(
'id' => 'last',
'name' => Loc::getMessage('MAIN_UI_SELECTOR_TAB_LAST'),
'sort' => 10
);
}
$selectedItemsByEntityType = array();
if (!empty($selectedItems))
{
foreach($selectedItems as $key => $entityType)
{
$entityType = mb_strtoupper($entityType);
if (!isset($selectedItemsByEntityType[$entityType]))
{
$selectedItemsByEntityType[$entityType] = array();
}
$selectedItemsByEntityType[$entityType][] = $key;
}
}
foreach($entityTypes as $entityType => $description)
{
$provider = self::getProviderByEntityType($entityType);
if ($provider !== false)
{
$result['ENTITIES'][$entityType] = $provider->getData(array(
'options' => (!empty($description['options']) ? $description['options'] : array()),
'lastItems' => $lastItems,
'selectedItems' => $selectedItemsByEntityType
));
$tabList = $provider->getTabList(array(
'options' => (!empty($description['options']) ? $description['options'] : array())
));
if (!empty($tabList))
{
foreach($tabList as $tab)
{
$result['TABS'][$tab['id']] = $tab;
}
}
}
}
return $result;
}