37 $logId = (int)($params[
'logId'] ?? 0);
38 $createdById = (int)($params[
'createdById'] ?? 0);
39 $destinationLimit = (int)($params[
'destinationLimit'] ?? 100);
41 $pathToUser = ($params[
'pathToUser'] ??
'');
42 $pathToWorkgroup = ($params[
'pathToWorkgroup'] ??
'');
43 $pathToDepartment = ($params[
'pathToDepartment'] ??
'');
44 $nameTemplate = ($params[
'nameTemplate'] ?? \CSite::getNameFormat());
45 $showLogin = ($params[
'showLogin'] ?? (ModuleManager::isModuleInstalled(
'intranet') ?
'Y' :
'N'));
49 $this->
addError(
new Error(
'Empty Log ID.',
'SONET_CONTROLLER_LIVEFEED_LOGENTRY_EMPTY_LOG_ID'));
53 if (!Loader::includeModule(
'socialnetwork'))
55 $this->
addError(
new Error(
'Cannot include Socialnetwork module.',
'SONET_CONTROLLER_LIVEFEED_LOGENTRY_MODULE_NOT_INSTALLED'));
59 \CSocNetTools::initGlobalExtranetArrays();
61 $extranetInstalled = Loader::includeModule(
"extranet");
62 $currentExtranetUser = ($extranetInstalled && !\CExtranet::isIntranetUser());
63 $extranetAdmin = ($extranetInstalled && \CExtranet::isExtranetAdmin());
64 $visibleUserIdList = $availableExtranetUserIdList =
false;
66 if ($currentExtranetUser)
68 $visibleUserIdList = \CExtranet::getMyGroupsUsersSimple(SITE_ID);
75 $availableExtranetUserIdList = \CExtranet::getMyGroupsUsersSimple(\CExtranet::getExtranetSiteID());
79 $skipGetRights =
false;
81 $res = GetModuleEvents(
'socialnetwork',
'OnBeforeSocNetLogEntryGetRights');
82 while ($event = $res->fetch())
84 if (ExecuteModuleEventEx(
87 [
'LOG_ID' => $logId ],
93 $skipGetRights =
true;
100 $res = \CSocNetLogRights::getList([], [
'LOG_ID' => $logId ]);
101 while ($rightFields = $res->fetch())
103 $rightsList[] = $rightFields[
'GROUP_CODE'];
107 $destinationParams = [
108 'PATH_TO_USER' => $pathToUser,
109 'PATH_TO_GROUP' => $pathToWorkgroup,
110 'PATH_TO_CONPANY_DEPARTMENT' => $pathToDepartment,
111 'NAME_TEMPLATE' => $nameTemplate,
112 'SHOW_LOGIN' => $showLogin,
113 'DESTINATION_LIMIT' => 100,
114 'CHECK_PERMISSIONS_DEST' =>
'N'
117 if ($createdById > 0)
119 $destinationParams[
"CREATED_BY"] = $createdById;
123 $destinationList = \CSocNetLogTools::formatDestinationFromRights($rightsList, $destinationParams, $moreCount);
124 $hiddenDestinationsCount = 0;
126 $availableWorkgroupsIdList = \CSocNetLogTools::getAvailableGroups();
128 foreach($destinationList as $key => $destinationFields)
131 isset($destinationFields[
'TYPE'], $destinationFields[
'ID'])
134 $destinationFields[
'TYPE'] ===
'SG'
135 && !in_array((
int)$destinationFields[
'ID'], $availableWorkgroupsIdList)
138 in_array($destinationFields[
'TYPE'], [
'CRMCOMPANY',
'CRMLEAD',
'CRMCONTACT',
'CRMDEAL'])
139 && Loader::includeModule(
'crm')
140 && !\
Bitrix\Crm\Security\EntityAuthorization::checkReadPermission(
141 \CCrmLiveFeedEntity::resolveEntityTypeID($destinationFields[
'TYPE']),
142 $destinationFields[
'ID']
146 in_array($destinationFields[
'TYPE'], [
'DR',
'D'])
147 && $currentExtranetUser
150 $destinationFields[
'TYPE'] ===
'U'
151 && is_array($visibleUserIdList)
152 && !in_array((
int)$destinationFields[
'ID'], $visibleUserIdList)
155 $destinationFields[
'TYPE'] ===
'U'
156 && isset($destinationFields[
'IS_EXTRANET'])
157 && $destinationFields[
'IS_EXTRANET'] ===
'Y'
158 && is_array($availableExtranetUserIdList)
159 && !in_array((
int)$destinationFields[
'ID'], $availableExtranetUserIdList)
164 unset($destinationList[$key]);
165 $hiddenDestinationsCount++;
170 'destinationList' => array_slice($destinationList, $destinationLimit),
171 'hiddenDestinationsCount' => $hiddenDestinationsCount
229 $logId = (isset($params[
'logId']) ? (int)$params[
'logId'] : 0);
233 $this->
addError(
new Error(
'Empty Log ID.',
'SONET_CONTROLLER_LIVEFEED_LOGENTRY_EMPTY_LOG_ID'));
241 'select' => [
'ID',
'ENTITY_ID',
'EVENT_ID',
'SOURCE_ID',
'RATING_TYPE_ID',
'RATING_ENTITY_ID' ]
243 if (!($logEntryFields = $res->fetch()))
245 $this->
addError(
new Error(
'Log entry not found.',
'SONET_CONTROLLER_LIVEFEED_LOGENTRY_NOT_FOUND'));
249 $contentId = \Bitrix\Socialnetwork\Livefeed\Provider::getContentId($logEntryFields);
252 $this->
addError(
new Error(
'Content entity not found.',
'SONET_CONTROLLER_LIVEFEED_CONTENT_NOT_FOUND'));
256 if (empty($contentId[
'ENTITY_TYPE']))
258 $this->
addError(
new Error(
'Content entity not found.',
'SONET_CONTROLLER_LIVEFEED_CONTENT_NOT_FOUND'));
262 $postProvider = \Bitrix\Socialnetwork\Livefeed\Provider::init([
263 'ENTITY_TYPE' => $contentId[
'ENTITY_TYPE'],
264 'ENTITY_ID' => $contentId[
'ENTITY_ID'],
265 'LOG_ID' => $logEntryFields[
'ID']
269 'TITLE' => htmlspecialcharsEx($postProvider->getPinnedTitle()),
270 'DESCRIPTION' => htmlspecialcharsEx($postProvider->getPinnedDescription())