- Модуль: socialnetwork
- Путь к файлу: ~/bitrix/modules/socialnetwork/lib/livefeed/provider.php
- Класс: BitrixSocialnetworkLivefeedProvider
- Вызов: Provider::setContentView
public function setContentView($params = [])
{
global $USER;
if (!is_array($params))
{
$params = [];
}
if (
!isset($params['user_id'])
&& is_object($USER)
&& CSocNetUser::isCurrentUserModuleAdmin()
) // don't track users on God Mode
{
return false;
}
$userId = (
isset($params['user_id'])
&& (int)$params['user_id'] > 0
? (int)$params['user_id']
: 0
);
if ($userId <= 0 && is_object($USER))
{
$userId = $USER->getId();
}
$contentTypeId = $this->getContentTypeId();
$contentEntityId = $this->getEntityId();
$logId = $this->getLogId();
$save = (!isset($params['save']) || (bool)$params['save']);
if (
(int)$userId <= 0
|| !$contentTypeId
|| !$contentEntityId
)
{
return false;
}
$viewParams = [
'userId' => $userId,
'typeId' => $contentTypeId,
'entityId' => $contentEntityId,
'logId' => $logId,
'save' => $save
];
$pool = Application::getInstance()->getConnectionPool();
$pool->useMasterOnly(true);
$result = UserContentViewTable::set($viewParams);
$pool->useMasterOnly(false);
if (
$result
&& isset($result['success'])
&& $result['success']
)
{
/*
TODO: markAsRead sonet module notifications
ContentViewHandler::onContentViewed($viewParams);
*/
if (UserContentView::getAvailability())
{
if (
isset($result['savedInDB'])
&& $result['savedInDB']
)
{
if (Loader::includeModule('pull'))
{
CPullWatch::addToStack('CONTENTVIEW' . $contentTypeId . '-' . $contentEntityId,
[
'module_id' => 'contentview',
'command' => 'add',
'expiry' => 0,
'params' => [
'USER_ID' => $userId,
'TYPE_ID' => $contentTypeId,
'ENTITY_ID' => $contentEntityId,
'CONTENT_ID' => $contentTypeId . '-' . $contentEntityId
]
]
);
}
}
if ($logId > 0)
{
Subscription::onContentViewed([
'userId' => $userId,
'logId' => $logId
]);
}
$event = new MainEvent(
'socialnetwork', 'onContentViewed',
$viewParams
);
$event->send();
}
}
return $result;
}