- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/integration/socialnetwork.php
- Класс: Bitrix\Crm\Integration\Socialnetwork
- Вызов: Socialnetwork::onLogProviderGetContentId
static function onLogProviderGetContentId(Event $event)
{
$result = new EventResult(
EventResult::UNDEFINED,
[],
'crm'
);
$eventFields = $event->getParameter('eventFields');
$contentEntityType = false;
$contentEntityId = false;
if (!empty($eventFields['EVENT_ID']))
{
$providersList = [
new Socialnetwork\Livefeed\CrmInvoice(),
new Socialnetwork\Livefeed\CrmActivity(),
new Socialnetwork\Livefeed\CrmEntityComment(),
];
foreach ($providersList as $provider)
{
if (in_array($eventFields['EVENT_ID'], $provider->getEventId(), true))
{
if ($provider::className() === Socialnetwork\Livefeed\CrmActivity::className())
{
$res = \CCrmActivity::getList(
[],
[
'ID' => (int)$eventFields['ENTITY_ID'],
'CHECK_PERMISSIONS' => 'N',
],
false,
false,
['ASSOCIATED_ENTITY_ID', 'TYPE_ID', 'PROVIDER_ID']
);
if (
($activityFields = $res->fetch())
&& ((int)$activityFields['ASSOCIATED_ENTITY_ID'] > 0)
)
{
if (
(int)$activityFields['TYPE_ID'] === \CCrmActivityType::Task
|| (
(int)$activityFields['TYPE_ID'] === \CCrmActivityType::Provider
&& $activityFields['PROVIDER_ID'] === Task::getId()
)
)
{
$provider = new \Bitrix\Socialnetwork\Livefeed\TasksTask();
$contentEntityType = $provider->getContentTypeId();
$contentEntityId = (int)$activityFields['ASSOCIATED_ENTITY_ID'];
}
}
}
if (!$contentEntityType)
{
$contentEntityType = $provider->getContentTypeId();
$contentEntityId = (int)$eventFields['ENTITY_ID'];
}
break;
}
}
if (!$contentEntityType)
{
$providersList = [
new Socialnetwork\Livefeed\CrmLead(),
new Socialnetwork\Livefeed\CrmContact(),
new Socialnetwork\Livefeed\CrmCompany(),
new Socialnetwork\Livefeed\CrmDeal(),
];
foreach ($providersList as $provider)
{
if (in_array($eventFields['EVENT_ID'], $provider->getEventId(), true))
{
$contentEntityType = $provider->getContentTypeId();
$contentEntityId = (int)$eventFields['ID'];
break;
}
}
}
}
if (
$contentEntityType
&& $contentEntityId > 0
)
{
$result = new EventResult(
EventResult::SUCCESS,
[
'contentEntityType' => $contentEntityType,
'contentEntityId' => $contentEntityId,
],
'crm'
);
}
return $result;
}