- Модуль: socialnetwork
- Путь к файлу: ~/bitrix/modules/socialnetwork/lib/livefeed/provider.php
- Класс: BitrixSocialnetworkLivefeedProvider
- Вызов: Provider::getLogId
public function getLogId($params = [])
{
$result = false;
if ($this->logId > 0)
{
$result = $this->logId;
}
else
{
$eventId = $this->getEventId();
if (
empty($eventId)
|| $this->entityId <= 0
)
{
return $result;
}
if ($this->getType() === Provider::TYPE_POST)
{
$filter = [
'EVENT_ID' => $eventId
];
if (static::getId() === LogEvent::PROVIDER_ID)
{
$filter['=ID'] = $this->entityId;
}
else
{
$filter['=SOURCE_ID'] = $this->entityId;
}
if (
is_array($params)
&& isset($params['inactive'])
&& $params['inactive']
)
{
$filter['=INACTIVE'] = 'Y';
}
$res = CSocNetLog::getList(
[],
$filter,
false,
[ 'nTopCount' => 1 ],
[ 'ID' ]
);
$logEntry = $res->fetch();
if (
!$logEntry
&& static::getId() === TasksTask::PROVIDER_ID
&& Loader::includeModule('crm')
)
{
$res = CCrmActivity::getList(
[],
[
'ASSOCIATED_ENTITY_ID' => $this->entityId,
'TYPE_ID' => CCrmActivityType::Task,
'CHECK_PERMISSIONS' => 'N'
],
false,
false,
[ 'ID' ]
);
if ($activityFields = $res->fetch())
{
$res = CSocNetLog::getList(
[],
[
'EVENT_ID' => $eventId,
'=ENTITY_TYPE' => 'CRMACTIVITY',
'=ENTITY_ID' => $activityFields['ID'],
],
false,
[ 'nTopCount' => 1 ],
[ 'ID' ]
);
$logEntry = $res->fetch();
}
}
if (
$logEntry
&& ((int)$logEntry['ID'] > 0)
)
{
$result = $this->logId = (int)$logEntry['ID'];
}
}
elseif ($this->getType() === Provider::TYPE_COMMENT)
{
$filter = [
'EVENT_ID' => $eventId
];
if (static::getId() === LogComment::PROVIDER_ID)
{
$filter['ID'] = $this->entityId;
}
else
{
$filter['SOURCE_ID'] = $this->entityId;
}
$res = CSocNetLogComments::getList(
[],
$filter,
false,
[ 'nTopCount' => 1 ],
[ 'ID', 'LOG_ID' ]
);
if (
($logCommentEntry = $res->fetch())
&& ((int)$logCommentEntry['LOG_ID'] > 0)
)
{
$result = $this->logId = (int)$logCommentEntry['LOG_ID'];
}
}
}
return $result;
}