- Модуль: socialnetwork
- Путь к файлу: ~/bitrix/modules/socialnetwork/lib/helper/servicecomment.php
- Класс: BitrixSocialnetworkHelperServiceComment
- Вызов: ServiceComment::getAuxLiveParams
static function getAuxLiveParams(array $params = []): array
{
$result = [];
$sourceEntityType = ($params['sourceEntityType'] ?? false);
$sourceEntityId = (int)($params['sourceEntityId'] ?? 0);
$sourceData = ($params['sourceData'] ?? []);
$entityType = ($params['entityType'] ?? false);
$entityId = (int)($params['entityId'] ?? 0);
$entityData = ($params['entityData'] ?? []);
$userPath = ($params['userPath'] ?? '');
$logId = (int)($params['logId'] ?? 0);
if (
!$sourceEntityType
|| $sourceEntityId <= 0
|| !$entityType
|| $entityId <= 0
|| empty($entityData)
|| !is_array($entityData)
)
{
return $result;
}
$entityProvider = LivefeedProvider::init([
'ENTITY_TYPE' => $sourceEntityType,
'ENTITY_ID' => $sourceEntityId,
'LOG_ID' => $logId
]);
$sourceEntityLink = (
$params['sourceEntityLink'] ?? self::getSourceEntityUrl([
'sourceEntityType' => $sourceEntityType,
'sourceEntityId' => $sourceEntityId,
'sourceData' => $sourceData,
'entityType' => $entityType,
'entityData' => $entityData,
'userPath' => $userPath,
])
);
$result = [
'sourceEntityType' => $sourceEntityType,
'sourceEntityId' => $sourceEntityId,
'entityType' => $entityType,
'entityId' => $entityId,
'entityUrl' => static::getEntityUrl([
'entityType' => $entityType,
'entityData' => $entityData,
]),
'entityName' => static::getEntityName([
'entityType' => $entityType,
'entityData' => $entityData,
]),
'sourceEntityLink' => $sourceEntityLink,
'suffix' => $entityProvider->getSuffix(),
];
if ($entityType === CommentAuxCreateEntity::ENTITY_TYPE_TASK)
{
$result['taskResponsibleId'] = static::getEntityAuthorId([
'entityType' => $entityType,
'entityData' => $entityData,
]);
}
elseif (
$entityType === CommentAuxCreateEntity::ENTITY_TYPE_BLOG_POST
&& Loader::includeModule('blog')
)
{
$result['socNetPermissions'] = CBlogPost::getSocNetPermsCode($entityId);
}
elseif ($entityType === CommentAuxCreateEntity::ENTITY_TYPE_CALENDAR_EVENT)
{
$attendees = [];
if (!empty($entityData['USER_IDS']) && is_array($entityData['USER_IDS']))
{
$attendees = $entityData['USER_IDS'];
}
elseif (!empty($entityData['attendeesEntityList']))
{
$attendees = array_map(static function($item) {
return (int)(isset($item['entityId'], $item['id']) && $item['entityId'] === 'user' ? $item['id'] : 0);
}, $entityData['attendeesEntityList']);
$attendees = array_filter($attendees, static function($item) {
return $item > 0;
});
}
if (
!empty($entityData['MEETING_HOST'])
&& (int)$entityData['MEETING_HOST'] > 0
)
{
$attendees[] = (int)($entityData['MEETING_HOST']);
}
elseif (
!empty($entityData['CREATED_BY'])
&& (int)$entityData['CREATED_BY'] > 0
)
{
$attendees[] = (int)($entityData['CREATED_BY']);
}
$result['attendees'] = array_unique($attendees);
}
return $result;
}