27 $entityType = (
$params[
'ENTITY_TYPE'] ??
false);
29 $sourceEntityType = (isset(
$params[
'SOURCE_ENTITY_TYPE']) && in_array(
$params[
'SOURCE_ENTITY_TYPE'], [
'BLOG_POST',
'BLOG_COMMENT' ]) ?
$params[
'SOURCE_ENTITY_TYPE'] :
false);
30 $sourceEntityId = (int)(
$params[
'SOURCE_ENTITY_ID'] ?? 0);
34 empty($sourceEntityType)
35 || $sourceEntityId <= 0
38 || !Loader::includeModule(
'blog')
44 $entity = static::getEntityData([
45 'entityType' => $entityType,
54 $source = static::getSourceData([
55 'sourceEntityType' => $sourceEntityType,
56 'sourceEntityId' => $sourceEntityId,
64 $authorId = static::getEntityAuthorId([
65 'entityType' => $entityType,
68 $userIP = \CBlogUser::getUserIP();
72 'POST_ID' => $source[
'post'][
'ID'],
73 'BLOG_ID' => $source[
'post'][
'BLOG_ID'],
74 'POST_TEXT' => $auxText,
75 'DATE_CREATE' => convertTimeStamp(time() + \CTimeZone::getOffset(),
'FULL'),
76 'AUTHOR_IP' => $userIP[0],
77 'AUTHOR_IP1' => $userIP[1],
79 'AUTHOR_ID' => $authorId,
80 'SHARE_DEST' => Json::encode([
81 'sourceType' => $sourceEntityType,
82 'sourceId' => $sourceEntityId,
83 'entityType' => $entityType,
88 $entityLivefeedPovider = Provider::getProvider($sourceEntityType);
89 $entityLivefeedPovider->setEntityId($sourceEntityId);
90 $entityLivefeedPovider->initSourceFields();
92 $url = $entityLivefeedPovider->getLiveFeedUrl();
95 $metaData = UrlPreview::getMetadataAndHtmlByUrl(
$url,
true,
false);
99 && !empty($metaData[
'ID'])
100 && (
int)$metaData[
'ID'] > 0
104 $logCommentFields[
'UF_BLOG_COMM_URL_PRV'] = $signer->sign($metaData[
'ID'] .
'', UrlPreview::SIGN_SALT);
108 $newCommentId = \CBlogComment::add($logCommentFields,
false);
114 BXClearCache(
true,
'/blog/comment/' . (
int)($source[
'post'][
'ID'] / 100) .
'/' . $source[
'post'][
'ID'] .
'/');
118 $res = \CSocNetLog::getList(
121 'EVENT_ID' => $blogPostLivefeedProvider->getEventId(),
122 'SOURCE_ID' => $source[
'post'][
'ID']
125 [
'nTopCount' => 1 ],
128 if ($log =
$res->fetch())
130 $logId = (int)$log[
'ID'];
138 $logCommentFields = [
140 'ENTITY_ID' => $source[
'post'][
'AUTHOR_ID'],
141 'EVENT_ID' =>
'blog_comment',
142 '=LOG_DATE' => $helper->getCurrentDateTimeFunction(),
144 'USER_ID' => $authorId,
145 'MESSAGE' => $auxText,
146 'TEXT_MESSAGE' => $auxText,
147 'MODULE_ID' =>
false,
148 'SOURCE_ID' => $newCommentId,
149 'RATING_TYPE_ID' =>
'BLOG_COMMENT',
150 'RATING_ENTITY_ID' => $newCommentId,
153 \CSocNetLogComments::add($logCommentFields,
false,
false);
160 $userPage = Option::get(
'socialnetwork',
'user_page',
SITE_DIR .
'company/personal/');
161 $userPath = $userPage .
'user/' . $source[
'post'][
'AUTHOR_ID'] .
'/';
163 $auxLiveParamList = static::getAuxLiveParams([
164 'sourceEntityType' => $sourceEntityType,
165 'sourceEntityId' => $sourceEntityId,
166 'sourceData' => $source,
167 'entityType' => $entityType,
170 'userPath' => $userPath,
175 'liveParamList' => $auxLiveParamList
179 'PATH_TO_USER' => $userPath,
181 'MODE' =>
'PULL_MESSAGE',
182 'AUX' =>
'createentity',
183 'AUX_LIVE_PARAMS' =>
$provider->getLiveParams(),
193 $entityType = (
$params[
'ENTITY_TYPE'] ??
false);
195 $postEntityType = (
$params[
'POST_ENTITY_TYPE'] ??
false);
196 $sourceEntityType = (
$params[
'SOURCE_ENTITY_TYPE'] ??
false);
197 $sourceEntityId = (int)(
$params[
'SOURCE_ENTITY_ID'] ?? 0);
198 $sourceEntityData = (
array)(
$params[
'SOURCE_ENTITY_DATA'] ?? []);
199 $logId = (int)(
$params[
'LOG_ID'] ?? 0);
205 'ENTITY_TYPE' => $entityType,
207 'SOURCE_ENTITY_TYPE' => $sourceEntityType,
208 'SOURCE_ENTITY_ID' => $sourceEntityId,
214 empty($postEntityType)
215 || empty($sourceEntityType)
216 || $sourceEntityId <= 0
217 || empty($entityType)
224 $entity = static::getEntityData([
225 'entityType' => $entityType,
238 'ENTITY_TYPE' => $sourceEntityType,
239 'ENTITY_ID' => $sourceEntityId,
240 'ADDITIONAL_PARAMS' => $sourceEntityData,
249 $commentProvider =
false;
250 if ($postProvider =
Livefeed\Provider::getProvider($postEntityType))
252 $commentProvider = $postProvider->getCommentProvider();
255 if (!$commentProvider)
260 if ($postProvider::className() === $provider::className())
262 $commentProvider->setParentProvider(
$provider);
266 $postEntityId =
$provider->getParentEntityId();
267 $postProvider->setEntityId($postEntityId);
268 $commentProvider->setParentProvider($postProvider);
281 $commentProvider->setLogId(
$provider->getLogId());
285 'sourceType' => $sourceEntityType,
286 'sourceId' => $sourceEntityId,
287 'entityType' => $entityType,
291 $authorId = static::getEntityAuthorId([
292 'entityType' => $entityType,
296 $sonetCommentData = $commentProvider->add([
298 'AUTHOR_ID' => $authorId,
299 'MESSAGE' =>
CommentAux\CreateEntity::getPostText(),
300 'SHARE_DEST' => Json::encode($auxData),
302 'AUX_DATA' => $auxData,
306 $sonetCommentId = (int)($sonetCommentData[
'sonetCommentId'] ?? 0);
307 $sourceCommentId = (int)($sonetCommentData[
'sourceCommentId'] ?? 0);
311 && $sourceCommentId <= 0
322 $userPage = Option::get(
'socialnetwork',
'user_page',
$site[
'DIR'] .
'company/personal/');
325 $auxLiveParamList = static::getAuxLiveParams([
326 'sourceEntityType' => $sourceEntityType,
327 'sourceEntityId' => $sourceEntityId,
328 'entityType' => $entityType,
331 'sourceEntityLink' =>
$provider->getLiveFeedUrl(),
334 $liveCommentParams = [
336 'TIME_FORMAT' => \CSite::getTimeFormat(),
337 'NAME_TEMPLATE' => \CSite::getNameFormat(
null,
$siteId),
339 'AVATAR_SIZE' => 100,
340 'LANGUAGE_ID' =>
$site[
'LANGUAGE_ID'],
343 'AUX' =>
'createentity',
346 if ($sonetCommentId > 0)
352 '=ID' => $logCommentFields[
'LOG_ID']
354 'select' => [
'ID',
'ENTITY_TYPE',
'ENTITY_ID',
'USER_ID',
'EVENT_ID',
'SOURCE_ID' ],
356 if (!($logEntry =
$res->fetch()))
361 $userPath = $userPage .
'user/' . $logEntry[
'USER_ID'] .
'/';
363 $auxLiveParamList[
'userPath'] = $userPath;
365 $serviceCommentProvider = CommentAux\Base::init(
368 'liveParamList' => $auxLiveParamList,
372 $commentEvent = \CSocNetLogTools::findLogCommentEventByLogEventID($logEntry[
'EVENT_ID']);
374 $liveCommentParams[
'SOURCE_ID'] = $logCommentFields[
'SOURCE_ID'];
375 $liveCommentParams[
'PATH_TO_USER'] = $userPath;
376 $liveCommentParams[
'AUX_LIVE_PARAMS'] = $serviceCommentProvider->getLiveParams();
380 $feedParams = $commentProvider->getFeedParams();
381 if (!empty($feedParams[
'xml_id']))
383 $liveCommentParams[
'ENTITY_XML_ID'] = $feedParams[
'xml_id'];
394 elseif ($sourceCommentId > 0)
396 $commentProvider->setEntityId($sourceCommentId);
397 $commentProvider->initSourceFields();
399 $serviceCommentProvider = CommentAux\Base::init(
402 'liveParamList' => $auxLiveParamList,
407 'postProvider' => $postProvider,
408 'commentProvider' => $commentProvider,
410 'languageId' =>
$site[
'LANGUAGE_ID'],
411 'nameTemplate' => \CSite::getNameFormat(
null,
$siteId),
414 'aux' =>
'createentity',
415 'auxLiveParams' => $serviceCommentProvider->getLiveParams()
540 $sourceEntityType = (
$params[
'sourceEntityType'] ??
false);
541 $sourceEntityId = (int)(
$params[
'sourceEntityId'] ?? 0);
542 $sourceData = (
$params[
'sourceData'] ?? []);
543 $entityType = (
$params[
'entityType'] ??
false);
545 $entityData = (
$params[
'entityData'] ?? []);
546 $userPath = (
$params[
'userPath'] ??
'');
547 $logId = (int)(
$params[
'logId'] ?? 0);
551 || $sourceEntityId <= 0
554 || empty($entityData)
555 || !is_array($entityData)
562 'ENTITY_TYPE' => $sourceEntityType,
563 'ENTITY_ID' => $sourceEntityId,
567 $sourceEntityLink = (
569 'sourceEntityType' => $sourceEntityType,
570 'sourceEntityId' => $sourceEntityId,
571 'sourceData' => $sourceData,
572 'entityType' => $entityType,
573 'entityData' => $entityData,
574 'userPath' => $userPath,
579 'sourceEntityType' => $sourceEntityType,
580 'sourceEntityId' => $sourceEntityId,
581 'entityType' => $entityType,
583 'entityUrl' => static::getEntityUrl([
584 'entityType' => $entityType,
585 'entityData' => $entityData,
587 'entityName' => static::getEntityName([
588 'entityType' => $entityType,
589 'entityData' => $entityData,
591 'sourceEntityLink' => $sourceEntityLink,
592 'suffix' => $entityProvider->getSuffix(),
597 $result[
'taskResponsibleId'] = static::getEntityAuthorId([
598 'entityType' => $entityType,
599 'entityData' => $entityData,
604 && Loader::includeModule(
'blog')
612 if (!empty($entityData[
'USER_IDS']) && is_array($entityData[
'USER_IDS']))
614 $attendees = $entityData[
'USER_IDS'];
616 elseif (!empty($entityData[
'attendeesEntityList']))
618 $attendees = array_map(
static function($item) {
619 return (
int)(isset($item[
'entityId'], $item[
'id']) && $item[
'entityId'] ===
'user' ? $item[
'id'] : 0);
620 }, $entityData[
'attendeesEntityList']);
621 $attendees = array_filter($attendees,
static function($item) {
627 !empty($entityData[
'MEETING_HOST'])
628 && (
int)$entityData[
'MEETING_HOST'] > 0
631 $attendees[] = (int)($entityData[
'MEETING_HOST']);
634 !empty($entityData[
'CREATED_BY'])
635 && (
int)$entityData[
'CREATED_BY'] > 0
638 $attendees[] = (int)($entityData[
'CREATED_BY']);
641 $result[
'attendees'] = array_unique($attendees);