3namespace Bitrix\Socialnetwork\Controller;
5use Bitrix\Main\Config\Option;
6use Bitrix\Main\Engine\Response\Component;
9use Bitrix\Socialnetwork\ComponentHelper;
10use Bitrix\Socialnetwork\Helper\ServiceComment;
11use Bitrix\Main\Engine\ActionFilter;
12use Bitrix\Socialnetwork\CommentAux;
13use Bitrix\Socialnetwork\Livefeed\Context\Context;
19 $configureActions = parent::configureActions();
20 $configureActions[
'getNextPage'] = [
22 ActionFilter\Authentication::class,
25 $configureActions[
'refresh'] = [
27 ActionFilter\Authentication::class,
30 $configureActions[
'mobileLogError'] = [
32 ActionFilter\Authentication::class,
36 return $configureActions;
44 $this->
addError(
new Error(
'No Log Id',
'SONET_CONTROLLER_LIVEFEED_NO_LOG_ID'));
48 if (!Loader::includeModule(
'socialnetwork'))
50 $this->
addError(
new Error(
'Cannot include Socialnetwork module',
'SONET_CONTROLLER_LIVEFEED_NO_SOCIALNETWORK_MODULE'));
54 if (!\CSocNetUser::isCurrentUserModuleAdmin(
SITE_ID,
false))
56 $this->
addError(
new Error(
'No permissions',
'SONET_CONTROLLER_LIVEFEED_NO_PERMISSIONS'));
61 'success' => \CSocNetLog::delete($logId)
67 $entityType = (isset(
$params[
'entityType']) &&
$params[
'entityType'] <>
'' ? preg_replace(
"/[^a-z0-9_]/i",
'',
$params[
'entityType']) :
false);
70 $additionalParams = (isset(
$params[
'additionalParams']) && is_array(
$params[
'additionalParams']) ?
$params[
'additionalParams'] : []);
72 if (!Loader::includeModule(
'socialnetwork'))
74 $this->
addError(
new Error(
'Cannot include Socialnetwork module',
'SONET_CONTROLLER_LIVEFEED_NO_SOCIALNETWORK_MODULE'));
79 'ENTITY_TYPE' => $entityType,
82 'CLONE_DISK_OBJECTS' =>
true
87 $this->
addError(
new Error(
'Cannot find Livefeed entity',
'SONET_CONTROLLER_LIVEFEED_NO_ENTITY'));
91 $returnFields = [
'TITLE',
'DESCRIPTION',
'DISK_OBJECTS',
'GROUPS_AVAILABLE',
'LIVEFEED_URL',
'SUFFIX',
'LOG_ID' ];
93 isset($additionalParams[
'returnFields'])
94 && is_array($additionalParams[
'returnFields'])
97 $returnFields = array_intersect($returnFields, $additionalParams[
'returnFields']);
102 'DESCRIPTION' =>
$provider->getSourceDescription(),
103 'DISK_OBJECTS' =>
$provider->getSourceDiskObjects()
107 isset($additionalParams[
'getSonetGroupAvailable'])
108 && $additionalParams[
'getSonetGroupAvailable'] ===
'Y'
111 $feature = $operation =
false;
112 if (isset($additionalParams[
'checkPermissions'][
'operation'], $additionalParams[
'checkPermissions'][
'feature']))
114 $feature = $additionalParams[
'checkPermissions'][
'feature'];
115 $operation = $additionalParams[
'checkPermissions'][
'operation'];
118 $result[
'GROUPS_AVAILABLE'] =
$provider->getSonetGroupsAvailable($feature, $operation);
122 isset($additionalParams[
'getLivefeedUrl'])
123 && $additionalParams[
'getLivefeedUrl'] ===
'Y'
128 isset($additionalParams[
'absoluteUrl'])
129 && $additionalParams[
'absoluteUrl'] ===
'Y'
132 $serverName = Option::get(
'main',
'server_name',
$_SERVER[
'SERVER_NAME']);
135 ($siteFields =
$res->fetch())
136 && $siteFields[
'SERVER_NAME'] <>
''
139 $serverName = $siteFields[
'SERVER_NAME'];
142 $protocol = (\Bitrix\Main\Context::getCurrent()->getRequest()->isHttps() ?
'https' :
'http');
154 return array_filter(
$result,
static function (
$key) use ($returnFields) {
155 return in_array(
$key, $returnFields,
true);
156 }, ARRAY_FILTER_USE_KEY);
161 $postEntityType = (isset(
$params[
'postEntityType']) &&
$params[
'postEntityType'] <>
'' ? preg_replace(
'/[^a-z0-9_]/i',
'',
$params[
'postEntityType']) :
false);
162 $sourceEntityType = (isset(
$params[
'sourceEntityType']) &&
$params[
'sourceEntityType'] <>
'' ? preg_replace(
'/[^a-z0-9_]/i',
'',
$params[
'sourceEntityType']) :
false);
163 $sourceEntityId = (int)(
$params[
'sourceEntityId'] ?? 0);
164 $sourceEntityData = (
array)(
$params[
'sourceEntityData'] ?? []);
165 $entityType = (isset(
$params[
'entityType']) &&
$params[
'entityType'] <>
'' ? preg_replace(
'/[^a-z0-9_]/i',
'',
$params[
'entityType']) :
false);
167 $logId = (int)(
$params[
'logId'] ?? 0);
171 || $sourceEntityId <= 0
182 'ENTITY_TYPE' => $entityType,
184 'SOURCE_ENTITY_TYPE' => $sourceEntityType,
185 'SOURCE_ENTITY_ID' => $sourceEntityId,
186 'SOURCE_ENTITY_DATA' => $sourceEntityData,
194 'ENTITY_TYPE' => $entityType,
196 'POST_ENTITY_TYPE' => $postEntityType,
197 'SOURCE_ENTITY_TYPE' => $sourceEntityType,
198 'SOURCE_ENTITY_ID' => $sourceEntityId,
199 'SOURCE_ENTITY_DATA' => $sourceEntityData,
211 $postEntityType = (isset(
$params[
'postEntityType']) &&
$params[
'postEntityType'] <>
'' ? preg_replace(
'/[^a-z0-9_]/i',
'',
$params[
'postEntityType']) :
false);
212 $sourceEntityType = (isset(
$params[
'entityType']) &&
$params[
'entityType'] <>
'' ? preg_replace(
"/[^a-z0-9_]/i",
'',
$params[
'entityType']) :
false);
213 $sourceEntityId = (isset(
$params[
'entityId']) && (int)
$params[
'entityId'] > 0 ? (
int)
$params[
'entityId'] :
false);
227 'postEntityType' => $postEntityType,
228 'sourceEntityType' => $sourceEntityType,
229 'sourceEntityId' => $sourceEntityId,
231 'entityId' => $taskId,
245 $logId = (int)$logId;
248 $this->
addError(
new Error(
'No Log Id',
'SONET_CONTROLLER_LIVEFEED_NO_LOG_ID'));
253 Loader::includeModule(
'socialnetwork')
254 && ($logFields = \CSocNetLog::getById($logId))
257 $this->
addError(
new Error(
'Cannot get log entry',
'SONET_CONTROLLER_LIVEFEED_EMPTY_LOG_ENTRY'));
261 $currentUserId = $this->getCurrentUser()->getId();
263 if (
$res = \CSocNetLogFavorites::change($currentUserId, $logId))
269 'userId' => $currentUserId,
272 'COUNTER_COMMENT_PUSH',
274 'followDate' => $logFields[
'LOG_UPDATE'],
282 $this->
addError(
new Error((($e =
$APPLICATION->getException()) ? $e->getString() :
'Cannot change log entry favorite value'),
'SONET_CONTROLLER_LIVEFEED_FAVORITES_CHANGE_ERROR'));
295 $logId = (int)$logId;
301 $logId = (int)$logId;
304 $this->
addError(
new Error(
'No Log Id',
'SONET_CONTROLLER_LIVEFEED_NO_LOG_ID'));
308 if (!Loader::includeModule(
'socialnetwork'))
310 $this->
addError(
new Error(
'Cannot include Socialnetwork module',
'SONET_CONTROLLER_LIVEFEED_NO_SOCIALNETWORK_MODULE'));
314 $currentUserId = $this->getCurrentUser()->getId();
319 'userId' => $currentUserId,
320 'typeList' => [
'FOLLOW',
'COUNTER_COMMENT_PUSH' ]
322 : \CSocNetLogFollow::set($currentUserId,
'L' . $logId,
'N')
330 if (!Loader::includeModule(
'socialnetwork'))
332 $this->
addError(
new Error(
'Cannot include Socialnetwork module',
'SONET_CONTROLLER_LIVEFEED_NO_SOCIALNETWORK_MODULE'));
337 'success' => \CSocNetLogFollow::set($this->getCurrentUser()->getId(),
'**', ($value ===
'Y' ?
'Y' :
'N'))
347 if (!Loader::includeModule(
'socialnetwork'))
349 $this->
addError(
new Error(
'Cannot include Socialnetwork module',
'SONET_CONTROLLER_LIVEFEED_NO_SOCIALNETWORK_MODULE'));
353 $viewValue = ($expertModeValue ===
'Y' ?
'N' :
'Y');
369 if (\CUserOptions::setOption(
'socialnetwork',
'~log_notasks_notification_read',
'Y'))
379 if (!\
Bitrix\
Main\ModuleManager::isModuleInstalled(
'bitrix24'))
381 AddMessage2Log(
"Mobile Livefeed javascript error:\nMessage: ".
$message.
"\nURL: ".
$url.
"\nLine number: ".$lineNumber.
"\nUser ID: ".$this->getCurrentUser()->getId());
391 $logId = (int)$logId;
394 $this->
addError(
new Error(
'No Log Id',
'SONET_CONTROLLER_LIVEFEED_NO_LOG_ID'));
398 return new Component(
'bitrix:mobile.socialnetwork.log.ex',
'', [
400 'SITE_TEMPLATE_ID' =>
'mobile_app',
401 'TARGET' =>
'postContent',
402 'PATH_TO_USER' =>
SITE_DIR.
'mobile/users/?user_id=#user_id#'
413 Loader::includeModule(
'bitrix24')
414 && \CBitrix24::isPortalAdmin(
$USER->getId())
419 private function getComponentReturnWhiteList():
array
421 return [
'LAST_TS',
'LAST_ID',
'EMPTY',
'FILTER_USED',
'FORCE_PAGE_REFRESH' ];
426 $componentParameters = $this->getUnsignedParameters();
427 if (!is_array($componentParameters))
429 $componentParameters = [];
432 $requestParameters = [
434 'PAGE_NUMBER' => (isset(
$params[
'PAGE_NUMBER']) && (int)
$params[
'PAGE_NUMBER'] >= 1 ? (
int)
$params[
'PAGE_NUMBER'] : 1),
435 'LAST_LOG_TIMESTAMP' => (isset(
$params[
'LAST_LOG_TIMESTAMP']) && (
int)
$params[
'LAST_LOG_TIMESTAMP'] > 0 ? (
int)
$params[
'LAST_LOG_TIMESTAMP'] : 0),
436 'PREV_PAGE_LOG_ID' => (
$params[
'PREV_PAGE_LOG_ID'] ??
''),
438 'useBXMainFilter' => (
$params[
'useBXMainFilter'] ??
'N'),
439 'siteTemplateId' => (
$params[
'siteTemplateId'] ??
'bitrix24'),
440 'preset_filter_top_id' => (
$params[
'preset_filter_top_id'] ??
''),
441 'preset_filter_id' => (
$params[
'preset_filter_id'] ??
''),
446 $requestParameters[
'SPACE_USER_ID'] = (int)(
$params[
'userId'] ?? $this->userId);
447 $requestParameters[
'GROUP_ID'] = (int)($componentParameters[
'GROUP_ID'] ??
$params[
'spaceId']);
451 return new Component(
'bitrix:socialnetwork.log.ex',
'', array_merge($componentParameters, $requestParameters), [], $this->getComponentReturnWhiteList());
456 $componentParameters = $this->getUnsignedParameters();
457 if (!is_array($componentParameters))
459 $componentParameters = [];
463 $requestParameters = [
468 'composition' =>
$params[
'composition'] ?? [],
469 'useBXMainFilter' => (
$params[
'useBXMainFilter'] ??
'N'),
470 'siteTemplateId' => (
$params[
'siteTemplateId'] ??
'bitrix24'),
471 'assetsCheckSum' => (
$params[
'assetsCheckSum'] ??
'')
476 $requestParameters[
'SPACE_USER_ID'] = (int)(
$params[
'userId'] ?? $this->userId);
477 $requestParameters[
'GROUP_ID'] = (int)($componentParameters[
'GROUP_ID'] ??
$params[
'spaceId']);
480 return new Component(
'bitrix:socialnetwork.log.ex',
'', array_merge($componentParameters, $requestParameters), [], $this->getComponentReturnWhiteList());
486 if (empty(
$params[1]) || empty(
$params[2]) || !Loader::includeModule(
'socialnetwork'))
491 $liveFeedEntity = \Bitrix\SocialNetwork\Livefeed\Provider::init([
496 $suffix = $liveFeedEntity->getSuffix();
497 if ($suffix ===
'TASK')
501 'ID' => $liveFeedEntity->getLogId()
503 'select' => [
'ENTITY_ID',
'EVENT_ID',
'SOURCE_ID' ]
505 if ($logEntryFields =
$res->fetch())
507 if ($logEntryFields[
'EVENT_ID'] ===
'crm_activity_add')
510 Loader::includeModule(
'crm')
511 && ($activityFields = \CCrmActivity::getById($logEntryFields[
'ENTITY_ID'],
false))
512 && $activityFields[
'TYPE_ID'] == \CCrmActivityType::Task
515 $taskId = (int)$activityFields[
'ASSOCIATED_ENTITY_ID'];
520 $taskId = (int)$logEntryFields[
'SOURCE_ID'];
523 if (isset($taskId) && $taskId > 0 && Loader::includeModule(
'mobile'))
525 return \CMobileHelper::getParamsToCreateTaskLink($taskId);
530 return SITE_DIR .
"mobile/log/?ACTION=CONVERT&ENTITY_TYPE_ID=FORUM_POST&ENTITY_ID=" .
$params[2];
if(!Loader::includeModule('messageservice')) $provider
static getList(array $parameters=array())
static userLogSubscribe($params=array())
getNextPageAction(array $params=[])
mobileGetDetailAction($logId)
readNoTasksNotificationAction()
mobileCreateNotificationLinkAction($tag)
changeFavoritesAction($logId, $value)
createTaskCommentAction(array $params=[])
mobileLogErrorAction($message, $url, $lineNumber)
deleteEntryAction($logId=0)
changeFollowAction($logId, $value)
changeExpertModeAction($expertModeValue)
getRawEntryDataAction(array $params=[])
createEntityCommentAction(array $params=[])
refreshAction(array $params=[])
changeFollowDefaultAction($value)
static init(array $params)
static set($userId, $eventId, $type)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
$_SERVER["DOCUMENT_ROOT"]
const SITE_DIR(!defined('LANG'))
AddMessage2Log($text, $module='', $traceDepth=6, $showArgs=false)
if(empty($signedUserToken)) $key
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']