1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
logentry.php
См. документацию.
1<?php
2
3namespace Bitrix\Socialnetwork\Component;
4
5use Bitrix\Main\AccessDeniedException;
6use Bitrix\Main\ArgumentException;
7use Bitrix\Main\Config\Option;
8use Bitrix\Main\Loader;
9use Bitrix\Main\Localization\Loc;
10use Bitrix\Main\ErrorCollection;
11use Bitrix\Main\Error;
12use Bitrix\Main\ModuleManager;
13use Bitrix\Main\Page\Asset;
14use Bitrix\Main\SystemException;
15use Bitrix\Main\UserTable;
16use Bitrix\Socialnetwork\ComponentHelper;
17
18Loc::loadMessages(__FILE__);
19
21{
22 protected const STATUS_SUCCESS = 'success';
23 protected const STATUS_DENIED = 'denied';
24 protected const STATUS_ERROR = 'error';
25
27
28 public function __construct($component = null)
29 {
30 parent::__construct($component);
31
32 $this->errorCollection = new ErrorCollection();
33 }
34
35 public function getErrorByCode($code)
36 {
37 return $this->errorCollection->getErrorByCode($code);
38 }
39
44 public function getErrors()
45 {
46 return $this->errorCollection->toArray();
47 }
48
49 public function configureActions(): array
50 {
51 return [];
52 }
53
54 public function onPrepareComponentParams($params = [])
55 {
56 if (
57 !isset($params['IND'])
58 || (string)$params['IND'] === ''
59 )
60 {
62 }
63
64 if (empty($params['LOG_PROPERTY']))
65 {
66 $params['LOG_PROPERTY'] = [ 'UF_SONET_LOG_FILE' ];
67 if (
68 ModuleManager::isModuleInstalled('webdav')
69 || ModuleManager::isModuleInstalled('disk'))
70 {
71 $params['LOG_PROPERTY'][] = 'UF_SONET_LOG_DOC';
72 }
73 }
74
75 if (empty($params['COMMENT_PROPERTY']))
76 {
77 $params['COMMENT_PROPERTY'] = [ 'UF_SONET_COM_FILE' ];
78 if (
79 ModuleManager::isModuleInstalled('webdav')
80 || ModuleManager::isModuleInstalled('disk')
81 )
82 {
83 $params['COMMENT_PROPERTY'][] = 'UF_SONET_COM_DOC';
84 }
85
86 $params['COMMENT_PROPERTY'][] = 'UF_SONET_COM_URL_PRV';
87 }
88
89 if (empty($params['PATH_TO_LOG_TAG']))
90 {
91 $folderUsers = Option::get('socialnetwork', 'user_page', false, SITE_ID);
92 $params['PATH_TO_LOG_TAG'] = $folderUsers . 'log/?TAG=#tag#';
93 if (SITE_TEMPLATE_ID === 'bitrix24' || SITE_TEMPLATE_ID === 'air')
94 {
95 $params['PATH_TO_LOG_TAG'] .= '&apply_filter=Y';
96 }
97 }
98
99 \CSocNetLogComponent::processDateTimeFormatParams($params);
100
101 $params['COMMENT_ID'] = (int) ($params['COMMENT_ID'] ?? 0);
102
103 return $params;
104 }
105
106 public static function addComment(array $params = []): array
107 {
109
110 $result = [];
111
112 $logId = (int)($params['logId'] ?? 0);
113 $currentUserId = (int)($params['currentUserId'] ?? $USER->getId());
114 $crm = (isset($params['crm']) && $params['crm'] === 'Y' ? 'Y' : 'N');
115 $languageId = (string)($params['languageId'] ?? LANGUAGE_ID);
116 $siteId = (string)($params['siteId'] ?? SITE_ID);
117 $commentParams = (isset($params['commentParams']) && is_array($params['commentParams']) ? $params['commentParams'] : []);
118 $message = (string)($params['message'] ?? '');
119 $forumId = (int)($params['forumId'] ?? 0);
120 $commentUid = (string)($params['commentUid'] ?? '');
121 $dateTimeFormat = (string)($params['dateTimeFormat'] ?? \CSite::getTimeFormat());
122 $nameTemplate = (string)($params['nameTemplate'] ?? \CSite::getNameFormat(null, $siteId));
123 $showLogin = (string)($params['showLogin'] ?? 'N');
124 $avatarSize = (int)($params['avatarSize'] ?? 100);
125 $pull = (string)($params['pull'] ?? 'N');
126
127 $pathToSmile = (string)($params['pathToSmile'] ?? '');
128 $pathToLogEntry = (string)($params['pathToLogEntry'] ?? '');
129 $pathToUser = (string)($params['pathToUser'] ?? '');
130 $pathToUserBlogPost = (string)($params['pathToUserBlogPost'] ?? '');
131 $pathToGroupBlogPost = (string)($params['pathToGroupBlogPost'] ?? '');
132 $pathToUserMicroBlogPost = (string)($params['pathToUserMicroBlogPost'] ?? '');
133 $pathToGroupMicroBlogPost = (string)($params['pathToGroupMicroBlogPost'] ?? '');
134 $blogAllowPostCode = (string)($params['blogAllowPostCode'] ?? 'N');
135
136 if ($logId <= 0)
137 {
138 return $result;
139 }
140
141 if (!isset($params['currentUserExternalAuthId']))
142 {
143 $currentUserExternalAuthId = '';
144
145 if ($USER->isAuthorized())
146 {
147 $res = \CUser::getById($currentUserId);
148 if ($userFields = $res->fetch())
149 {
150 $currentUserExternalAuthId = $userFields['EXTERNAL_AUTH_ID'];
151 }
152 }
153 }
154 else
155 {
156 $currentUserExternalAuthId = '';
157 }
158
159 if ($logFields = \CSocNetLog::getById($logId))
160 {
161 $listParams = [
162 'CHECK_RIGHTS' => 'Y',
163 'USE_SUBSCRIBE' => 'N'
164 ];
165
166 if (
167 $currentUserExternalAuthId !== 'email'
168 && mb_strpos($logFields['ENTITY_TYPE'], 'CRM') === 0
169 && (
170 !in_array($logFields['EVENT_ID'], [ 'crm_lead_message', 'crm_deal_message', 'crm_company_message', 'crm_contact_message', 'crm_activity_add' ])
171 || $crm === 'Y'
172 )
173 && ModuleManager::isModuleInstalled('crm')
174 )
175 {
176 $listParams = [
177 'IS_CRM' => 'Y',
178 'CHECK_CRM_RIGHTS' => 'Y'
179 ];
180 }
181 }
182 else
183 {
184 $logId = 0;
185 }
186
187 if (
188 $logId <= 0
189 || !($res = \CSocNetLog::GetList(array(), array("ID" => $logId), false, false, array(), $listParams))
190 || !($logFields = $res->fetch())
191 )
192 {
193 $result['strMessage'] = Loc::getMessage('SONET_LOG_COMMENT_NO_PERMISSIONS', false, $languageId);
194 return $result;
195 }
196
197 $commentEvent = \CSocNetLogTools::FindLogCommentEventByLogEventID($logFields['EVENT_ID']);
198 if (!$commentEvent)
199 {
200 return $result;
201 }
202
203 $canAddComments = ComponentHelper::canAddComment($logFields, $commentEvent);
204
205 if (!$canAddComments)
206 {
207 $result['strMessage'] = Loc::getMessage('SONET_LOG_COMMENT_NO_PERMISSIONS', false, $languageId);
208 return $result;
209 }
210
211 $editCommentSourceId = (
212 isset($commentParams[1]) && (int)$commentParams[1] > 0
213 ? (int)$commentParams[1]
214 : 0
215 );
216
217 // add source object and get source_id, $source_url
218 $options = [
219 'PATH_TO_SMILE' => $pathToSmile,
220 'PATH_TO_LOG_ENTRY' => $pathToLogEntry,
221 'PATH_TO_USER_BLOG_POST' => $pathToUserBlogPost,
222 'PATH_TO_GROUP_BLOG_POST' => $pathToGroupBlogPost,
223 'PATH_TO_USER_MICROBLOG_POST' => $pathToUserMicroBlogPost,
224 'PATH_TO_GROUP_MICROBLOG_POST' => $pathToGroupMicroBlogPost,
225 'BLOG_ALLOW_POST_CODE' => $blogAllowPostCode,
226 ];
227
228 $commentText = preg_replace("/\xe2\x81\xa0/is", ' ', $message); // INVISIBLE_CURSOR from editor
229 $commentText = trim($commentText);
230
231 if ($commentText === '')
232 {
233 $result['strMessage'] = Loc::getMessage('SONET_LOG_COMMENT_EMPTY', false, $languageId);
234 return $result;
235 }
236
237 $searchParams = [];
238
239 if ($commentEvent['EVENT_ID'] === 'forum')
240 {
241 $searchParams['FORUM_ID'] = $forumId;
242 $searchParams['PATH_TO_GROUP_FORUM_MESSAGE'] = (
243 $logFields['ENTITY_TYPE'] === SONET_SUBSCRIBE_ENTITY_GROUP
244 ? static::replaceGroupPath($logFields['URL'], $siteId)
245 : ''
246 );
247 $searchParams['PATH_TO_USER_FORUM_MESSAGE'] = (
248 $logFields['ENTITY_TYPE'] === SONET_SUBSCRIBE_ENTITY_USER
249 ? $logFields['URL']
250 : ''
251 );
252 }
253 elseif ($commentEvent['EVENT_ID'] === 'files_comment')
254 {
255 $filesForumId = 0;
256
257 if ((string)$logFields['PARAMS'] !== '')
258 {
259 $logParams = explode('&', htmlspecialcharsback($logFields["PARAMS"]));
260 foreach ($logParams as $prm)
261 {
262 [ $k, $v ] = explode('=', $prm);
263 if ($k === 'forum_id')
264 {
265 $filesForumId = (int)$v;
266 break;
267 }
268 }
269 }
270
271 $searchParams['FILES_FORUM_ID'] = $filesForumId;
272 $searchParams['PATH_TO_GROUP_FILES_ELEMENT'] = (
273 $logFields['ENTITY_TYPE'] === SONET_SUBSCRIBE_ENTITY_GROUP
274 ? static::replaceGroupPath($logFields['URL'], $siteId)
275 : ''
276 );
277 $searchParams['PATH_TO_USER_FILES_ELEMENT'] = (
278 $logFields['ENTITY_TYPE'] === SONET_SUBSCRIBE_ENTITY_USER
279 ? $logFields['URL']
280 : ''
281 );
282 }
283 elseif ($commentEvent['EVENT_ID'] === 'photo_comment')
284 {
285 $photoForumId = 0;
286
287 if ((string)$logFields['PARAMS'] !== '')
288 {
289 $logParams = unserialize(htmlspecialcharsback($logFields['PARAMS']), [ 'allowed_classes' => false ]);
290 if (
291 isset($logParams['FORUM_ID'])
292 && (int)$logParams['FORUM_ID'] > 0
293 )
294 {
295 $photoForumId = $logParams["FORUM_ID"];
296 }
297 }
298 $searchParams['PHOTO_FORUM_ID'] = $photoForumId;
299 $searchParams['PATH_TO_GROUP_PHOTO_ELEMENT'] = (
300 $logFields['ENTITY_TYPE'] === SONET_SUBSCRIBE_ENTITY_GROUP
301 ? static::replaceGroupPath($logFields['URL'], $siteId)
302 : ''
303 );
304 $searchParams['PATH_TO_USER_PHOTO_ELEMENT'] = (
305 $logFields['ENTITY_TYPE'] === SONET_SUBSCRIBE_ENTITY_USER
306 ? $logFields['URL']
307 : ''
308 );
309 }
310 elseif ($commentEvent['EVENT_ID'] === 'wiki_comment')
311 {
312 $searchParams['PATH_TO_GROUP_WIKI_POST_COMMENT'] = (
313 $logFields['ENTITY_TYPE'] === SONET_SUBSCRIBE_ENTITY_GROUP
314 ? Option::get('socialnetwork', 'workgroups_page', '', $siteId) . 'group/#group_id#/wiki/#wiki_name#/?MID=#message_id##message#message_id#'
315 : ''
316 );
317 }
318 elseif ($commentEvent["EVENT_ID"] === 'tasks_comment')
319 {
320 if (Loader::includeModule('tasks'))
321 {
322 $tasksForumId = 0;
323
324 try
325 {
326 $tasksForumId = \CTasksTools::getForumIdForIntranet();
327 }
328 catch (\Exception $e)
329 {
330 }
331
332 if ($tasksForumId > 0)
333 {
334 $searchParams['TASK_FORUM_ID'] = $tasksForumId;
335 $searchParams['PATH_TO_GROUP_TASK_ELEMENT'] = (
336 $logFields['ENTITY_TYPE'] === SONET_SUBSCRIBE_ENTITY_GROUP
337 ? Option::get('socialnetwork', 'workgroups_page', '', $siteId) . 'group/#group_id#/tasks/task/view/#task_id#/'
338 : ''
339 );
340 $searchParams['PATH_TO_USER_TASK_ELEMENT'] = (
341 $logFields['ENTITY_TYPE'] === SONET_SUBSCRIBE_ENTITY_USER
342 ? Option::get('socialnetwork', 'user_page', '', $siteId) . 'user/#user_id#/tasks/task/view/#task_id#/'
343 : ""
344 );
345 }
346 }
347 }
348 elseif ($commentEvent['EVENT_ID'] === 'calendar_comment')
349 {
350 $searchParams['PATH_TO_GROUP_CALENDAR_ELEMENT'] = (
351 $logFields['ENTITY_TYPE'] === SONET_SUBSCRIBE_ENTITY_GROUP
352 ? Option::get('socialnetwork', 'workgroups_page', '', $siteId) . 'group/#group_id#/calendar/?EVENT_ID=#element_id#'
353 : ''
354 );
355 }
356 elseif ($commentEvent['EVENT_ID'] === 'lists_new_element_comment')
357 {
358 $searchParams['PATH_TO_WORKFLOW'] = '/services/processes/#list_id#/bp_log/#workflow_id#/';
359 }
360
361 global $bxSocNetSearch;
362
363 if (
364 !empty($searchParams)
365 && !is_object($bxSocNetSearch)
366 )
367 {
368 $bxSocNetSearch = new \CSocNetSearch(
369 ($logFields['ENTITY_TYPE'] === SONET_SUBSCRIBE_ENTITY_USER ? $logFields['ENTITY_ID'] : false),
370 ($logFields['ENTITY_TYPE'] === SONET_SUBSCRIBE_ENTITY_GROUP ? $logFields['ENTITY_ID'] : false),
371 $searchParams
372 );
373 AddEventHandler('search', 'BeforeIndex', [ $bxSocNetSearch, 'BeforeIndex' ]);
374 }
375
376 if ($editCommentSourceId > 0)
377 {
378 $fields = [
379 'EVENT_ID' => $commentEvent['EVENT_ID'],
380 'MESSAGE' => $commentText,
381 'TEXT_MESSAGE' => $commentText,
382 'BLOG_ALLOW_POST_CODE' => $options['BLOG_ALLOW_POST_CODE']
383 ];
384 }
385 else
386 {
387 $fields = [
388 'ENTITY_TYPE' => $logFields['ENTITY_TYPE'],
389 'ENTITY_ID' => $logFields['ENTITY_ID'],
390 'EVENT_ID' => $commentEvent['EVENT_ID'],
391 '=LOG_DATE' => \CDatabase::currentTimeFunction(),
392 'MESSAGE' => $commentText,
393 'TEXT_MESSAGE' => $commentText,
394 'MODULE_ID' => false,
395 'LOG_ID' => $logFields['ID'],
396 'USER_ID' => $currentUserId,
397 'PATH_TO_USER_BLOG_POST' => $options['PATH_TO_USER_BLOG_POST'],
398 'PATH_TO_GROUP_BLOG_POST' => $options['PATH_TO_GROUP_BLOG_POST'],
399 'PATH_TO_USER_MICROBLOG_POST' => $options['PATH_TO_USER_MICROBLOG_POST'],
400 'PATH_TO_GROUP_MICROBLOG_POST' => $options['PATH_TO_GROUP_MICROBLOG_POST'],
401 'BLOG_ALLOW_POST_CODE' => $options['BLOG_ALLOW_POST_CODE']
402 ];
403 }
404
405 $USER_FIELD_MANAGER->EditFormAddFields('SONET_COMMENT', $fields);
406
407 if (
408 array_key_exists('UF_SONET_COM_FILE', $fields)
409 && !empty($fields['UF_SONET_COM_FILE'])
410 )
411 {
412 if (is_array($fields['UF_SONET_COM_FILE']))
413 {
414 foreach ($fields["UF_SONET_COM_FILE"] as $key => $fileID)
415 {
416 if (
417 !$commentUid
418 || !array_key_exists('MFI_UPLOADED_FILES_' . $commentUid, $_SESSION)
419 || !in_array($fileID, $_SESSION['MFI_UPLOADED_FILES_' . $commentUid], true)
420 )
421 {
422 unset($fields['UF_SONET_COM_FILE'][$key]);
423 }
424 }
425 }
426 elseif (
427 !$commentUid
428 || !array_key_exists('MFI_UPLOADED_FILES_' . $commentUid, $_SESSION)
429 || !in_array($fields['UF_SONET_COM_FILE'], $_SESSION['MFI_UPLOADED_FILES_' . $commentUid], true)
430 )
431 {
432 unset($fields['UF_SONET_COM_FILE']);
433 }
434 }
435
436 $inlineTagList = \Bitrix\Socialnetwork\Util::detectTags($fields, [ 'MESSAGE' ]);
437
438 if (!empty($inlineTagList))
439 {
440 $fields['TAG'] = $inlineTagList;
441 }
442
443 $updatedCommentId = 0;
444
445 if ($editCommentSourceId > 0)
446 {
447 $updatedCommentLogId = 0;
448 $updatedCommentUserId = 0;
449
450 if (
451 isset($commentEvent['ADD_CALLBACK'])
452 && is_callable($commentEvent['ADD_CALLBACK'])
453 )
454 {
455 $res = \CSocNetLogComments::getList(
456 [],
457 [
458 'EVENT_ID' => $commentEvent['EVENT_ID'],
459 'SOURCE_ID' => $editCommentSourceId
460 ],
461 false,
462 false,
463 [ 'ID', 'USER_ID', 'LOG_ID', 'SOURCE_ID' ]
464 );
465 if ($commentFields = $res->fetch())
466 {
467 $updatedCommentId = $commentFields['ID'];
468 $updatedCommentLogId = $commentFields['LOG_ID'];
469 $updatedCommentUserId = $commentFields['USER_ID'];
470 }
471 }
472
473 if ((int)$updatedCommentId <= 0)
474 {
475 $res = \CSocNetLogComments::getList(
476 [],
477 [
478 'ID' => $editCommentSourceId,
479 ],
480 false,
481 false,
482 [ 'ID', 'USER_ID', 'LOG_ID', 'SOURCE_ID' ]
483 );
484 if ($commentFields = $res->fetch())
485 {
486 $updatedCommentId = $commentFields['ID'];
487 $updatedCommentLogId = $commentFields['LOG_ID'];
488 $updatedCommentUserId = $commentFields['USER_ID'];
489 }
490 }
491
492 $canUpdate = false;
493
494 if ((int)$updatedCommentId > 0)
495 {
496 $canUpdate = \CSocNetLogComponent::canUserChangeComment(array(
497 'ACTION' => 'EDIT',
498 'LOG_ID' => $updatedCommentLogId,
499 'LOG_EVENT_ID' => $logFields['EVENT_ID'],
500 'LOG_SOURCE_ID' => $logFields['SOURCE_ID'],
501 'COMMENT_ID' => $updatedCommentId,
502 'COMMENT_USER_ID' => $updatedCommentUserId
503 ));
504 }
505
506 if ($canUpdate)
507 {
508 $commentId = \CSocNetLogComments::update($updatedCommentId, $fields, true);
509 }
510 else
511 {
512 $result['strMessage'] = Loc::getMessage("SONET_LOG_COMMENT_NO_PERMISSIONS_UPDATE", false, $languageId);
513 $result["commentText"] = $commentText;
514
515 return $result;
516 }
517 }
518 else
519 {
520 $commentId = \CSocNetLogComments::add($fields, true, false);
521 }
522
523 if ((int)$commentId <= 0)
524 {
525 return $result;
526 }
527
528 $bSkipCounterIncrement = false;
529
530 if ($editCommentSourceId <= 0)
531 {
532 $res = getModuleEvents('socialnetwork', 'OnAfterSocNetLogEntryCommentAdd');
533 while ($event = $res->fetch())
534 {
536 $logFields,
537 [
538 'SITE_ID' => $siteId,
539 'COMMENT_ID' => $commentId,
540 ]
541 ]);
542 }
543
544 $res = getModuleEvents('socialnetwork', 'OnBeforeSocNetLogCommentCounterIncrement');
545 while ($event = $res->fetch())
546 {
547 if (ExecuteModuleEventEx($event, [ $logFields ]) === false)
548 {
549 $bSkipCounterIncrement = true;
550 break;
551 }
552 }
553 }
554 else
555 {
556 $bSkipCounterIncrement = true;
557 }
558
559 if (!$bSkipCounterIncrement)
560 {
561 \CSocNetLog::counterIncrement(
562 $commentId,
563 false,
564 false,
565 "LC",
566 \CSocNetLogRights::checkForUserAll($logFields['ID'])
567 );
568 }
569
570 $result['commentID'] = $commentId;
571
572 if ($commentFields = \CSocNetLogComments::getById($result['commentID']))
573 {
575 $commentFields,
576 $logFields,
577 $commentEvent,
578 [
579 'ACTION' => ((int)$updatedCommentId <= 0 ? 'ADD' : "UPDATE"),
580 'SOURCE_ID' => $editCommentSourceId,
581 'TIME_FORMAT' => $dateTimeFormat,
582 "PATH_TO_USER" => $pathToUser,
583 'PATH_TO_LOG_ENTRY' => $pathToLogEntry,
584 'NAME_TEMPLATE' => $nameTemplate,
585 'SHOW_LOGIN' => $showLogin,
586 'AVATAR_SIZE' => $avatarSize,
587 'PATH_TO_SMILE' => $pathToSmile,
588 'LANGUAGE_ID' => $languageId,
589 'SITE_ID' => $siteId,
590 'PULL' => $pull,
591 ]
592 );
593
594 $result = array_merge($result, $res);
595 }
596
597 return $result;
598 }
599
600 public static function deleteComment(array $params = [])
601 {
602 global $APPLICATION;
603
604 $result = false;
605
606 $logId = (int)($params['logId'] ?? 0);
607 $commentId = (int)($params['commentId'] ?? 0);
608
609 if (
610 $logId <= 0
611 || $commentId <= 0
612 )
613 {
614 throw new ArgumentException('Wrong method parameters');
615 }
616
617 $commentFields = \CSocNetLogComponent::getCommentByRequest($commentId, $logId, 'delete');
618 if (!$commentFields)
619 {
620 throw new AccessDeniedException('Cannot get comment');
621 }
622
623 if (!\CSocNetLogComments::delete($commentFields['ID'], true))
624 {
625 if ($e = $APPLICATION->getException())
626 {
627 throw new SystemException($e->getString());
628 }
629 }
630 else
631 {
632 $result = (int)(
633 $commentFields['SOURCE_ID'] > 0
634 ? $commentFields['SOURCE_ID']
635 : $commentFields['ID']
636 );
637 }
638
639 return $result;
640 }
641
642 public static function replaceGroupPath($url = '', $siteId = SITE_ID): string
643 {
644 static $workgroupsPage = null;
645 if ($workgroupsPage === null)
646 {
647 $workgroupsPage = Option::get('socialnetwork', 'workgroups_page', false, $siteId);
648 }
649
650 return str_replace(
651 '#GROUPS_PATH#',
652 $workgroupsPage,
653 $url
654 );
655 }
656
657 public static function getUserFieldsFMetaData()
658 {
659 global $USER_FIELD_MANAGER;
660 static $arUFMeta;
661 if (!$arUFMeta)
662 {
663 $arUFMeta = $USER_FIELD_MANAGER->GetUserFields("SONET_COMMENT", 0, LANGUAGE_ID);
664 }
665 return $arUFMeta;
666 }
667
668 public static function getCommentsFullList(array $eventData, array &$params, array $options = [], array &$arResult = [])
669 {
670 global $CACHE_MANAGER;
671
672 $nTopCount = (isset($options['nTopCount']) && (int)$options['nTopCount'] > 0 ? (int)$options['nTopCount'] : 20);
673 $timeZoneOffzet = (isset($options['timeZoneOffzet']) && (int)$options['timeZoneOffzet'] > 0 ? (int)$options['timeZoneOffzet'] : 0);
674 $commentEvent = (isset($options['commentEvent']) && is_array($options['commentEvent']) ? $options['commentEvent'] : []);
675 $commentProvider = ($options['commentProvider'] ?? false);
676
677 $cacheTime = 31536000;
678 $cache = false;
679
680 $useCache = ($params['COMMENT_ID'] <= 0);
681
682 if ($useCache)
683 {
684 $cache = new \CPHPCache;
685 }
686
687 $cacheIdPartsList = [];
688 $keysList = [
689 'AVATAR_SIZE_COMMENT',
690 'NAME_TEMPLATE',
691 'NAME_TEMPLATE_WO_NOBR',
692 'SHOW_LOGIN',
693 'DATE_TIME_FORMAT',
694 'PATH_TO_USER',
695 'PATH_TO_GROUP',
696 'PATH_TO_CONPANY_DEPARTMENT',
697 'FILTER',
698 ];
699
700 foreach ($keysList as $paramKey)
701 {
702 $cacheIdPartsList[$paramKey] = (
703 array_key_exists($paramKey, $params)
704 ? $params[$paramKey]
705 : false
706 );
707 }
708
709 $navParams = \CDBResult::getNavParams($params['COMMENTS_IN_EVENT'] ?? null);
710 $navPage = (int)($navParams['PAGEN'] ?? 1);
711
712 $cacheId = implode('_', [
713 'log_comments',
714 $params['LOG_ID'],
715 md5(serialize($cacheIdPartsList)),
716 SITE_TEMPLATE_ID,
717 SITE_ID,
718 LANGUAGE_ID,
720 $timeZoneOffzet,
721 $nTopCount,
722 $navPage,
723 ]);
724
725 $cachePath = '/sonet/log/' . (int)((int)$params['LOG_ID'] / 1000) . '/' . $params['LOG_ID'] . '/comments/';
726
727 $result = [];
728
729 if (
730 $useCache
731 && $cache->initCache($cacheTime, $cacheId, $cachePath)
732 )
733 {
734 $cacheVariables = $cache->getVars();
735 $result = $cacheVariables['COMMENTS_FULL_LIST'];
736
737 $navResultData = $cacheVariables['NAV_RESULT_DATA'];
738 $navResult = new \CDBResult;
739 $navResult->bShowAll = $navResultData['bShowAll'];
740 $navResult->bDescPageNumbering = $navResultData['bDescPageNumbering'];
741 $navResult->NavNum = $navResultData['NavNum'];
742 $navResult->NavRecordCount = $navResultData['NavRecordCount'];
743 $navResult->NavPageNomer = $navResultData['NavPageNomer'];
744 $navResult->NavPageSize = $navResultData['NavPageSize'];
745
746 if (!empty($cacheVariables['Assets']))
747 {
748 if (!empty($cacheVariables['Assets']['CSS']))
749 {
750 foreach ($cacheVariables['Assets']['CSS'] as $cssFile)
751 {
752 Asset::getInstance()->addCss($cssFile);
753 }
754 }
755
756 if (!empty($cacheVariables['Assets']['JS']))
757 {
758 foreach ($cacheVariables["Assets"]['JS'] as $jsFile)
759 {
760 Asset::getInstance()->addJs($jsFile);
761 }
762 }
763 }
764 }
765 else
766 {
767 if ($useCache)
768 {
769 $cache->startDataCache($cacheTime, $cacheId, $cachePath);
770 }
771
772 if (defined('BX_COMP_MANAGED_CACHE'))
773 {
774 $CACHE_MANAGER->startTagCache($cachePath);
775 }
776
777 $filter = [
778 'LOG_ID' => $params['LOG_ID']
779 ];
780
781 $logCommentId = 0;
782
783 if ($params['COMMENT_ID'] > 0)
784 {
785 $logCommentId = $params['COMMENT_ID'];
786 }
787 elseif (
788 !empty($params['FILTER'])
789 && !empty($params['FILTER']['<ID'])
790 && (int)$params['FILTER']['<ID'] > 0
791 )
792 {
793 $logCommentId = (int)$params['FILTER']['<ID'];
794 }
795
796 if (
797 !empty($commentEvent)
798 && !empty($commentEvent['RATING_TYPE_ID'])
799 && $logCommentId > 0
800 )
801 {
802 $res = \CSocNetLogComments::getList(
803 [],
804 [
805 'RATING_TYPE_ID' => $commentEvent['RATING_TYPE_ID'],
806 'RATING_ENTITY_ID' => $logCommentId,
807 ],
808 false,
809 false,
810 [ 'ID' ]
811 );
812
813 if ($logCommentFields = $res->fetch())
814 {
815 $logCommentId = (int)$logCommentFields['ID'];
816 }
817 }
818
819 if ($logCommentId > 0)
820 {
821 if ($params['COMMENT_ID'] > 0)
822 {
823 $filter['>=ID'] = $logCommentId;
824 }
825 elseif (
826 !empty($params['FILTER'])
827 && !empty($params['FILTER']['<ID'])
828 && (int)$params['FILTER']['<ID'] > 0
829 )
830 {
831 $filter['<ID'] = $logCommentId;
832 }
833 }
834
835 $select = [
836 'ID', 'LOG_ID', 'SOURCE_ID', 'ENTITY_TYPE', 'ENTITY_ID', 'USER_ID', 'EVENT_ID', 'LOG_DATE', 'MESSAGE', 'LOG_DATE_TS', 'TEXT_MESSAGE', 'URL', 'MODULE_ID',
837 'GROUP_NAME', 'GROUP_OWNER_ID', 'GROUP_VISIBLE', 'GROUP_OPENED', 'GROUP_IMAGE_ID',
838 'USER_NAME', 'USER_LAST_NAME', 'USER_SECOND_NAME', 'USER_LOGIN', 'USER_PERSONAL_PHOTO', 'USER_PERSONAL_GENDER',
839 'CREATED_BY_NAME', 'CREATED_BY_LAST_NAME', 'CREATED_BY_SECOND_NAME', 'CREATED_BY_LOGIN', 'CREATED_BY_PERSONAL_PHOTO', 'CREATED_BY_PERSONAL_GENDER', 'CREATED_BY_EXTERNAL_AUTH_ID',
840 'SHARE_DEST',
841 'LOG_SITE_ID', 'LOG_SOURCE_ID',
842 'RATING_TYPE_ID', 'RATING_ENTITY_ID',
843 'UF_*'
844 ];
845
846 $listParams = [
847 'USE_SUBSCRIBE' => 'N',
848 'CHECK_RIGHTS' => 'N'
849 ];
850
851 $usetFieldsMetaData = self::getUserFieldsFMetaData();
852
853 if ($params['COMMENT_ID'] > 0)
854 {
855 $navParams = false;
856 }
857 elseif ($navPage > 1)
858 {
859 $navParams = [
860 'iNumPage' => $navPage,
861 'nPageSize' => $params['COMMENTS_IN_EVENT'],
862 ];
863 }
864 else
865 {
866 $navParams = [
867 'nTopCount' => $nTopCount,
868 ];
869 }
870
871 $assets = [
872 'CSS' => [],
873 'JS' => []
874 ];
875
876 $res = \CSocNetLogComments::getList(
877 [ 'LOG_DATE' => 'DESC', 'ID' => 'DESC' ], // revert then
878 $filter,
879 false,
881 $select,
882 $listParams
883 );
884
885 $navResultData = null;
886 if ($res->NavNum !== null)
887 {
888 $navResultData = [
889 'bShowAll' => $res->bShowAll,
890 'bDescPageNumbering' => $res->bDescPageNumbering,
891 'NavNum' => $res->NavNum,
892 'NavRecordCount' => $res->NavRecordCount,
893 'NavPageNomer' => $res->NavPageNomer,
894 'NavPageSize' => $res->NavPageSize,
895 ];
896 }
897
898 if (
899 !empty($eventData['EVENT_FORMATTED'])
900 && !empty($eventData['EVENT_FORMATTED']['DESTINATION'])
901 && is_array($eventData['EVENT_FORMATTED']['DESTINATION'])
902 )
903 {
904 foreach ($eventData['EVENT_FORMATTED']['DESTINATION'] as $destination)
905 {
906 if (!empty($destination['CRM_USER_ID']))
907 {
908 $params['ENTRY_HAS_CRM_USER'] = true;
909 break;
910 }
911 }
912 }
913
914 $commentsList = $commentSourceIdList = [];
915 while ($commentFields = $res->getNext())
916 {
917 if (!empty($commentFields['SHARE_DEST']))
918 {
919 $commentFields['SHARE_DEST'] = htmlspecialcharsback($commentFields['SHARE_DEST']);
920 }
921
922 if (defined('BX_COMP_MANAGED_CACHE'))
923 {
924 $CACHE_MANAGER->registerTag('USER_NAME_'.(int)$commentFields['USER_ID']);
925 }
926
927 $commentFields['UF'] = $usetFieldsMetaData;
928 foreach ($usetFieldsMetaData as $fieldName => $userFieldData)
929 {
930 if (array_key_exists($fieldName, $commentFields))
931 {
932 $commentFields['UF'][$fieldName]['VALUE'] = $commentFields[$fieldName];
933 $commentFields['UF'][$fieldName]['ENTITY_VALUE_ID'] = $commentFields['ID'];
934 if (method_exists($GLOBALS['USER_FIELD_MANAGER'], 'getCustomData'))
935 {
936 $commentFields['UF'][$fieldName]['CUSTOM_DATA'] = $GLOBALS['USER_FIELD_MANAGER']->getCustomData(
937 $commentFields['UF'][$fieldName],
938 (int)$commentFields['ID']
939 );
940 }
941
942 }
943 }
944 $commentsList[] = $commentFields;
945 if ((int)$commentFields['SOURCE_ID'] > 0)
946 {
947 $commentSourceIdList[] = (int)$commentFields['SOURCE_ID'];
948 }
949 }
950
951 if (
952 !empty($commentSourceIdList)
953 && !empty($commentProvider)
954 )
955 {
956 $sourceAdditonalData = $commentProvider->getAdditionalData([
957 'id' => $commentSourceIdList
958 ]);
959
960 if (!empty($sourceAdditonalData))
961 {
962 foreach ($commentsList as $key => $comment)
963 {
964 if (
965 !empty($comment['SOURCE_ID'])
966 && isset($sourceAdditonalData[$comment['SOURCE_ID']])
967 )
968 {
969 $commentsList[$key]['ADDITIONAL_DATA'] = $sourceAdditonalData[$comment['SOURCE_ID']];
970 }
971 }
972 }
973 }
974
975 foreach ($commentsList as $commentFields)
976 {
977 $result[] = self::getLogCommentRecord($commentFields, $params, $assets);
978 }
979
980 if (
981 $params['COMMENT_ID'] <= 0
982 && $navResultData === null
983 )
984 {
985 $navResult = \CSocNetLogComments::getList(
986 [],
987 $filter,
988 false,
989 [
990 'nPageSize' => $params['COMMENTS_IN_EVENT'],
991 'bShowAll' => false,
992 ],
993 [ 'ID' ],
994 $listParams
995 );
996
997 $navResultData = [
998 'bShowAll' => $navResult->bShowAll,
999 'bDescPageNumbering' => $navResult->bDescPageNumbering,
1000 'NavNum' => $navResult->NavNum,
1001 'NavRecordCount' => $navResult->NavRecordCount,
1002 'NavPageNomer' => $navResult->NavPageNomer,
1003 'NavPageSize' => $navResult->NavPageSize,
1004 ];
1005 }
1006
1007 if ($useCache)
1008 {
1009 $cacheData = [
1010 'COMMENTS_FULL_LIST' => $result,
1011 'NAV_RESULT_DATA' => $navResultData,
1012 'Assets' => $assets
1013 ];
1014 $cache->endDataCache($cacheData);
1015 if (defined('BX_COMP_MANAGED_CACHE'))
1016 {
1017 $CACHE_MANAGER->endTagCache();
1018 }
1019 }
1020 }
1021
1022 $arResult['NAV_RESULT'] = $navResult ?? null;
1023
1024 return $result;
1025 }
1026
1027 public static function getLogCommentRecord(array $comment, array $params, array &$assets): array
1028 {
1029 global $APPLICATION, $arExtranetUserID;
1030
1031 $extranetUserIdList = $arExtranetUserID;
1032
1033 static $userCache = array();
1034
1035 // for the same post log_update - time only, if not - date and time
1036 $timestamp = makeTimeStamp(array_key_exists('LOG_DATE_FORMAT', $comment)
1037 ? $comment['LOG_DATE_FORMAT']
1038 : $comment['LOG_DATE']
1039 );
1040
1041 $timeFormated = formatDateFromDB($comment['LOG_DATE'],
1042 (
1043 mb_stripos($params['DATE_TIME_FORMAT'], 'a')
1044 || (
1045 $params['DATE_TIME_FORMAT'] === 'FULL'
1046 && isAmPmMode()
1047 ) !== false
1048 ? (mb_strpos(FORMAT_DATETIME, 'TT') !== false ? 'G:MI TT' : 'G:MI T')
1049 : 'HH:MI'
1050 )
1051 );
1052
1053 $dateTimeFormated = formatDate(
1054 (!empty($params['DATE_TIME_FORMAT'])
1055 ? ($params['DATE_TIME_FORMAT'] === 'FULL'
1056 ? \CDatabase::dateFormatToPHP(str_replace(':SS', '', FORMAT_DATETIME))
1057 : $params['DATE_TIME_FORMAT']
1058 )
1059 : \CDatabase::dateFormatToPHP(FORMAT_DATETIME)
1060 ),
1061 $timestamp
1062 );
1063
1064 if (
1065 strcasecmp(LANGUAGE_ID, 'EN') !== 0
1066 && strcasecmp(LANGUAGE_ID, 'DE') !== 0
1067 )
1068 {
1069 $dateTimeFormated = mb_strtolower($dateTimeFormated);
1070 }
1071
1072 // strip current year
1073 if (
1074 !empty($params['DATE_TIME_FORMAT'])
1075 && (
1076 $params['DATE_TIME_FORMAT'] === 'j F Y G:i'
1077 || $params['DATE_TIME_FORMAT'] === 'j F Y g:i a'
1078 )
1079 )
1080 {
1081 $dateTimeFormated = ltrim($dateTimeFormated, '0');
1082 $currentYear = date('Y');
1083 $dateTimeFormated = str_replace(array('-'.$currentYear, '/'.$currentYear, ' '.$currentYear, '.'.$currentYear), '', $dateTimeFormated);
1084 }
1085
1086 $path2Entity = (
1087 $comment['ENTITY_TYPE'] === SONET_ENTITY_GROUP
1088 ? \CComponentEngine::MakePathFromTemplate($params['PATH_TO_GROUP'], [ 'group_id' => $comment['ENTITY_ID'] ])
1089 : \CComponentEngine::MakePathFromTemplate($params['PATH_TO_USER'], [ 'user_id' => $comment['ENTITY_ID'] ])
1090 );
1091
1092 if ((int)$comment['USER_ID'] > 0)
1093 {
1094 $suffix = (
1095 is_array($extranetUserIdList)
1096 && in_array($comment['USER_ID'], $extranetUserIdList)
1097 ? Loc::getMessage('SONET_LOG_EXTRANET_SUFFIX')
1098 : ""
1099 );
1100
1101 $userFields = [
1102 'NAME' => $comment['~CREATED_BY_NAME'],
1103 'LAST_NAME' => $comment['~CREATED_BY_LAST_NAME'],
1104 'SECOND_NAME' => $comment['~CREATED_BY_SECOND_NAME'],
1105 'LOGIN' => $comment['~CREATED_BY_LOGIN']
1106 ];
1107 $useLogin = ($params["SHOW_LOGIN"] !== "N");
1108 $createdByFields = [
1109 'FORMATTED' => \CUser::formatName($params['NAME_TEMPLATE'], $userFields, $useLogin).$suffix,
1110 'URL' => \CComponentEngine::makePathFromTemplate($params['PATH_TO_USER'], [
1111 'user_id' => $comment['USER_ID'],
1112 'id' => $comment['USER_ID']
1113 ])
1114 ];
1115
1116 $createdByFields['TOOLTIP_FIELDS'] = [
1117 'ID' => $comment['USER_ID'],
1118 'NAME' => $comment['~CREATED_BY_NAME'],
1119 'LAST_NAME' => $comment['~CREATED_BY_LAST_NAME'],
1120 'SECOND_NAME' => $comment['~CREATED_BY_SECOND_NAME'],
1121 'LOGIN' => $comment['~CREATED_BY_LOGIN'],
1122 'PERSONAL_GENDER' => $comment['~CREATED_BY_PERSONAL_GENDER'],
1123 'USE_THUMBNAIL_LIST' => 'N',
1124 'PATH_TO_SONET_MESSAGES_CHAT' => $params['PATH_TO_MESSAGES_CHAT'] ?? null,
1125 'PATH_TO_SONET_USER_PROFILE' => $params['PATH_TO_USER'] ?? null,
1126 'PATH_TO_VIDEO_CALL' => $params['PATH_TO_VIDEO_CALL'] ?? null,
1127 'DATE_TIME_FORMAT' => $params['DATE_TIME_FORMAT'],
1128 'SHOW_YEAR' => $params['SHOW_YEAR'],
1129 'CACHE_TYPE' => $params['CACHE_TYPE'] ?? null,
1130 'CACHE_TIME' => $params['CACHE_TIME'] ?? null,
1131 'NAME_TEMPLATE' => $params['NAME_TEMPLATE'].$suffix,
1132 'SHOW_LOGIN' => $params['SHOW_LOGIN'],
1133 'PATH_TO_CONPANY_DEPARTMENT' => $params['PATH_TO_CONPANY_DEPARTMENT'] ?? null,
1134 'INLINE' => 'Y',
1135 'EXTERNAL_AUTH_ID' => $comment['~CREATED_BY_EXTERNAL_AUTH_ID']
1136 ];
1137 if (
1138 isset($params['ENTRY_HAS_CRM_USER'])
1139 && $params['ENTRY_HAS_CRM_USER']
1140 && ModuleManager::isModuleInstalled('crm')
1141 )
1142 {
1143 if (isset($userCache[$comment['USER_ID']]))
1144 {
1145 $userFields = $userCache[$comment['USER_ID']];
1146 }
1147 else
1148 {
1149 $res = UserTable::getList([
1150 'filter' => [
1151 'ID' => (int)$comment['USER_ID']
1152 ],
1153 'select' => [ 'ID', 'UF_USER_CRM_ENTITY' ]
1154 ]);
1155 if ($userFields = $res->fetch())
1156 {
1157 $userCache[$userFields['ID']] = $userFields;
1158 }
1159 }
1160
1161 if (!empty($userFields))
1162 {
1163 $createdByFields['TOOLTIP_FIELDS'] = array_merge($createdByFields['TOOLTIP_FIELDS'], $userFields);
1164 }
1165 }
1166 }
1167 else
1168 {
1169 $createdByFields = [
1170 'FORMATTED' => Loc::getMessage("SONET_C73_CREATED_BY_ANONYMOUS")
1171 ];
1172 }
1173
1174 $userFields = [
1175 'NAME' => $comment['~USER_NAME'],
1176 'LAST_NAME' => $comment['~USER_LAST_NAME'],
1177 'SECOND_NAME' => $comment['~USER_SECOND_NAME'],
1178 'LOGIN' => $comment['~USER_LOGIN']
1179 ];
1180
1181 $temporaryParams = $params;
1182 $temporaryParams['AVATAR_SIZE'] = ($params['AVATAR_SIZE_COMMON'] ?? $params['AVATAR_SIZE']);
1183
1184 $commentEventFields = [
1185 'EVENT' => $comment,
1186 'LOG_DATE' => $comment['LOG_DATE'],
1187 'LOG_DATE_TS' => makeTimeStamp($comment['LOG_DATE']),
1188 'LOG_DATE_DAY' => convertTimeStamp(makeTimeStamp($comment['LOG_DATE']), 'SHORT'),
1189 'LOG_TIME_FORMAT' => $timeFormated,
1190 'LOG_DATETIME_FORMAT' => $dateTimeFormated,
1191 'TITLE_TEMPLATE' => '',
1192 'TITLE' => '',
1193 'TITLE_FORMAT' => '', // need to use url here
1194 'ENTITY_NAME' => (
1195 $comment["ENTITY_TYPE"] === SONET_ENTITY_GROUP
1196 ? $comment["GROUP_NAME"]
1197 : \CUser::formatName($params['NAME_TEMPLATE'], $userFields, $useLogin)
1198 ),
1199 'ENTITY_PATH' => $path2Entity,
1200 'CREATED_BY' => $createdByFields,
1201 'AVATAR_SRC' => \CSocNetLogTools::formatEvent_CreateAvatar($comment, $temporaryParams)
1202 ];
1203
1204 $commentEventData = \CSocNetLogTools::findLogCommentEventByID($comment['EVENT_ID']);
1205 $formattedFields = [];
1206
1207 if (
1208 is_array($commentEventData)
1209 && array_key_exists('CLASS_FORMAT', $commentEventData)
1210 && array_key_exists('METHOD_FORMAT', $commentEventData)
1211 )
1212 {
1213 $logFields = (
1214 ($params['USER_COMMENTS'] ?? '') === "Y"
1215 ? []
1216 : [
1217 'TITLE' => $comment['~LOG_TITLE'] ?? '',
1218 'URL' => $comment['~LOG_URL'] ?? '',
1219 'PARAMS' => $comment['~LOG_PARAMS'] ?? null
1220 ]
1221 );
1222
1223 $formattedFields = call_user_func([ $commentEventData['CLASS_FORMAT'], $commentEventData['METHOD_FORMAT'] ], $comment, $params, false, $logFields);
1224
1225 if (
1226 ($params['USE_COMMENTS'] ?? null) !== 'Y'
1227 && array_key_exists('CREATED_BY', $formattedFields)
1228 && isset($formattedFields['CREATED_BY']['TOOLTIP_FIELDS']))
1229 {
1230 $commentEventFields['CREATED_BY']['TOOLTIP_FIELDS'] = $formattedFields['CREATED_BY']['TOOLTIP_FIELDS'];
1231 }
1232 }
1233
1234 $commentAuxProvider = \Bitrix\Socialnetwork\CommentAux\Base::findProvider(
1235 [
1236 'POST_TEXT' => $comment['MESSAGE'],
1237 'SHARE_DEST' => $comment['SHARE_DEST'],
1238 'SOURCE_ID' => (int)$comment['SOURCE_ID'],
1239 'EVENT_ID' => $comment['EVENT_ID'],
1240 'RATING_TYPE_ID' => $comment['RATING_TYPE_ID'],
1241 ],
1242 [
1243 'eventId' => $comment['EVENT_ID']
1244 ]
1245 );
1246
1247 if ($commentAuxProvider)
1248 {
1249 $commentAuxProvider->setOptions([
1250 'suffix' => (!empty($params['COMMENT_ENTITY_SUFFIX']) ? $params['COMMENT_ENTITY_SUFFIX'] : ''),
1251 'logId' => $comment['LOG_ID'],
1252 'cache' => true,
1253 'parseBBCode' => true,
1254 'uf' => $comment['UF'],
1255 ]);
1256
1257 $formattedFields["EVENT_FORMATTED"]["FULL_MESSAGE_CUT"] = nl2br($commentAuxProvider->getText());
1258 }
1259 else
1260 {
1261 $message = (string)(
1262 is_array($formattedFields)
1263 && array_key_exists('EVENT_FORMATTED', $formattedFields)
1264 && array_key_exists('MESSAGE', $formattedFields['EVENT_FORMATTED'])
1265 ? $formattedFields['EVENT_FORMATTED']['MESSAGE']
1266 : $commentEventFields['EVENT']['MESSAGE']
1267 );
1268
1269 if ($message !== '')
1270 {
1271 $formattedFields['EVENT_FORMATTED']['FULL_MESSAGE_CUT'] = \CSocNetTextParser::closetags(htmlspecialcharsback($message));
1272 }
1273 }
1274
1275 $formattedFields['EVENT_FORMATTED']['DATETIME'] = (
1276 $commentEventFields['LOG_DATE_DAY'] == convertTimeStamp()
1277 ? $timeFormated
1278 : $dateTimeFormated
1279 );
1280 $commentEventFields['EVENT_FORMATTED'] = $formattedFields['EVENT_FORMATTED'];
1281 $commentEventFields['EVENT_FORMATTED']['URLPREVIEW'] = false;
1282
1283 if (
1284 isset($comment['UF']['UF_SONET_COM_URL_PRV'])
1285 && !empty($comment['UF']['UF_SONET_COM_URL_PRV']['VALUE'])
1286 )
1287 {
1288 $css = $APPLICATION->sPath2css;
1289 $js = $APPLICATION->arHeadScripts;
1290
1291 $urlPreviewText = ComponentHelper::getUrlPreviewContent($comment['UF']['UF_SONET_COM_URL_PRV'], array(
1292 'MOBILE' => 'N',
1293 'NAME_TEMPLATE' => $params['NAME_TEMPLATE'],
1294 'PATH_TO_USER' => $params['~PATH_TO_USER']
1295 ));
1296
1297 if (!empty($urlPreviewText))
1298 {
1299 $commentEventFields['EVENT_FORMATTED']['URLPREVIEW'] = true;
1300 $commentEventFields['EVENT_FORMATTED']['FULL_MESSAGE_CUT'] .= $urlPreviewText;
1301 }
1302
1303 $assets['CSS'] = array_merge($assets['CSS'], array_diff($APPLICATION->sPath2css, $css));
1304 $assets['JS'] = array_merge($assets['JS'], array_diff($APPLICATION->arHeadScripts, $js));
1305
1306 $commentEventFields['UF_HIDDEN']['UF_SONET_COM_URL_PRV'] = $comment['UF']['UF_SONET_COM_URL_PRV'];
1307 unset($comment['UF']['UF_SONET_COM_URL_PRV']);
1308 }
1309
1310 $commentEventFields['UF'] = $comment['UF'];
1311
1312 if (
1313 isset($commentEventFields['EVENT_FORMATTED'])
1314 && is_array($commentEventFields['EVENT_FORMATTED'])
1315 )
1316 {
1317 $fields2Cache = [
1318 'DATETIME',
1319 'MESSAGE',
1320 'FULL_MESSAGE_CUT',
1321 'ERROR_MSG',
1322 'URLPREVIEW',
1323 ];
1324 foreach ($commentEventFields['EVENT_FORMATTED'] as $field => $value)
1325 {
1326 if (!in_array($field, $fields2Cache, true))
1327 {
1328 unset($commentEventFields['EVENT_FORMATTED'][$field]);
1329 }
1330 }
1331 }
1332
1333 if (
1334 isset($commentEventFields['EVENT'])
1335 && is_array($commentEventFields['EVENT'])
1336 )
1337 {
1338 if (!empty($commentEventFields["EVENT"]["URL"]))
1339 {
1340 $commentEventFields['EVENT']['URL'] = str_replace(
1341 '#GROUPS_PATH#',
1342 Option::get('socialnetwork', 'workgroups_page', '/workgroups/', SITE_ID),
1343 $commentEventFields['EVENT']['URL']
1344 );
1345 }
1346
1347 $fields2Cache = [
1348 'ID',
1349 'SOURCE_ID',
1350 'EVENT_ID',
1351 'USER_ID',
1352 'LOG_DATE',
1353 'RATING_TYPE_ID',
1354 'RATING_ENTITY_ID',
1355 'URL',
1356 'SHARE_DEST'
1357 ];
1358
1359 if (
1360 (
1361 isset($params['MAIL'])
1362 && $params['MAIL'] === 'Y'
1363 )
1364 || (
1365 isset($params['COMMENT_ID'])
1366 && (int)$params['COMMENT_ID'] > 0
1367 )
1368 )
1369 {
1370 $fields2Cache[] = 'MESSAGE';
1371 }
1372
1373 foreach ($commentEventFields['EVENT'] as $field => $value)
1374 {
1375 if (!in_array($field, $fields2Cache, true))
1376 {
1377 unset($commentEventFields['EVENT'][$field]);
1378 }
1379 }
1380 }
1381
1382 if (
1383 isset($commentEventFields['CREATED_BY'])
1384 && is_array($commentEventFields['CREATED_BY'])
1385 )
1386 {
1387 $fields2Cache = [
1388 'TOOLTIP_FIELDS',
1389 'FORMATTED',
1390 'URL'
1391 ];
1392 foreach ($commentEventFields['CREATED_BY'] as $field => $value)
1393 {
1394 if (!in_array($field, $fields2Cache, true))
1395 {
1396 unset($commentEventFields['CREATED_BY'][$field]);
1397 }
1398 }
1399
1400 if (
1401 isset($commentEventFields['CREATED_BY']['TOOLTIP_FIELDS'])
1402 && is_array($commentEventFields['CREATED_BY']['TOOLTIP_FIELDS'])
1403 )
1404 {
1405 $fields2Cache = [
1406 'ID',
1407 'PATH_TO_SONET_USER_PROFILE',
1408 'NAME',
1409 'LAST_NAME',
1410 'SECOND_NAME',
1411 'PERSONAL_GENDER',
1412 'LOGIN',
1413 'EMAIL',
1414 'EXTERNAL_AUTH_ID',
1415 'UF_USER_CRM_ENTITY',
1416 'UF_DEPARTMENT'
1417 ];
1418 foreach ($commentEventFields['CREATED_BY']['TOOLTIP_FIELDS'] as $field => $value)
1419 {
1420 if (!in_array($field, $fields2Cache, true))
1421 {
1422 unset($commentEventFields['CREATED_BY']['TOOLTIP_FIELDS'][$field]);
1423 }
1424 }
1425 }
1426 }
1427
1428 foreach ($commentEventFields['EVENT'] as $key => $value)
1429 {
1430 if (mb_strpos($key, '~') === 0)
1431 {
1432 unset($commentEventFields['EVENT'][$key]);
1433 }
1434 }
1435
1436 return $commentEventFields;
1437 }
1438
1439 public static function formatStubEvent($arFields, $arParams): array
1440 {
1441 $arResult = [
1442 'HAS_COMMENTS' => 'N',
1443 'EVENT' => $arFields,
1444 'EVENT_FORMATTED' => [
1445 'TITLE' => '',
1446 'TITLE_24' => '',
1447 'URL' => '',
1448 'MESSAGE' => '',
1449 'SHORT_MESSAGE' => '',
1450 'IS_IMPORTANT' => false,
1451 'STUB' => true,
1452 ],
1453 ];
1454 $arResult['ENTITY']['FORMATTED']['NAME'] = '';
1455 $arResult['ENTITY']['FORMATTED']['URL'] = '';
1457
1458 $arFieldsTooltip = [
1459 'ID' => $arFields['USER_ID'],
1460 'NAME' => $arFields['~CREATED_BY_NAME'],
1461 'LAST_NAME' => $arFields['~CREATED_BY_LAST_NAME'],
1462 'SECOND_NAME' => $arFields['~CREATED_BY_SECOND_NAME'],
1463 'LOGIN' => $arFields['~CREATED_BY_LOGIN'],
1464 ];
1465 $arResult['CREATED_BY']['TOOLTIP_FIELDS'] = \CSocNetLog::FormatEvent_FillTooltip($arFieldsTooltip, $arParams);
1466
1467 return $arResult;
1468 }
1469
1470
1471}
global $APPLICATION
Определения include.php:80
static getString($length, $caseSensitive=false)
Определения random.php:76
Определения logentry.php:21
const STATUS_ERROR
Определения logentry.php:24
static getLogCommentRecord(array $comment, array $params, array &$assets)
Определения logentry.php:1027
__construct($component=null)
Определения logentry.php:28
const STATUS_DENIED
Определения logentry.php:23
getErrors()
Определения logentry.php:44
static replaceGroupPath($url='', $siteId=SITE_ID)
Определения logentry.php:642
static getUserFieldsFMetaData()
Определения logentry.php:657
onPrepareComponentParams($params=[])
Определения logentry.php:54
static addComment(array $params=[])
Определения logentry.php:106
configureActions()
Определения logentry.php:49
ErrorCollection $errorCollection
Определения logentry.php:26
static deleteComment(array $params=[])
Определения logentry.php:600
getErrorByCode($code)
Определения logentry.php:35
const STATUS_SUCCESS
Определения logentry.php:22
static getCommentsFullList(array $eventData, array &$params, array $options=[], array &$arResult=[])
Определения logentry.php:668
static formatStubEvent($arFields, $arParams)
Определения logentry.php:1439
static getUrlPreviewContent($uf, $params=array())
Определения componenthelper.php:1258
static addLiveComment($comment=[], $logEntry=[], $commentEvent=[], $params=[])
Определения componenthelper.php:2262
static canAddComment($logEntry=array(), $commentEvent=array())
Определения componenthelper.php:2183
static detectTags($fieldList, $codeList=array())
Определения util.php:251
static FormatEvent_CreateAvatar($arFields, $arParams, $source="CREATED_BY_")
Определения log.php:950
static FormatEvent_FillTooltip($arFields, $arParams)
Определения log.php:945
$arResult
Определения component.php:26
$arParams
Определения component.php:25
static makePathFromTemplate($template, $arParams=array())
Определения component_engine.php:355
static GetList($arOrder=Array("ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array(), $arParams=array())
Определения log.php:338
static FindLogCommentEventByLogEventID($log_event_id)
Определения log_tools.php:142
static closetags($html)
Определения functions.php:996
global $CACHE_MANAGER
Определения clear_component_cache.php:7
$options
Определения commerceml2.php:49
$arFields
Определения dblapprove.php:5
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
global $USER_FIELD_MANAGER
Определения attempt.php:6
$result
Определения get_property_values.php:14
$select
Определения iblock_catalog_list.php:194
$filter
Определения iblock_catalog_list.php:54
global $USER
Определения csv_new_run.php:40
$navParams
Определения csv_new_run.php:35
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
const FORMAT_DATETIME
Определения include.php:64
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения tools.php:5214
htmlspecialcharsback($str)
Определения tools.php:2693
AddEventHandler($FROM_MODULE_ID, $MESSAGE_ID, $CALLBACK, $SORT=100, $FULL_PATH=false)
Определения tools.php:5165
$GLOBALS['____1690880296']
Определения license.php:1
$message
Определения payment.php:8
$event
Определения prolog_after.php:141
return false
Определения prolog_main_admin.php:185
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if(empty($signedUserToken)) $key
Определения quickway.php:257
$comment
Определения template.php:15
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
const SONET_SUBSCRIBE_ENTITY_USER
Определения include.php:121
const SONET_ENTITY_GROUP
Определения include.php:117
const SONET_SUBSCRIBE_ENTITY_GROUP
Определения include.php:120
const SITE_ID
Определения sonet_set_content_view.php:12
$k
Определения template_pdf.php:567
$url
Определения iframe.php:7
$fields
Определения yandex_run.php:501