1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
log_tools.php
См. документацию.
1<?php
2
10
11IncludeModuleLangFile(__FILE__);
12
14{
15 public static function FindFeatureByEventID($event_id)
16 {
17 $feature = false;
18
19 $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
20 foreach ($arSocNetFeaturesSettings as $feature_tmp => $arFeature)
21 {
22 if (array_key_exists("subscribe_events", $arFeature))
23 {
24 if (array_key_exists($event_id, $arFeature["subscribe_events"]))
25 {
26 $feature = $feature_tmp;
27 break;
28 }
29
30 foreach ($arFeature["subscribe_events"] as $event_id_tmp => $arEventTmp)
31 {
32 if (
33 array_key_exists("COMMENT_EVENT", $arEventTmp)
34 && array_key_exists("EVENT_ID", $arEventTmp["COMMENT_EVENT"])
35 && $arEventTmp["COMMENT_EVENT"]["EVENT_ID"] == $event_id
36 )
37 {
38 $feature = $feature_tmp;
39 break;
40 }
41 }
42
43 if ($feature)
44 break;
45 }
46 }
47
48 return $feature;
49 }
50
51 public static function FindLogEventByID($event_id, $entity_type = false)
52 {
53 $arEvent = false;
54 $arSocNetLogEvents = CSocNetAllowed::GetAllowedLogEvents();
55
56 if (
57 array_key_exists($event_id, $arSocNetLogEvents)
58 && array_key_exists("ENTITIES", $arSocNetLogEvents[$event_id])
59 )
60 {
61 if (
62 !$entity_type
63 || ($entity_type && array_key_exists($entity_type, $arSocNetLogEvents[$event_id]["ENTITIES"]))
64 )
65 {
66 $arEvent = $arSocNetLogEvents[$event_id];
67 }
68 }
69
70 if (!$arEvent)
71 {
72 $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
73 foreach($arSocNetFeaturesSettings as $feature => $arFeature)
74 {
75 if (
76 array_key_exists("subscribe_events", $arFeature)
77 && array_key_exists($event_id, $arFeature["subscribe_events"])
78 && array_key_exists("ENTITIES", $arFeature["subscribe_events"][$event_id])
79
80 )
81 {
82 if (
83 !$entity_type
84 || ($entity_type && array_key_exists($entity_type, $arFeature["subscribe_events"][$event_id]["ENTITIES"]))
85 )
86 $arEvent = $arFeature["subscribe_events"][$event_id];
87 break;
88 }
89 }
90 }
91
92 return $arEvent;
93 }
94
95 public static function FindLogCommentEventByID($event_id)
96 {
97 $arEvent = false;
98 $arSocNetLogEvents = CSocNetAllowed::GetAllowedLogEvents();
99
100 foreach($arSocNetLogEvents as $event_id_tmp => $arEventTmp)
101 {
102 if (
103 array_key_exists("COMMENT_EVENT", $arEventTmp)
104 && array_key_exists("EVENT_ID", $arEventTmp["COMMENT_EVENT"])
105 && $event_id == $arEventTmp["COMMENT_EVENT"]["EVENT_ID"]
106 )
107 {
108 $arEvent = $arEventTmp["COMMENT_EVENT"];
109 break;
110 }
111 }
112
113 if (!$arEvent)
114 {
115 $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
116 foreach($arSocNetFeaturesSettings as $feature => $arFeature)
117 {
118 if (array_key_exists("subscribe_events", $arFeature))
119 {
120 foreach( $arFeature["subscribe_events"] as $event_id_tmp => $arEventTmp)
121 {
122 if (
123 array_key_exists("COMMENT_EVENT", $arEventTmp)
124 && array_key_exists("EVENT_ID", $arEventTmp["COMMENT_EVENT"])
125 && $event_id == $arEventTmp["COMMENT_EVENT"]["EVENT_ID"]
126 )
127 {
128 $arEvent = $arEventTmp["COMMENT_EVENT"];
129 break;
130 }
131 }
132
133 if ($arEvent)
134 break;
135 }
136 }
137 }
138
139 return $arEvent;
140 }
141
142 public static function FindLogCommentEventByLogEventID($log_event_id)
143 {
144 $arEvent = false;
145 $arSocNetLogEvents = CSocNetAllowed::GetAllowedLogEvents();
146
147 if (
148 array_key_exists($log_event_id, $arSocNetLogEvents)
149 && array_key_exists("COMMENT_EVENT", $arSocNetLogEvents[$log_event_id])
150 )
151 {
152 $arEvent = $arSocNetLogEvents[$log_event_id]["COMMENT_EVENT"];
153 }
154 else
155 {
156 $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
157 foreach ($arSocNetFeaturesSettings as $feature_id_tmp => $arFeatureTmp)
158 {
159 if (
160 array_key_exists("subscribe_events", $arFeatureTmp)
161 && array_key_exists($log_event_id, $arFeatureTmp["subscribe_events"])
162 && array_key_exists("COMMENT_EVENT", $arFeatureTmp["subscribe_events"][$log_event_id])
163 )
164 {
165 $arEvent = $arFeatureTmp["subscribe_events"][$log_event_id]["COMMENT_EVENT"];
166 break;
167 }
168 }
169 }
170
171 return $arEvent;
172 }
173
174 public static function FindLogEventByCommentID($event_id)
175 {
176 $arEvent = false;
177 $arSocNetLogEvents = CSocNetAllowed::GetAllowedLogEvents();
178
179 foreach ($arSocNetLogEvents as $event_id_tmp => $arEventTmp)
180 {
181 if (
182 array_key_exists("COMMENT_EVENT", $arEventTmp)
183 && isset($arEventTmp["COMMENT_EVENT"]["EVENT_ID"])
184 && $arEventTmp["COMMENT_EVENT"]["EVENT_ID"] == $event_id
185 )
186 {
187 $arEvent = $arEventTmp;
188 $arEvent["EVENT_ID"] = $event_id_tmp;
189 break;
190 }
191 }
192
193 if (!$arEvent)
194 {
195 $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
196 foreach ($arSocNetFeaturesSettings as $feature_id_tmp => $arFeatureTmp)
197 {
198 if (array_key_exists("subscribe_events", $arFeatureTmp))
199 {
200 foreach ($arFeatureTmp["subscribe_events"] as $event_id_tmp => $arEventTmp)
201 {
202 if (
203 array_key_exists("COMMENT_EVENT", $arEventTmp)
204 && isset($arEventTmp["COMMENT_EVENT"]["EVENT_ID"])
205 && $arEventTmp["COMMENT_EVENT"]["EVENT_ID"] == $event_id
206 )
207 {
208 $arEvent = $arEventTmp;
209 $arEvent["EVENT_ID"] = $event_id_tmp;
210 break;
211 }
212 }
213
214 if ($arEvent)
215 break;
216 }
217 }
218 }
219
220 return $arEvent;
221 }
222
223 public static function FindFullSetByEventID($event_id)
224 {
225 $bFound = false;
226 $arSocNetLogEvents = CSocNetAllowed::GetAllowedLogEvents();
227
228 foreach ($arSocNetLogEvents as $event_id_tmp => $arEventTmp)
229 {
230 if (
231 array_key_exists("FULL_SET", $arEventTmp)
232 && in_array($event_id, $arEventTmp["FULL_SET"])
233 )
234 {
235 $arFullSet = $arEventTmp["FULL_SET"];
236 $bFound = true;
237 break;
238 }
239 }
240
241 if (!$bFound)
242 {
243 $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
244 foreach($arSocNetFeaturesSettings as $arFeatureTmp)
245 {
246 if (array_key_exists("subscribe_events", $arFeatureTmp))
247 {
248 foreach($arFeatureTmp["subscribe_events"] as $event_id_tmp => $arEventTmp)
249 {
250 if (
251 array_key_exists("FULL_SET", $arEventTmp)
252 && in_array($event_id, $arEventTmp["FULL_SET"])
253 )
254 {
255 $arFullSet = $arEventTmp["FULL_SET"];
256 $bFound = true;
257 break;
258 }
259 }
260 if ($bFound)
261 break;
262 }
263 }
264 }
265
266 if (!$bFound)
267 {
268 $arFullSet = array($event_id);
269 }
270
271 return $arFullSet;
272 }
273
274 public static function FindFullSetEventIDByEventID($event_id)
275 {
276 $event_id_fullset = false;
277 $arSocNetLogEvents = CSocNetAllowed::GetAllowedLogEvents();
278
279 foreach ($arSocNetLogEvents as $event_id_tmp => $arEventTmp)
280 {
281 if (
282 array_key_exists("FULL_SET", $arEventTmp)
283 && is_array($arEventTmp["FULL_SET"])
284 && in_array($event_id, $arEventTmp["FULL_SET"])
285 )
286 {
287 $event_id_fullset = $event_id_tmp;
288 break;
289 }
290 }
291
292 if (!$event_id_fullset)
293 {
294 $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
295 foreach ($arSocNetFeaturesSettings as $feature_id_tmp => $arFeatureTmp)
296 {
297 if (array_key_exists("subscribe_events", $arFeatureTmp))
298 {
299 foreach ($arFeatureTmp["subscribe_events"] as $event_id_tmp => $arEventTmp)
300 {
301 if (
302 array_key_exists("FULL_SET", $arEventTmp)
303 && is_array($arEventTmp["FULL_SET"])
304 && in_array($event_id, $arEventTmp["FULL_SET"])
305 )
306 {
307 $event_id_fullset = $event_id_tmp;
308 break;
309 }
310 }
311 }
312 if ($event_id_fullset)
313 break;
314 }
315 }
316
317 return $event_id_fullset;
318 }
319
320 public static function ShowGroup($arEntityDesc, $strEntityURL, $arParams)
321 {
322 if ($strEntityURL <> '')
323 $name = "<a href=\"".$strEntityURL."\">".$arEntityDesc["NAME"]."</a>";
324 else
325 $name = $arEntityDesc["NAME"];
326
327 return $name;
328 }
329
330 public static function ShowUser($arEntityDesc, $strEntityURL, $arParams)
331 {
332 global $APPLICATION;
333
334 $name = $APPLICATION->IncludeComponent("bitrix:main.user.link",
335 '',
336 array(
337 "ID" => $arEntityDesc["ID"],
338 "HTML_ID" => "subscribe_list_".$arEntityDesc["ID"],
339 "NAME" => $arEntityDesc["~NAME"],
340 "LAST_NAME" => $arEntityDesc["~LAST_NAME"],
341 "SECOND_NAME" => $arEntityDesc["~SECOND_NAME"],
342 "LOGIN" => $arEntityDesc["~LOGIN"],
343 "USE_THUMBNAIL_LIST" => "N",
344 "PROFILE_URL" => $strEntityURL,
345 "PATH_TO_SONET_MESSAGES_CHAT" => $arParams["~PATH_TO_MESSAGES_CHAT"],
346 "PATH_TO_SONET_USER_PROFILE" => $arParams["~PATH_TO_USER"],
347 "PATH_TO_VIDEO_CALL" => $arParams["~PATH_TO_VIDEO_CALL"],
348 "SHOW_FIELDS" => $arParams["SHOW_FIELDS_TOOLTIP"],
349 "USER_PROPERTY" => $arParams["USER_PROPERTY_TOOLTIP"],
350 "DATE_TIME_FORMAT" => $arParams["DATE_TIME_FORMAT"],
351 "SHOW_YEAR" => $arParams["SHOW_YEAR"],
352 "CACHE_TYPE" => $arParams["CACHE_TYPE"],
353 "CACHE_TIME" => $arParams["CACHE_TIME"],
354 "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"],
355 "SHOW_LOGIN" => $arParams["SHOW_LOGIN"],
356 "PATH_TO_CONPANY_DEPARTMENT" => $arParams["~PATH_TO_CONPANY_DEPARTMENT"],
357 "DO_RETURN" => "Y",
358 "INLINE" => "Y",
359 ),
360 false,
361 array("HIDE_ICONS" => "Y")
362 );
363
364 return $name;
365 }
366
367 public static function HasLogEventCreatedBy($event_id)
368 {
369 $bFound = false;
370
371 $arEvent = CSocNetLogTools::FindLogEventByID($event_id);
372 if ($arEvent)
373 {
374 if (
375 isset($arEvent["HAS_CB"])
376 && $arEvent["HAS_CB"] === "Y"
377 )
378 {
379 $bFound = true;
380 }
381 }
382 else
383 {
384 $arEvent = CSocNetLogTools::FindLogCommentEventByID($event_id);
385 if ($arEvent)
386 {
387 $bFound = true;
388 }
389 }
390
391 return $bFound;
392 }
393
395 {
396 return [
397 "ID" => $arFields["ID"] ?? null,
398 "NAME" => $arFields["NAME"] ?? null,
399 "LAST_NAME" => $arFields["LAST_NAME"] ?? null,
400 "SECOND_NAME" => $arFields["SECOND_NAME"] ?? null,
401 "LOGIN" => $arFields["LOGIN"] ?? null,
402 "PERSONAL_GENDER" => $arFields["PERSONAL_GENDER"] ?? '',
403 "USE_THUMBNAIL_LIST" => "N",
404 "PATH_TO_SONET_MESSAGES_CHAT" => $arParams["PATH_TO_MESSAGES_CHAT"] ?? null,
405 "PATH_TO_SONET_USER_PROFILE" => $arParams["PATH_TO_USER"] ?? null,
406 "PATH_TO_VIDEO_CALL" => $arParams["PATH_TO_VIDEO_CALL"] ?? null,
407 "DATE_TIME_FORMAT" => $arParams["DATE_TIME_FORMAT"] ?? null,
408 "SHOW_YEAR" => $arParams["SHOW_YEAR"] ?? null,
409 "CACHE_TYPE" => $arParams["CACHE_TYPE"] ?? null,
410 "CACHE_TIME" => $arParams["CACHE_TIME"] ?? null,
411 "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"] ?? null,
412 "SHOW_LOGIN" => $arParams["SHOW_LOGIN"] ?? null,
413 "PATH_TO_CONPANY_DEPARTMENT" => $arParams["PATH_TO_CONPANY_DEPARTMENT"] ?? null,
414 "INLINE" => "Y"
415 ];
416 }
417
418 public static function FormatEvent_CreateAvatar($arFields, $arParams, $source = "CREATED_BY_", $site_id = SITE_ID)
419 {
420 if (
421 isset($arParams["AVATAR_SIZE_COMMON"])
422 && (int)$arParams["AVATAR_SIZE_COMMON"] > 0
423 )
424 {
425 $arParams["AVATAR_SIZE"] = (int)$arParams["AVATAR_SIZE_COMMON"];
426 }
427 elseif ((int) ($arParams["AVATAR_SIZE"] ?? null) <= 0)
428 {
429 $arParams["AVATAR_SIZE"] = 30;
430 }
431
432 if ($source <> '' && mb_substr($source, -1) !== "_")
433 {
434 $source .= "_";
435 }
436
437 $AvatarPath = false;
438
439 if ((int) ($arFields[$source . "PERSONAL_PHOTO"] ?? null) <= 0)
440 {
441 switch ($arFields[$source."PERSONAL_GENDER"] ?? null)
442 {
443 case "M":
444 $suffix = "male";
445 break;
446 case "F":
447 $suffix = "female";
448 break;
449 default:
450 $suffix = "unknown";
451 }
452 $arFields[$source."PERSONAL_PHOTO"] = COption::GetOptionInt("socialnetwork", "default_user_picture_".$suffix, false, $site_id);
453 }
454
455 if ((int)$arFields[$source . "PERSONAL_PHOTO"] > 0)
456 {
457 static $cachedAvatars = array();
458 if (empty($cachedAvatars[$arParams["AVATAR_SIZE"]][$arFields[$source."PERSONAL_PHOTO"]]))
459 {
460 $imageFile = CFile::GetFileArray($arFields[$source."PERSONAL_PHOTO"]);
461 if ($imageFile !== false)
462 {
463 $arFileTmp = CFile::ResizeImageGet(
464 $imageFile,
465 array("width" => $arParams["AVATAR_SIZE"], "height" => $arParams["AVATAR_SIZE"]),
466 BX_RESIZE_IMAGE_EXACT,
467 false
468 );
469 $AvatarPath = $arFileTmp["src"];
470 $cachedAvatars[$arParams["AVATAR_SIZE"]][$arFields[$source."PERSONAL_PHOTO"]] = $AvatarPath;
471 }
472 }
473 else
474 {
475 $AvatarPath = $cachedAvatars[$arParams["AVATAR_SIZE"]][$arFields[$source."PERSONAL_PHOTO"]];
476 }
477 }
478
479 return $AvatarPath;
480 }
481
483 {
484 if ((int)$arParams["AVATAR_SIZE"] <= 0)
485 {
486 $arParams["AVATAR_SIZE"] = 30;
487 }
488
489 $AvatarPath = false;
490
491 if ((int)$arFields["IMAGE_ID"] <= 0)
492 {
493 $arFields["IMAGE_ID"] = COption::GetOptionInt("socialnetwork", "default_group_picture", false, SITE_ID);
494 }
495
496 if ((int)$arFields["IMAGE_ID"] > 0)
497 {
498 $imageFile = CFile::GetFileArray($arFields["IMAGE_ID"]);
499 if ($imageFile !== false)
500 {
501 $arFileTmp = CFile::ResizeImageGet(
502 $imageFile,
503 array("width" => $arParams["AVATAR_SIZE"], "height" => $arParams["AVATAR_SIZE"]),
505 false
506 );
507 $AvatarPath = $arFileTmp["src"];
508 }
509 }
510
511 return $AvatarPath;
512 }
513
514 public static function FormatEvent_IsMessageShort($message, $short_message = false)
515 {
516 if (!$short_message)
517 {
518 return (
519 mb_strlen(HTMLToTxt($message)) < 1000
520 && (mb_strlen($message) - mb_strlen(HTMLToTxt(htmlspecialcharsback($message)))) <= 0
521 ? true
522 : false
523 );
524 }
525 else
526 return (
527 mb_strlen($short_message) < 1000
528 && (mb_strlen(htmlspecialcharsback($message)) - mb_strlen($short_message)) <= 0
529 ? true
530 : false
531 );
532 }
533
534 public static function FormatEvent_GetCreatedBy($arFields, $arParams, $bMail, $bFirstCaps = false)
535 {
536 $suffix = '';
537
538 if ((int)$arFields["USER_ID"] > 0)
539 {
540 $arCreatedBy = array();
541 if (
542 is_array($GLOBALS["arExtranetUserID"] ?? null)
543 && in_array($arFields["USER_ID"], $GLOBALS["arExtranetUserID"])
544 )
545 {
546 $arCreatedBy["IS_EXTRANET"] = "Y";
547 $arCreatedBy["IS_COLLAB"] = User::isCollaber((int)$arFields["USER_ID"]) ? "Y" : "N";
548 $suffix = (SITE_TEMPLATE_ID !== "bitrix24" && SITE_TEMPLATE_ID !== 'air' ? GetMessage("SONET_LOG_EXTRANET_SUFFIX") : "");
549 }
550 else
551 {
552 $arCreatedBy["IS_EXTRANET"] = "N";
553 }
554
555 if ($bMail)
556 {
557 $arCreatedBy["FORMATTED"] = (
558 $arFields["CREATED_BY_NAME"] <> ''
559 || $arFields["CREATED_BY_LAST_NAME"] <> ''
560 ? GetMessage("SONET_GL_EVENT_USER".($bFirstCaps ? "_CAPS" : ""))." ".$arFields["CREATED_BY_NAME"]." ".$arFields["CREATED_BY_LAST_NAME"].$suffix
561 : GetMessage("SONET_GL_EVENT_USER".($bFirstCaps ? "_CAPS" : ""))." ".$arFields["CREATED_BY_LOGIN"].$suffix
562 );
563 }
564 else
565 {
566 $arFieldsTooltip = array(
567 "ID" => $arFields["USER_ID"],
568 "NAME" => $arFields["~CREATED_BY_NAME"] ?? null,
569 "LAST_NAME" => $arFields["~CREATED_BY_LAST_NAME"] ?? null,
570 "SECOND_NAME" => $arFields["~CREATED_BY_SECOND_NAME"] ?? null,
571 "LOGIN" => $arFields["~CREATED_BY_LOGIN"] ?? null,
572 "PERSONAL_GENDER" => (!empty($arFields["~CREATED_BY_PERSONAL_GENDER"]) ? $arFields["~CREATED_BY_PERSONAL_GENDER"] : '')
573 );
574 $arParams["NAME_TEMPLATE"] = ($arParams["NAME_TEMPLATE"] ?? '') . $suffix;
575 $arCreatedBy["TOOLTIP_FIELDS"] = CSocNetLogTools::FormatEvent_FillTooltip($arFieldsTooltip, $arParams);
576 }
577 }
578 else
579 {
580 $arCreatedBy["FORMATTED"] = GetMessage("SONET_GL_EVENT_ANONYMOUS_USER".($bFirstCaps ? "_CAPS" : ""));
581 }
582
583 return $arCreatedBy;
584 }
585
586 public static function FormatEvent_GetEntity($arFields, $arParams, $bMail)
587 {
588 $arEntity = [];
589
590 if (
591 ($arFields["ENTITY_TYPE"] ?? null) == SONET_SUBSCRIBE_ENTITY_USER
592 && intval($arFields["ENTITY_ID"]) > 0
593 )
594 {
595 $suffix = (
596 is_array($GLOBALS["arExtranetUserID"] ?? null)
597 && in_array($arFields["ENTITY_ID"], $GLOBALS["arExtranetUserID"])
598 ? GetMessage("SONET_LOG_EXTRANET_SUFFIX")
599 : ""
600 );
601
602 if ($bMail)
603 {
604 if (
605 $arFields["USER_NAME"] <> ''
606 || $arFields["USER_LAST_NAME"] <> ''
607 )
608 $arEntity["FORMATTED"] = $arFields["USER_NAME"]." ".$arFields["USER_LAST_NAME"].$suffix;
609 else
610 $arEntity["FORMATTED"] = $arFields["USER_LOGIN"].$suffix;
611 $arEntity["TYPE_MAIL"] = GetMessage("SONET_GL_EVENT_ENTITY_U");
612 }
613 else
614 {
615 $arFieldsTooltip = array(
616 "ID" => $arFields["ENTITY_ID"],
617 "NAME" => $arFields["~USER_NAME"] ?? null,
618 "LAST_NAME" => $arFields["~USER_LAST_NAME"] ?? null,
619 "SECOND_NAME" => $arFields["~USER_SECOND_NAME"] ?? null,
620 "LOGIN" => $arFields["~USER_LOGIN"] ?? null,
621 );
622 $arParams["NAME_TEMPLATE"] = ($arParams["NAME_TEMPLATE"] ?? '') . $suffix;
623 $arEntity["TOOLTIP_FIELDS"] = CSocNetLogTools::FormatEvent_FillTooltip($arFieldsTooltip, $arParams);
624 $arEntity["FORMATTED"] = "";
625 }
626 }
627 elseif (
628 ($arFields["ENTITY_TYPE"] ?? null) == SONET_SUBSCRIBE_ENTITY_GROUP
629 && intval($arFields["ENTITY_ID"]) > 0
630 )
631 {
632 $suffix = (
633 (
634 is_array($GLOBALS["arExtranetGroupID"] ?? null)
635 && in_array($arFields["ENTITY_ID"], $GLOBALS["arExtranetGroupID"])
636 )
637 ? GetMessage("SONET_LOG_EXTRANET_SUFFIX")
638 : ""
639 );
640
641 if ($bMail)
642 {
643 $arEntity["FORMATTED"] = $arFields["GROUP_NAME"].$suffix;
644 $arEntity["TYPE_MAIL"] = GetMessage("SONET_GL_EVENT_ENTITY_G");
645 }
646 else
647 {
649
650 $arSocNetAllowedSubscribeEntityTypesDesc = CSocNetAllowed::GetAllowedEntityTypesDesc();
651 $arEntity["FORMATTED"]["TYPE_NAME"] = $arSocNetAllowedSubscribeEntityTypesDesc[$arFields["ENTITY_TYPE"]]["TITLE_ENTITY"];
652
653 $arEntity["FORMATTED"]["URL"] = $url;
654 $arEntity["FORMATTED"]["NAME"] = $arFields["GROUP_NAME"];
655 }
656 }
657
658 return $arEntity;
659 }
660
661 public static function FormatEvent_GetURL($arFields, $bAbsolute = false)
662 {
663 $url = false;
664 static $arSiteServerName;
665
666 if (!$arSiteServerName)
667 {
668 $arSiteServerName = array();
669 }
670
671 if ($arFields["URL"] <> '')
672 {
673 if (
674 !$bAbsolute
675 && (
676 mb_strpos($arFields["URL"], "http://") === 0
677 || mb_strpos($arFields["URL"], "https://") === 0
678 )
679 )
680 {
681 $bAbsolute = true;
682 }
683
684 if (!$bAbsolute)
685 {
686 if (
687 ($arFields["ENTITY_TYPE"] ?? null) == SONET_ENTITY_GROUP
688 && CModule::IncludeModule("extranet")
689 )
690 {
691 $server_name = "#SERVER_NAME#";
692 }
693 else
694 {
695 $rsLogSite = CSocNetLog::GetSite($arFields["ID"] ?? null);
696 $siteID = null;
697 if($arLogSite = $rsLogSite->Fetch())
698 {
699 $siteID = $arLogSite["LID"];
700 }
701
702 if (in_array($siteID, $arSiteServerName))
703 {
704 $server_name = $arSiteServerName[$siteID];
705 }
706 else
707 {
708 $rsSites = CSite::GetByID($siteID);
709 $arSite = $rsSites->Fetch();
710 $server_name = ($arSite["SERVER_NAME"] <> '' ? $arSite["SERVER_NAME"] : COption::GetOptionString("main", "server_name", $GLOBALS["SERVER_NAME"]));
711 $arSiteServerName[$siteID] = $server_name;
712 }
713 }
714
715 $protocol = (CMain::IsHTTPS() ? "https" : "http");
716 $url = $protocol."://".$server_name.$arFields["URL"];
717 }
718 else
719 {
720 $url = $arFields["URL"];
721 }
722 }
723
724 return $url;
725 }
726
727 public static function FormatEvent_Blog($arFields, $arParams, $bMail = false)
728 {
729 if (
730 $bMail
731 && $arFields["MAIL_LANGUAGE_ID"] <> ''
732 )
733 {
734 IncludeModuleLangFile(__FILE__, $arFields["MAIL_LANGUAGE_ID"]);
735 }
736
738 "EVENT" => $arFields,
741 "EVENT_FORMATTED" => array()
742 );
743 $arResult["CREATED_BY"]["ACTION_TYPE"] = "wrote";
744
745 if (!$bMail)
746 {
748 }
749
750 if ($bMail)
751 {
752 $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_".($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? "GROUP" : "USER")."_BLOG_POST_MAIL");
753
754 //if the title duplicates message, don't show it
755 $arFields["TITLE"] = (
756 mb_strpos($arFields["MESSAGE"], $arFields["TITLE"]) === 0
757 ? ""
758 : ' "'.$arFields["TITLE"].'"'
759 );
760 }
761 else
762 {
763 $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_BLOG_POST");
764 }
765
766 $post_tmp = (
767 !$bMail
768 && array_key_exists("URL", $arFields)
769 && $arFields["URL"] <> ''
770 ? '<a href="'.$arFields["URL"].'">'.$arFields["TITLE"].'</a>'
771 : $arFields["TITLE"]
772 );
773
774 $title = str_replace(
775 array("#TITLE#", "#ENTITY#", "#CREATED_BY#"),
776 array($post_tmp, $arResult["ENTITY"]["FORMATTED"], ($bMail ? $arResult["CREATED_BY"]["FORMATTED"] : "")),
777 $title_tmp
778 );
779
780 $title = trim(preg_replace('/\s+/', ' ', $title));
781
782 $arResult["EVENT_FORMATTED"] = array(
783 "TITLE" => $title,
784 "TITLE_24" => GetMessage("SONET_GL_EVENT_TITLE_BLOG_POST_24"),
785 "TITLE_24_2" => $arFields["TITLE"],
786 "MESSAGE" => ($bMail ? $arFields["TEXT_MESSAGE"] : $arFields["~MESSAGE"])
787 );
788
789 if (!$bMail)
790 {
791 if (
792 ($arParams["NEW_TEMPLATE"] ?? null) != "Y"
793 || $arFields["EVENT_ID"] == "idea"
794 )
795 {
796 if (CModule::IncludeModule("blog"))
797 {
798 $parserLog = new blogTextParser(false, $arParams["PATH_TO_SMILE"]);
799 $arImages = array();
800
801 $arBlogPost = CBlogPost::GetByID($arFields["SOURCE_ID"]);
802 if($arBlogPost["HAS_IMAGES"] != "N")
803 {
804 $res = CBlogImage::GetList(array("ID"=>"ASC"),array("POST_ID"=>$arBlogPost['ID'], "IS_COMMENT" => "N"));
805 while ($arImage = $res->Fetch())
806 {
807 $arImages[$arImage['ID']] = $arImage['FILE_ID'];
808 }
809 }
810 }
811 else
812 {
813 $parserLog = new logTextParser(false, $arParams["PATH_TO_SMILE"]);
814 }
815
816 $arAllow = array(
817 "HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y",
818 "IMG" => "Y",
819 "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "MULTIPLE_BR" => "N", "VIDEO" => "Y", "LOG_VIDEO" => "N", "SHORT_ANCHOR" => "Y"
820 );
821
822 if (get_class($parserLog) == "blogTextParser")
823 {
824 $arResult["EVENT_FORMATTED"]["MESSAGE"] = $parserLog->html_cut(
825 $parserLog->convert(
826 htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]),
827 true,
828 $arImages,
829 $arAllow
830 ),
831 10000
832 );
833 }
834 else
835 {
836 $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx(
837 $parserLog->convert(
838 htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]),
839 array(),
840 $arAllow
841 )
842 );
843 }
844
845
846 $arResult["EVENT_FORMATTED"]["MESSAGE"] = str_replace(
847 "#CUT#",
848 '<br><a href="'.$arFields["URL"].'">'.GetMessage("SONET_GL_EVENT_BLOG_MORE").'</a>',
849 htmlspecialcharsEx($arResult["EVENT_FORMATTED"]["MESSAGE"])
850 );
851
852 $arResult["EVENT_FORMATTED"]["IS_MESSAGE_SHORT"] = CSocNetLogTools::FormatEvent_IsMessageShort(
853 $arResult["EVENT_FORMATTED"]["MESSAGE"] ?? null,
854 $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] ?? null
855 );
856
857 if ($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP)
858 $arResult["EVENT_FORMATTED"]["DESTINATION"] = array(
859 array(
860 "STYLE" => "sonetgroups",
861 "TITLE" => $arResult["ENTITY"]["FORMATTED"]["NAME"],
862 "URL" => $arResult["ENTITY"]["FORMATTED"]["URL"],
863 )
864 );
865 }
866
867 $dbRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $arFields["ID"]));
868 while ($arRight = $dbRight->Fetch())
869 {
870 $arRights[] = $arRight["GROUP_CODE"];
871 }
872
873 if (($arParams["MOBILE"] ?? null) == "Y")
874 {
875 $arResult["EVENT_FORMATTED"]["DESTINATION"] = CSocNetLogTools::FormatDestinationFromRights($arRights, array_merge($arParams, array("CREATED_BY" => $arFields["USER_ID"], "USE_ALL_DESTINATION" => true)), $iMoreCount);
876 if (intval($iMoreCount) > 0)
877 {
878 $arResult["EVENT_FORMATTED"]["DESTINATION_MORE"] = $iMoreCount;
879 }
880 }
881 else
882 {
883 $arResult["EVENT_FORMATTED"]["DESTINATION_CODE"] = CSocNetLogTools::GetDestinationFromRights($arRights, array_merge($arParams, array("CREATED_BY" => $arFields["USER_ID"])));
884 }
885 }
886 else
887 {
889 if ($url <> '')
890 {
891 $arResult["EVENT_FORMATTED"]["URL"] = $url;
892 }
893 }
894
895 $arResult["HAS_COMMENTS"] = (intval($arFields["SOURCE_ID"]) > 0 ? "Y" : "N");
896
897 if (
898 $bMail
899 && $arFields["MAIL_LANGUAGE_ID"] <> ''
900 )
901 {
902 IncludeModuleLangFile(__FILE__, LANGUAGE_ID);
903 }
904
905 return $arResult;
906 }
907
908 public static function FormatComment_Blog($arFields, $arParams, $bMail = false, $arLog = array())
909 {
910 if (
911 $bMail
912 && $arFields["MAIL_LANGUAGE_ID"] <> ''
913 )
914 {
915 IncludeModuleLangFile(__FILE__, $arFields["MAIL_LANGUAGE_ID"]);
916 }
917
919 "EVENT_FORMATTED" => array(),
920 );
921
922 if ($bMail)
923 {
925 $arResult["CREATED_BY"]["ACTION_TYPE"] = "wrote";
927 }
928 elseif (($arParams["USE_COMMENT"] ?? null) != "Y")
930
931 if ($bMail)
932 $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_".($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? "GROUP" : "USER")."_BLOG_COMMENT_MAIL");
933 else
934 $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_BLOG_COMMENT");
935
936 if (
937 !$bMail
938 && array_key_exists("URL", $arLog)
939 && $arLog["URL"] <> ''
940 )
941 $post_tmp = '<a href="'.$arLog["URL"].'">'.$arLog["TITLE"].'</a>';
942 else
943 $post_tmp = $arLog["TITLE"] ?? '';
944
945 $title = str_replace(
946 array("#TITLE#", "#ENTITY#", "#CREATED_BY#"),
947 array($post_tmp, $arResult["ENTITY"]["FORMATTED"], ($bMail ? $arResult["CREATED_BY"]["FORMATTED"] : "")),
948 $title_tmp
949 );
950
951 $arResult["EVENT_FORMATTED"] = array(
952 "TITLE" => $title,
953 "MESSAGE" => ($bMail ? $arFields["TEXT_MESSAGE"] : $arFields["MESSAGE"])
954 );
955
956 if ($bMail)
957 {
959 if ($url <> '')
960 $arResult["EVENT_FORMATTED"]["URL"] = $url;
961 }
962 elseif (($arParams["NEW_TEMPLATE"] ?? null) != "Y")
963 {
964 $parserLog = new logTextParser(false, $arParams["PATH_TO_SMILE"]);
965 $arAllow = array(
966 "HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y",
967 "IMG" => "Y", "LOG_IMG" => "N",
968 "QUOTE" => "Y", "LOG_QUOTE" => "N",
969 "CODE" => "Y", "LOG_CODE" => "N",
970 "FONT" => "Y", "LOG_FONT" => "N",
971 "LIST" => "Y",
972 "SMILES" => "Y",
973 "NL2BR" => "N",
974 "MULTIPLE_BR" => "N",
975 "VIDEO" => "Y", "LOG_VIDEO" => "N"
976 );
977
978 $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut(
979 $parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow),
980 500
981 );
982
983 $arAllow = array(
984 "HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y",
985 "IMG" => "Y",
986 "QUOTE" => "Y",
987 "CODE" => "Y",
988 "FONT" => "Y",
989 "LIST" => "Y",
990 "SMILES" => "Y",
991 "NL2BR" => "N",
992 "VIDEO" => "Y",
993 "LOG_VIDEO" => "N",
994 "USERFIELDS" => $arFields["UF"] ?? [],
995 "USER" => "Y"
996 );
997 $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow));
998
999 $arResult["EVENT_FORMATTED"]["IS_MESSAGE_SHORT"] = CSocNetLogTools::FormatEvent_IsMessageShort($arResult["EVENT_FORMATTED"]["MESSAGE"], $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"]);
1000 }
1001 else
1002 {
1003 $parserLog = new logTextParser(false, $arParams["PATH_TO_SMILE"]);
1004 $parserLog->pathToUser = $arParams["PATH_TO_USER"];
1005
1006 $arAllow = array(
1007 "HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y",
1008 "IMG" => "Y",
1009 "QUOTE" => "Y",
1010 "CODE" => "Y",
1011 "FONT" => "Y",
1012 "LIST" => "Y",
1013 "SMILES" => "Y",
1014 "NL2BR" => "N",
1015 "VIDEO" => "Y",
1016 "LOG_VIDEO" => "N",
1017 "USERFIELDS" => $arFields["UF"],
1018 "USER" => "Y"
1019 );
1020 $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow));
1021 }
1022
1023 if (
1024 $bMail
1025 && $arFields["MAIL_LANGUAGE_ID"] <> ''
1026 )
1027 {
1028 IncludeModuleLangFile(__FILE__, LANGUAGE_ID);
1029 }
1030
1031 return $arResult;
1032 }
1033
1034 public static function FormatEvent_Microblog($arFields, $arParams, $bMail = false)
1035 {
1036 if (
1037 $bMail
1038 && $arFields["MAIL_LANGUAGE_ID"] <> ''
1039 )
1040 IncludeModuleLangFile(__FILE__, $arFields["MAIL_LANGUAGE_ID"]);
1041
1042 $arResult = array(
1043 "EVENT" => $arFields,
1046 "EVENT_FORMATTED" => array(),
1047 );
1048 $arResult["CREATED_BY"]["ACTION_TYPE"] = "wrote";
1049
1050 if (!$bMail)
1052
1053 if ($bMail)
1054 $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_".($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? "GROUP" : "USER")."_BLOG_POST_MICRO_MAIL");
1055 else
1056 {
1057 if($arFields["URL"] <> '')
1058 $title_tmp = "<a href=\"".$arFields["URL"]."\">".GetMessage("SONET_GL_EVENT_TITLE_BLOG_POST_MICRO")."</a>";
1059 else
1060 $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_BLOG_POST_MICRO");
1061 }
1062
1063 if (
1064 !$bMail
1065 && array_key_exists("URL", $arFields)
1066 && $arFields["URL"] <> ''
1067 )
1068 $post_tmp = '<a href="'.$arFields["URL"].'">'.$arFields["TITLE"].'</a>';
1069 else
1070 $post_tmp = $arFields["TITLE"];
1071
1072 $title = str_replace(
1073 array("#TITLE#", "#ENTITY#", "#CREATED_BY#"),
1074 array($post_tmp, $arResult["ENTITY"]["FORMATTED"], ($bMail ? $arResult["CREATED_BY"]["FORMATTED"] : "")),
1075 $title_tmp
1076 );
1077
1078 $arResult["EVENT_FORMATTED"] = array(
1079 "TITLE" => $title,
1080 "MESSAGE" => ($bMail ? $arFields["TEXT_MESSAGE"] : $arFields["MESSAGE"])
1081 );
1082
1083 if (!$bMail)
1084 {
1085 if ($arParams["NEW_TEMPLATE"] != "Y")
1086 {
1087 $parserLog = new logTextParser(false, $arParams["PATH_TO_SMILE"]);
1088 $arAllow = array(
1089 "HTML" => "Y", "ANCHOR" => "Y", "BIU" => "Y",
1090 "IMG" => "Y", "LOG_IMG" => "N",
1091 "QUOTE" => "Y", "LOG_QUOTE" => "N",
1092 "CODE" => "Y", "LOG_CODE" => "N",
1093 "FONT" => "Y", "LOG_FONT" => "N",
1094 "LIST" => "Y",
1095 "SMILES" => "Y",
1096 "NL2BR" => "N",
1097 "MULTIPLE_BR" => "N",
1098 "VIDEO" => "Y", "LOG_VIDEO" => "N"
1099 );
1100
1101 $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut(
1102 $parserLog->convert(htmlspecialcharsback(str_replace("#CUT#", "", $arResult["EVENT_FORMATTED"]["MESSAGE"])), array(), $arAllow),
1103 1000
1104 );
1105
1106 $arAllow = array("HTML" => "Y", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "MULTIPLE_BR" => "N", "VIDEO" => "Y", "LOG_VIDEO" => "N");
1107 $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow));
1108
1109 $arResult["EVENT_FORMATTED"]["MESSAGE"] = str_replace(
1110 "#CUT#",
1111 '<br><a href="'.$arFields["URL"].'">'.GetMessage("SONET_GL_EVENT_BLOG_MORE").'</a>',
1112 $arResult["EVENT_FORMATTED"]["MESSAGE"]
1113 );
1114
1115 $arResult["EVENT_FORMATTED"]["IS_MESSAGE_SHORT"] = CSocNetLogTools::FormatEvent_IsMessageShort($arResult["EVENT_FORMATTED"]["MESSAGE"], $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"]);
1116 }
1117 }
1118 else
1119 {
1121 if ($url <> '')
1122 $arResult["EVENT_FORMATTED"]["URL"] = $url;
1123 }
1124
1125 $arResult["HAS_COMMENTS"] = (intval($arFields["SOURCE_ID"]) > 0 ? "Y" : "N");
1126
1127 if (
1128 $bMail
1129 && $arFields["MAIL_LANGUAGE_ID"] <> ''
1130 )
1131 IncludeModuleLangFile(__FILE__, LANGUAGE_ID);
1132
1133 return $arResult;
1134 }
1135
1136 public static function FormatComment_Microblog($arFields, $arParams, $bMail = false, $arLog = array())
1137 {
1138 if (
1139 $bMail
1140 && $arFields["MAIL_LANGUAGE_ID"] <> ''
1141 )
1142 IncludeModuleLangFile(__FILE__, $arFields["MAIL_LANGUAGE_ID"]);
1143
1144 $arResult = array(
1145 "EVENT_FORMATTED" => array(),
1146 );
1147
1148 if ($bMail)
1149 {
1151 $arResult["CREATED_BY"]["ACTION_TYPE"] = "wrote";
1152 $arResult["ENTITY"] = CSocNetLogTools::FormatEvent_GetEntity($arLog, $arParams, $bMail);
1153 }
1154 elseif($arParams["USE_COMMENT"] != "Y")
1156
1157 if ($bMail)
1158 $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_".($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? "GROUP" : "USER")."_BLOG_COMMENT_MICRO_MAIL");
1159 else
1160 $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_BLOG_COMMENT_MICRO");
1161
1162 if (
1163 !$bMail
1164 && array_key_exists("URL", $arLog)
1165 && $arLog["URL"] <> ''
1166 )
1167 $post_tmp = '<a href="'.$arLog["URL"].'">'.$arLog["TITLE"].'</a>';
1168 else
1169 $post_tmp = $arLog["TITLE"];
1170
1171 $title = str_replace(
1172 array("#TITLE#", "#ENTITY#", "#CREATED_BY#"),
1173 array($post_tmp, $arResult["ENTITY"]["FORMATTED"], ($bMail ? $arResult["CREATED_BY"]["FORMATTED"] : "")),
1174 $title_tmp
1175 );
1176
1177 $arResult["EVENT_FORMATTED"] = array(
1178 "TITLE" => $title,
1179 "MESSAGE" => ($bMail ? $arFields["TEXT_MESSAGE"] : $arFields["MESSAGE"])
1180 );
1181
1182 if ($bMail)
1183 {
1184 $url = CSocNetLogTools::FormatEvent_GetURL(($arFields["URL"] <> '' ? $arFields : $arLog));
1185 if ($url <> '')
1186 $arResult["EVENT_FORMATTED"]["URL"] = $url;
1187 }
1188 elseif ($arParams["NEW_TEMPLATE"] != "Y")
1189 {
1190 $parserLog = new logTextParser(false, $arParams["PATH_TO_SMILE"]);
1191 $arAllow = array(
1192 "HTML" => "Y", "ANCHOR" => "Y", "BIU" => "Y",
1193 "IMG" => "Y", "LOG_IMG" => "N",
1194 "QUOTE" => "Y", "LOG_QUOTE" => "N",
1195 "CODE" => "Y", "LOG_CODE" => "N",
1196 "FONT" => "Y", "LOG_FONT" => "N",
1197 "LIST" => "Y",
1198 "SMILES" => "Y",
1199 "NL2BR" => "Y",
1200 "MULTIPLE_BR" => "N",
1201 "VIDEO" => "Y", "LOG_VIDEO" => "N"
1202 );
1203
1204 $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut(
1205 $parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow),
1206 500
1207 );
1208
1209 $arAllow = array("HTML" => "Y", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "LOG_VIDEO" => "N");
1210 $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow));
1211
1212 $arResult["EVENT_FORMATTED"]["IS_MESSAGE_SHORT"] = CSocNetLogTools::FormatEvent_IsMessageShort($arResult["EVENT_FORMATTED"]["MESSAGE"], $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"]);
1213 }
1214
1215 if (
1216 $bMail
1217 && $arFields["MAIL_LANGUAGE_ID"] <> ''
1218 )
1219 IncludeModuleLangFile(__FILE__, LANGUAGE_ID);
1220
1221 return $arResult;
1222 }
1223
1224 public static function FormatEvent_Forum($arFields, $arParams, $bMail = false)
1225 {
1226 if (
1227 $bMail
1228 && $arFields["MAIL_LANGUAGE_ID"] <> ''
1229 )
1230 {
1231 IncludeModuleLangFile(__FILE__, $arFields["MAIL_LANGUAGE_ID"]);
1232 }
1233
1234 $arResult = array(
1235 "EVENT" => $arFields,
1238 "EVENT_FORMATTED" => array(),
1239 );
1240
1241 if (!$bMail)
1242 {
1244 }
1245
1246 if ($arFields["PARAMS"] == "type=M")
1247 {
1248 $title_tmp = (
1249 $bMail
1250 ? GetMessage("SONET_GL_EVENT_TITLE_".($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? "GROUP" : "USER")."_FORUM_MESSAGE_MAIL")
1251 : GetMessage("SONET_GL_EVENT_TITLE_FORUM_MESSAGE")
1252 );
1253 }
1254 else
1255 {
1256 $title_tmp = (
1257 $bMail
1258 ? GetMessage("SONET_GL_EVENT_TITLE_".($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? "GROUP" : "USER")."_FORUM_TOPIC_MAIL")
1259 : GetMessage("SONET_GL_EVENT_TITLE_FORUM_TOPIC")
1260 );
1261 }
1262
1263 $topic_tmp = (
1264 !$bMail
1265 && array_key_exists("URL", $arFields)
1266 && $arFields["URL"] <> ''
1267 ? '<a href="'.$arFields["URL"].'">'.$arFields["TITLE"].'</a>'
1268 : $arFields["TITLE"]
1269 );
1270
1271 $title = str_replace(
1272 [
1273 "#TITLE#",
1274 "#ENTITY#",
1275 "#CREATED_BY#",
1276 ],
1277 [
1278 $topic_tmp,
1279 (is_string($arResult["ENTITY"]["FORMATTED"]) ? $arResult["ENTITY"]["FORMATTED"] : ''),
1280 ($bMail ? $arResult["CREATED_BY"]["FORMATTED"] : "")
1281 ],
1282 $title_tmp
1283 );
1284
1285 static $parser = false;
1286 if (CModule::IncludeModule("forum"))
1287 {
1288 if (!$parser)
1289 {
1290 $parser = new forumTextParser(LANGUAGE_ID);
1291 }
1292
1293 $parser->pathToUser = $arParams["PATH_TO_USER"];
1294 $parser->LAZYLOAD = (isset($arParams["LAZYLOAD"]) && $arParams["LAZYLOAD"] == "Y" ? "Y" : "N");
1295 $parser->bMobile = (($arParams["MOBILE"] ?? null) == "Y");
1296
1297 $arFields["FILES"] = CForumFiles::getByMessageID($arFields["SOURCE_ID"]);
1298 }
1299
1300 $arResult["EVENT_FORMATTED"] = array(
1301 "TITLE" => $title,
1302 "TITLE_24" => GetMessage("SONET_GL_EVENT_TITLE_FORUM_TOPIC_24"),
1303 "TITLE_24_2" => $arFields["TITLE"],
1304 "MESSAGE" => ($bMail ? $arFields["TEXT_MESSAGE"] : $arFields["~MESSAGE"]),
1305 "FILES" => (!!$arFields["FILES"] ? array_keys($arFields["FILES"]) : array())
1306 );
1307
1308 if (!$bMail)
1309 {
1310 static $parserLog = false;
1311 if (($arParams["MOBILE"] ?? null) != "Y")
1312 {
1313 if (!$parserLog)
1314 {
1315 $parserLog = new logTextParser(false, $arParams["PATH_TO_SMILE"]);
1316 }
1317
1318 $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut(
1319 $parserLog->convert(
1320 str_replace("#CUT#", "", $arResult["EVENT_FORMATTED"]["MESSAGE"]),
1321 array(),
1322 array(
1323 "HTML" => "Y",
1324 "ALIGN" => "Y",
1325 "ANCHOR" => "Y", "BIU" => "Y",
1326 "IMG" => "Y", "LOG_IMG" => "N",
1327 "QUOTE" => "Y", "LOG_QUOTE" => "N",
1328 "CODE" => "Y", "LOG_CODE" => "N",
1329 "FONT" => "Y", "LOG_FONT" => "N",
1330 "LIST" => "Y",
1331 "SMILES" => (
1332 !empty($arFields["ADDITIONAL_DATA"])
1333 && !empty($arFields["ADDITIONAL_DATA"]["USE_SMILES"])
1334 ? $arFields["ADDITIONAL_DATA"]["USE_SMILES"]
1335 : "Y"
1336 ),
1337 "NL2BR" => "N", "MULTIPLE_BR" => "N",
1338 "VIDEO" => "Y", "LOG_VIDEO" => "N"
1339 )),
1340 1000
1341 );
1342 }
1343
1344 $parser = (is_object($parser) ? $parser : (is_object($parserLog) ? $parserLog : new logTextParser(false, $arParams["PATH_TO_SMILE"])));
1345 if (get_class($parser) === "forumTextParser")
1346 {
1347 $parser->arUserfields = $arFields["UF"];
1348 $arResult["EVENT_FORMATTED"]["MESSAGE"] = $parser->convert(
1349 $arResult["EVENT_FORMATTED"]["MESSAGE"],
1350 array(
1351 "HTML" => "N",
1352 "ALIGN" => "Y",
1353 "ANCHOR" => "Y", "BIU" => "Y",
1354 "IMG" => "Y", "QUOTE" => "Y",
1355 "CODE" => "Y", "FONT" => "Y",
1356 "LIST" => "Y",
1357 "SMILES" => (
1358 !empty($arFields["ADDITIONAL_DATA"])
1359 && !empty($arFields["ADDITIONAL_DATA"]["USE_SMILES"])
1360 ? $arFields["ADDITIONAL_DATA"]["USE_SMILES"]
1361 : "Y"
1362 ),
1363 "NL2BR" => "Y", "MULTIPLE_BR" => "N",
1364 "VIDEO" => "Y", "LOG_VIDEO" => "N",
1365 "SHORT_ANCHOR" => "Y",
1366 "USERFIELDS" => $arFields["UF"]
1367 ),
1368 "html",
1369 $arResult["EVENT_FORMATTED"]["FILES"]);
1370 $arResult["EVENT_FORMATTED"]["PARSED_FILES"] = $parser->arFilesParsed;
1371 }
1372 else
1373 {
1374 $arResult["EVENT_FORMATTED"]["MESSAGE"] = $parser->convert(
1375 $arResult["EVENT_FORMATTED"]["MESSAGE"],
1376 array(),
1377 array(
1378 "HTML" => "N",
1379 "ALIGN" => "Y",
1380 "ANCHOR" => "Y", "BIU" => "Y",
1381 "IMG" => "Y", "QUOTE" => "Y",
1382 "CODE" => "Y", "FONT" => "Y",
1383 "LIST" => "Y", "SMILES" => "Y",
1384 "NL2BR" => "Y", "MULTIPLE_BR" => "N",
1385 "VIDEO" => "Y", "LOG_VIDEO" => "N",
1386 "SHORT_ANCHOR" => "Y",
1387 "USERFIELDS" => $arFields["UF"]
1388 )
1389 );
1390 }
1391
1392 $arResult["EVENT_FORMATTED"]["MESSAGE"] = str_replace(
1393 "#CUT#",
1394 '<br><a href="'.$arFields["URL"].'">'.GetMessage("SONET_GL_EVENT_BLOG_MORE").'</a>',
1395 htmlspecialcharsbx($arResult["EVENT_FORMATTED"]["MESSAGE"])
1396 );
1397
1398 if (
1399 ($arParams["MOBILE"] ?? null) !== "Y"
1400 && ($arParams["NEW_TEMPLATE"] ?? null) !== "Y"
1401 )
1402 {
1403 $arResult["EVENT_FORMATTED"]["IS_MESSAGE_SHORT"] = CSocNetLogTools::FormatEvent_IsMessageShort(
1404 $arResult["EVENT_FORMATTED"]["MESSAGE"],
1405 $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"]
1406 );
1407 }
1408
1409 if ($arFields["ENTITY_TYPE"] === SONET_SUBSCRIBE_ENTITY_GROUP)
1410 {
1411 $arResult["EVENT_FORMATTED"]["DESTINATION"] = array(
1412 array(
1413 "STYLE" => "sonetgroups",
1414 "TITLE" => $arResult["ENTITY"]["FORMATTED"]["NAME"],
1415 "URL" => $arResult["ENTITY"]["FORMATTED"]["URL"],
1416 "IS_EXTRANET" => (
1417 is_array($GLOBALS["arExtranetGroupID"] ?? null)
1418 && in_array($arFields["ENTITY_ID"], $GLOBALS["arExtranetGroupID"])
1419 )
1420 )
1421 );
1422 }
1423 }
1424 else
1425 {
1427 if ($url <> '')
1428 {
1429 $arResult["EVENT_FORMATTED"]["URL"] = $url;
1430 }
1431 }
1432
1433 $arResult["HAS_COMMENTS"] = ((int)$arFields["SOURCE_ID"] > 0 ? "Y" : "N");
1434
1435 if (
1436 $bMail
1437 && $arFields["MAIL_LANGUAGE_ID"] <> ''
1438 )
1439 {
1440 IncludeModuleLangFile(__FILE__, LANGUAGE_ID);
1441 }
1442
1443 return $arResult;
1444 }
1445
1446 public static function FormatComment_Forum($arFields, $arParams, $bMail = false, $arLog = array())
1447 {
1448 if (
1449 $bMail
1450 && $arFields["MAIL_LANGUAGE_ID"] <> ''
1451 )
1452 {
1453 IncludeModuleLangFile(__FILE__, $arFields["MAIL_LANGUAGE_ID"]);
1454 }
1455
1456 $arResult = array(
1457 "EVENT_FORMATTED" => array(),
1458 );
1459
1460 if ($bMail)
1461 {
1463 $arResult["ENTITY"] = CSocNetLogTools::FormatEvent_GetEntity($arLog, $arParams, $bMail);
1464 }
1465 elseif (($arParams["USE_COMMENT"] ?? null) !== "Y")
1466 {
1468 }
1469
1470 $title_tmp = (
1471 $bMail
1472 ? GetMessage("SONET_GL_EVENT_TITLE_".($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? "GROUP" : "USER")."_FORUM_MESSAGE_MAIL")
1473 : GetMessage("SONET_GL_EVENT_TITLE_FORUM_MESSAGE")
1474 );
1475
1476 $topic_tmp = (
1477 !$bMail
1478 && array_key_exists("URL", $arLog)
1479 && !empty($arLog["URL"])
1480 ? '<a href="'.$arLog["URL"].'">'.($arLog["TITLE"] ?? '').'</a>'
1481 : ($arLog["TITLE"] ?? '')
1482 );
1483
1484 $title = str_replace(
1485 [
1486 "#TITLE#",
1487 "#ENTITY#",
1488 "#CREATED_BY#"
1489 ],
1490 [
1491 $topic_tmp,
1492 is_string($arResult["ENTITY"]["FORMATTED"] ?? null) ? $arResult["ENTITY"]["FORMATTED"] : '',
1493 ($bMail ? $arResult["CREATED_BY"]["FORMATTED"] : "")
1494 ],
1495 $title_tmp
1496 );
1497
1498 static $parser = false;
1499 if (CModule::IncludeModule("forum"))
1500 {
1501 if (!$parser)
1502 {
1503 $parser = new forumTextParser(LANGUAGE_ID);
1504 }
1505
1506 $parser->pathToUser = $parser->userPath = $arParams["PATH_TO_USER"];
1507 $parser->bMobile = (($arParams["MOBILE"] ?? null) === "Y");
1508 $parser->LAZYLOAD = (isset($arParams["LAZYLOAD"]) && $arParams["LAZYLOAD"] === "Y" ? "Y" : "N");
1509
1510 $arFields["FILES"] = CForumFiles::GetByMessageID($arFields["SOURCE_ID"]);
1511 if (($arParams['MOBILE'] ?? null) !== 'Y')
1512 {
1513 if (!empty($arParams['IMAGE_MAX_WIDTH']))
1514 {
1515 $parser->imageWidth = (int)$arParams['IMAGE_MAX_WIDTH'];
1516 }
1517 if (!empty($arParams['IMAGE_MAX_HEIGHT']))
1518 {
1519 $parser->imageHeight = (int)$arParams['IMAGE_MAX_HEIGHT'];
1520 }
1521 }
1522 }
1523
1524 $arResult["EVENT_FORMATTED"] = array(
1525 "TITLE" => $title,
1526 "MESSAGE" => ($bMail ? $arFields["TEXT_MESSAGE"] : htmlspecialcharsBack($arFields["MESSAGE"])),
1527 "FILES" => (!!$arFields["FILES"] ? array_keys($arFields["FILES"]) : array())
1528 );
1529
1530 if (!$bMail)
1531 {
1532 if (($arParams["MOBILE"] ?? null) !== "Y")
1533 {
1534 static $parserLog = false;
1535 if (!$parserLog)
1536 {
1537 $parserLog = new logTextParser(false, ($arParams["PATH_TO_SMILE"] ?? null));
1538 }
1539 $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut(
1540 $parserLog->convert(
1541 $arResult["EVENT_FORMATTED"]["MESSAGE"],
1542 array(),
1543 array(
1544 "HTML" => "Y",
1545 "ALIGN" => "Y",
1546 "ANCHOR" => "Y", "BIU" => "Y",
1547 "IMG" => "Y", "LOG_IMG" => "N",
1548 "QUOTE" => "Y", "LOG_QUOTE" => "N",
1549 "CODE" => "Y", "LOG_CODE" => "N",
1550 "FONT" => "Y", "LOG_FONT" => "N",
1551 "LIST" => "Y",
1552 "SMILES" => (
1553 !empty($arFields["ADDITIONAL_DATA"])
1554 && !empty($arFields["ADDITIONAL_DATA"]["USE_SMILES"])
1555 ? $arFields["ADDITIONAL_DATA"]["USE_SMILES"]
1556 : "Y"
1557 ),
1558 "NL2BR" => "Y", "MULTIPLE_BR" => "N",
1559 "VIDEO" => "Y", "LOG_VIDEO" => "N",
1560 "USERFIELDS" => $arFields["UF"] ?? []
1561 )
1562 ),
1563 500
1564 );
1565 }
1566
1567 $parser = (is_object($parser) ? $parser : (is_object($parserLog) ? $parserLog : new logTextParser(false, $arParams["PATH_TO_SMILE"])));
1568 if (get_class($parser) === "forumTextParser")
1569 {
1570 $parser->arUserfields = $arFields["UF"] ?? [];
1571 $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parser->convert(
1572 $arResult["EVENT_FORMATTED"]["MESSAGE"],
1573 array(
1574 "HTML" => "N",
1575 "ALIGN" => "Y",
1576 "ANCHOR" => "Y", "BIU" => "Y",
1577 "IMG" => "Y", "QUOTE" => "Y",
1578 "CODE" => "Y", "FONT" => "Y",
1579 "LIST" => "Y",
1580 "SMILES" => (
1581 !empty($arFields["ADDITIONAL_DATA"])
1582 && !empty($arFields["ADDITIONAL_DATA"]["USE_SMILES"])
1583 ? $arFields["ADDITIONAL_DATA"]["USE_SMILES"]
1584 : "Y"
1585 ),
1586 "NL2BR" => "Y", "VIDEO" => "Y",
1587 "LOG_VIDEO" => "N", "SHORT_ANCHOR" => "Y",
1588 "USERFIELDS" => $arFields["UF"] ?? [],
1589 "USER" => "Y",
1590 "TAG" => "Y"
1591 ),
1592 "html",
1593 $arResult["EVENT_FORMATTED"]["FILES"]
1594 ));
1595 $arResult["EVENT_FORMATTED"]["PARSED_FILES"] = $parser->arFilesIDParsed;
1596 }
1597 else
1598 {
1599 $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parser->convert(
1600 $arResult["EVENT_FORMATTED"]["MESSAGE"],
1601 array(),
1602 array(
1603 "HTML" => "N",
1604 "ALIGN" => "Y",
1605 "ANCHOR" => "Y", "BIU" => "Y",
1606 "IMG" => "Y", "QUOTE" => "Y",
1607 "CODE" => "Y", "FONT" => "Y",
1608 "LIST" => "Y",
1609 "SMILES" => (
1610 !empty($arFields["ADDITIONAL_DATA"])
1611 && !empty($arFields["ADDITIONAL_DATA"]["USE_SMILES"])
1612 ? $arFields["ADDITIONAL_DATA"]["USE_SMILES"]
1613 : "Y"
1614 ),
1615 "NL2BR" => "Y", "VIDEO" => "Y",
1616 "LOG_VIDEO" => "N", "SHORT_ANCHOR" => "Y",
1617 "USERFIELDS" => $arFields["UF"],
1618 "TAG" => "Y"
1619 )
1620 ));
1621 }
1622
1623 if (
1624 ($arParams["MOBILE"] ?? null) !== "Y"
1625 && (!isset($arParams["NEW_TEMPLATE"]) || $arParams["NEW_TEMPLATE"] !== "Y")
1626 )
1627 {
1628 $arResult["EVENT_FORMATTED"]["IS_MESSAGE_SHORT"] = CSocNetLogTools::FormatEvent_IsMessageShort($arResult["EVENT_FORMATTED"]["MESSAGE"], $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"]);
1629 }
1630 }
1631 else
1632 {
1633 if ($arFields["URL"] <> '')
1634 {
1635 $url = $arFields["URL"];
1636 }
1637 elseif (
1638 $arLog["PARAMS"] <> ''
1639 && unserialize($arLog["PARAMS"], [ 'allowed_classes' => false ])
1640 )
1641 {
1642 $arTmp = unserialize($arLog["PARAMS"], [ 'allowed_classes' => false ]);
1643 if (
1644 array_key_exists("PATH_TO_MESSAGE", $arTmp)
1645 && $arTmp["PATH_TO_MESSAGE"] <> ''
1646 )
1647 {
1648 $url = CComponentEngine::MakePathFromTemplate($arTmp["PATH_TO_MESSAGE"], array("MID" => $arFields["SOURCE_ID"]));
1649 }
1650 }
1651
1652 $url = (
1653 $url <> ''
1654 ? CSocNetLogTools::FormatEvent_GetURL(array("ID" => $arLog["ID"], "URL" => $url))
1656 );
1657
1658 if ($url <> '')
1659 {
1660 $arResult["EVENT_FORMATTED"]["URL"] = $url;
1661 }
1662 }
1663
1664 if (
1665 $bMail
1666 && $arFields["MAIL_LANGUAGE_ID"] <> ''
1667 )
1668 {
1669 IncludeModuleLangFile(__FILE__, LANGUAGE_ID);
1670 }
1671
1672 return $arResult;
1673 }
1674
1675 public static function FormatEvent_Photo($arFields, $arParams, $bMail = false)
1676 {
1677 global $CACHE_MANAGER;
1678
1679 static $arAlbumName = array();
1680
1681 if (
1682 $bMail
1683 && $arFields["MAIL_LANGUAGE_ID"] <> ''
1684 )
1685 IncludeModuleLangFile(__FILE__, $arFields["MAIL_LANGUAGE_ID"]);
1686
1687 $arResult = array(
1688 "EVENT" => $arFields,
1691 "EVENT_FORMATTED" => array(),
1692 );
1693
1694 if (!$bMail)
1696
1697 $count = false;
1698 if ($arFields["PARAMS"] <> '')
1699 {
1700 $arTmp = unserialize(htmlspecialcharsback($arFields["PARAMS"]), [ 'allowed_classes' => false ]);
1701 if ($arTmp)
1702 {
1703 $count = $arTmp["COUNT"];
1704 }
1705 else
1706 {
1707 $arFieldsParams = explode("&", $arFields["PARAMS"]);
1708 if (is_array($arFieldsParams) && count($arFieldsParams) > 0)
1709 {
1710 foreach ($arFieldsParams as $tmp)
1711 {
1712 list($key, $value) = explode("=", $tmp);
1713 if ($key === "count")
1714 {
1715 $count = $value;
1716 break;
1717 }
1718 }
1719 }
1720 }
1721 }
1722
1723 if (!$count)
1724 $count_tmp = "";
1725 else
1726 $count_tmp = intval($count);
1727
1728 $album_default = GetMessage("SONET_GL_EVENT_TITLE_PHOTO_ALBUM");
1729 $album_default_24 = GetMessage("SONET_GL_EVENT_TITLE_PHOTO_ALBUM_24");
1730 $album_default_24_mobile = GetMessage("SONET_GL_EVENT_TITLE_PHOTO_ALBUM_24_MOBILE");
1731
1732 $section_name = false;
1733 if (
1734 intval($arFields["SOURCE_ID"]) > 0
1735 && CModule::IncludeModule('iblock')
1736 )
1737 {
1738 if (array_key_exists($arFields["SOURCE_ID"], $arAlbumName))
1739 $section_name = $arAlbumName[$arFields["SOURCE_ID"]];
1740 else
1741 {
1742 $rsSection = CIBlockSection::GetByID($arFields["SOURCE_ID"]);
1743 if ($arSection = $rsSection->GetNext())
1744 {
1745 $section_name = $arSection["NAME"];
1746 $arAlbumName[$arFields["SOURCE_ID"]] = $arSection["NAME"];
1747
1748 if(defined("BX_COMP_MANAGED_CACHE"))
1749 {
1750 $CACHE_MANAGER->RegisterTag("iblock_id_".$arSection["IBLOCK_ID"]);
1751 }
1752 }
1753 }
1754 }
1755
1756 if (
1757 !$bMail
1758 && array_key_exists("URL", $arFields)
1759 && $arFields["URL"] <> ''
1760 )
1761 {
1762 $album_tmp = ($section_name ? $album_default.' <a href="'.$arFields["URL"].'">'.$section_name.'</a>' : '<a href="'.$arFields["URL"].'">'.$album_default.'</a>');
1763 $album_tmp_24 = ($section_name ? $album_default_24.': <a href="'.$arFields["URL"].'">'.$section_name.'</a>' : '<a href="'.$arFields["URL"].'">'.$album_default_24.'</a>');
1764 $album_tmp_24_mobile = ($section_name ? $album_default_24_mobile.': '.$section_name : $album_default_24_mobile);
1765 }
1766 else
1767 {
1768 $album_tmp = ($section_name ? $album_default.' '.$section_name : $album_default);
1769 $album_tmp_24 = ($section_name ? $album_default_24.': ' . $section_name : $album_default_24);
1770 $album_tmp_24_mobile = ($section_name ? $album_default_24_mobile.': '.$section_name : $album_default_24_mobile);
1771 }
1772
1773 $title_tmp = '';
1774 if ($bMail)
1775 $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_".($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? "GROUP" : "USER")."_PHOTO_MAIL");
1776 elseif (($arParams["MOBILE"] ?? null) == "Y")
1777 $title_tmp_24 = GetMessage("SONET_GL_EVENT_TITLE_PHOTO_24_MOBILE");
1778 else
1779 {
1780 $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_PHOTO");
1781 switch ($arFields["CREATED_BY_PERSONAL_GENDER"])
1782 {
1783 case "M":
1784 $suffix = "_M";
1785 break;
1786 case "F":
1787 $suffix = "_F";
1788 break;
1789 default:
1790 $suffix = "";
1791 }
1792 $title_tmp_24 = GetMessage("SONET_GL_EVENT_TITLE_PHOTO_24".$suffix);
1793 }
1794
1795 $title = str_replace(
1796 [
1797 "#ALBUM#",
1798 "#COUNT#",
1799 "#ENTITY#",
1800 "#CREATED_BY#"
1801 ],
1802 [
1803 $album_tmp,
1804 $count_tmp,
1805 (is_string($arResult["ENTITY"]["FORMATTED"]) ? $arResult["ENTITY"]["FORMATTED"] : ''),
1806 ($bMail ? $arResult["CREATED_BY"]["FORMATTED"] : "")
1807 ],
1808 $title_tmp
1809 );
1810
1811 if (!$bMail)
1812 {
1813 $title_24 = str_replace(
1814 [
1815 "#ALBUM#",
1816 "#COUNT#",
1817 "#ENTITY#",
1818 "#CREATED_BY#"
1819 ],
1820 [
1821 (($arParams["MOBILE"] ?? null) === "Y" ? $album_tmp_24_mobile : $album_tmp_24),
1822 $count_tmp,
1823 (is_string($arResult["ENTITY"]["FORMATTED"]) ? $arResult["ENTITY"]["FORMATTED"] : ''),
1824 ($bMail ? $arResult["CREATED_BY"]["FORMATTED"] : "")
1825 ],
1826 $title_tmp_24
1827 );
1828 }
1829
1830 $arResult["EVENT_FORMATTED"] = (
1831 (($arParams["MOBILE"] ?? null) === "Y")
1832 ? [
1833 "TITLE_24" => $title_24,
1834 "MESSAGE" => "",
1835 ]
1836 : [
1837 "TITLE" => $title,
1838 "TITLE_24" => $title_24,
1839 "MESSAGE" => "",
1840 "IS_MESSAGE_SHORT" => true,
1841 ]
1842 );
1843
1844 if ($bMail)
1845 {
1847 if ($url <> '')
1848 {
1849 $arResult["EVENT_FORMATTED"]["URL"] = $url;
1850 }
1851 }
1852 else
1853 {
1854 $dbRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $arFields["ID"]));
1855 while ($arRight = $dbRight->Fetch())
1856 {
1857 $arRights[] = $arRight["GROUP_CODE"];
1858 }
1859
1860 $arResult["EVENT_FORMATTED"]["DESTINATION"] = CSocNetLogTools::FormatDestinationFromRights($arRights, array_merge($arParams, array("CREATED_BY" => $arFields["USER_ID"])), $iMoreCount);
1861 if (intval($iMoreCount) > 0)
1862 {
1863 $arResult["EVENT_FORMATTED"]["DESTINATION_MORE"] = $iMoreCount;
1864 }
1865 }
1866
1867 if (
1868 $bMail
1869 && $arFields["MAIL_LANGUAGE_ID"] <> ''
1870 )
1871 {
1872 IncludeModuleLangFile(__FILE__, LANGUAGE_ID);
1873 }
1874
1875 return $arResult;
1876 }
1877
1878 public static function FormatEvent_PhotoPhoto($arFields, $arParams, $bMail = false)
1879 {
1880 if (
1881 $bMail
1882 && $arFields["MAIL_LANGUAGE_ID"] <> ''
1883 )
1884 IncludeModuleLangFile(__FILE__, $arFields["MAIL_LANGUAGE_ID"]);
1885
1886 $arResult = array(
1887 "EVENT" => $arFields,
1890 "EVENT_FORMATTED" => array(),
1891 );
1892
1894
1895 $album_tmp = GetMessage("SONET_GL_EVENT_TITLE_PHOTO_ALBUM");
1896 if ($arFields["PARAMS"] <> '')
1897 {
1898 $arTmp = unserialize(htmlspecialcharsback($arFields["PARAMS"]), [ 'allowed_classes' => false ]);
1899 if ($arTmp && array_key_exists("SECTION_NAME", $arTmp))
1900 {
1901 if (
1902 !$bMail
1903 && array_key_exists("SECTION_URL", $arTmp)
1904 && $arTmp["SECTION_URL"] <> ''
1905 )
1906 {
1907 if (
1908 $arFields["ENTITY_TYPE"] === SONET_ENTITY_GROUP
1909 && (
1910 ModuleManager::isModuleInstalled('extranet')
1911 || (mb_strpos($arTmp["SECTION_URL"], "#GROUPS_PATH#") !== false)
1912 )
1913 )
1914 {
1915 $arTmp["SECTION_URL"] = str_replace("#GROUPS_PATH#", COption::GetOptionString("socialnetwork", "workgroups_page", "/workgroups/", SITE_ID), $arTmp["SECTION_URL"]);
1916 }
1917
1918 $album_tmp .= (
1919 ($arParams["MOBILE"] ?? null) === "Y"
1920 ? ' '.htmlspecialcharsbx($arTmp["SECTION_NAME"])
1921 : ' <a href="'.$arTmp["SECTION_URL"].'">'.htmlspecialcharsbx($arTmp["SECTION_NAME"]).'</a>'
1922 );
1923 }
1924 else
1925 {
1926 $album_tmp .= ' '.htmlspecialcharsbx($arTmp["SECTION_NAME"]);
1927 }
1928 }
1929 }
1930
1931 $title = str_replace(
1932 array("#ALBUM#", "#ENTITY#", "#CREATED_BY#"),
1933 array($album_tmp, $arResult["ENTITY"]["FORMATTED"], ($bMail ? $arResult["CREATED_BY"]["FORMATTED"] : "")),
1934 (
1935 ($arParams["MOBILE"] ?? null) === "Y"
1936 ? GetMessage("SONET_GL_EVENT_TITLE_PHOTOPHOTO_MOBILE")
1937 : GetMessage("SONET_GL_EVENT_TITLE_PHOTOPHOTO")
1938 )
1939 );
1940
1941 $arResult["EVENT_FORMATTED"] = (
1942 ($arParams["MOBILE"] ?? null) === "Y"
1943 ? [
1944 "TITLE" => $title,
1945 "MESSAGE" => "",
1946 ]
1947 : [
1948 "TITLE" => $title,
1949 "MESSAGE" => $arFields["MESSAGE"],
1950 "IS_MESSAGE_SHORT" => "Y",
1951 ]
1952 );
1953
1954 if (!$bMail)
1955 {
1956 $dbRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $arFields["ID"]));
1957 while ($arRight = $dbRight->Fetch())
1958 {
1959 $arRights[] = $arRight["GROUP_CODE"];
1960 }
1961
1962 $arResult["EVENT_FORMATTED"]["DESTINATION"] = CSocNetLogTools::FormatDestinationFromRights($arRights, array_merge($arParams, array("CREATED_BY" => $arFields["USER_ID"])), $iMoreCount);
1963 if ((int)$iMoreCount > 0)
1964 {
1965 $arResult["EVENT_FORMATTED"]["DESTINATION_MORE"] = $iMoreCount;
1966 }
1967 }
1968
1969 if (
1970 $bMail
1971 && $arFields["MAIL_LANGUAGE_ID"] <> ''
1972 )
1973 IncludeModuleLangFile(__FILE__, LANGUAGE_ID);
1974
1975 return $arResult;
1976 }
1977
1978 public static function FormatComment_Photo($arFields, $arParams, $bMail = false, $arLog = array())
1979 {
1980 if (
1981 $bMail
1982 && $arFields["MAIL_LANGUAGE_ID"] <> ''
1983 )
1984 IncludeModuleLangFile(__FILE__, $arFields["MAIL_LANGUAGE_ID"]);
1985
1986 $arResult = [
1987 "EVENT_FORMATTED" => [],
1988 ];
1989
1990 if ($bMail)
1991 {
1993 $arResult["ENTITY"] = CSocNetLogTools::FormatEvent_GetEntity($arLog, $arParams, $bMail);
1994 }
1995 elseif ($arParams["USE_COMMENT"] !== "Y")
1996 {
1998 }
1999
2000 $photo_tmp = (
2001 !$bMail
2002 && array_key_exists("URL", $arLog)
2003 && $arLog["URL"] <> ''
2004 ? '<a href="'.$arLog["URL"].'">'.$arLog["TITLE"].'</a>'
2005 : $arLog["TITLE"]
2006 );
2007
2008 $album_name = "";
2009 if (
2010 array_key_exists("PARAMS", $arLog)
2011 && $arLog["PARAMS"] <> ''
2012 )
2013 {
2014 $arTmp = unserialize($arLog["PARAMS"], [ 'allowed_classes' => false ]);
2015 if ($arTmp && array_key_exists("SECTION_NAME", $arTmp))
2016 $album_name = $arTmp["SECTION_NAME"];
2017 }
2018
2019 $title_tmp = (
2020 $bMail
2021 ? GetMessage("SONET_GL_EVENT_TITLE_".($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? "GROUP" : "USER")."_PHOTO_COMMENT_MAIL")
2022 : GetMessage("SONET_GL_EVENT_TITLE_PHOTO_COMMENT")
2023 );
2024
2025 $title = str_replace(
2026 array("#TITLE#", "#ENTITY#", "#CREATED_BY#", "#ALBUM#"),
2027 array($photo_tmp, $arResult["ENTITY"]["FORMATTED"], ($bMail ? $arResult["CREATED_BY"]["FORMATTED"] : ""), $album_name),
2028 $title_tmp
2029 );
2030
2031 $arResult["EVENT_FORMATTED"] = array(
2032 "TITLE" => ($bMail || $arParams["USE_COMMENT"] !== "Y" ? $title : ""),
2033 "MESSAGE" => ($bMail ? $arFields["TEXT_MESSAGE"] : $arFields["MESSAGE"])
2034 );
2035
2036 if ($bMail)
2037 {
2039 if ($url <> '')
2040 $arResult["EVENT_FORMATTED"]["URL"] = $url;
2041 }
2042 else
2043 {
2044 static $parserLog = false;
2045 if (CModule::IncludeModule("forum"))
2046 {
2047 $arAllow = array(
2048 "HTML" => "Y", "ANCHOR" => "Y", "BIU" => "Y",
2049 "IMG" => "Y", "LOG_IMG" => "N",
2050 "QUOTE" => "Y", "LOG_QUOTE" => "N",
2051 "CODE" => "Y", "LOG_CODE" => "N",
2052 "FONT" => "Y", "LOG_FONT" => "N",
2053 "LIST" => "Y",
2054 "SMILES" => "Y",
2055 "NL2BR" => "Y",
2056 "MULTIPLE_BR" => "N",
2057 "VIDEO" => "Y", "LOG_VIDEO" => "N",
2058 "USERFIELDS" => $arFields["UF"],
2059 "USER" => ($arParams["IM"] == "Y" ? "N" : "Y")
2060 );
2061
2062 if (!$parserLog)
2063 $parserLog = new forumTextParser(LANGUAGE_ID);
2064
2065 $parserLog->arUserfields = $arFields["UF"] ?? [];
2066 $parserLog->pathToUser = $parserLog->userPath = $arParams["PATH_TO_USER"];
2067 $parserLog->bMobile = (($arParams["MOBILE"] ?? null) === "Y");
2068 $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), $arAllow));
2069 $arResult['EVENT_FORMATTED']['MESSAGE'] = Mention::clear($arResult['EVENT_FORMATTED']['MESSAGE']);
2070 }
2071 else
2072 {
2073 $arAllow = array(
2074 "HTML" => "Y", "ANCHOR" => "Y", "BIU" => "Y",
2075 "IMG" => "Y", "LOG_IMG" => "N",
2076 "QUOTE" => "Y", "LOG_QUOTE" => "N",
2077 "CODE" => "Y", "LOG_CODE" => "N",
2078 "FONT" => "Y", "LOG_FONT" => "N",
2079 "LIST" => "Y",
2080 "SMILES" => "Y",
2081 "NL2BR" => "Y",
2082 "MULTIPLE_BR" => "N",
2083 "VIDEO" => "Y", "LOG_VIDEO" => "N"
2084 );
2085
2086 if (!$parserLog)
2087 $parserLog = new logTextParser(false, $arParams["PATH_TO_SMILE"]);
2088
2089 $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow));
2090 }
2091
2092 if (
2093 ($arParams["MOBILE"] ?? null) != "Y"
2094 && $arParams["NEW_TEMPLATE"] != "Y"
2095 )
2096 {
2097 if (CModule::IncludeModule("forum"))
2098 $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut(
2099 $parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), $arAllow),
2100 500
2101 );
2102 else
2103 $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"] = $parserLog->html_cut(
2104 $parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow),
2105 500
2106 );
2107
2108 $arResult["EVENT_FORMATTED"]["IS_MESSAGE_SHORT"] = CSocNetLogTools::FormatEvent_IsMessageShort($arResult["EVENT_FORMATTED"]["MESSAGE"], $arResult["EVENT_FORMATTED"]["SHORT_MESSAGE"]);
2109 }
2110 }
2111
2112 if (
2113 $bMail
2114 && $arFields["MAIL_LANGUAGE_ID"] <> ''
2115 )
2116 IncludeModuleLangFile(__FILE__, LANGUAGE_ID);
2117
2118 return $arResult;
2119 }
2120
2121 public static function FormatComment_PhotoAlbum($arFields, $arParams, $bMail = false, $arLog = array())
2122 {
2123
2124 $arResult = array(
2125 "EVENT_FORMATTED" => array(
2126 "TITLE" => (
2127 $bMail
2128 || ($arParams["USE_COMMENT"] ?? null) !== "Y"
2129 ? GetMessage("SONET_GL_COMMENT_TITLE_PHOTO_ALBUM")
2130 : ""
2131 ),
2132 "MESSAGE" => ($bMail ? $arFields["TEXT_MESSAGE"] : $arFields["MESSAGE"])
2133 ),
2134 );
2135
2136 if(
2137 !$bMail
2138 && ($arParams["USE_COMMENT"] ?? null) !== "Y"
2139 )
2140 {
2142 }
2143
2144 if (!$bMail)
2145 {
2146 static $parserLog = false;
2147 if (CModule::IncludeModule("forum"))
2148 {
2149 $arAllow = array(
2150 "HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y",
2151 "IMG" => "Y", "LOG_IMG" => "N",
2152 "QUOTE" => "Y", "LOG_QUOTE" => "N",
2153 "CODE" => "Y", "LOG_CODE" => "N",
2154 "FONT" => "Y", "LOG_FONT" => "N",
2155 "LIST" => "Y",
2156 "SMILES" => "Y",
2157 "NL2BR" => "Y",
2158 "MULTIPLE_BR" => "N",
2159 "VIDEO" => "Y", "LOG_VIDEO" => "N",
2160 "USERFIELDS" => $arFields["UF"],
2161 "USER" => (($arParams["IM"] ?? null) === "Y" ? "N" : "Y")
2162 );
2163
2164 if (!$parserLog)
2165 $parserLog = new forumTextParser(LANGUAGE_ID);
2166
2167 $parserLog->arUserfields = $arFields["UF"] ?? [];
2168 $parserLog->pathToUser = $parserLog->userPath = $arParams["PATH_TO_USER"];
2169 $parserLog->bMobile = (($arParams["MOBILE"] ?? null) === "Y");
2170 $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), $arAllow));
2171 $arResult['EVENT_FORMATTED']['MESSAGE'] = Mention::clear($arResult['EVENT_FORMATTED']['MESSAGE']);
2172 }
2173 else
2174 {
2175 $arAllow = array(
2176 "HTML" => "Y", "ANCHOR" => "Y", "BIU" => "Y",
2177 "IMG" => "Y", "LOG_IMG" => "N",
2178 "QUOTE" => "Y", "LOG_QUOTE" => "N",
2179 "CODE" => "Y", "LOG_CODE" => "N",
2180 "FONT" => "Y", "LOG_FONT" => "N",
2181 "LIST" => "Y",
2182 "SMILES" => "Y",
2183 "NL2BR" => "Y",
2184 "MULTIPLE_BR" => "N",
2185 "VIDEO" => "Y", "LOG_VIDEO" => "N"
2186 );
2187
2188 if (!$parserLog)
2189 {
2190 $parserLog = new logTextParser(false, $arParams["PATH_TO_SMILE"]);
2191 }
2192
2193 $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow));
2194 }
2195 }
2196
2197 return $arResult;
2198 }
2199
2200 public static function FormatEvent_Files($arFields, $arParams, $bMail = false)
2201 {
2202 if (
2203 $bMail
2204 && $arFields["MAIL_LANGUAGE_ID"] <> ''
2205 )
2206 IncludeModuleLangFile(__FILE__, $arFields["MAIL_LANGUAGE_ID"]);
2207
2208 $arResult = array(
2209 "EVENT" => $arFields,
2212 "EVENT_FORMATTED" => array(),
2213 );
2214
2215 if (!$bMail)
2217
2218 if (
2219 !$bMail
2220 && array_key_exists("URL", $arFields)
2221 && $arFields["URL"] <> ''
2222 )
2223 {
2224 if (
2225 $arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP
2226 && (
2227 ModuleManager::isModuleInstalled('extranet')
2228 || (mb_strpos($arFields["URL"], "#GROUPS_PATH#") !== false)
2229 )
2230 )
2231 {
2232 $arFields["URL"] = str_replace("#GROUPS_PATH#", COption::GetOptionString("socialnetwork", "workgroups_page", "/workgroups/", SITE_ID), $arFields["URL"]);
2233 $arResult["EVENT"]["URL"] = $arFields["URL"];
2234 }
2235 $file_tmp = '<a href="'.$arFields["URL"].'">'.$arFields["TITLE"].'</a>';
2236 }
2237 else
2238 $file_tmp = $arFields["TITLE"];
2239
2240 if ($bMail)
2241 $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_".($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? "GROUP" : "USER")."_FILE_MAIL");
2242 else
2243 {
2244 $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_FILE");
2245
2246 switch ($arFields["CREATED_BY_PERSONAL_GENDER"])
2247 {
2248 case "M":
2249 $suffix = "_M";
2250 break;
2251 case "F":
2252 $suffix = "_F";
2253 break;
2254 default:
2255 $suffix = "";
2256 }
2257 $title_tmp_24 = GetMessage("SONET_GL_EVENT_TITLE_FILE_24".$suffix);
2258 }
2259
2260 $title = str_replace(
2261 array("#TITLE#", "#ENTITY#", "#CREATED_BY#"),
2262 array($file_tmp, $arResult["ENTITY"]["FORMATTED"], ($bMail ? $arResult["CREATED_BY"]["FORMATTED"] : "")),
2263 $title_tmp
2264 );
2265
2266 if (($arParams["MOBILE"] ?? null) == "Y")
2267 $arResult["EVENT_FORMATTED"] = array(
2268 "TITLE_24" => GetMessage("SONET_GL_EVENT_TITLE_FILE_24_MOBILE"),
2269 "MESSAGE" => $arFields["MESSAGE"]
2270 );
2271 else
2272 $arResult["EVENT_FORMATTED"] = array(
2273 "TITLE" => ($bMail ? $title : ""),
2274 "MESSAGE_TITLE_24" => $title_tmp_24,
2275 "MESSAGE" => ($bMail ? $arFields["TEXT_MESSAGE"] : $arFields["MESSAGE"])
2276 );
2277
2278 if (!$bMail)
2279 $arResult["EVENT_FORMATTED"]["IS_MESSAGE_SHORT"] = true;
2280
2281 $arResult["HAS_COMMENTS"] = "N";
2282 if (
2283 intval($arFields["SOURCE_ID"]) > 0
2284 && array_key_exists("PARAMS", $arFields)
2285 && $arFields["PARAMS"] <> ''
2286 )
2287 {
2288 $arFieldsParams = explode("&", $arFields["PARAMS"]);
2289 if (is_array($arFieldsParams) && count($arFieldsParams) > 0)
2290 {
2291 foreach ($arFieldsParams as $tmp)
2292 {
2293 list($key, $value) = explode("=", $tmp);
2294 if ($key == "forum_id")
2295 {
2296 $arResult["HAS_COMMENTS"] = "Y";
2297 break;
2298 }
2299 }
2300 }
2301 }
2302
2303 if ($bMail)
2304 {
2306 if ($url <> '')
2307 $arResult["EVENT_FORMATTED"]["URL"] = $url;
2308 }
2309
2310 if (!$bMail)
2311 {
2312 $dbRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $arFields["ID"]));
2313 while ($arRight = $dbRight->Fetch())
2314 $arRights[] = $arRight["GROUP_CODE"];
2315
2316 $arResult["EVENT_FORMATTED"]["DESTINATION"] = CSocNetLogTools::FormatDestinationFromRights($arRights, array_merge($arParams, array("CREATED_BY" => $arFields["USER_ID"])), $iMoreCount);
2317 if (intval($iMoreCount) > 0)
2318 $arResult["EVENT_FORMATTED"]["DESTINATION_MORE"] = $iMoreCount;
2319 }
2320
2321 if (
2322 $bMail
2323 && $arFields["MAIL_LANGUAGE_ID"] <> ''
2324 )
2325 IncludeModuleLangFile(__FILE__, LANGUAGE_ID);
2326
2327 return $arResult;
2328 }
2329
2330 public static function FormatComment_Files($arFields, $arParams, $bMail = false, $arLog = array())
2331 {
2332 if (
2333 $bMail
2334 && $arFields["MAIL_LANGUAGE_ID"] <> ''
2335 )
2336 IncludeModuleLangFile(__FILE__, $arFields["MAIL_LANGUAGE_ID"]);
2337
2338 $arResult = array(
2339 "EVENT_FORMATTED" => array(),
2340 );
2341
2342 if ($bMail)
2343 {
2345 $arResult["ENTITY"] = CSocNetLogTools::FormatEvent_GetEntity($arLog, $arParams, $bMail);
2346 }
2347 elseif($arParams["USE_COMMENT"] != "Y")
2349
2350 if (
2351 !$bMail
2352 && array_key_exists("URL", $arLog)
2353 && $arLog["URL"] <> ''
2354 )
2355 $file_tmp = '<a href="'.$arLog["URL"].'">'.$arLog["TITLE"].'</a>';
2356 else
2357 $file_tmp = $arLog["TITLE"];
2358
2359 if ($bMail)
2360 $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_".($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? "GROUP" : "USER")."_FILE_COMMENT_MAIL");
2361 else
2362 $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_FILE_COMMENT");
2363
2364 $title = str_replace(
2365 array("#TITLE#", "#ENTITY#", "#CREATED_BY#"),
2366 array($file_tmp, $arResult["ENTITY"]["FORMATTED"], ($bMail ? $arResult["CREATED_BY"]["FORMATTED"] : "")),
2367 $title_tmp
2368 );
2369
2370 $arResult["EVENT_FORMATTED"] = array(
2371 "TITLE" => ($bMail || $arParams["USE_COMMENT"] != "Y" ? $title : ""),
2372 "MESSAGE" => ($bMail ? $arFields["TEXT_MESSAGE"] : $arFields["MESSAGE"])
2373 );
2374
2375 if (!$bMail)
2376 {
2377 $parserLog = new logTextParser(false, $arParams["PATH_TO_SMILE"]);
2378 $arAllow = array(
2379 "HTML" => "Y",
2380 "ANCHOR" => "Y",
2381 "BIU" => "Y",
2382 "IMG" => "Y",
2383 "QUOTE" => "Y",
2384 "CODE" => "Y",
2385 "FONT" => "Y",
2386 "LIST" => "Y",
2387 "SMILES" => "Y",
2388 "NL2BR" => "N",
2389 "VIDEO" => "Y",
2390 "LOG_VIDEO" => "N",
2391 "SHORT_ANCHOR" => "Y"
2392 );
2393 $arResult["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsbx($parserLog->convert(htmlspecialcharsback($arResult["EVENT_FORMATTED"]["MESSAGE"]), array(), $arAllow));
2394 }
2395
2396 if ($bMail)
2397 {
2399 if ($url <> '')
2400 $arResult["EVENT_FORMATTED"]["URL"] = $url;
2401 }
2402
2403 if (
2404 $bMail
2405 && $arFields["MAIL_LANGUAGE_ID"] <> ''
2406 )
2407 IncludeModuleLangFile(__FILE__, LANGUAGE_ID);
2408
2409 return $arResult;
2410 }
2411
2412 public static function FormatEvent_Task($arFields, $arParams, $bMail = false)
2413 {
2414 if (
2415 $bMail
2416 && $arFields["MAIL_LANGUAGE_ID"] <> ''
2417 )
2418 IncludeModuleLangFile(__FILE__, $arFields["MAIL_LANGUAGE_ID"]);
2419
2420 $arResult = array(
2421 "EVENT" => $arFields,
2424 "EVENT_FORMATTED" => array(),
2425 );
2426
2427 if (!$bMail)
2429
2430 if (
2431 !$bMail
2432 && array_key_exists("URL", $arFields)
2433 && $arFields["URL"] <> ''
2434 )
2435 $task_tmp = '<a href="'.$arFields["URL"].'">'.$arFields["TITLE"].'</a>';
2436 else
2437 $task_tmp = $arFields["TITLE"];
2438
2439 $title_tmp = str_replace(
2440 "#TITLE#",
2441 $task_tmp,
2442 $arFields["TITLE_TEMPLATE"]
2443 );
2444
2445 if ($bMail)
2446 $title = str_replace(
2447 array("#TASK#", "#ENTITY#", "#CREATED_BY#"),
2448 array($title_tmp, $arResult["ENTITY"]["FORMATTED"], ($bMail ? $arResult["CREATED_BY"]["FORMATTED"] : "")),
2449 GetMessage("SONET_GL_EVENT_TITLE_".($arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? "GROUP" : "USER")."_TASK_MAIL")
2450 );
2451 else
2452 $title = $title_tmp;
2453
2454 $arResult["EVENT_FORMATTED"] = array(
2455 "TITLE" => $title,
2456 "MESSAGE" => ($bMail ? str_replace(array("<nobr>", "</nobr>"), array("", ""), $arFields["TEXT_MESSAGE"]) : $arFields["MESSAGE"])
2457 );
2458
2459 if ($bMail)
2460 {
2462 if ($url <> '')
2463 $arResult["EVENT_FORMATTED"]["URL"] = $url;
2464 }
2465
2466 if (
2467 $bMail
2468 && $arFields["MAIL_LANGUAGE_ID"] <> ''
2469 )
2470 IncludeModuleLangFile(__FILE__, LANGUAGE_ID);
2471
2472 return $arResult;
2473 }
2474
2475 public static function FormatEvent_Task2($arFields, $arParams)
2476 {
2477 if (CModule::IncludeModule('tasks'))
2478 {
2479 return \Bitrix\Tasks\Integration\SocialNetwork\UI\Task::formatFeedEntry($arFields, $arParams);
2480 }
2481
2482 return false;
2483 }
2484
2485 public static function FormatEvent_SystemGroups($arFields, $arParams, $bMail = false)
2486 {
2487 global $arSocNetLogGroups, $CACHE_MANAGER;
2488
2489 if (
2490 $bMail
2491 && $arFields["MAIL_LANGUAGE_ID"] <> ''
2492 )
2493 IncludeModuleLangFile(__FILE__, $arFields["MAIL_LANGUAGE_ID"]);
2494
2495 $arResult = array(
2496 "EVENT" => $arFields,
2497 "CREATED_BY" => array(),
2498 "ENTITY" => array(),
2499 "EVENT_FORMATTED" => array(),
2500 );
2501
2502 if (
2503 $arFields["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_USER
2504 && intval($arFields["ENTITY_ID"]) > 0
2505 )
2506 {
2507 $suffix = (is_array($GLOBALS["arExtranetUserID"]) && in_array($arFields["ENTITY_ID"], $GLOBALS["arExtranetUserID"]) ? GetMessage("SONET_LOG_EXTRANET_SUFFIX") : "");
2508
2509 if ($bMail)
2510 {
2511 if (
2512 $arFields["USER_NAME"] <> ''
2513 || $arFields["USER_LAST_NAME"] <> ''
2514 )
2515 $arResult["ENTITY"]["FORMATTED"] = $arFields["USER_NAME"]." ".$arFields["USER_LAST_NAME"].$suffix;
2516 else
2517 $arResult["ENTITY"]["FORMATTED"] = $arFields["USER_LOGIN"].$suffix;
2518
2519 $arResult["ENTITY"]["TYPE_MAIL"] = GetMessage("SONET_GL_EVENT_ENTITY_U");
2520 }
2521 else
2522 {
2523 $arFieldsTooltip = array(
2524 "ID" => $arFields["ENTITY_ID"],
2525 "NAME" => $arFields["~USER_NAME"],
2526 "LAST_NAME" => $arFields["~USER_LAST_NAME"],
2527 "SECOND_NAME" => $arFields["~USER_SECOND_NAME"],
2528 "LOGIN" => $arFields["~USER_LOGIN"],
2529 );
2530 $arParams["NAME_TEMPLATE"] .= $suffix;
2531 $arResult["CREATED_BY"]["TOOLTIP_FIELDS"] = CSocNetLogTools::FormatEvent_FillTooltip($arFieldsTooltip, $arParams);
2532
2533 if (!$bMail)
2534 {
2536 }
2537 }
2538 }
2539
2540 if ((int)$arFields["MESSAGE"] > 0)
2541 {
2542 if (!is_array($arSocNetLogGroups))
2543 {
2544 $arSocNetLogGroups = array();
2545 }
2546
2547 if (array_key_exists($arFields["MESSAGE"], $arSocNetLogGroups))
2548 {
2549 $arGroup = $arSocNetLogGroups[$arFields["MESSAGE"]];
2550 }
2551 else
2552 {
2553 $rsGroup = CSocNetGroup::GetList(
2554 array("ID" => "DESC"),
2555 array(
2556 "ID" => $arFields["MESSAGE"],
2557 "ACTIVE" => "Y"
2558 )
2559 );
2560 if ($arGroup = $rsGroup->GetNext())
2561 {
2562 if (!empty($arGroup['NAME']))
2563 {
2564 $arGroup['NAME'] = Emoji::decode($arGroup['NAME']);
2565 }
2566 if (!empty($arGroup['DESCRIPTION']))
2567 {
2568 $arGroup['DESCRIPTION'] = Emoji::decode($arGroup['DESCRIPTION']);
2569 }
2570 }
2571 }
2572
2573 if ($arGroup)
2574 {
2575 if (!array_key_exists($arGroup["ID"], $arSocNetLogGroups))
2576 {
2577 $arSocNetLogGroups[$arGroup["ID"]] = $arGroup;
2578 if(defined("BX_COMP_MANAGED_CACHE"))
2579 {
2580 $CACHE_MANAGER->RegisterTag("sonet_group_".$arGroup["ID"]);
2581 }
2582 }
2583
2584 $suffix = (is_array($GLOBALS["arExtranetGroupID"]) && in_array($arFields["MESSAGE"], $GLOBALS["arExtranetGroupID"]) ? GetMessage("SONET_LOG_EXTRANET_SUFFIX") : "");
2585
2586 if ($bMail)
2587 {
2588 $group_tmp = $arGroup["NAME"].$suffix;
2589 }
2590 else
2591 {
2592 $url = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_GROUP"], array("group_id" => $arFields["MESSAGE"]));
2593 $group_tmp = '<a href="'.$url.'">'.$arGroup["NAME"].$suffix.'</a>';
2594 }
2595
2596 if ($bMail)
2597 {
2598 $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_SYSTEM_GROUPS_".mb_strtoupper($arFields["TITLE"])."_MAIL");
2599 }
2600 else
2601 {
2602 $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_SYSTEM_GROUPS_".mb_strtoupper($arFields["TITLE"]).(trim($arFields["USER_PERSONAL_GENDER"]) <> '' ? "_".$arFields["USER_PERSONAL_GENDER"] : ""));
2603 $title_tmp_24 = GetMessage("SONET_GL_EVENT_TITLE_SYSTEM_GROUPS_".mb_strtoupper($arFields["TITLE"])."_24".(trim($arFields["USER_PERSONAL_GENDER"]) <> '' ? "_".$arFields["USER_PERSONAL_GENDER"] : ""));
2604 }
2605
2606 $title = str_replace(
2607 array("#GROUP_NAME#", "#ENTITY#"),
2608 array($group_tmp, $arResult["ENTITY"]["FORMATTED"]),
2609 $title_tmp
2610 );
2611
2612 if ($bMail)
2613 {
2614 $arResult["EVENT_FORMATTED"] = array(
2615 "TITLE" => $title,
2616 "MESSAGE" => false
2617 );
2618 }
2619 else
2620 {
2621 switch ($arFields["TITLE"])
2622 {
2623 case "group":
2624 $classname = "join-group";
2625 break;
2626 case "exclude_user":
2627 case "ungroup":
2628 $classname = "leave-group";
2629 break;
2630 default:
2631 $classname = "";
2632 }
2633
2634 $arResult["EVENT_FORMATTED"] = array(
2635 "TITLE" => false,
2636 "TITLE_24" => $title_tmp_24,
2637 "MESSAGE" => $title,
2638 "IS_MESSAGE_SHORT" => true,
2639 "DESTINATION" => array(
2640 array(
2641 "STYLE" => "sonetgroups",
2642 "TITLE" => $group_tmp
2643 )
2644 ),
2645 "STYLE" => $classname
2646 );
2647 }
2648 }
2649 }
2650
2651 if (
2652 $bMail
2653 && $arFields["MAIL_LANGUAGE_ID"] <> ''
2654 )
2655 {
2656 IncludeModuleLangFile(__FILE__, LANGUAGE_ID);
2657 }
2658
2659 return $arResult;
2660 }
2661
2662 public static function FormatEvent_SystemFriends($arFields, $arParams, $bMail = false)
2663 {
2664 global $CACHE_MANAGER;
2665
2666 if (
2667 $bMail
2668 && $arFields["MAIL_LANGUAGE_ID"] <> ''
2669 )
2670 {
2671 IncludeModuleLangFile(__FILE__, $arFields["MAIL_LANGUAGE_ID"]);
2672 }
2673
2674 $arResult = array();
2675 $bActiveUsers = false;
2676
2677 if ((int)$arFields["MESSAGE"] > 0)
2678 {
2679 $dbUser = CUser::GetByID($arFields["MESSAGE"]);
2680 if ($arUser = $dbUser->Fetch())
2681 {
2682 if(defined("BX_COMP_MANAGED_CACHE"))
2683 {
2684 $CACHE_MANAGER->RegisterTag("USER_NAME_".intval($arUser["ID"]));
2685 }
2686
2687 $messageUserID = $arFields["MESSAGE"];
2688
2689 if (
2690 $arFields["ENTITY_TYPE"] === SONET_SUBSCRIBE_ENTITY_USER
2691 && (int)$arFields["ENTITY_ID"] > 0
2692 )
2693 {
2694 $dbUser2 = CUser::GetByID($arFields["ENTITY_ID"]);
2695 if ($arUser2 = $dbUser2->Fetch())
2696 {
2697 if(defined("BX_COMP_MANAGED_CACHE"))
2698 {
2699 $CACHE_MANAGER->RegisterTag("USER_NAME_".intval($arUser2["ID"]));
2700 }
2701
2702 $secondUserID = $arFields["ENTITY_ID"];
2703 $bActiveUsers = true;
2704 }
2705 }
2706 }
2707 }
2708
2709 if ($bActiveUsers)
2710 {
2711 $arResult = array(
2712 "EVENT" => $arFields,
2713 "CREATED_BY" => array(),
2714 "ENTITY" => array(),
2715 "EVENT_FORMATTED" => array(),
2716 );
2717
2718 $suffix = (is_array($GLOBALS["arExtranetUserID"]) && in_array($secondUserID, $GLOBALS["arExtranetUserID"]) ? GetMessage("SONET_LOG_EXTRANET_SUFFIX") : "");
2719
2720 if ($bMail)
2721 {
2722 if ($arFields["USER_NAME"] <> '' || $arFields["USER_LAST_NAME"] <> '')
2723 $arResult["ENTITY"]["FORMATTED"] = $arFields["USER_NAME"]." ".$arFields["USER_LAST_NAME"].$suffix;
2724 else
2725 $arResult["ENTITY"]["FORMATTED"] = $arFields["USER_LOGIN"].$suffix;
2726
2727 $arResult["ENTITY"]["TYPE_MAIL"] = GetMessage("SONET_GL_EVENT_ENTITY_U");
2728 }
2729 else
2730 {
2731 $arFieldsTooltip = array(
2732 "ID" => $secondUserID,
2733 "NAME" => $arFields["~USER_NAME"],
2734 "LAST_NAME" => $arFields["~USER_LAST_NAME"],
2735 "SECOND_NAME" => $arFields["~USER_SECOND_NAME"],
2736 "LOGIN" => $arFields["~USER_LOGIN"],
2737 );
2738 $oldNameTemplate = $arParams["NAME_TEMPLATE"];
2739 $arParams["NAME_TEMPLATE"] .= $suffix;
2740 $arResult["CREATED_BY"]["TOOLTIP_FIELDS"] = CSocNetLogTools::FormatEvent_FillTooltip($arFieldsTooltip, $arParams);
2741 $arParams["NAME_TEMPLATE"] = $oldNameTemplate;
2742
2743 if (!$bMail)
2745 }
2746
2747 $suffix = (is_array($GLOBALS["arExtranetUserID"]) && in_array($messageUserID, $GLOBALS["arExtranetUserID"]) ? GetMessage("SONET_LOG_EXTRANET_SUFFIX") : "");
2748 $user_tmp = '';
2749
2750 if ($bMail)
2751 {
2752 $user_tmp .= (
2753 $arUser["NAME"] <> ''
2754 || $arUser["LAST_NAME"] <> ''
2755 ? $arUser["NAME"]." ".$arUser["LAST_NAME"].$suffix
2756 : $arUser["LOGIN"].$suffix
2757 );
2758 }
2759 else
2760 {
2761 $suffix = (is_array($GLOBALS["arExtranetUserID"]) && in_array($messageUserID, $GLOBALS["arExtranetUserID"]) ? GetMessage("SONET_LOG_EXTRANET_SUFFIX") : "");
2762
2763 $oldNameTemplate = $arParams["NAME_TEMPLATE"];
2764 $arParams["NAME_TEMPLATE"] .= $suffix;
2765
2766 $anchor_id = RandString(8);
2767
2768 $user_tmp .= '<span id="anchor_'.$anchor_id.'" bx-tooltip-user-id="'.$arUser["ID"].'">'.CUser::FormatName($arParams["NAME_TEMPLATE"], $arUser, ($arParams["SHOW_LOGIN"] !== "N" ? true : false)).'</span>';
2769 $arParams["NAME_TEMPLATE"] = $oldNameTemplate;
2770 }
2771
2772 if ($bMail)
2773 {
2774 $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_SYSTEM_FRIENDS_".mb_strtoupper($arFields["TITLE"])."_MAIL");
2775 }
2776 else
2777 {
2778 $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_SYSTEM_FRIENDS_".mb_strtoupper($arFields["TITLE"]).(trim($arFields["USER_PERSONAL_GENDER"]) <> '' ? "_".$arFields["USER_PERSONAL_GENDER"]: ""));
2779 $title_tmp_24 = GetMessage("SONET_GL_EVENT_TITLE_SYSTEM_FRIENDS_".mb_strtoupper($arFields["TITLE"])."_24".(trim($arFields["USER_PERSONAL_GENDER"]) <> '' ? "_".$arFields["USER_PERSONAL_GENDER"] : ""));
2780 }
2781
2782 $title = str_replace(
2783 array("#USER_NAME#", "#ENTITY#"),
2784 array($user_tmp, $arResult["ENTITY"]["FORMATTED"]),
2785 $title_tmp
2786 );
2787
2788 if ($bMail)
2789 {
2790 $arResult["EVENT_FORMATTED"] = array(
2791 "TITLE" => $title,
2792 "MESSAGE" => false
2793 );
2794
2795 $friends_page = COption::GetOptionString("socialnetwork", "friends_page", false, SITE_ID);
2796 if ($friends_page <> '')
2797 {
2798 $arFields["URL"] = str_replace(array("#user_id#", "#USER_ID#"), $secondUserID, $friends_page);
2799 $arResult["EVENT_FORMATTED"]["URL"] = CSocNetLogTools::FormatEvent_GetURL($arFields);
2800 }
2801 }
2802 else
2803 {
2804 switch ($arFields["TITLE"])
2805 {
2806 case "friend":
2807 $classname = "join-group";
2808 break;
2809 case "unfriend":
2810 $classname = "leave-group";
2811 break;
2812 default:
2813 $classname = "";
2814 }
2815
2816 $arResult["EVENT_FORMATTED"] = array(
2817 "TITLE" => false,
2818 "TITLE_24" => $title_tmp_24,
2819 "MESSAGE" => $title,
2820 "IS_MESSAGE_SHORT" => true,
2821 "DESTINATION" => array(
2822 array(
2823 "STYLE" => "users",
2824 "TITLE" => $user_tmp,
2825 "URL" => str_replace(array("#user_id#", "#USER_ID#", "#id#", "#ID#"), $arFields["MESSAGE"], $arParams["~PATH_TO_USER"])
2826 )
2827 ),
2828 "STYLE" => $classname
2829 );
2830 }
2831 }
2832
2833 if (
2834 $bMail
2835 && $arFields["MAIL_LANGUAGE_ID"] <> ''
2836 )
2837 IncludeModuleLangFile(__FILE__, LANGUAGE_ID);
2838
2839 return $arResult;
2840 }
2841
2842 public static function FormatEvent_System($arFields, $arParams, $bMail = false)
2843 {
2844 global $CACHE_MANAGER;
2845
2846 if (
2847 $bMail
2848 && $arFields["MAIL_LANGUAGE_ID"] <> ''
2849 )
2850 IncludeModuleLangFile(__FILE__, $arFields["MAIL_LANGUAGE_ID"]);
2851
2852 $arResult = array(
2853 "EVENT" => $arFields,
2854 "CREATED_BY" => array(),
2855 "ENTITY" => array(),
2856 "EVENT_FORMATTED" => array(),
2857 );
2858
2859 if (intval($arFields["ENTITY_ID"]) > 0)
2860 {
2861 $suffix = (is_array($GLOBALS["arExtranetGroupID"]) && in_array($arFields["ENTITY_ID"], $GLOBALS["arExtranetGroupID"]) ? GetMessage("SONET_LOG_EXTRANET_SUFFIX") : "");
2862 if ($bMail)
2863 {
2864 $arResult["ENTITY"]["FORMATTED"] = $arFields["GROUP_NAME"].$suffix;
2865 $arResult["ENTITY"]["TYPE_MAIL"] = GetMessage("SONET_GL_EVENT_ENTITY_G");
2866 }
2867 elseif (mb_strpos($arFields["MESSAGE"], ",") > 0)
2869 }
2870
2871 if (in_array($arFields["TITLE"], array("moderate", "unmoderate", "join", "unjoin")))
2872 {
2873 if (mb_strpos($arFields["MESSAGE"], ",") !== false)
2874 {
2875 $arResult["CREATED_BY"] = false;
2876 $arGroup = array(
2877 "IMAGE_ID" => $arFields["GROUP_IMAGE_ID"]
2878 );
2879 $arResult["AVATAR_SRC"] = CSocNetLogTools::FormatEvent_CreateAvatarGroup($arGroup, $arParams); // group avatar
2880 }
2881 else
2882 {
2883 $suffix = (is_array($GLOBALS["arExtranetUserID"]) && in_array($arFields["MESSAGE"], $GLOBALS["arExtranetUserID"]) ? GetMessage("SONET_LOG_EXTRANET_SUFFIX") : "");
2884
2885 $dbUser = CUser::GetByID($arFields["MESSAGE"]);
2886 if ($arUser = $dbUser->Fetch())
2887 {
2888 $arFieldsTooltip = array(
2889 "ID" => $arUser["ID"],
2890 "NAME" => $arUser["NAME"],
2891 "LAST_NAME" => $arUser["LAST_NAME"],
2892 "SECOND_NAME" => $arUser["SECOND_NAME"],
2893 "LOGIN" => $arUser["LOGIN"],
2894 );
2895 $oldNameTemplate = $arParams["NAME_TEMPLATE"];
2896 $arParams["NAME_TEMPLATE"] .= $suffix;
2897 $arResult["CREATED_BY"]["TOOLTIP_FIELDS"] = CSocNetLogTools::FormatEvent_FillTooltip($arFieldsTooltip, $arParams);
2898 $arParams["NAME_TEMPLATE"] = $oldNameTemplate;
2899
2900 if (!$bMail)
2902 }
2903 }
2904 }
2905 else
2906 {
2907 $suffix = (is_array($GLOBALS["arExtranetUserID"]) && in_array($arFields["USER_ID"], $GLOBALS["arExtranetUserID"]) ? GetMessage("SONET_LOG_EXTRANET_SUFFIX") : "");
2908
2909 $arFieldsTooltip = array(
2910 "ID" => $arFields["USER_ID"],
2911 "NAME" => $arFields["~CREATED_BY_NAME"],
2912 "LAST_NAME" => $arFields["~CREATED_BY_LAST_NAME"],
2913 "SECOND_NAME" => $arFields["~CREATED_BY_SECOND_NAME"],
2914 "LOGIN" => $arFields["~CREATED_BY_LOGIN"],
2915 );
2916 $oldNameTemplate = $arParams["NAME_TEMPLATE"];
2917 $arParams["NAME_TEMPLATE"] .= $suffix;
2918 $arResult["CREATED_BY"]["TOOLTIP_FIELDS"] = CSocNetLogTools::FormatEvent_FillTooltip($arFieldsTooltip, $arParams);
2919 $arParams["NAME_TEMPLATE"] = $oldNameTemplate;
2920
2921 if (!$bMail)
2923 }
2924
2925 if ($arFields["MESSAGE"] <> '')
2926 {
2927 $arUsersID = explode(",", $arFields["MESSAGE"]);
2928
2929 $bFirst = true;
2930 $count = 0;
2931 $user_tmp = "";
2932
2933 if ($bMail)
2934 {
2935 $dbUser = CUser::GetList(
2936 "last_name",
2937 "asc",
2938 array(
2939 "ID" => implode(" | ", $arUsersID)
2940 )
2941 );
2942 while($arUser = $dbUser->Fetch())
2943 {
2944 $suffix = (is_array($GLOBALS["arExtranetUserID"]) && in_array($arUser["ID"], $GLOBALS["arExtranetUserID"]) ? GetMessage("SONET_LOG_EXTRANET_SUFFIX") : "");
2945
2946 $count++;
2947 if (!$bFirst)
2948 $user_tmp .= ", ";
2949
2950 if (
2951 $arUser["NAME"] <> ''
2952 || $arUser["LAST_NAME"] <> ''
2953 )
2954 $user_tmp .= $arUser["NAME"]." ".$arUser["LAST_NAME"].$suffix;
2955 else
2956 $user_tmp .= $arUser["LOGIN"].$suffix;
2957
2958 $bFirst = false;
2959 }
2960 }
2961 else
2962 {
2963 $dbUser = CUser::GetList(
2964 "last_name",
2965 "asc",
2966 array(
2967 "ID" => implode(" | ", $arUsersID)
2968 ),
2969 array("FIELDS" => array("ID", "NAME", "LAST_NAME", "SECOND_NAME", "LOGIN", "PERSONAL_GENDER"))
2970 );
2971 while($arUser = $dbUser->Fetch())
2972 {
2973 if (defined("BX_COMP_MANAGED_CACHE"))
2974 {
2975 $CACHE_MANAGER->RegisterTag("USER_NAME_".intval($arUser["ID"]));
2976 }
2977
2978 $suffix = (is_array($GLOBALS["arExtranetUserID"]) && in_array($arUser["ID"], $GLOBALS["arExtranetUserID"]) ? GetMessage("SONET_LOG_EXTRANET_SUFFIX") : "");
2979
2980 $count++;
2981 if (!$bFirst)
2982 $user_tmp .= ", ";
2983
2984 $oldNameTemplate = $arParams["NAME_TEMPLATE"];
2985 $arParams["NAME_TEMPLATE"] .= $suffix;
2986
2987 $anchor_id = RandString(8);
2988
2989 $user_tmp .= '<a class="" id="anchor_'.$anchor_id.'" href="'.str_replace(array("#user_id#", "#USER_ID#", "#id#", "#ID#"), $arUser["ID"], $arParams["~PATH_TO_USER"]).'" bx-tooltip-user-id="'.$arUser["ID"].'">'.CUser::FormatName($arParams["NAME_TEMPLATE"], $arUser, ($arParams["SHOW_LOGIN"] != "N" ? true : false)).'</a>';
2990
2991 $arParams["NAME_TEMPLATE"] = $oldNameTemplate;
2992
2993 $bFirst = false;
2994 $arLastUser = $arUser;
2995 }
2996 }
2997 }
2998
2999 if ($bMail)
3000 $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_SYSTEM_".mb_strtoupper($arFields["TITLE"])."_".($count > 1 ? "2" : "1")."_MAIL");
3001 else
3002 {
3003 if (in_array($arFields["TITLE"], array("moderate", "unmoderate", "join", "unjoin")))
3004 {
3005 if (
3006 $count == 1
3007 && $arLastUser
3008 )
3009 $suffix = $arLastUser["PERSONAL_GENDER"];
3010 else
3011 $suffix = "";
3012 }
3013 else
3014 $suffix = $arFields["CREATED_BY_PERSONAL_GENDER"];
3015
3016 $title_tmp = GetMessage("SONET_GL_EVENT_TITLE_SYSTEM_".mb_strtoupper($arFields["TITLE"])."_".($count > 1 ? "2" : "1".(trim($suffix) <> '' ? "_".$suffix : "")));
3017
3018 $title_tmp_24 = GetMessage("SONET_GL_EVENT_TITLE_SYSTEM_".mb_strtoupper($arFields["TITLE"])."_".($count > 1 ? "2_24" : "1_24".(trim($suffix) <> '' ? "_".$suffix : "")));
3019 }
3020
3021 $url = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_GROUP"], array("group_id" => $arFields["ENTITY_ID"]));
3022 $suffix = (is_array($GLOBALS["arExtranetGroupID"]) && in_array($arFields["ENTITY_ID"], $GLOBALS["arExtranetGroupID"]) ? GetMessage("SONET_LOG_EXTRANET_SUFFIX") : "");
3023
3024 if ($url <> '')
3025 $group_tmp = '<a href="'.$url.'">'.$arFields["GROUP_NAME"].'</a>'.$suffix;
3026 else
3027 $group_tmp = $arFields["GROUP_NAME"].$suffix;
3028
3029 $title = str_replace(
3030 array("#USER_NAME#", "#ENTITY#", "#GROUP_NAME#"),
3031 array($user_tmp, $arResult["ENTITY"]["FORMATTED"], $group_tmp),
3032 $title_tmp
3033 );
3034
3035 $title_tmp_24 = str_replace(
3036 array("#USER_NAME#"),
3037 array($user_tmp),
3038 $title_tmp_24
3039 );
3040
3041 if ($bMail)
3042 $arResult["EVENT_FORMATTED"] = array(
3043 "TITLE" => $title,
3044 "MESSAGE" => false
3045 );
3046 else
3047 {
3048 switch ($arFields["TITLE"])
3049 {
3050 case "join":
3051 case "moderate":
3052 case "owner":
3053 $classname = "join-group";
3054 break;
3055 case "unjoin":
3056 case "exclude_group":
3057 case "unmoderate":
3058 $classname = "leave-group";
3059 break;
3060 default:
3061 $classname = "";
3062 }
3063
3064 if (($arParams["MOBILE"] ?? null) == "Y")
3065 $arResult["EVENT_FORMATTED"] = array(
3066 "TITLE_24" => $title_tmp_24,
3067 "DESTINATION" => array(
3068 array(
3069 "STYLE" => "",
3070 "TITLE" => $arFields["GROUP_NAME"].$suffix,
3071 "URL" => $url
3072 )
3073 ),
3074 "STYLE" => $classname
3075 );
3076 else
3077 $arResult["EVENT_FORMATTED"] = array(
3078 "TITLE" => false,
3079 "MESSAGE" => $title,
3080 "IS_MESSAGE_SHORT" => true,
3081 "TITLE_24" => $title_tmp_24,
3082 "DESTINATION" => array(
3083 array(
3084 "STYLE" => "sonetgroups",
3085 "TITLE" => $arFields["GROUP_NAME"].$suffix,
3086 "URL" => $url
3087 )
3088 ),
3089 "STYLE" => $classname
3090 );
3091 }
3092
3093 if (
3094 $bMail
3095 && $arFields["MAIL_LANGUAGE_ID"] <> ''
3096 )
3097 IncludeModuleLangFile(__FILE__, LANGUAGE_ID);
3098
3099 return $arResult;
3100 }
3101
3102 public static function SetCacheLastLogID($type = "log", $id = 0)
3103 {
3104 global $CACHE_MANAGER;
3105
3106 $CACHE_MANAGER->Read(86400*365, "socnet_log_".$type."_id", "log");
3107 $CACHE_MANAGER->Clean("socnet_log_".$type."_id", "log");
3108 $CACHE_MANAGER->Read(86400*365, "socnet_log_".$type."_id", "log");
3109 $CACHE_MANAGER->SetImmediate("socnet_log_".$type."_id", intval($id));
3110 }
3111
3112 public static function GetCacheLastLogID($type = "log")
3113 {
3114 global $CACHE_MANAGER;
3115
3116 $id = 0;
3117 if ($CACHE_MANAGER->Read(86400*365, "socnet_log_".$type."_id", "log"))
3118 $id = $CACHE_MANAGER->Get("socnet_log_".$type."_id");
3119
3120 return $id;
3121 }
3122
3123 public static function SetUserCache(
3124 $type = "log",
3125 $user_id = null,
3126 $max_id = null,
3127 $max_viewed_id = null,
3128 $count = null,
3129 $bSetViewTime = false,
3130 $LastViewTS = 0
3131 )
3132 {
3133 global $CACHE_MANAGER;
3134
3135 $user_id = intval($user_id);
3136
3137 $CACHE_MANAGER->Read(86400*365, "socnet_log_user_".$type."_".$user_id);
3138 $CACHE_MANAGER->Clean("socnet_log_user_".$type."_".$user_id);
3139 $CACHE_MANAGER->Read(86400*365, "socnet_log_user_".$type."_".$user_id);
3140
3141 $CACHE_MANAGER->SetImmediate("socnet_log_user_".$type."_".$user_id, array(
3142 "Type" => $type,
3143 "UserID" => $user_id,
3144 "MaxID" => intval($max_id),
3145 "MaxViewedID" => intval($max_viewed_id),
3146 "Count" => intval($count),
3147 "LastVisitTS" => time(),
3148 "LastViewTS" => ($bSetViewTime ? time() : intval($LastViewTS))
3149 ));
3150 }
3151
3152 public static function GetUserCache($type = "log", $user_id = 0)
3153 {
3154 global $CACHE_MANAGER;
3155
3156 if ($CACHE_MANAGER->Read(86400*365, "socnet_log_user_".$type."_".intval($user_id)))
3157 return $CACHE_MANAGER->Get("socnet_log_user_".$type."_".intval($user_id));
3158 else
3159 return array(
3160 "Type" => "",
3161 "UserID" => 0,
3162 "MaxID" => 0,
3163 "MaxViewedID" => 0,
3164 "Count" => 0,
3165 "LastVisitTS" => 0,
3166 "LastViewTS" => 0
3167 );
3168 }
3169
3170 public static function AddComment_Forum($arFields)
3171 {
3172 global $USER_FIELD_MANAGER, $USER;
3173
3174 if (!CModule::IncludeModule("forum"))
3175 {
3176 return false;
3177 }
3178
3179 $ufFileID = array();
3180 $ufDocID = array();
3181
3182 $sNote = '';
3183
3185 array(),
3186 array("ID" => $arFields["LOG_ID"]),
3187 false,
3188 false,
3189 array("ID", "SOURCE_ID", "SITE_ID", "TITLE", "PARAMS")
3190 );
3191
3192 if ($arLog = $dbResult->Fetch())
3193 {
3194 $arMessage = CForumMessage::GetByID($arLog["SOURCE_ID"]);
3195 if ($arMessage)
3196 {
3197 $userID = $USER->GetID();
3198 $notificationSiteId = false;
3199
3200 $arLogSites = array();
3201 $rsLogSite = CSocNetLog::GetSite($arLog["ID"]);
3202 while ($arLogSite = $rsLogSite->Fetch())
3203 {
3204 $arLogSites[] = $arLogSite["LID"];
3205 if (
3206 !$notificationSiteId
3207 && (
3208 !CModule::IncludeModule('extranet')
3209 || $arLogSite["LID"] != CExtranet::GetExtranetSiteID()
3210 )
3211 )
3212 {
3213 $notificationSiteId = $arLogSite["LID"];
3214 }
3215 }
3216
3217 $bCurrentUserIsAdmin = CSocNetUser::IsCurrentUserModuleAdmin($arLogSites);
3218
3219 if ($arFields["ENTITY_TYPE"] == SONET_ENTITY_GROUP)
3220 {
3221 if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "forum", "full", $bCurrentUserIsAdmin))
3222 $strPermission = "Y";
3223 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "forum", "newtopic", $bCurrentUserIsAdmin))
3224 $strPermission = "M";
3225 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "forum", "answer", $bCurrentUserIsAdmin))
3226 $strPermission = "I";
3227 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "forum", "view", $bCurrentUserIsAdmin))
3228 $strPermission = "E";
3229 }
3230 else
3231 {
3232 if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "forum", "full", $bCurrentUserIsAdmin))
3233 $strPermission = "Y";
3234 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "forum", "newtopic", $bCurrentUserIsAdmin))
3235 $strPermission = "M";
3236 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "forum", "answer", $bCurrentUserIsAdmin))
3237 $strPermission = "I";
3238 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "forum", "view", $bCurrentUserIsAdmin))
3239 $strPermission = "E";
3240 }
3241
3242 $arFieldsMessage = array(
3243 "POST_MESSAGE" => $arFields["TEXT_MESSAGE"],
3244 "USE_SMILES" => "Y",
3245 "PERMISSION_EXTERNAL" => "Q",
3246 "PERMISSION" => $strPermission,
3247 "APPROVED" => "Y"
3248 );
3249
3250 $arTmp = array();
3251 $USER_FIELD_MANAGER->EditFormAddFields("SONET_COMMENT", $arTmp);
3252 if (is_array($arTmp))
3253 {
3254 if (array_key_exists("UF_SONET_COM_DOC", $arTmp))
3255 {
3256 $GLOBALS["UF_FORUM_MESSAGE_DOC"] = $arTmp["UF_SONET_COM_DOC"];
3257 }
3258 elseif (array_key_exists("UF_SONET_COM_FILE", $arTmp))
3259 {
3260 $arFieldsMessage["FILES"] = array();
3261 foreach($arTmp["UF_SONET_COM_FILE"] as $file_id)
3262 {
3263 $arFieldsMessage["FILES"][$file_id] = array("FILE_ID" => $file_id);
3264 }
3265
3266 if (!empty($arFieldsMessage["FILES"]))
3267 {
3268 $arFileParams = array("FORUM_ID" => $arMessage["FORUM_ID"], "TOPIC_ID" => $arMessage["TOPIC_ID"]);
3269 if (CForumFiles::CheckFields($arFieldsMessage["FILES"], $arFileParams, "NOT_CHECK_DB"))
3270 {
3271 CForumFiles::Add(array_keys($arFieldsMessage["FILES"]), $arFileParams);
3272 }
3273 }
3274 }
3275 }
3276
3277 $messageID = ForumAddMessage("REPLY", $arMessage["FORUM_ID"], $arMessage["TOPIC_ID"], 0, $arFieldsMessage, $sError, $sNote);
3278 unset($GLOBALS["UF_FORUM_MESSAGE_DOC"]);
3279
3280 // get UF DOC value and FILE_ID there
3281 if ($messageID > 0)
3282 {
3283 $dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $messageID));
3284 while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch())
3285 {
3286 $ufFileID[] = $arAddedMessageFiles["FILE_ID"];
3287 }
3288
3289 $ufDocID = $USER_FIELD_MANAGER->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $messageID, LANGUAGE_ID);
3290 }
3291
3292 if (
3293 $messageID > 0
3294 && CModule::IncludeModule("im")
3295 && intval($arMessage["AUTHOR_ID"]) > 0
3296 && $arMessage["AUTHOR_ID"] != $userID
3297 )
3298 {
3299 $rsUnFollower = CSocNetLogFollow::GetList(
3300 array(
3301 "USER_ID" => $arMessage["AUTHOR_ID"],
3302 "CODE" => "L".$arLog["ID"],
3303 "TYPE" => "N"
3304 ),
3305 array("USER_ID")
3306 );
3307
3308 $arUnFollower = $rsUnFollower->Fetch();
3309 if (!$arUnFollower)
3310 {
3311 $arMessageFields = array(
3312 "MESSAGE_TYPE" => IM_MESSAGE_SYSTEM,
3313 "TO_USER_ID" => $arMessage["AUTHOR_ID"],
3314 "FROM_USER_ID" => $userID,
3315 "LOG_ID" => $arLog["ID"],
3316 "NOTIFY_TYPE" => IM_NOTIFY_FROM,
3317 "NOTIFY_MODULE" => "forum",
3318 "NOTIFY_EVENT" => "comment",
3319 );
3320
3321 $arParams["TITLE"] = str_replace(Array("\r\n", "\n"), " ", $arLog["TITLE"]);
3322 $arParams["TITLE"] = TruncateText($arParams["TITLE"], 100);
3323 $arParams["TITLE_OUT"] = TruncateText($arParams["TITLE"], 255);
3324
3325 $arParams["URL"] = "";
3326 if ($arLog["PARAMS"] <> '')
3327 {
3328 $arTmp = unserialize(htmlspecialcharsback($arLog["PARAMS"]), [ 'allowed_classes' => false ]);
3329 if (
3330 $arTmp
3331 && array_key_exists("PATH_TO_MESSAGE", $arTmp)
3332 )
3333 $arParams["URL"] = CComponentEngine::MakePathFromTemplate(
3334 $arTmp["PATH_TO_MESSAGE"],
3335 array("MID" => $messageID)
3336 );
3337 }
3338
3339 $arTmp = CSocNetLogTools::ProcessPath(array("MESSAGE_URL" => $arParams["URL"]), $arMessage["AUTHOR_ID"], $notificationSiteId);
3340 $serverName = $arTmp["SERVER_NAME"];
3341 $url = $arTmp["URLS"]["MESSAGE_URL"];
3342
3343 $arMessageFields["NOTIFY_TAG"] = "FORUM|COMMENT|".$messageID;
3344 $arMessageFields["NOTIFY_MESSAGE"] = fn (?string $languageId = null) =>
3345 Loc::getMessage(
3346 "SONET_FORUM_IM_COMMENT",
3347 [
3348 "#title#" => (
3349 $url <> ''
3350 ? "<a href=\"".$url."\" class=\"bx-notifier-item-action\">".htmlspecialcharsbx($arParams["TITLE"])."</a>"
3351 : htmlspecialcharsbx($arParams["TITLE"])
3352 )
3353 ],
3354 $languageId
3355 )
3356 ;
3357
3358 $arMessageFields["NOTIFY_MESSAGE_OUT"] = fn (?string $languageId = null) =>
3359 Loc::getMessage(
3360 "SONET_FORUM_IM_COMMENT",
3361 [
3362 "#title#" => htmlspecialcharsbx($arParams["TITLE"])
3363 ],
3364 $languageId
3365 )
3366 . ($url <> '' ? " (".$serverName.$url.")" : "")
3367 ."#BR##BR#" . $arFields["TEXT_MESSAGE"]
3368 ;
3369
3370 CIMNotify::Add($arMessageFields);
3371 }
3372 }
3373 }
3374 else
3375 {
3376 $sError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
3377 }
3378 }
3379 else
3380 {
3381 $sError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
3382 }
3383
3384 return array(
3385 "SOURCE_ID" => $messageID,
3386 "RATING_TYPE_ID" => "FORUM_POST",
3387 "RATING_ENTITY_ID" => $messageID,
3388 "ERROR" => $sError,
3389 "NOTES" => $sNote,
3390 "UF" => array(
3391 "FILE" => $ufFileID,
3392 "DOC" => $ufDocID
3393 )
3394 );
3395 }
3396
3397 public static function UpdateComment_Forum($arFields)
3398 {
3399 global $USER_FIELD_MANAGER;
3400
3401 if (!CModule::IncludeModule("forum"))
3402 {
3403 return false;
3404 }
3405
3406 if (
3407 !isset($arFields["SOURCE_ID"])
3408 || intval($arFields["SOURCE_ID"]) <= 0
3409 )
3410 {
3411 return false;
3412 }
3413
3414 $messageId = intval($arFields["SOURCE_ID"]);
3415
3416 $ufFileID = array();
3417 $ufDocID = array();
3418 $sNote = '';
3419
3420 if ($arForumMessage = CForumMessage::GetByID($messageId))
3421 {
3422 $arFieldsMessage = array(
3423 "POST_MESSAGE" => $arFields["TEXT_MESSAGE"],
3424 "USE_SMILES" => "Y",
3425 "APPROVED" => "Y",
3426 "SONET_PERMS" => array("bCanFull" => true)
3427 );
3428
3429 $USER_FIELD_MANAGER->EditFormAddFields("SONET_COMMENT", $arTmp);
3430 if (is_array($arTmp))
3431 {
3432 if (array_key_exists("UF_SONET_COM_DOC", $arTmp))
3433 {
3434 $GLOBALS["UF_FORUM_MESSAGE_DOC"] = $arTmp["UF_SONET_COM_DOC"];
3435 }
3436 elseif (array_key_exists("UF_SONET_COM_FILE", $arTmp))
3437 {
3438 $arFieldsMessage["FILES"] = array();
3439 foreach($arTmp["UF_SONET_COM_FILE"] as $file_id)
3440 {
3441 $arFieldsMessage["FILES"][$file_id] = array("FILE_ID" => $file_id);
3442 }
3443 if (!empty($arFieldsMessage["FILES"]))
3444 {
3445 $arFileParams = array("FORUM_ID" => $arForumMessage["FORUM_ID"], "TOPIC_ID" => $arForumMessage["TOPIC_ID"]);
3446 if(CForumFiles::CheckFields($arFieldsMessage["FILES"], $arFileParams, "NOT_CHECK_DB"))
3447 {
3448 CForumFiles::Add(array_keys($arFieldsMessage["FILES"]), $arFileParams);
3449 }
3450 }
3451 }
3452 }
3453
3454 $messageID = ForumAddMessage("EDIT", $arForumMessage["FORUM_ID"], $arForumMessage["TOPIC_ID"], $messageId, $arFieldsMessage, $sError, $sNote);
3455 unset($GLOBALS["UF_FORUM_MESSAGE_DOC"]);
3456
3457 // get UF DOC value and FILE_ID there
3458 if ($messageID > 0)
3459 {
3460 $dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $messageID));
3461 while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch())
3462 {
3463 $ufFileID[] = $arAddedMessageFiles["FILE_ID"];
3464 }
3465
3466 $ufDocID = $USER_FIELD_MANAGER->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $messageID, LANGUAGE_ID);
3467 }
3468 }
3469 else
3470 {
3471 $sError = GetMessage("SONET_UPDATE_COMMENT_SOURCE_ERROR");
3472 }
3473
3474 return array(
3475 "ERROR" => $sError,
3476 "NOTES" => $sNote,
3477 "UF" => array(
3478 "FILE" => $ufFileID,
3479 "DOC" => $ufDocID
3480 )
3481 );
3482 }
3483
3484 public static function DeleteComment_Forum($arFields)
3485 {
3486 $arRes = array();
3487
3488 if (
3489 CModule::IncludeModule("forum")
3490 && isset($arFields["SOURCE_ID"])
3491 && intval($arFields["SOURCE_ID"]) > 0
3492 && isset($arFields["EVENT_ID"])
3493 && $arFields["EVENT_ID"] <> ''
3494 && isset($arFields["LOG_SOURCE_ID"])
3495 && (int)$arFields["LOG_SOURCE_ID"] > 0
3496 )
3497 {
3498 $logEventMeta = CSocNetLogTools::FindLogEventByCommentID($arFields["EVENT_ID"]);
3499
3500 if (
3501 true || // we are not ready to use \Bitrix\Forum\Comments\Feed yet
3502 $logEventMeta["EVENT_ID"] == "forum"
3503 )
3504 {
3505 if (CModule::IncludeModule("forum"))
3506 {
3507 ForumActions("DEL", array(
3508 'MID' => (int)$arFields['SOURCE_ID'],
3509 "PERMISSION" => "Y"
3510 ), $strErrorMessage, $strOKMessage);
3511
3512 $arRes["ERROR"] = $strErrorMessage;
3513 $arRes["NOTES"] = $strOKMessage;
3514 }
3515 }
3516 else
3517 {
3518 if ($logEventMeta)
3519 {
3520 $arForumMetaData = CSocNetLogTools::GetForumCommentMetaData($logEventMeta["EVENT_ID"]);
3521 }
3522
3523 if ($arForumMetaData)
3524 {
3525 $messageId = (int)$arFields["SOURCE_ID"];
3526
3527 $rsMessage = CForumMessage::GetList(
3528 array(),
3529 array("ID" => $messageId),
3530 false,
3531 0,
3532 array(
3533 "SELECT" => array("FORUM_ID")
3534 )
3535 );
3536 if ($arMessage = $rsMessage->Fetch())
3537 {
3538 $forumId = (int)$arMessage["FORUM_ID"];
3539 }
3540
3541 if (
3542 $forumId
3543 && intval($forumId) > 0
3544 )
3545 {
3546 if (
3547 (
3548 $arForumMetaData[0] == 'WF'
3549 || $arForumMetaData[0] == 'FORUM'
3550 )
3551 && isset($arFields["LOG_ID"])
3552 && intval($arFields["LOG_ID"]) > 0
3553 )
3554 {
3555 $rsLog = CSocNetLog::GetList(
3556 array(),
3557 array("ID" => (int)$arFields["LOG_ID"]),
3558 false,
3559 false,
3560 array("MESSAGE", "RATING_ENTITY_ID")
3561 );
3562 if ($arLog = $rsLog->Fetch())
3563 {
3564 if ($arForumMetaData[0] === 'WF')
3565 {
3566 $entityId = $arLog["MESSAGE"];
3567 }
3568 elseif ($arForumMetaData[0] === 'FORUM')
3569 {
3570 $entityId = $arLog["RATING_ENTITY_ID"];
3571 }
3572 }
3573 }
3574 elseif (
3575 $arForumMetaData[0] === 'FORUM'
3576 && isset($arFields["LOG_ID"])
3577 && intval($arFields["LOG_ID"]) > 0
3578 )
3579 {
3580 $rsLog = CSocNetLog::GetList(
3581 array(),
3582 array("ID" => (int)$arFields["LOG_ID"]),
3583 false,
3584 false,
3585 array("MESSAGE")
3586 );
3587 if ($arLog = $rsLog->Fetch())
3588 {
3589 $entityId = $arLog["MESSAGE"];
3590 }
3591 }
3592 else
3593 {
3594 $entityId = $arFields["LOG_SOURCE_ID"];
3595 }
3596
3597 $feed = new \Bitrix\Forum\Comments\Feed(
3598 intval($forumId),
3599 array(
3600 "type" => $arForumMetaData[1],
3601 "id" => intval($arFields["LOG_SOURCE_ID"]),
3602 "xml_id" => $arForumMetaData[0]."_".$entityId
3603 )
3604 );
3605
3606 if (!$feed->delete($messageId))
3607 {
3608 $arRes["ERROR"] = "";
3609 foreach($feed->getErrors() as $error)
3610 {
3611 $arRes["ERROR"] .= $error->getMessage();
3612 }
3613 }
3614 else
3615 {
3616 $arRes["NOTES"] = GetMessage("SONET_DELETE_COMMENT_SOURCE_SUCCESS");
3617 }
3618 }
3619 }
3620 }
3621 }
3622
3623 if (!isset($arRes["NOTES"]))
3624 {
3625 $arRes["ERROR"] = GetMessage("SONET_DELETE_COMMENT_SOURCE_ERROR");
3626 }
3627
3628 return $arRes;
3629 }
3630
3631 public static function AddComment_Blog($arFields)
3632 {
3633 global $USER, $APPLICATION;
3634
3635 if (!CModule::IncludeModule("blog"))
3636 return false;
3637
3639 array(),
3640 array("ID" => $arFields["LOG_ID"]),
3641 false,
3642 false,
3643 array("ID", "SOURCE_ID", "SITE_ID")
3644 );
3645
3646 if ($arLog = $dbResult->Fetch())
3647 {
3648 $arPost = CBlogPost::GetByID($arLog["SOURCE_ID"]);
3649 if ($arPost)
3650 {
3651 $arBlog = CBlog::GetByID($arPost["BLOG_ID"]);
3652 $userID = $USER->GetID();
3653
3654 $arLogSites = array();
3655 $rsLogSite = CSocNetLog::GetSite($arLog["ID"]);
3656 while ($arLogSite = $rsLogSite->Fetch())
3657 $arLogSites[] = $arLogSite["LID"];
3658
3659 $bCurrentUserIsAdmin = CSocNetUser::IsCurrentUserModuleAdmin($arLogSites);
3660 $strPermission = BLOG_PERMS_DENY;
3661 $strPostPermission = BLOG_PERMS_DENY;
3662
3663 if ($arFields["ENTITY_TYPE"] === SONET_ENTITY_GROUP)
3664 {
3665 if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "full_post", $bCurrentUserIsAdmin))
3666 $strPostPermission = BLOG_PERMS_FULL;
3667 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "premoderate_post"))
3668 $strPostPermission = BLOG_PERMS_PREMODERATE;
3669 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "write_post"))
3670 $strPostPermission = BLOG_PERMS_WRITE;
3671 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "moderate_post"))
3672 $strPostPermission = BLOG_PERMS_MODERATE;
3673 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "view_post"))
3674 $strPostPermission = BLOG_PERMS_READ;
3675
3676 if($strPostPermission > BLOG_PERMS_DENY)
3677 {
3678 if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "full_comment", $bCurrentUserIsAdmin))
3679 $strPermission = BLOG_PERMS_FULL;
3680 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "moderate_comment"))
3681 $strPermission = BLOG_PERMS_MODERATE;
3682 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "write_comment"))
3683 $strPermission = BLOG_PERMS_WRITE;
3684 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "premoderate_comment"))
3685 $strPermission = BLOG_PERMS_PREMODERATE;
3686 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "view_comment"))
3687 $strPermission = BLOG_PERMS_READ;
3688 }
3689 }
3690 else
3691 {
3692 if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "full_post", $bCurrentUserIsAdmin) || CMain::GetGroupRight("blog") >= "W" || $arFields["USER_ID"] == $userID)
3693 $strPostPermission = BLOG_PERMS_FULL;
3694 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "moderate_post"))
3695 $strPostPermission = BLOG_PERMS_MODERATE;
3696 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "write_post"))
3697 $strPostPermission = BLOG_PERMS_WRITE;
3698 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "premoderate_post"))
3699 $strPostPermission = BLOG_PERMS_PREMODERATE;
3700 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "view_post"))
3701 $strPostPermission = BLOG_PERMS_READ;
3702
3703 if($strPostPermission > BLOG_PERMS_DENY)
3704 {
3705 if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "full_comment", $bCurrentUserIsAdmin) || CMain::GetGroupRight("blog") >= "W" || $arFields["USER_ID"] == $userID)
3706 $strPermission = BLOG_PERMS_FULL;
3707 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "moderate_comment"))
3708 $strPermission = BLOG_PERMS_MODERATE;
3709 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "write_comment"))
3710 $strPermission = BLOG_PERMS_WRITE;
3711 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "premoderate_comment"))
3712 $strPermission = BLOG_PERMS_PREMODERATE;
3713 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "view_comment"))
3714 $strPermission = BLOG_PERMS_READ;
3715 }
3716 }
3717
3718 $UserIP = CBlogUser::GetUserIP();
3719 $path_to_post = ($arFields["ENTITY_TYPE"] == SONET_ENTITY_GROUP ? $arFields["PATH_TO_GROUP_BLOG_POST"] : $arFields["PATH_TO_USER_BLOG_POST"]);
3720
3721 $arFieldsComment = Array(
3722 "POST_ID" => $arPost["ID"],
3723 "BLOG_ID" => $arBlog["ID"],
3724 "POST_TEXT" => $arFields["TEXT_MESSAGE"],
3725 "DATE_CREATE" => ConvertTimeStamp(time()+CTimeZone::GetOffset(), "FULL"),
3726 "AUTHOR_IP" => $UserIP[0],
3727 "AUTHOR_IP1" => $UserIP[1],
3728 "AUTHOR_ID" => $userID,
3729 "PARENT_ID" => false
3730 );
3731
3732 if($strPermission == BLOG_PERMS_PREMODERATE)
3733 {
3734 $arFieldsComment["PUBLISH_STATUS"] = BLOG_PUBLISH_STATUS_READY;
3735 $strNotes = GetMessage("SONET_GL_ADD_COMMENT_BLOG_PREMODERATE");
3736 }
3737
3738 $commentUrl = CComponentEngine::MakePathFromTemplate(
3739 htmlspecialcharsBack($path_to_post),
3740 array(
3741 "blog" => $arBlog["URL"],
3742 "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arFields["BLOG_ALLOW_POST_CODE"]),
3743 "user_id" => $arBlog["OWNER_ID"],
3744 "group_id" => ($arFields["ENTITY_TYPE"] == SONET_ENTITY_GROUP ? $arFields["ENTITY_ID"] : false)
3745 )
3746 );
3747
3748 $arFieldsComment["PATH"] = $commentUrl.(mb_strpos($arFieldsComment["PATH"], "?") !== false ? "&" : "?")."commentId=#comment_id##com#comment_id#";
3749
3750 $commentId = CBlogComment::Add($arFieldsComment);
3751 if($strPermission == BLOG_PERMS_PREMODERATE)
3752 unset($commentId);
3753
3754 BXClearCache(True, "/".SITE_ID."/blog/".$arBlog["URL"]."/comment/".$arPost["ID"]."/");
3755 BXClearCache(True, "/".SITE_ID."/blog/".$arBlog["URL"]."/post/".$arPost["ID"]."/");
3756 BXClearCache(True, "/".SITE_ID."/blog/".$arBlog["URL"]."/first_page/");
3757 BXClearCache(True, "/".SITE_ID."/blog/last_comments/");
3758 BXClearCache(True, "/".SITE_ID."/blog/".$arBlog["URL"]."/rss_out/".$arPost["POST_ID"]."/C/");
3759 BXClearCache(True, "/".SITE_ID."/blog/last_messages/");
3760 BXClearCache(True, "/".SITE_ID."/blog/commented_posts/");
3761 BXClearCache(True, ComponentHelper::getBlogPostCacheDir(array(
3762 'TYPE' => 'posts_popular',
3763 'SITE_ID' => SITE_ID
3764 )));
3765 }
3766 else
3767 $strError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
3768 }
3769
3770 return array(
3771 "SOURCE_ID" => $commentId,
3772 "RATING_TYPE_ID" => "BLOG_COMMENT",
3773 "RATING_ENTITY_ID" => $commentId,
3774 "ERROR" => $strError,
3775 "NOTES" => $strNotes
3776 );
3777 }
3778
3779 public static function AddComment_Microblog($arFields)
3780 {
3781 global $USER, $APPLICATION;
3782
3783 if (!CModule::IncludeModule("blog"))
3784 return false;
3785
3787 array(),
3788 array("ID" => $arFields["LOG_ID"]),
3789 false,
3790 false,
3791 array("ID", "SOURCE_ID", "SITE_ID")
3792 );
3793
3794 if ($arLog = $dbResult->Fetch())
3795 {
3796 $arPost = CBlogPost::GetByID($arLog["SOURCE_ID"]);
3797 if ($arPost)
3798 {
3799 $arBlog = CBlog::GetByID($arPost["BLOG_ID"]);
3800 $userID = $USER->GetID();
3801
3802 $arLogSites = array();
3803 $rsLogSite = CSocNetLog::GetSite($arLog["ID"]);
3804 while ($arLogSite = $rsLogSite->Fetch())
3805 $arLogSites[] = $arLogSite["LID"];
3806
3807 $bCurrentUserIsAdmin = CSocNetUser::IsCurrentUserModuleAdmin($arLogSites);
3808 $strPermission = BLOG_PERMS_DENY;
3809 $strPostPermission = BLOG_PERMS_DENY;
3810
3811 if ($arFields["ENTITY_TYPE"] == SONET_ENTITY_GROUP)
3812 {
3813 if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "full_post", $bCurrentUserIsAdmin))
3814 $strPostPermission = BLOG_PERMS_FULL;
3815 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "premoderate_post"))
3816 $strPostPermission = BLOG_PERMS_PREMODERATE;
3817 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "write_post"))
3818 $strPostPermission = BLOG_PERMS_WRITE;
3819 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "moderate_post"))
3820 $strPostPermission = BLOG_PERMS_MODERATE;
3821 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "view_post"))
3822 $strPostPermission = BLOG_PERMS_READ;
3823
3824 if($strPostPermission > BLOG_PERMS_DENY)
3825 {
3826 if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "full_comment", $bCurrentUserIsAdmin))
3827 $strPermission = BLOG_PERMS_FULL;
3828 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "moderate_comment"))
3829 $strPermission = BLOG_PERMS_MODERATE;
3830 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "write_comment"))
3831 $strPermission = BLOG_PERMS_WRITE;
3832 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "premoderate_comment"))
3833 $strPermission = BLOG_PERMS_PREMODERATE;
3834 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "blog", "view_comment"))
3835 $strPermission = BLOG_PERMS_READ;
3836 }
3837 }
3838 else
3839 {
3840 if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "full_post", $bCurrentUserIsAdmin) || CMain::GetGroupRight("blog") >= "W" || $arFields["USER_ID"] == $userID)
3841 $strPostPermission = BLOG_PERMS_FULL;
3842 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "moderate_post"))
3843 $strPostPermission = BLOG_PERMS_MODERATE;
3844 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "write_post"))
3845 $strPostPermission = BLOG_PERMS_WRITE;
3846 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "premoderate_post"))
3847 $strPostPermission = BLOG_PERMS_PREMODERATE;
3848 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "view_post"))
3849 $strPostPermission = BLOG_PERMS_READ;
3850
3851 if($strPostPermission > BLOG_PERMS_DENY)
3852 {
3853 if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "full_comment", $bCurrentUserIsAdmin) || CMain::GetGroupRight("blog") >= "W" || $arFields["USER_ID"] == $userID)
3854 $strPermission = BLOG_PERMS_FULL;
3855 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "moderate_comment"))
3856 $strPermission = BLOG_PERMS_MODERATE;
3857 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "write_comment"))
3858 $strPermission = BLOG_PERMS_WRITE;
3859 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "premoderate_comment"))
3860 $strPermission = BLOG_PERMS_PREMODERATE;
3861 elseif (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $arFields["ENTITY_ID"], "blog", "view_comment"))
3862 $strPermission = BLOG_PERMS_READ;
3863 }
3864 }
3865
3866 $UserIP = CBlogUser::GetUserIP();
3867 $path_to_post = ($arFields["ENTITY_TYPE"] == SONET_ENTITY_GROUP ? $arFields["PATH_TO_GROUP_MICROBLOG_POST"] : $arFields["PATH_TO_USER_MICROBLOG_POST"]);
3868
3869 $arFieldsComment = Array(
3870 "POST_ID" => $arPost["ID"],
3871 "BLOG_ID" => $arBlog["ID"],
3872 "POST_TEXT" => $arFields["TEXT_MESSAGE"],
3873 "DATE_CREATE" => ConvertTimeStamp(time()+CTimeZone::GetOffset(), "FULL"),
3874 "AUTHOR_IP" => $UserIP[0],
3875 "AUTHOR_IP1" => $UserIP[1],
3876 "AUTHOR_ID" => $userID,
3877 "PARENT_ID" => false
3878 );
3879
3880 if($strPermission == BLOG_PERMS_PREMODERATE)
3881 {
3882 $arFieldsComment["PUBLISH_STATUS"] = BLOG_PUBLISH_STATUS_READY;
3883 $strNotes = GetMessage("SONET_GL_ADD_COMMENT_BLOG_PREMODERATE");
3884 }
3885
3886 $commentUrl = CComponentEngine::MakePathFromTemplate(
3887 htmlspecialcharsBack($path_to_post),
3888 array(
3889 "blog" => $arBlog["URL"],
3890 "post_id" => CBlogPost::GetPostID($arPost["ID"], $arPost["CODE"], $arFields["BLOG_ALLOW_POST_CODE"]),
3891 "user_id" => $arBlog["OWNER_ID"],
3892 "group_id" => ($arFields["ENTITY_TYPE"] == SONET_ENTITY_GROUP ? $arFields["ENTITY_ID"] : false)
3893 )
3894 );
3895
3896 $arFieldsComment["PATH"] = $commentUrl.(mb_strpos($arFieldsComment["PATH"], "?") !== false ? "&" : "?")."commentId=#comment_id##com#comment_id#";
3897
3898 $commentId = CBlogComment::Add($arFieldsComment);
3899 if($strPermission == BLOG_PERMS_PREMODERATE)
3900 unset($commentId);
3901
3902 BXClearCache(True, "/".SITE_ID."/blog/".$arBlog["URL"]."/comment/".$arPost["ID"]."/");
3903 BXClearCache(True, "/".SITE_ID."/blog/".$arBlog["URL"]."/post/".$arPost["ID"]."/");
3904 BXClearCache(True, "/".SITE_ID."/blog/".$arBlog["URL"]."/first_page/");
3905 BXClearCache(True, "/".SITE_ID."/blog/last_comments/");
3906 BXClearCache(True, "/".SITE_ID."/blog/".$arBlog["URL"]."/rss_out/".$arPost["POST_ID"]."/C/");
3907 BXClearCache(True, "/".SITE_ID."/blog/last_messages/");
3908 BXClearCache(True, "/".SITE_ID."/blog/commented_posts/");
3909 BXClearCache(True, ComponentHelper::getBlogPostCacheDir(array(
3910 'TYPE' => 'posts_popular',
3911 'SITE_ID' => SITE_ID
3912 )));
3913 }
3914 else
3915 $strError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
3916 }
3917
3918 return array(
3919 "SOURCE_ID" => $commentId,
3920 "RATING_TYPE_ID" => "BLOG_COMMENT",
3921 "RATING_ENTITY_ID" => $commentId,
3922 "ERROR" => $strError,
3923 "NOTES" => $strNotes
3924 );
3925 }
3926
3927 public static function AddComment_Files($arFields)
3928 {
3929 if (!CModule::IncludeModule("forum"))
3930 return false;
3931
3932 if (!CModule::IncludeModule("iblock"))
3933 return false;
3934
3936 array(),
3937 array("ID" => $arFields["LOG_ID"]),
3938 false,
3939 false,
3940 array("ID", "SOURCE_ID", "PARAMS")
3941 );
3942
3943 $bFound = false;
3944 if ($arLog = $dbResult->Fetch())
3945 {
3946 if ($arLog["PARAMS"] <> '')
3947 {
3948 $arFieldsParams = explode("&", $arLog["PARAMS"]);
3949 if (is_array($arFieldsParams) && count($arFieldsParams) > 0)
3950 {
3951 foreach ($arFieldsParams as $tmp)
3952 {
3953 list($key, $value) = explode("=", $tmp);
3954 if ($key == "forum_id")
3955 {
3956 $FORUM_ID = intval($value);
3957 break;
3958 }
3959 }
3960 }
3961 }
3962 if ($FORUM_ID > 0 && intval($arLog["SOURCE_ID"]) > 0)
3963 $bFound = true;
3964 }
3965
3966 if ($bFound)
3967 {
3968 $arElement = false;
3969
3970 $arFilter = array("ID" => $arLog["SOURCE_ID"]);
3971 $arSelectedFields = array("IBLOCK_ID", "ID", "NAME", "TAGS", "CODE", "IBLOCK_SECTION_ID", "DETAIL_PAGE_URL",
3972 "CREATED_BY", "PREVIEW_PICTURE", "PREVIEW_TEXT", "PROPERTY_FORUM_TOPIC_ID", "PROPERTY_FORUM_MESSAGE_CNT");
3973 $db_res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelectedFields);
3974 if ($db_res && $res = $db_res->GetNext())
3975 $arElement = $res;
3976
3977 if ($arElement)
3978 {
3979 // check iblock properties
3981
3983 array(),
3984 array(
3985 "PARAM1" => "IB",
3986 "PARAM2" => $arElement["ID"]
3987 )
3988 );
3989
3990 if (!$arMessage = $dbMessage->Fetch())
3991 {
3992 // Add Topic and Root Message
3993 $arForum = CForumNew::GetByID($FORUM_ID);
3994 $sImage = "";
3995 if (intval($arElement["PREVIEW_PICTURE"]) > 0):
3996 $arImage = CFile::GetFileArray($arElement["PREVIEW_PICTURE"]);
3997 if (!empty($arImage))
3998 $sImage = ($arForum["ALLOW_IMG"] == "Y" ? "[IMG]".$arImage["SRC"]."[/IMG]" : '');
3999 endif;
4000 $sElementPreview = $arElement["~PREVIEW_TEXT"];
4001 if ($arForum["ALLOW_HTML"] != "Y")
4002 $sElementPreview = strip_tags($sElementPreview);
4003
4004 $strFirstMessage = str_replace(array("#IMAGE#", "#TITLE#", "#BODY#"),
4005 array($sImage, $arElement["~NAME"], $sElementPreview),
4006 GetMessage("WD_TEMPLATE_MESSAGE"));
4007
4008 $TOPIC_ID = CSocNetLogTools::AddComment_Review_CreateRoot_Forum($arElement, $FORUM_ID, true, $strFirstMessage);
4009 $bNewTopic = true;
4010 }
4011 else
4012 $TOPIC_ID = $arMessage["TOPIC_ID"];
4013
4014 if(intval($TOPIC_ID) > 0)
4015 {
4016 // Add comment
4017 $messageID = false;
4018 $arFieldsMessage = array(
4019 "POST_MESSAGE" => $arFields["TEXT_MESSAGE"],
4020 "USE_SMILES" => "Y",
4021 "PARAM2" => $arElement["ID"],
4022 "APPROVED" => "Y"
4023 );
4024 $messageID = ForumAddMessage("REPLY", $FORUM_ID, $TOPIC_ID, 0, $arFieldsMessage, $sError, $sNote);
4025
4026 if (!$messageID)
4027 $strError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
4028 else
4029 CSocNetLogTools::AddComment_Review_UpdateElement_Forum($arElement, $TOPIC_ID, $bNewTopic);
4030 }
4031 else
4032 $strError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
4033 }
4034 else
4035 $strError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
4036 }
4037 else
4038 $strError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
4039
4040 return array(
4041 "SOURCE_ID" => $messageID,
4042 "RATING_TYPE_ID" => "FORUM_POST",
4043 "RATING_ENTITY_ID" => $messageID,
4044 "ERROR" => $strError,
4045 "NOTES" => ""
4046 );
4047 }
4048
4049 public static function AddComment_Review_CheckIBlock($arElement)
4050 {
4052 }
4053
4054 public static function AddComment_Review_CheckIBlock_Forum($arElement)
4055 {
4056 if (!CModule::IncludeModule("iblock"))
4057 return false;
4058
4059 if (!CModule::IncludeModule("forum"))
4060 return false;
4061
4062 $needProperty = array();
4063 $ELEMENT_IBLOCK_ID = intval($arElement["IBLOCK_ID"]);
4064 $ELEMENT_FORUM_TOPIC_ID = intval($arElement["PROPERTY_FORUM_TOPIC_ID_VALUE"]);
4065 $ELEMENT_FORUM_MESSAGE_CNT = intval($arElement["PROPERTY_FORUM_MESSAGE_CNT_VALUE"]);
4066
4067 if ($ELEMENT_FORUM_TOPIC_ID <= 0):
4068 $db_res = CIBlockElement::GetProperty($ELEMENT_IBLOCK_ID, $arElement["ID"], false, false, array("CODE" => "FORUM_TOPIC_ID"));
4069 if (!($db_res && $res = $db_res->Fetch()))
4070 $needProperty[] = "FORUM_TOPIC_ID";
4071 endif;
4072 if ($ELEMENT_FORUM_MESSAGE_CNT <= 0):
4073 $db_res = CIBlockElement::GetProperty($ELEMENT_IBLOCK_ID, $arElement["ID"], false, false, array("CODE" => "FORUM_MESSAGE_CNT"));
4074 if (!($db_res && $res = $db_res->Fetch()))
4075 $needProperty[] = "FORUM_MESSAGE_CNT";
4076 endif;
4077 if (!empty($needProperty)):
4078 $obProperty = new CIBlockProperty;
4079 $res = true;
4080 foreach ($needProperty as $nameProperty)
4081 {
4082 $sName = trim($nameProperty == "FORUM_TOPIC_ID" ? GetMessage("F_FORUM_TOPIC_ID") : GetMessage("F_FORUM_MESSAGE_CNT"));
4083 $sName = (empty($sName) ? $nameProperty : $sName);
4084 $res = $obProperty->Add(array(
4085 "IBLOCK_ID" => $ELEMENT_IBLOCK_ID,
4086 "ACTIVE" => "Y",
4087 "PROPERTY_TYPE" => "N",
4088 "MULTIPLE" => "N",
4089 "NAME" => $sName,
4090 "CODE" => $nameProperty
4091 )
4092 );
4093 }
4094 endif;
4095
4096 // Set NULL for topic_id if it was deleted
4097 if ($ELEMENT_FORUM_TOPIC_ID > 0):
4098 $arTopic = CForumTopic::GetByID($ELEMENT_FORUM_TOPIC_ID);
4099 if (!$arTopic || !is_array($arTopic) || count($arTopic) <= 0)
4100 {
4101 CIBlockElement::SetPropertyValues($arElement["ID"], $ELEMENT_IBLOCK_ID, 0, "FORUM_TOPIC_ID");
4102 $ELEMENT_FORUM_TOPIC_ID = 0;
4103 }
4104 endif;
4105
4106 return true;
4107 }
4108
4109 public static function AddComment_Review_CheckIBlock_Blog($arElement)
4110 {
4111 if (!CModule::IncludeModule("iblock"))
4112 return false;
4113
4114 if (!CModule::IncludeModule("blog"))
4115 return false;
4116
4117 $needProperty = array();
4118 $ELEMENT_IBLOCK_ID = intval($arElement["IBLOCK_ID"]);
4119 $ELEMENT_BLOG_POST_ID = intval($arElement["PROPERTY_BLOG_POST_ID_VALUE"]);
4120 $ELEMENT_BLOG_COMMENT_CNT = intval($arElement["PROPERTY_BLOG_COMMENT_CNT_VALUE"]);
4121
4122 if ($ELEMENT_BLOG_POST_ID <= 0):
4123 $db_res = CIBlockElement::GetProperty($ELEMENT_IBLOCK_ID, $arElement["ID"], false, false, array("CODE" => "BLOG_POST_ID"));
4124 if (!($db_res && $res = $db_res->Fetch()))
4125 $needProperty[] = "BLOG_POST_ID";
4126 endif;
4127 if ($ELEMENT_BLOG_COMMENT_CNT <= 0):
4128 $db_res = CIBlockElement::GetProperty($ELEMENT_IBLOCK_ID, $arElement["ID"], false, false, array("CODE" => "BLOG_COMMENT_CNT"));
4129 if (!($db_res && $res = $db_res->Fetch()))
4130 $needProperty[] = "BLOG_COMMENT_CNT";
4131 endif;
4132 if (!empty($needProperty)):
4133 $obProperty = new CIBlockProperty;
4134 $res = true;
4135 foreach ($needProperty as $nameProperty)
4136 {
4137 $sName = trim($nameProperty == "BLOG_POST_ID" ? GetMessage("P_BLOG_POST_ID") : GetMessage("P_BLOG_COMMENTS_CNT"));
4138 $sName = (empty($sName) ? $nameProperty : $sName);
4139 $res = $obProperty->Add(array(
4140 "IBLOCK_ID" => $ELEMENT_IBLOCK_ID,
4141 "ACTIVE" => "Y",
4142 "PROPERTY_TYPE" => "N",
4143 "MULTIPLE" => "N",
4144 "NAME" => $sName,
4145 "CODE" => $nameProperty
4146 )
4147 );
4148 }
4149 endif;
4150
4151 // Set NULL for post_id if it was deleted
4152 if ($ELEMENT_BLOG_POST_ID > 0):
4153 $arTopic = CBlogPost::GetByID($ELEMENT_BLOG_POST_ID);
4154 if (!$arTopic || !is_array($arTopic) || count($arTopic) <= 0)
4155 {
4156 CIBlockElement::SetPropertyValues($arElement["ID"], $ELEMENT_IBLOCK_ID, 0, "BLOG_POST_ID");
4157 $ELEMENT_BLOG_POST_ID = 0;
4158 }
4159 endif;
4160
4161 return $ELEMENT_BLOG_POST_ID;
4162 }
4163
4164 public static function AddComment_Review_CreateRoot($arElement, $forumID, $bPostFirstMessage = false, $strFirstMessage = "")
4165 {
4166 return CSocNetLogTools::AddComment_Review_CreateRoot_Forum($arElement, $forumID, $bPostFirstMessage, $strFirstMessage);
4167 }
4168
4169 public static function AddComment_Review_CreateRoot_Forum($arElement, $forumID, $bPostFirstMessage = false, $strFirstMessage = "")
4170 {
4171 global $DB;
4172
4173 if (!CModule::IncludeModule("forum"))
4174 return false;
4175
4176 if ($bPostFirstMessage && $strFirstMessage == '')
4177 return false;
4178
4179 // Add Topic
4180 $arUserStart = array(
4181 "ID" => intval($arElement["~CREATED_BY"]),
4182 "NAME" => $GLOBALS["FORUM_STATUS_NAME"]["guest"]
4183 );
4184 if ($arUserStart["ID"] > 0)
4185 {
4186 $res = array();
4187 $db_res = CForumUser::GetListEx(array(), array("USER_ID" => $arElement["~CREATED_BY"]));
4188 if ($db_res && $res = $db_res->Fetch()):
4189 $res["FORUM_USER_ID"] = intval($res["ID"]);
4190 $res["ID"] = $res["USER_ID"];
4191 else:
4192 $db_res = CUser::GetByID($arElement["~CREATED_BY"]);
4193 if ($db_res && $res = $db_res->Fetch()):
4194 $res["SHOW_NAME"] = COption::GetOptionString("forum", "USER_SHOW_NAME", "Y");
4195 $res["USER_PROFILE"] = "N";
4196 endif;
4197 endif;
4198 if (!empty($res)):
4199 $arUserStart = $res;
4200 $sName = ($res["SHOW_NAME"] == "Y" ? trim($res["NAME"]." ".$res["LAST_NAME"]) : "");
4201 $arUserStart["NAME"] = (empty($sName) ? trim($res["LOGIN"]) : $sName);
4202 endif;
4203 }
4204 $arUserStart["NAME"] = (empty($arUserStart["NAME"]) ? $GLOBALS["FORUM_STATUS_NAME"]["guest"] : $arUserStart["NAME"]);
4205
4206 $DB->StartTransaction();
4207 $arFields = Array(
4208 "TITLE" => $arElement["~NAME"],
4209 "TAGS" => $arElement["~TAGS"],
4210 "FORUM_ID" => $forumID,
4211 "USER_START_ID" => $arUserStart["ID"],
4212 "USER_START_NAME" => $arUserStart["NAME"],
4213 "LAST_POSTER_NAME" => $arUserStart["NAME"],
4214 "APPROVED" => "Y",
4215 "XML_ID" => "IBLOCK_".$arElement["ID"]
4216 );
4217
4218 if (
4219 isset($arElement["ENTITY_TYPE"])
4220 && $arElement["ENTITY_TYPE"] == SONET_ENTITY_GROUP
4221 && isset($arElement["ENTITY_ID"])
4222 && intval($arElement["ENTITY_ID"]) > 0
4223 )
4224 {
4225 $arFields["SOCNET_GROUP_ID"] = intval($arElement["ENTITY_ID"]);
4226 }
4227
4228 $TOPIC_ID = CForumTopic::Add($arFields);
4229
4230 if ($bPostFirstMessage && intval($TOPIC_ID) > 0)
4231 {
4232 if (COption::GetOptionString("forum", "FILTER", "Y") == "Y")
4233 $strFirstMessage = CFilterUnquotableWords::Filter($strFirstMessage);
4234
4235 // Add post as new message
4236 $arFields = Array(
4237 "POST_MESSAGE" => $strFirstMessage,
4238 "AUTHOR_ID" => $arUserStart["ID"],
4239 "AUTHOR_NAME" => $arUserStart["NAME"],
4240 "FORUM_ID" => $forumID,
4241 "TOPIC_ID" => $TOPIC_ID,
4242 "APPROVED" => "Y",
4243 "NEW_TOPIC" => "Y",
4244 "PARAM1" => "IB",
4245 "PARAM2" => intval($arElement["ID"])
4246 );
4247 $MID = CForumMessage::Add($arFields, false, array("SKIP_INDEXING" => "Y", "SKIP_STATISTIC" => "N"));
4248
4249 if (intval($MID) <= 0)
4250 {
4251 $arError[] = array(
4252 "code" => "message is not added 1",
4253 "title" => GetMessage("F_ERR_ADD_MESSAGE"));
4254 CForumTopic::Delete($TOPIC_ID);
4255 $TOPIC_ID = 0;
4256 }
4257 }
4258 elseif (intval($TOPIC_ID) <= 0)
4259 {
4260 $DB->Rollback();
4261 return false;
4262 }
4263
4264 $DB->Commit();
4265
4266 return $TOPIC_ID;
4267 }
4268
4269 public static function AddComment_Review_CreateRoot_Blog($arElement, $blogID)
4270 {
4271 global $DB;
4272
4273 if (!CModule::IncludeModule("blog"))
4274 return false;
4275
4276 $arBlog = CBlog::GetByID($blogID);
4277
4278 $arElement["DETAIL_PICTURE"] = CFile::GetFileArray($arElement["DETAIL_PICTURE"]);
4279 $arElement["REAL_PICTURE"] = CFile::GetFileArray($arElement["PROPERTY_REAL_PICTURE_VALUE"]);
4280
4281 if (!empty($arElement["TAGS"]))
4282 {
4283 $arCategoryVal = explode(",", $arElement["TAGS"]);
4284 foreach($arCategoryVal as $k => $v)
4285 {
4286 if ($id = CBlogCategory::Add(array("BLOG_ID" => $arBlog["ID"],"NAME" => $v)))
4287 $arCategory[] = $id;
4288 }
4289 }
4290
4292 "TITLE" => $arElement["NAME"],
4293 "DETAIL_TEXT" =>
4294 "[IMG]http://".$_SERVER['HTTP_HOST'].$arElement["DETAIL_PICTURE"]["SRC"]."[/IMG]\n".
4295 "[URL=http://".$_SERVER['HTTP_HOST'].$arElement["~DETAIL_PAGE_URL"]."]".$arElement["NAME"]."[/URL]\n".
4296 (!empty($arElement["TAGS"]) ? $arElement["TAGS"]."\n" : "").
4297 $arElement["~DETAIL_TEXT"]."\n".
4298 "[URL=http://".$_SERVER['HTTP_HOST'].$arElement["REAL_PICTURE"]["SRC"]."]".GetMessage("P_ORIGINAL")."[/URL]",
4299 "CATEGORY_ID" => implode(",", $arCategory),
4300 "PUBLISH_STATUS" => "P",
4301 "PERMS_POST" => array(),
4302 "PERMS_COMMENT" => array(),
4303 "=DATE_CREATE" => $DB->GetNowFunction(),
4304 "=DATE_PUBLISH" => $DB->GetNowFunction(),
4305 "AUTHOR_ID" => (!empty($arElement["CREATED_BY"]) ? $arElement["CREATED_BY"] : 1),
4306 "BLOG_ID" => $arBlog["ID"],
4307 "ENABLE_TRACKBACK" => "N"
4308 );
4309
4310 $POST_ID = CBlogPost::Add($arFields);
4311
4312 return $POST_ID;
4313 }
4314
4315 public static function AddComment_Review_UpdateElement($arElement, $topicID, $bNewTopic)
4316 {
4317 CSocNetLogTools::AddComment_Review_UpdateElement_Forum($arElement, $topicID, $bNewTopic);
4318 }
4319
4320 public static function AddComment_Review_UpdateElement_Forum($arElement, $topicID, $bNewTopic)
4321 {
4322 if (!CModule::IncludeModule("forum"))
4323 return false;
4324
4325 if ($bNewTopic):
4326 CIBlockElement::SetPropertyValues($arElement["ID"], $arElement["IBLOCK_ID"], intval($topicID), "FORUM_TOPIC_ID");
4327 $FORUM_MESSAGE_CNT = 1;
4328 else:
4329 $FORUM_MESSAGE_CNT = CForumMessage::GetList(array(), array("TOPIC_ID" => $topicID, "APPROVED" => "Y", "!PARAM1" => "IB"), true);
4330 endif;
4331 CIBlockElement::SetPropertyValues($arElement["ID"], $arElement["IBLOCK_ID"], intval($FORUM_MESSAGE_CNT), "FORUM_MESSAGE_CNT");
4332 ForumClearComponentCache("bitrix:forum.topic.reviews");
4333 }
4334
4335 public static function AddComment_Review_UpdateElement_Blog($arElement, $postID, $blogID, $bNewPost)
4336 {
4337 if (!CModule::IncludeModule("blog"))
4338 return false;
4339
4340 if ($bNewPost):
4341 CIBlockElement::SetPropertyValues($arElement["ID"], $arElement["IBLOCK_ID"], intval($postID), "BLOG_POST_ID");
4342 $BLOG_COMMENT_CNT = 1;
4343 else:
4344 $BLOG_COMMENT_CNT = CBlogComment::GetList(array(), array("POST_ID" => $postID), array());
4345 endif;
4346
4347 CIBlockElement::SetPropertyValues($arElement["ID"], $arElement["IBLOCK_ID"], intval($BLOG_COMMENT_CNT), "BLOG_COMMENT_CNT");
4348
4349 $arBlog = CBlog::GetByID($blogID);
4350
4351 BXClearCache(True, "/".SITE_ID."/blog/".$arBlog["URL"]."/comment/".$postID."/");
4352 BXClearCache(True, "/".SITE_ID."/blog/".$arBlog["URL"]."/post/".$postID."/");
4353 BXClearCache(True, "/".SITE_ID."/blog/".$arBlog["URL"]."/first_page/");
4354 BXClearCache(True, "/".SITE_ID."/blog/last_comments/");
4355 BXClearCache(True, "/".SITE_ID."/blog/".$arBlog["URL"]."/rss_out/".$postID."/C/");
4356 BXClearCache(True, "/".SITE_ID."/blog/last_messages/");
4357 BXClearCache(True, "/".SITE_ID."/blog/commented_posts/");
4358 BXClearCache(True, ComponentHelper::getBlogPostCacheDir(array(
4359 'TYPE' => 'posts_popular',
4360 'SITE_ID' => SITE_ID
4361 )));
4362 }
4363
4364 public static function OnAfterPhotoUpload($arFields, $arComponentParams, $arComponentResult)
4365 {
4366 CSocNetLogToolsPhoto::OnAfterPhotoUpload($arFields, $arComponentParams, $arComponentResult);
4367 }
4368
4369 public static function OnAfterPhotoDrop($arFields, $arComponentParams)
4370 {
4372 }
4373
4374 public static function OnBeforeSectionDrop($sectionID, $arComponentParams, $arComponentResult, &$arSectionID, &$arElementID)
4375 {
4376 CSocNetLogToolsPhoto::OnBeforeSectionDrop($sectionID, $arComponentParams, $arComponentResult, $arSectionID, $arElementID);
4377 }
4378
4379 public static function OnAfterSectionDrop($ID, $arFields, $arComponentParams, $arComponentResult)
4380 {
4381 CSocNetLogToolsPhoto::OnAfterSectionDrop($ID, $arFields, $arComponentParams, $arComponentResult);
4382 }
4383
4384 public static function OnAfterSectionEdit($arFields, $arComponentParams, $arComponentResult)
4385 {
4386 CSocNetLogToolsPhoto::OnAfterSectionEdit($arFields, $arComponentParams, $arComponentResult);
4387 }
4388
4389 public static function FormatDestinationFromRights($arRights, $arParams, &$iMoreCount = false)
4390 {
4391 static $arDepartmentsStaticCache = array();
4392
4393 if (empty($arRights))
4394 {
4395 return array();
4396 }
4397
4398 $arDestination = array();
4399 $arSonetGroups = array();
4400
4401 $bCheckPermissions = (
4402 !array_key_exists("CHECK_PERMISSIONS_DEST", $arParams)
4403 || $arParams["CHECK_PERMISSIONS_DEST"] !== "N"
4404 );
4405
4406 $htmlEncode = (
4407 !array_key_exists("HTML_ENCODE", $arParams)
4408 || $arParams["HTML_ENCODE"] !== "N"
4409 );
4410
4411 if (!function_exists("__DestinationRightsSort"))
4412 {
4413 function __DestinationRightsSort($a, $b)
4414 {
4415 if ($a == $b)
4416 {
4417 return 0;
4418 }
4419
4420 if (preg_match('/^US\d+$/', $a))
4421 {
4422 return -1;
4423 }
4424 elseif (in_array($a, array("G2", "AU")))
4425 {
4426 if (in_array($b, array("G2", "AU")))
4427 {
4428 return 0;
4429 }
4430
4431 if (preg_match('/^US\d+$/', $b))
4432 {
4433 return 1;
4434 }
4435
4436 return -1;
4437 }
4438 elseif (preg_match('/^CRMDEAL\d+$/', $a))
4439 {
4440 if (preg_match('/^CRMDEAL\d+$/', $b))
4441 {
4442 return 0;
4443 }
4444
4445 if (
4446 preg_match('/^US\d+$/', $b)
4447 || in_array($b, array("G2", "AU"))
4448 )
4449 {
4450 return 1;
4451 }
4452
4453 return -1;
4454 }
4455 elseif (preg_match('/^CRMCONTACT\d+$/', $a))
4456 {
4457 if (preg_match('/^CRMCONTACT\d+$/', $b))
4458 {
4459 return 0;
4460 }
4461
4462 if (
4463 preg_match('/^US\d+$/', $b)
4464 || in_array($b, array("G2", "AU"))
4465 || preg_match('/^CRMDEAL\d+$/', $b)
4466 )
4467 {
4468 return 1;
4469 }
4470
4471 return -1;
4472 }
4473 elseif (preg_match('/^CRMCOMPANY\d+$/', $a))
4474 {
4475 if (preg_match('/^CRMCOMPANY\d+$/', $b))
4476 {
4477 return 0;
4478 }
4479
4480 if (
4481 preg_match('/^US\d+$/', $b)
4482 || in_array($b, array("G2", "AU"))
4483 || preg_match('/^CRMDEAL\d+$/', $b)
4484 || preg_match('/^CRMCONTACT\d+$/', $b)
4485 )
4486 {
4487 return 1;
4488 }
4489
4490 return -1;
4491 }
4492 elseif (preg_match('/^CRMLEAD\d+$/', $a))
4493 {
4494 if (preg_match('/^CRMLEAD\d+$/', $b))
4495 {
4496 return 0;
4497 }
4498
4499 if (
4500 preg_match('/^US\d+$/', $b)
4501 || in_array($b, array("G2", "AU"))
4502 || preg_match('/^CRMDEAL\d+$/', $b)
4503 || preg_match('/^CRMCONTACT\d+$/', $b)
4504 || preg_match('/^CRMCOMPANY\d+$/', $b)
4505 )
4506 {
4507 return 1;
4508 }
4509
4510 return -1;
4511 }
4512 elseif (preg_match('/^CRMDYNAMIC\d+ENTITY\d+$/', $a))
4513 {
4514 if (preg_match('/^CRMDYNAMIC\d+ENTITY\d+$/', $b))
4515 {
4516 return 0;
4517 }
4518
4519 if (
4520 preg_match('/^US\d+$/', $b)
4521 || in_array($b, array("G2", "AU"))
4522 || preg_match('/^CRMDEAL\d+$/', $b)
4523 || preg_match('/^CRMCONTACT\d+$/', $b)
4524 || preg_match('/^CRMCOMPANY\d+$/', $b)
4525 || preg_match('/^CRMLEAD\d+$/', $b)
4526 )
4527 {
4528 return 1;
4529 }
4530
4531 return -1;
4532 }
4533 elseif (preg_match('/^CRMSUSDYNAMIC\d+ENTITY\d+$/', $a))
4534 {
4535 if (preg_match('/^CRMSUSDYNAMIC\d+ENTITY\d+$/', $b))
4536 {
4537 return 0;
4538 }
4539
4540 if (
4541 preg_match('/^US\d+$/', $b)
4542 || in_array($b, array("G2", "AU"))
4543 || preg_match('/^CRMDEAL\d+$/', $b)
4544 || preg_match('/^CRMCONTACT\d+$/', $b)
4545 || preg_match('/^CRMCOMPANY\d+$/', $b)
4546 || preg_match('/^CRMLEAD\d+$/', $b)
4547 || preg_match('/^CRMDYNAMIC\d+ENTITY\d+$/', $b)
4548 )
4549 {
4550 return 1;
4551 }
4552
4553 return -1;
4554 }
4555 elseif (preg_match('/^SG\d+_'.SONET_ROLES_USER.'$/', $a))
4556 {
4557 if (preg_match('/^SG\d+_'.SONET_ROLES_USER.'$/', $b))
4558 {
4559 return 0;
4560 }
4561
4562 if (
4563 preg_match('/^US\d+$/', $b)
4564 || in_array($b, array("G2", "AU"))
4565 || preg_match('/^CRMDEAL\d+$/', $b)
4566 || preg_match('/^CRMCONTACT\d+$/', $b)
4567 || preg_match('/^CRMCOMPANY\d+$/', $b)
4568 || preg_match('/^CRMLEAD\d+$/', $b)
4569 || preg_match('/^CRMDYNAMIC\d+ENTITY\d+$/', $b)
4570 || preg_match('/^CRMSUSDYNAMIC\d+ENTITY\d+$/', $b)
4571 )
4572 {
4573 return 1;
4574 }
4575
4576 return -1;
4577 }
4578 elseif (preg_match('/^SG\d+_'.SONET_ROLES_MODERATOR.'$/', $a))
4579 {
4580 if (preg_match('/^SG\d+_'.SONET_ROLES_MODERATOR.'$/', $b))
4581 {
4582 return 0;
4583 }
4584
4585 if (
4586 preg_match('/^US\d+$/', $b)
4587 || in_array($b, array("G2", "AU"))
4588 || preg_match('/^SG\d+_'.SONET_ROLES_USER.'$/', $b)
4589 || preg_match('/^CRMDEAL\d+$/', $b)
4590 || preg_match('/^CRMCONTACT\d+$/', $b)
4591 || preg_match('/^CRMCOMPANY\d+$/', $b)
4592 || preg_match('/^CRMLEAD\d+$/', $b)
4593 || preg_match('/^CRMDYNAMIC\d+ENTITY\d+$/', $b)
4594 || preg_match('/^CRMSUSDYNAMIC\d+ENTITY\d+$/', $b)
4595 )
4596 {
4597 return 1;
4598 }
4599
4600 return -1;
4601 }
4602 elseif (preg_match('/^SG\d+_'.SONET_ROLES_OWNER.'$/', $a))
4603 {
4604 if (preg_match('/^SG\d+_'.SONET_ROLES_OWNER.'$/', $b))
4605 {
4606 return 0;
4607 }
4608
4609 if (
4610 preg_match('/^US\d+$/', $b)
4611 || in_array($b, array("G2", "AU"))
4612 || preg_match('/^SG\d+_'.SONET_ROLES_USER.'$/', $b)
4613 || preg_match('/^SG\d+_'.SONET_ROLES_MODERATOR.'$/', $b)
4614 || preg_match('/^CRMDEAL\d+$/', $b)
4615 || preg_match('/^CRMCONTACT\d+$/', $b)
4616 || preg_match('/^CRMCOMPANY\d+$/', $b)
4617 || preg_match('/^CRMLEAD\d+$/', $b)
4618 || preg_match('/^CRMDYNAMIC\d+ENTITY\d+$/', $b)
4619 || preg_match('/^CRMSUSDYNAMIC\d+ENTITY\d+$/', $b)
4620 )
4621 {
4622 return 1;
4623 }
4624
4625 return -1;
4626 }
4627 elseif (preg_match('/^D\d+$/', $a))
4628 {
4629 if (preg_match('/^D\d+$/', $b))
4630 {
4631 return 0;
4632 }
4633
4634 if (
4635 preg_match('/^US\d+$/', $b)
4636 || in_array($b, array("G2", "AU"))
4637 || preg_match('/^SG\d+_'.SONET_ROLES_USER.'$/', $b)
4638 || preg_match('/^SG\d+_'.SONET_ROLES_MODERATOR.'$/', $b)
4639 || preg_match('/^SG\d+_'.SONET_ROLES_OWNER.'$/', $b)
4640 || preg_match('/^CRMDEAL\d+$/', $b)
4641 || preg_match('/^CRMCONTACT\d+$/', $b)
4642 || preg_match('/^CRMCOMPANY\d+$/', $b)
4643 || preg_match('/^CRMLEAD\d+$/', $b)
4644 || preg_match('/^CRMDYNAMIC\d+ENTITY\d+$/', $b)
4645 || preg_match('/^CRMSUSDYNAMIC\d+ENTITY\d+$/', $b)
4646 )
4647 {
4648 return 1;
4649 }
4650
4651 return -1;
4652 }
4653 elseif (preg_match('/^DR\d+$/', $a))
4654 {
4655 if (preg_match('/^DR\d+$/', $b))
4656 {
4657 return 0;
4658 }
4659
4660 if (
4661 preg_match('/^US\d+$/', $b)
4662 || in_array($b, array("G2", "AU"))
4663 || preg_match('/^SG\d+_'.SONET_ROLES_USER.'$/', $b)
4664 || preg_match('/^SG\d+_'.SONET_ROLES_MODERATOR.'$/', $b)
4665 || preg_match('/^SG\d+_'.SONET_ROLES_OWNER.'$/', $b)
4666 || preg_match('/^D\d+$/', $b)
4667 || preg_match('/^CRMDEAL\d+$/', $b)
4668 || preg_match('/^CRMCONTACT\d+$/', $b)
4669 || preg_match('/^CRMCOMPANY\d+$/', $b)
4670 || preg_match('/^CRMLEAD\d+$/', $b)
4671 || preg_match('/^CRMDYNAMIC\d+ENTITY\d+$/', $b)
4672 || preg_match('/^CRMSUSDYNAMIC\d+ENTITY\d+$/', $b)
4673 )
4674 {
4675 return 1;
4676 }
4677
4678 return -1;
4679 }
4680 elseif(preg_match('/^U\d+$/', $a))
4681 {
4682 if (preg_match('/^U\d+$/', $b))
4683 {
4684 return 0;
4685 }
4686
4687 if (
4688 preg_match('/^US\d+$/', $b)
4689 || in_array($b, [ "G2", "AU" ])
4690 || preg_match('/^SG\d+_'.SONET_ROLES_USER.'$/', $b)
4691 || preg_match('/^SG\d+_'.SONET_ROLES_MODERATOR.'$/', $b)
4692 || preg_match('/^SG\d+_'.SONET_ROLES_OWNER.'$/', $b)
4693 || preg_match('/^D\d+$/', $b)
4694 || preg_match('/^DR\d+$/', $b)
4695 || preg_match('/^CRMDEAL\d+$/', $b)
4696 || preg_match('/^CRMCONTACT\d+$/', $b)
4697 || preg_match('/^CRMCOMPANY\d+$/', $b)
4698 || preg_match('/^CRMLEAD\d+$/', $b)
4699 || preg_match('/^CRMDYNAMIC\d+ENTITY\d+$/', $b)
4700 || preg_match('/^CRMSUSDYNAMIC\d+ENTITY\d+$/', $b)
4701 )
4702 {
4703 return 1;
4704 }
4705
4706 return -1;
4707 }
4708 elseif(preg_match('/^G\d+$/', $a))
4709 {
4710 if (preg_match('/^G\d+$/', $b))
4711 {
4712 return 0;
4713 }
4714
4715 if (
4716 preg_match('/^US\d+$/', $b)
4717 || in_array($b, [ "G2", "AU" ])
4718 || preg_match('/^SG\d+_'.SONET_ROLES_USER.'$/', $b)
4719 || preg_match('/^SG\d+_'.SONET_ROLES_MODERATOR.'$/', $b)
4720 || preg_match('/^SG\d+_'.SONET_ROLES_OWNER.'$/', $b)
4721 || preg_match('/^D\d+$/', $b)
4722 || preg_match('/^DR\d+$/', $b)
4723 || preg_match('/^U\d+$/', $b)
4724 || preg_match('/^CRMDEAL\d+$/', $b)
4725 || preg_match('/^CRMCONTACT\d+$/', $b)
4726 || preg_match('/^CRMCOMPANY\d+$/', $b)
4727 || preg_match('/^CRMLEAD\d+$/', $b)
4728 || preg_match('/^CRMDYNAMIC\d+ENTITY\d+$/', $b)
4729 || preg_match('/^CRMSUSDYNAMIC\d+ENTITY\d+$/', $b)
4730 )
4731 {
4732 return 1;
4733 }
4734
4735 return -1;
4736 }
4737 else
4738 {
4739 return 0;
4740 }
4741 }
4742 }
4743
4744 $arRights = array_unique($arRights);
4745 usort($arRights, "__DestinationRightsSort");
4746
4747 $cnt = 0;
4748 $bAll = false;
4749 $bJustCount = false;
4750
4751 $arGroupIdToGet = array();
4752 $arUserIdToGet = array();
4753 $arDepartmentIdToGet = array();
4754 $arSonetGroupIdToGet = array();
4755
4756 $avatarSize = (isset($arParams['AVATAR_SIZE']) ? (int)$arParams['AVATAR_SIZE'] : 100);
4757
4758 $arParams["DESTINATION_LIMIT"] = !isset($arParams["DESTINATION_LIMIT"]) || intval($arParams["DESTINATION_LIMIT"]) <= 0 ? 3 : $arParams["DESTINATION_LIMIT"];
4759
4760 $arModuleEvents = array();
4761 $db_events = GetModuleEvents("socialnetwork", "OnSocNetLogFormatDestination");
4762 while ($arEvent = $db_events->Fetch())
4763 {
4764 $arModuleEvents[] = $arEvent;
4765 }
4766
4767 foreach ($arRights as $right_tmp)
4768 {
4769 if ($cnt >= $arParams["DESTINATION_LIMIT"])
4770 {
4771 $bJustCount = true;
4772 }
4773
4774 if (
4775 $right_tmp === "G1"
4776 && count($arRights) > 1
4777 )
4778 {
4779 continue;
4780 }
4781
4782 if (
4783 preg_match('/^US\d+$/', $right_tmp, $matches)
4784 || in_array($right_tmp, array("G2", "AU"))
4785 )
4786 {
4787 if ($bAll)
4788 {
4789 continue;
4790 }
4791
4792 if (
4793 isset($arParams["USE_ALL_DESTINATION"])
4794 && $arParams["USE_ALL_DESTINATION"]
4795 && in_array($right_tmp, array("G2", "AU"))
4796 )
4797 {
4798 continue;
4799 }
4800
4801 if (!$bJustCount)
4802 {
4803 $destinationTitle = (
4804 ModuleManager::isModuleInstalled('intranet')
4805 ? GetMessage("SONET_GL_DESTINATION_G2")
4806 : GetMessage("SONET_GL_DESTINATION_G2_BSM")
4807 );
4808 $arDestination[] = array(
4809 "STYLE" => "all-users",
4810 "TITLE" => ($htmlEncode ? htmlspecialcharsEx($destinationTitle) : $destinationTitle)
4811 );
4812 }
4813
4814 $bAll = true;
4815 $cnt++;
4816 }
4817 elseif (preg_match('/^G(\d+)$/', $right_tmp, $matches))
4818 {
4819 $cnt++;
4820 if (!$bJustCount)
4821 {
4822 $arGroupIdToGet[] = $matches[1];
4823 }
4824 }
4825 elseif (preg_match('/^U(\d+)$/', $right_tmp, $matches))
4826 {
4827 if (
4828 array_key_exists("CREATED_BY", $arParams)
4829 && intval($arParams["CREATED_BY"]) > 0
4830 && $arParams["CREATED_BY"] == $matches[1]
4831 )
4832 {
4833 continue;
4834 }
4835
4836 $cnt++;
4837 if (!$bJustCount)
4838 {
4839 $arUserIdToGet[] = $matches[1];
4840 }
4841 }
4842 elseif (
4843 (
4844 preg_match('/^D(\d+)$/', $right_tmp, $matches)
4845 || preg_match('/^DR(\d+)$/', $right_tmp, $matches)
4846 )
4847 && CModule::IncludeModule("iblock")
4848 )
4849 {
4850 $cnt++;
4851 if (!$bJustCount)
4852 {
4853 $arDepartmentIdToGet[] = $matches[1];
4854 }
4855 }
4856 elseif (
4857 preg_match('/^SG(\d+)_'.SONET_ROLES_USER.'$/', $right_tmp, $matches)
4858 || preg_match('/^SG(\d+)$/', $right_tmp, $matches)
4859 )
4860 {
4861 if (
4862 array_key_exists($matches[1], $arSonetGroups)
4863 && is_array($arSonetGroups[$matches[1]])
4864 && in_array(SONET_ROLES_USER, $arSonetGroups[$matches[1]])
4865 )
4866 {
4867 continue;
4868 }
4869
4870 $cnt++;
4871 if (!$bJustCount)
4872 {
4873 // already cached
4874 $workgroupFields = \CSocNetGroup::getById($matches[1], $bCheckPermissions);
4875 if ($workgroupFields)
4876 {
4877 $avatarUrl = (
4878 isset($arParams['GET_AVATARS']) && (bool)$arParams['GET_AVATARS']
4879 ? self::getResizedAvatarUrl([
4880 'fileId' => (int)$workgroupFields['IMAGE_ID'],
4881 'avatarSize' => $avatarSize,
4882 ])
4883 : ''
4884 );
4885 $arDestination[] = array(
4886 "TYPE" => "SG",
4887 "ID" => $workgroupFields["ID"],
4888 "STYLE" => "sonetgroups",
4889 "TITLE" => ($htmlEncode ?
4890 $workgroupFields["NAME"]
4891 : htmlspecialcharsback($workgroupFields["NAME"])
4892 ),
4893 "URL" => \Bitrix\Socialnetwork\Site\GroupUrl::get((int)$workgroupFields["ID"]),
4894 "IS_EXTRANET" => (
4895 is_array($GLOBALS["arExtranetGroupID"] ?? null)
4896 && in_array($workgroupFields["ID"], $GLOBALS["arExtranetGroupID"])
4897 ? "Y"
4898 : "N"
4899 ),
4900 'AVATAR' => $avatarUrl,
4901 );
4902
4903 if (!array_key_exists($workgroupFields["ID"], $arSonetGroups))
4904 {
4905 $arSonetGroups[$workgroupFields["ID"]] = array();
4906 }
4907 $arSonetGroups[$workgroupFields["ID"]][] = SONET_ROLES_USER;
4908 }
4909 }
4910 }
4911 elseif (preg_match('/^SG(\d+)_'.SONET_ROLES_MODERATOR.'$/', $right_tmp, $matches))
4912 {
4913 if (!in_array("SG".$matches[1]."_".SONET_ROLES_USER, $arRights))
4914 {
4915 $cnt++;
4916 if (!$bJustCount)
4917 {
4918 $workgroupFields = \CSocNetGroup::getById($matches[1], $bCheckPermissions);
4919 if ($workgroupFields)
4920 {
4921 $avatarUrl = (
4922 isset($arParams['GET_AVATARS']) && (bool)$arParams['GET_AVATARS']
4923 ? self::getResizedAvatarUrl([
4924 'fileId' => (int)$workgroupFields['IMAGE_ID'],
4925 'avatarSize' => $avatarSize,
4926 ])
4927 : ''
4928 );
4929
4930 $arDestination[] = array(
4931 "TYPE" => "SG",
4932 "ID" => $workgroupFields["ID"],
4933 "STYLE" => "sonetgroups",
4934 "TITLE" => ($htmlEncode ? $workgroupFields["NAME"] : htmlspecialcharsback($workgroupFields["NAME"])).GetMessage("SONET_GL_DESTINATION_SG_MODERATOR"),
4935 "URL" => str_replace("#group_id#", $workgroupFields["ID"], $arParams["PATH_TO_GROUP"]),
4936 "IS_EXTRANET" => (
4937 is_array($GLOBALS["arExtranetGroupID"] ?? null)
4938 && in_array($workgroupFields["ID"], $GLOBALS["arExtranetGroupID"])
4939 ? "Y"
4940 : "N"
4941 ),
4942 'AVATAR' => $avatarUrl,
4943 );
4944
4945 if (!array_key_exists($workgroupFields["ID"], $arSonetGroups))
4946 {
4947 $arSonetGroups[$workgroupFields["ID"]] = array();
4948 }
4949 $arSonetGroups[$workgroupFields["ID"]][] = SONET_ROLES_MODERATOR;
4950 }
4951 }
4952 }
4953 }
4954 elseif (preg_match('/^SG(\d+)_'.SONET_ROLES_OWNER.'$/', $right_tmp, $matches))
4955 {
4956 if (!in_array("SG".$matches[1]."_".SONET_ROLES_USER, $arRights) && !in_array("SG".$matches[1]."_".SONET_ROLES_MODERATOR, $arRights))
4957 {
4958 $cnt++;
4959 if (!$bJustCount)
4960 {
4961 $workgroupFields = \CSocNetGroup::getById($matches[1], $bCheckPermissions);
4962 if ($workgroupFields)
4963 {
4964 $avatarUrl = (
4965 isset($arParams['GET_AVATARS']) && (bool)$arParams['GET_AVATARS']
4966 ? self::getResizedAvatarUrl([
4967 'fileId' => (int)$workgroupFields['IMAGE_ID'],
4968 'avatarSize' => $avatarSize,
4969 ])
4970 : ''
4971 );
4972
4973 $arDestination[] = array(
4974 "TYPE" => "SG",
4975 "ID" => $workgroupFields["ID"],
4976 "STYLE" => "sonetgroups",
4977 "TITLE" => ($htmlEncode ? $workgroupFields["NAME"] : htmlspecialcharsback($workgroupFields["NAME"])).GetMessage("SONET_GL_DESTINATION_SG_OWNER"),
4978 "URL" => str_replace(
4979 "#group_id#",
4980 $workgroupFields["ID"],
4981 $arParams["PATH_TO_GROUP"] ?? ''
4982 ),
4983 "IS_EXTRANET" => (
4984 is_array($GLOBALS["arExtranetGroupID"] ?? null)
4985 && in_array($workgroupFields["ID"], $GLOBALS["arExtranetGroupID"])
4986 ? "Y"
4987 : "N"
4988 ),
4989 'AVATAR' => $avatarUrl,
4990 );
4991
4992 if (!array_key_exists($workgroupFields["ID"], $arSonetGroups))
4993 {
4994 $arSonetGroups[$workgroupFields["ID"]] = array();
4995 }
4996 $arSonetGroups[$workgroupFields["ID"]][] = SONET_ROLES_OWNER;
4997 }
4998 }
4999 }
5000 }
5001 else
5002 {
5003 $cnt++;
5004 if (!$bJustCount)
5005 {
5006 foreach ($arModuleEvents as $arEvent)
5007 {
5008 ExecuteModuleEventEx($arEvent, array(&$arDestination, $right_tmp, $arRights, $arParams, $bCheckPermissions));
5009 }
5010 }
5011 }
5012 }
5013
5014 if (!empty($arGroupIdToGet))
5015 {
5016 $rsGroupTmp = \Bitrix\Main\GroupTable::getList([
5017 'select' => [ 'ID', 'NAME' ],
5018 'filter' => [
5019 'ID' => $arGroupIdToGet
5020 ],
5021 ]);
5022
5023 while ($groupFields = $rsGroupTmp->fetch())
5024 {
5025 $arDestination[] = array(
5026 "TYPE" => "G",
5027 "ID" => $groupFields["ID"],
5028 "STYLE" => "groups",
5029 "TITLE" => ($htmlEncode ? htmlspecialcharsEx($groupFields["NAME"]) : $groupFields["NAME"]),
5030 "URL" => "",
5031 );
5032 }
5033 }
5034
5035 if (!empty($arUserIdToGet))
5036 {
5037 $select = [ 'ID', 'NAME', 'LAST_NAME', 'SECOND_NAME', 'LOGIN', 'EMAIL', 'PERSONAL_PHOTO' ];
5038 if (ModuleManager::isModuleInstalled('mail'))
5039 {
5040 $select[] = 'EXTERNAL_AUTH_ID';
5041 }
5042 if (ModuleManager::isModuleInstalled('crm'))
5043 {
5044 $select[] = 'UF_USER_CRM_ENTITY';
5045 }
5046
5048 'order' => array(),
5049 'filter' => array(
5050 "ID" => $arUserIdToGet
5051 ),
5052 'select' => $select
5053 ));
5054
5055 while ($arUserTmp = $rsUserTmp->fetch())
5056 {
5057 $avatarUrl = (
5058 isset($arParams['GET_AVATARS']) && (bool)$arParams['GET_AVATARS']
5059 ? self::getResizedAvatarUrl([
5060 'fileId' => (int)$arUserTmp['PERSONAL_PHOTO'],
5061 'avatarSize' => $avatarSize,
5062 ])
5063 : ''
5064 );
5065
5066 $isEmail = (isset($arUserTmp['EXTERNAL_AUTH_ID']) && $arUserTmp['EXTERNAL_AUTH_ID'] === 'email');
5067 $url = str_replace("#user_id#", $arUserTmp["ID"], $arParams["PATH_TO_USER"] ?? '');
5068 if (
5069 $isEmail
5070 && !empty($arParams['LOG_ID'])
5071 && (int)$arParams['LOG_ID'] > 0
5072 )
5073 {
5074 $url = (new \Bitrix\Main\Web\Uri($url))->addParams([
5075 'entityType' => 'LOG_ENTRY',
5076 'entityId' => (int)$arParams['LOG_ID'],
5077 ])->getUri();
5078 }
5079
5080 $arDestination[] = [
5081 "TYPE" => "U",
5082 "ID" => $arUserTmp["ID"],
5083 "STYLE" => "users",
5084 "TITLE" => CUser::FormatName($arParams["NAME_TEMPLATE"], $arUserTmp, ($arParams["SHOW_LOGIN"] === "Y"), $htmlEncode),
5085 'SHORT_TITLE' => trim($htmlEncode ? htmlspecialcharsEx($arUserTmp['NAME']) : $arUserTmp['NAME']),
5086 'URL' => $url,
5087 "IS_EXTRANET" => (isset($GLOBALS["arExtranetUserID"]) && is_array($GLOBALS["arExtranetUserID"]) && in_array($arUserTmp["ID"], $GLOBALS["arExtranetUserID"]) ? "Y" : "N"),
5088 'IS_EMAIL' => ($isEmail ? 'Y' : 'N'),
5089 "CRM_ENTITY" => (!empty($arUserTmp["UF_USER_CRM_ENTITY"]) ? $arUserTmp["UF_USER_CRM_ENTITY"] : false),
5090 'AVATAR' => $avatarUrl,
5091 ];
5092 }
5093 }
5094
5095 if (!empty($arDepartmentIdToGet))
5096 {
5097 foreach ($arDepartmentIdToGet as $key => $value)
5098 {
5099 if (array_key_exists($value, $arDepartmentsStaticCache))
5100 {
5101 $arDestination[] = array(
5102 "TYPE" => "D",
5103 "ID" => $arDepartmentsStaticCache[$value]["ID"],
5104 "STYLE" => "department",
5105 "TITLE" => $arDepartmentsStaticCache[$value]["NAME"],
5106 "URL" => str_replace(array("#ID#", "#id#"), $arDepartmentsStaticCache[$value]["ID"], $arParams["PATH_TO_CONPANY_DEPARTMENT"])
5107 );
5108 unset($arDepartmentIdToGet[$key]);
5109 }
5110 }
5111
5112 if (!empty($arDepartmentIdToGet))
5113 {
5114 $rsDepartmentTmp = CIBlockSection::GetList(
5115 array(),
5116 array(
5117 "ID" => $arDepartmentIdToGet
5118 ),
5119 false,
5120 array('ID', 'NAME')
5121 );
5122
5123 while ($arDepartmentTmp = $rsDepartmentTmp->fetch())
5124 {
5125 $arDestination[] = array(
5126 "TYPE" => "D",
5127 "ID" => $arDepartmentTmp["ID"],
5128 "STYLE" => "department",
5129 "TITLE" => ($htmlEncode ? htmlspecialcharsEx($arDepartmentTmp["NAME"]) : $arDepartmentTmp["NAME"]),
5130 "URL" => str_replace(array("#ID#", "#id#"), $arDepartmentTmp["ID"], $arParams["PATH_TO_CONPANY_DEPARTMENT"])
5131 );
5132 $arDepartmentsStaticCache[$arDepartmentTmp["ID"]] = $arDepartmentTmp;
5133 }
5134 }
5135 }
5136
5137 $db_events = GetModuleEvents("socialnetwork", "OnAfterSocNetLogFormatDestination");
5138 while ($arEvent = $db_events->Fetch())
5139 {
5140 ExecuteModuleEventEx($arEvent, array(&$arDestination));
5141 }
5142
5143 if ($cnt > $arParams["DESTINATION_LIMIT"])
5144 {
5145 $iMoreCount = $cnt - $arParams["DESTINATION_LIMIT"];
5146 }
5147
5148 return $arDestination;
5149 }
5150
5151 public static function GetDestinationFromRights($arRights, $arParams)
5152 {
5153 if (empty($arRights))
5154 {
5155 return array();
5156 }
5157
5158 $arDestination = array();
5159 $arSonetGroups = array();
5160
5161 $arRights = array_unique($arRights);
5162
5163 $bAll = false;
5164 $arParams["DESTINATION_LIMIT"] = (
5165 (int) ($arParams["DESTINATION_LIMIT"] ?? null) <= 0
5166 ? 3
5167 : $arParams["DESTINATION_LIMIT"]
5168 );
5169 $bCheckPermissions = (!array_key_exists("CHECK_PERMISSIONS_DEST", $arParams) || $arParams["CHECK_PERMISSIONS_DEST"] !== 'N');
5170
5171 foreach ($arRights as $right_tmp)
5172 {
5173 if ($right_tmp === "G1" && count($arRights) > 1)
5174 {
5175 continue;
5176 }
5177
5178 if (in_array($right_tmp, array("G2", "AU")))
5179 {
5180 if ($bAll)
5181 {
5182 continue;
5183 }
5184
5185 $arDestination[] = $right_tmp;
5186 $bAll = true;
5187 }
5188 elseif (preg_match('/^G(\d+)$/', $right_tmp, $matches))
5189 {
5190 $arDestination[] = $matches[1];
5191 }
5192 elseif (preg_match('/^U(\d+)$/', $right_tmp, $matches))
5193 {
5194 if (
5195 array_key_exists("CREATED_BY", $arParams)
5196 && (int)$arParams["CREATED_BY"] > 0
5197 && $arParams["CREATED_BY"] == $matches[1]
5198 )
5199 {
5200 continue;
5201 }
5202
5203 $arDestination[] = $right_tmp;
5204 }
5205 elseif (
5206 preg_match('/^D(\d+)$/', $right_tmp, $matches)
5207 || preg_match('/^DR(\d+)$/', $right_tmp, $matches)
5208 )
5209 {
5210 $arDestination[] = $right_tmp;
5211 }
5212 elseif (
5213 preg_match('/^SG(\d+)_'.SONET_ROLES_USER.'$/', $right_tmp, $matches)
5214 || preg_match('/^SG(\d+)$/', $right_tmp, $matches)
5215 )
5216 {
5217 if (
5218 array_key_exists($matches[1], $arSonetGroups)
5219 && is_array($arSonetGroups[$matches[1]])
5220 && in_array(SONET_ROLES_USER, $arSonetGroups[$matches[1]], true)
5221 )
5222 {
5223 continue;
5224 }
5225
5226 // already cached
5227 $arSonetGroup = CSocNetGroup::GetByID($matches[1], $bCheckPermissions);
5228 if ($arSonetGroup)
5229 {
5230 $arDestination[] = "SG".$matches[1];
5231
5232 if (!array_key_exists($arSonetGroup["ID"], $arSonetGroups))
5233 {
5234 $arSonetGroups[$arSonetGroup["ID"]] = array();
5235 }
5236 $arSonetGroups[$arSonetGroup["ID"]][] = SONET_ROLES_USER;
5237 }
5238 }
5239 elseif (preg_match('/^SG(\d+)_'.SONET_ROLES_MODERATOR.'$/', $right_tmp, $matches))
5240 {
5241 if (!in_array("SG".$matches[1]."_".SONET_ROLES_USER, $arRights))
5242 {
5243 $arSonetGroup = CSocNetGroup::GetByID($matches[1], $bCheckPermissions);
5244 if ($arSonetGroup)
5245 {
5246 $arDestination[] = "SG".$matches[1];
5247
5248 if (!array_key_exists($arSonetGroup["ID"], $arSonetGroups))
5249 {
5250 $arSonetGroups[$arSonetGroup["ID"]] = [];
5251 }
5252
5253 $arSonetGroups[$arSonetGroup["ID"]][] = SONET_ROLES_MODERATOR;
5254 }
5255 }
5256 }
5257 elseif (preg_match('/^SG(\d+)_'.SONET_ROLES_OWNER.'$/', $right_tmp, $matches))
5258 {
5259 if (
5260 !in_array("SG" . $matches[1] . "_" . SONET_ROLES_USER, $arRights, true)
5261 && !in_array("SG" . $matches[1] . "_" . SONET_ROLES_MODERATOR, $arRights, true)
5262 )
5263 {
5264 $arSonetGroup = CSocNetGroup::GetByID($matches[1], $bCheckPermissions);
5265 if ($arSonetGroup)
5266 {
5267 $arDestination[] = "SG".$matches[1];
5268
5269 if (!array_key_exists($arSonetGroup["ID"], $arSonetGroups))
5270 {
5271 $arSonetGroups[$arSonetGroup["ID"]] = [];
5272 }
5273
5274 $arSonetGroups[$arSonetGroup["ID"]][] = SONET_ROLES_OWNER;
5275 }
5276 }
5277 }
5278 }
5279
5280 return $arDestination;
5281 }
5282
5283 public static function ProcessPath($arUrl, $user_id, $explicit_site_id = false)
5284 {
5285 static $arIntranetUsers, $arSiteData, $extranet_site_id, $intranet_site_id;
5286
5287 if (!is_array($arUrl))
5288 {
5289 $arUrl = array($arUrl);
5290 }
5291
5292 if (
5293 CModule::IncludeModule("extranet")
5294 && !$arIntranetUsers
5295 )
5296 {
5297 $extranet_site_id = CExtranet::GetExtranetSiteID();
5298 $intranet_site_id = CSite::GetDefSite();
5299 $arIntranetUsers = CExtranet::GetIntranetUsers();
5300 }
5301
5302 if (!$arSiteData)
5303 {
5304 $arSiteData = self::GetSiteData();
5305 }
5306
5307 $user_site_id = (
5308 ModuleManager::isModuleInstalled('extranet')
5309 ? (
5310 (
5311 !in_array($user_id, $arIntranetUsers)
5312 && $extranet_site_id
5313 )
5314 ? $extranet_site_id // extranet user
5315 : (
5316 $explicit_site_id
5317 && $explicit_site_id != $extranet_site_id
5318 ? $explicit_site_id
5319 : $intranet_site_id
5320 )
5321 )
5322 : ($explicit_site_id ? $explicit_site_id : SITE_ID)
5323 );
5324
5325 $server_name = (CMain::IsHTTPS() ? "https" : "http")
5326 . "://" . ($arSiteData[$user_site_id]["SERVER_NAME"] ?? '')
5327 ;
5328
5329 $arUrl = str_replace(
5330 array("#SERVER_NAME#", "#GROUPS_PATH#", "#USER_PATH#"),
5331 array(
5332 $server_name,
5333 $arSiteData[$user_site_id]["GROUPS_PATH"] ?? '',
5334 $arSiteData[$user_site_id]["USER_PATH"] ?? ''
5335 ),
5336 $arUrl
5337 );
5338
5339 return array(
5340 "SERVER_NAME" => $server_name,
5341 "URLS" => $arUrl,
5342 "DOMAIN" => (count($arSiteData) > 1 ? $arSiteData[$user_site_id]["SERVER_NAME"] ?? null : false)
5343 );
5344 }
5345
5346 public static function GetSiteData()
5347 {
5348 $arSiteData = array();
5349
5350 $extranetSiteId = \Bitrix\Socialnetwork\Site\Site::getInstance()->getExtranetSiteId();
5351
5352 $rsSite = CSite::GetList("sort", "desc", Array("ACTIVE" => "Y"));
5353 while ($arSite = $rsSite->Fetch())
5354 {
5355 $userPage = $arSite['ID'] === $extranetSiteId ? 'contacts/personal/' : 'company/personal/';
5356 $serverName = htmlspecialcharsEx($arSite["SERVER_NAME"]);
5357 $arSiteData[$arSite["ID"]] = array(
5358 "GROUPS_PATH" => COption::GetOptionString("socialnetwork", "workgroups_page", $arSite["DIR"]."workgroups/", $arSite["ID"]),
5359 "USER_PATH" => COption::GetOptionString("socialnetwork", "user_page", $arSite["DIR"] . $userPage, $arSite["ID"]),
5360 "SERVER_NAME" => (
5361 $serverName <> ''
5362 ? $serverName
5363 : (
5364 defined("SITE_SERVER_NAME") && SITE_SERVER_NAME <> ''
5365 ? SITE_SERVER_NAME
5366 : COption::GetOptionString("main", "server_name", "")
5367 )
5368 )
5369 );
5370 }
5371
5372 return $arSiteData;
5373 }
5374
5375 public static function ShowSourceType($source_type = false, $bMobile = false)
5376 {
5377 if (!$source_type)
5378 return false;
5379 else
5380 {
5381 $events = GetModuleEvents("socialnetwork", "OnShowSocNetSourceType");
5382 while ($arEvent = $events->Fetch())
5383 {
5384 $arResult = ExecuteModuleEventEx($arEvent, array($source_type, $bMobile));
5385 if (is_array($arResult))
5386 return $arResult;
5387 }
5388 }
5389 }
5390
5391 public static function GetDataFromRatingEntity($rating_entity_type_id, $rating_entity_id, $bCheckRights = true)
5392 {
5393 static $blogPostEventIdList = null;
5394
5395 $rating_entity_type_id = preg_replace("/[^a-z0-9_-]/i", "", $rating_entity_type_id);
5396 $rating_entity_id = (int)$rating_entity_id;
5397
5398 if (
5399 $rating_entity_type_id == ''
5400 || $rating_entity_id <= 0
5401 )
5402 {
5403 return false;
5404 }
5405
5406 $log_type = '';
5407
5408 switch ($rating_entity_type_id)
5409 {
5410 case "BLOG_POST":
5411 $log_type = "log";
5412 if ($blogPostEventIdList === null)
5413 {
5414 $blogPostLivefeedProvider = new \Bitrix\Socialnetwork\Livefeed\BlogPost;
5415 $blogPostEventIdList = $blogPostLivefeedProvider->getEventId();
5416 }
5417 $log_event_id = array_merge($blogPostEventIdList, array("idea"));
5418 break;
5419 case "BLOG_COMMENT":
5420 $log_type = "comment";
5421 $log_event_id = array("blog_comment", "photo_comment");
5422 break;
5423 case "FORUM_TOPIC":
5424 $log_type = "log";
5425 $log_event_id = array("forum");
5426 if (CModule::IncludeModule("forum"))
5427 {
5428 $dbForumMessage = CForumMessage::GetList(
5429 array("ID" => "ASC"),
5430 array("TOPIC_ID" => $rating_entity_id),
5431 false,
5432 1
5433 );
5434 if ($arForumMessage = $dbForumMessage->Fetch())
5435 {
5436 $rating_entity_id = $arForumMessage["ID"];
5437 }
5438 }
5439 break;
5440 case "FORUM_POST":
5441 $log_type = "comment";
5442 $forumPostLivefeedProvider = new \Bitrix\Socialnetwork\Livefeed\ForumPost();
5443 $log_event_id = $forumPostLivefeedProvider->getEventId();
5444 break;
5445 case "IBLOCK_ELEMENT":
5446 $log_type = "log";
5447 $log_event_id = array("photo_photo", "files", "commondocs", "wiki");
5448 break;
5449 case "INTRANET_NEW_USER":
5450 $log_type = "log";
5451 $log_event_id = array("intranet_new_user");
5452 break;
5453 case "INTRANET_NEW_USER_COMMENT":
5454 $log_type = "comment";
5455 $log_event_id = array("intranet_new_user_comment");
5456 break;
5457 case "BITRIX24_NEW_USER":
5458 $log_type = "log";
5459 $log_event_id = array("bitrix24_new_user");
5460 break;
5461 case "BITRIX24_NEW_USER_COMMENT":
5462 $log_type = "comment";
5463 $log_event_id = array("bitrix24_new_user_comment");
5464 break;
5465 case "VOTING":
5466 $log_type = "log";
5467 if ($blogPostEventIdList === null)
5468 {
5469 $blogPostLivefeedProvider = new \Bitrix\Socialnetwork\Livefeed\BlogPost;
5470 $blogPostEventIdList = $blogPostLivefeedProvider->getEventId();
5471 }
5472 $log_event_id = $blogPostEventIdList;
5473 if (CModule::IncludeModule("blog"))
5474 {
5475 $rsBlogPost = CBlogPost::GetList(
5476 array("ID" => "DESC"),
5477 array("UF_BLOG_POST_VOTE" => $rating_entity_id),
5478 false,
5479 array("nTopCount" => 1),
5480 array("ID")
5481 );
5482
5483 if ($arBlogPost = $rsBlogPost->Fetch())
5484 {
5485 $rating_entity_id = $arBlogPost["ID"];
5486 }
5487 }
5488 break;
5489 case "LISTS_NEW_ELEMENT":
5490 $log_type = "log";
5491 $log_event_id = array("lists_new_element");
5492 break;
5493 case "LOG_ENTRY":
5494 $log_type = "log_entry";
5495 break;
5496 case "LOG_COMMENT":
5497 $log_type = "log_comment";
5498 break;
5499 default:
5500 }
5501
5502 $log_id = null;
5503 $log_comment_id = null;
5504
5505 if ($log_type === "log")
5506 {
5507 $rsLogSrc = CSocNetLog::GetList(
5508 array(),
5509 array(
5510 "EVENT_ID" => $log_event_id,
5511 "SOURCE_ID" => $rating_entity_id
5512 ),
5513 false,
5514 false,
5515 array("ID"),
5516 array(
5517 "CHECK_RIGHTS" => ($bCheckRights ? "Y" : "N"),
5518 "USE_SUBSCRIBE" => "N"
5519 )
5520 );
5521 if ($arLogSrc = $rsLogSrc->Fetch())
5522 {
5523 $log_id = $arLogSrc["ID"];
5524 }
5525 }
5526 elseif ($log_type === "log_entry")
5527 {
5528 $rsLogSrc = CSocNetLog::GetList(
5529 array(),
5530 array(
5531 "ID" => $rating_entity_id
5532 ),
5533 false,
5534 false,
5535 array("ID"),
5536 array(
5537 "CHECK_RIGHTS" => ($bCheckRights ? "Y" : "N"),
5538 "USE_SUBSCRIBE" => "N"
5539 )
5540 );
5541 if ($arLogSrc = $rsLogSrc->Fetch())
5542 $log_id = $arLogSrc["ID"];
5543 }
5544 elseif ($log_type === "comment")
5545 {
5546 $rsLogCommentSrc = CSocNetLogComments::GetList(
5547 array(),
5548 array(
5549 "EVENT_ID" => $log_event_id,
5550 "SOURCE_ID" => $rating_entity_id
5551 ),
5552 false,
5553 false,
5554 array("ID", "LOG_ID"),
5555 array(
5556 "CHECK_RIGHTS" => ($bCheckRights ? "Y" : "N"),
5557 "USE_SUBSCRIBE" => "N"
5558 )
5559 );
5560 if ($arLogCommentSrc = $rsLogCommentSrc->Fetch())
5561 {
5562 $log_id = $arLogCommentSrc["LOG_ID"];
5563 $log_comment_id = $arLogCommentSrc["ID"];
5564 }
5565 }
5566 elseif ($log_type == "log_comment")
5567 {
5568 $rsLogCommentSrc = CSocNetLogComments::GetList(
5569 array(),
5570 array(
5571 "ID" => $rating_entity_id
5572 ),
5573 false,
5574 false,
5575 array("ID", "LOG_ID"),
5576 array(
5577 "CHECK_RIGHTS" => ($bCheckRights ? "Y" : "N"),
5578 "USE_SUBSCRIBE" => "N"
5579 )
5580 );
5581 if ($arLogCommentSrc = $rsLogCommentSrc->Fetch())
5582 {
5583 $log_id = $arLogCommentSrc["LOG_ID"];
5584 $log_comment_id = $arLogCommentSrc["ID"];
5585 }
5586 }
5587
5588 if ($log_id > 0)
5589 {
5590 $arResult = array("LOG_ID" => $log_id);
5591 if ($log_comment_id > 0)
5592 $arResult["LOG_COMMENT_ID"] = $log_comment_id;
5593
5594 return $arResult;
5595 }
5596 else
5597 return false;
5598 }
5599
5600 public static function AddComment_Photo($arFields)
5601 {
5603 }
5604
5605 public static function AddComment_Photo_Forum($arFields, $FORUM_ID, $arLog)
5606 {
5608 }
5609
5610 public static function AddComment_Photo_Blog($arFields, $BLOG_ID, $arLog)
5611 {
5613 }
5614
5615 public static function logUFfileShow($arResult, $arParams)
5616 {
5617 $result = false;
5618 if (
5619 $arParams["arUserField"]["FIELD_NAME"] === "UF_SONET_COM_FILE"
5620 || mb_strpos($arParams["arUserField"]["FIELD_NAME"], "UF_SONET_COM_FILE") === 0
5621 || $arParams["arUserField"]["FIELD_NAME"] === "UF_SONET_LOG_FILE"
5622 || mb_strpos($arParams["arUserField"]["FIELD_NAME"], "UF_SONET_LOG_FILE") === 0
5623 )
5624 {
5625 if (
5626 $arParams["arUserField"]["FIELD_NAME"] === "UF_SONET_COM_FILE"
5627 || mb_strpos($arParams["arUserField"]["FIELD_NAME"], "UF_SONET_COM_FILE") === 0
5628 )
5629 $type = "comment";
5630 else
5631 $type = "post";
5632
5633 if (count($arResult["VALUE"]) > 0)
5634 {
5635 ?><div class="feed-com-files">
5636 <div class="feed-com-files-title"><?=GetMessage("LOG_FILES")?></div>
5637 <div class="feed-com-files-cont"><?
5638
5639 foreach ($arResult["VALUE"] as $fileID)
5640 {
5641 $arFile = CFile::GetFileArray($fileID);
5642 if($arFile)
5643 {
5644 $name = $arFile["ORIGINAL_NAME"];
5645 $ext = '';
5646 $dotpos = mb_strrpos($name, ".");
5647 if (($dotpos !== false) && ($dotpos + 1 < mb_strlen($name)))
5648 $ext = mb_substr($name, $dotpos + 1);
5649 if (mb_strlen($ext) < 3 || mb_strlen($ext) > 5)
5650 $ext = '';
5651 $arFile["EXTENSION"] = $ext;
5652 $arFile["LINK"] = "/bitrix/components/bitrix/socialnetwork.log.ex/show_file.php?fid=".$fileID."&ltype=".$type;
5653 $arFile["FILE_SIZE"] = CFile::FormatSize($arFile["FILE_SIZE"]);
5654 ?><div id="wdif-doc-<?=$arFile["ID"]?>" class="feed-com-file-wrap">
5655 <div class="feed-con-file-name-wrap">
5656 <div class="feed-con-file-icon feed-file-icon-<?=htmlspecialcharsbx($arFile["EXTENSION"])?>"></div>
5657 <a target="_blank" href="<?=htmlspecialcharsbx($arFile["LINK"])?>" class="feed-com-file-name"><?=htmlspecialcharsbx($arFile["ORIGINAL_NAME"])?></a>
5658 <span class="feed-con-file-size">(<?=$arFile["FILE_SIZE"]?>)</span>
5659 </div>
5660 </div><?
5661 }
5662 }
5663
5664 ?></div>
5665 </div><?
5666 }
5667
5668 $result = true;
5669 }
5670 return $result;
5671 }
5672
5673 public static function SetUFRights($files, $rights)
5674 {
5675 static $arTasks = null;
5676 global $USER;
5677
5678 if (!CModule::IncludeModule('iblock') || !CModule::IncludeModule('webdav'))
5679 return false;
5680
5681 if (!is_array($rights) || count($rights) <= 0)
5682 return false;
5683
5684 if ($files === null || $files===false)
5685 return false;
5686 if (!is_array($files))
5687 $files = array($files);
5688
5689 $arFiles = array();
5690 foreach($files as $id)
5691 {
5692 $id = intval($id);
5693 if (intval($id) > 0)
5694 $arFiles[] = $id;
5695 }
5696
5697 if (count($arFiles) <= 0)
5698 return false;
5699
5700 if ($arTasks == null)
5701 $arTasks = CWebDavIblock::GetTasks();
5702
5703 $arCodes = array();
5704 foreach($rights as $value)
5705 {
5706 if (mb_substr($value, 0, 2) === 'SG')
5707 $arCodes[] = $value.'_K';
5708 $arCodes[] = $value;
5709 }
5710 $arCodes = array_unique($arCodes);
5711
5712 $i=0;
5713 $arViewRights = array();
5714 $curUserID = 'U'.$USER->GetID();
5715 foreach($arCodes as $right)
5716 {
5717 if ($curUserID == $right) // do not override owner's rights
5718 continue;
5719 $key = "n".$i++;
5720 $arViewRights[$key] = array(
5721 "GROUP_CODE" => $right,
5722 "TASK_ID" => $arTasks["R"],
5723 );
5724 }
5725
5726 $ibe = new CIBlockElement();
5727 $dbWDFile = CIBlockElement::GetList(array(), array("ID" => $arFiles, "SHOW_NEW" => "Y"), false, false, array("ID", "NAME", "SECTION_ID", "IBLOCK_ID", "WF_NEW"));
5728 $iblockIds = array();
5729 if ($dbWDFile)
5730 {
5731 while ($arWDFile = $dbWDFile->Fetch())
5732 {
5733 $id = $arWDFile["ID"];
5734
5735 if ($arWDFile["WF_NEW"] === "Y")
5736 {
5737 $ibe->Update($id, array("BP_PUBLISHED" => "Y"));
5738 }
5739
5740 if (CIBlock::GetArrayByID($arWDFile['IBLOCK_ID'], "RIGHTS_MODE") === "E")
5741 {
5742 $ibRights = CWebDavIblock::_get_ib_rights_object("ELEMENT", $id, $arWDFile["IBLOCK_ID"]);
5743 $ibRights->SetRights(CWebDavTools::appendRights($ibRights, $arViewRights, $arTasks));
5744 if (empty($iblockIds[$arWDFile["IBLOCK_ID"]]))
5745 {
5746 $iblockIds[$arWDFile["IBLOCK_ID"]] = $arWDFile["IBLOCK_ID"];
5747 }
5748 }
5749 }
5750
5751 global $CACHE_MANAGER;
5752
5753 foreach ($iblockIds as $iblockId)
5754 {
5755 $CACHE_MANAGER->ClearByTag("iblock_id_".$iblockId);
5756 }
5757
5758 unset($iblockId);
5759 }
5760
5761 return false;
5762 }
5763
5764 public static function GetAvailableGroups($isExtranetUser = false, $isExtranetSite = false)
5765 {
5766 static $arSonetGroupIDAvailable = false;
5767 global $CACHE_MANAGER, $USER;
5768
5769 if (is_array($arSonetGroupIDAvailable))
5770 {
5771 return $arSonetGroupIDAvailable;
5772 }
5773 else
5774 {
5775 $arSonetGroupIDAvailable = array();
5776
5777 if (!$isExtranetUser)
5778 {
5779 $isExtranetUser = (CModule::IncludeModule("extranet") && !CExtranet::IsIntranetUser() ? "Y" : "N");
5780 }
5781
5782 if (!$isExtranetSite)
5783 {
5784 $isExtranetSite = (CModule::IncludeModule("extranet") && CExtranet::IsExtranetSite() ? "Y" : "N");
5785 }
5786
5787 $cache = new CPHPCache;
5788 $cache_time = 31536000;
5789 $cache_id = $USER->GetID().($isExtranetUser == "Y" ? "_ex" : "");
5790 $cache_path = "/sonet/groups_available/".$USER->GetID()."/";
5791
5792 if ($cache->InitCache($cache_time, $cache_id, $cache_path))
5793 {
5794 $arCacheVars = $cache->GetVars();
5795 $arSonetGroupIDAvailable = $arCacheVars["arGroupID"];
5796 }
5797 else
5798 {
5799 $cache->StartDataCache($cache_time, $cache_id, $cache_path);
5800 if (defined("BX_COMP_MANAGED_CACHE"))
5801 {
5802 $CACHE_MANAGER->StartTagCache($cache_path);
5803 $CACHE_MANAGER->RegisterTag("sonet_user2group_U".$USER->GetID());
5804 $CACHE_MANAGER->RegisterTag("sonet_group");
5805 }
5806
5807 $arFilter = array("CHECK_PERMISSIONS" => $USER->GetID());
5808
5809 if (
5810 $isExtranetUser == "Y"
5811 && $isExtranetSite == "Y"
5812 && CModule::IncludeModule("extranet")
5813 )
5814 {
5815 $arFilter["SITE_ID"] = CExtranet::GetExtranetSiteID();
5816 }
5817
5818 $rsGroup = CSocNetGroup::GetList(
5819 array(),
5820 $arFilter,
5821 false,
5822 false,
5823 array("ID")
5824 );
5825 while($arGroup = $rsGroup->Fetch())
5826 {
5827 $arSonetGroupIDAvailable[] = $arGroup["ID"];
5828 }
5829
5830 $arCacheData = array(
5831 "arGroupID" => $arSonetGroupIDAvailable
5832 );
5833
5834 if(defined("BX_COMP_MANAGED_CACHE"))
5835 {
5836 $CACHE_MANAGER->EndTagCache();
5837 }
5838
5839 $cache->EndDataCache($arCacheData);
5840 }
5841
5842 return $arSonetGroupIDAvailable;
5843 }
5844 }
5845
5846 public static function GetForumCommentMetaData($logEventId)
5847 {
5848 static $arData = array(
5849// "blog_post" => array("BLOG", "BG"),
5850 "tasks" => array("TASK", "TK", "FORUM|COMMENT"),
5851 "forum" => array("FORUM", "FM", "FORUM|COMMENT"),
5852 "photo_photo" => array("PHOTO", "PH", "FORUM|COMMENT"),
5853 "sonet" => array("SOCNET", "SC", ""),
5854 "calendar" => array("EVENT", "EV", ""),
5855 "lists_new_element" => array("WF", "WF", ""),
5856 "news" => array("IBLOCK", "IB", ""),
5857 "wiki" => array("IBLOCK", "IB", ""),
5858 "timeman_entry"=> array("TIMEMAN_ENTRY", "TM", ""),
5859 "report"=> array("TIMEMAN_REPORT", "TR", ""),
5860 );
5861
5862 $arRes = false;
5863
5864 if (isset($arData[$logEventId]))
5865 {
5866 $arRes = $arData[$logEventId];
5867 }
5868
5869 return $arRes;
5870 }
5871
5873 // working with task comments
5875
5876 public static function AddComment_Tasks($arFields)
5877 {
5878 global $USER, $USER_FIELD_MANAGER;
5879
5880 if (!CModule::IncludeModule("forum"))
5881 return false;
5882
5883 if (!CModule::IncludeModule("tasks"))
5884 return false;
5885
5886 $sError = '';
5887 $sNote = '';
5888 $messageID = $ufUrlPreview = false;
5889
5890 $arFieldsMessage = array();
5891 $ufFileID = array();
5892 $ufDocID = array();
5893
5895 array(),
5896 array("ID" => $arFields["LOG_ID"]),
5897 false,
5898 false,
5899 array("ID", "SOURCE_ID", "SITE_ID")
5900 );
5901
5902 if ($arLog = $dbResult->Fetch())
5903 {
5904 $rsTask = CTasks::getById($arLog["SOURCE_ID"]);
5905 if ($arTask = $rsTask->Fetch())
5906 {
5907 $forumID = \Bitrix\Tasks\Integration\SocialNetwork\Task::getCommentForumId();
5908 if ($forumID)
5909 {
5910 $userID = $USER->GetID();
5911
5913 // file prop & UF_* forwarding
5914
5915 $arLogSites = array();
5916 $rsLogSite = CSocNetLog::GetSite($arLog["ID"]);
5917 while ($arLogSite = $rsLogSite->Fetch())
5918 $arLogSites[] = $arLogSite["LID"];
5919
5920 $bCurrentUserIsAdmin = CSocNetUser::isCurrentUserModuleAdmin($arLogSites);
5921 $strPermission = false;
5922
5923 if ($arFields["ENTITY_TYPE"] == SONET_ENTITY_GROUP)
5924 {
5925 if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $arFields["ENTITY_ID"], "tasks", "view", $bCurrentUserIsAdmin))
5926 $strPermission = "I";
5927 }
5928 else
5929 {
5930 if (
5931 CModule::IncludeModule('tasks')
5932 && \Bitrix\Tasks\Access\TaskAccessController::can($userID, \Bitrix\Tasks\Access\ActionDictionary::ACTION_TASK_READ, (int) $arTask['ID'])
5933 )
5934 {
5935 $strPermission = "I";
5936 }
5937 }
5938
5939 $arFieldsMessage = array(
5940 "POST_MESSAGE" => $arFields["TEXT_MESSAGE"],
5941 "USE_SMILES" => "Y",
5942 "PERMISSION_EXTERNAL" => "Q",
5943 "PERMISSION" => $strPermission,
5944 "APPROVED" => "Y"
5945 );
5946
5947 $USER_FIELD_MANAGER->EditFormAddFields("SONET_COMMENT", $arTmp);
5948 if (is_array($arTmp))
5949 {
5950 if (array_key_exists("UF_SONET_COM_DOC", $arTmp))
5951 {
5952 $GLOBALS["UF_FORUM_MESSAGE_DOC"] = $arTmp["UF_SONET_COM_DOC"];
5953 }
5954 elseif (array_key_exists("UF_SONET_COM_FILE", $arTmp))
5955 {
5956 $arFieldsMessage["FILES"] = array();
5957 foreach($arTmp["UF_SONET_COM_FILE"] as $file_id)
5958 {
5959 $arFieldsMessage["FILES"][] = array("FILE_ID" => $file_id);
5960 }
5961 }
5962
5963 if (array_key_exists("UF_SONET_COM_URL_PRV", $arTmp))
5964 {
5965 $GLOBALS["UF_FORUM_MES_URL_PRV"] = $arTmp["UF_SONET_COM_URL_PRV"];
5966 }
5967 }
5968
5969 // file prop & UF_* forwarding END
5971
5972 $feed = new \Bitrix\Forum\Comments\Feed(
5973 $forumID,
5974 array(
5975 "type" => "TK",
5976 "id" => $arTask['ID'],
5977 "xml_id" => "TASK_".$arTask['ID']
5978 ),
5979 (
5980 is_object($USER)
5981 && $USER instanceof \CUser
5982 ? $USER->getId()
5983 : (isset($arFields['CURRENT_USER_ID']) ? $arFields['CURRENT_USER_ID'] : 0)
5984 )
5985 );
5986
5987 \Bitrix\Tasks\Integration\SocialNetwork::disable(); // disable socnet on comment add to avoid recursion
5988 $message = $feed->add($arFieldsMessage);
5989 \Bitrix\Tasks\Integration\SocialNetwork::enable(); // enable it back
5990
5991 if(is_array($message))
5992 {
5993 $messageID = $message['ID'];
5994 }
5995 else
5996 {
5997 foreach($feed->getErrors() as $error)
5998 {
5999 $sError .= $error->getMessage();
6000 }
6001 }
6002
6003 // get UF DOC value and FILE_ID there
6004 if ($messageID > 0)
6005 {
6006 // legacy files? will it work?
6007 $dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $messageID));
6008 while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch())
6009 $ufFileID[] = $arAddedMessageFiles["FILE_ID"];
6010
6011 // files in UF_*
6012 $ufDocID = $USER_FIELD_MANAGER->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $messageID, LANGUAGE_ID);
6013 $ufUrlPreview = $USER_FIELD_MANAGER->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MES_URL_PRV", $messageID, LANGUAGE_ID);
6014 }
6015
6016 if ($messageID && ($arMessage = CForumMessage::GetByID($messageID)))
6017 {
6019 $arFields["LOG_ID"],
6020 array(
6021 'PARAMS' => serialize(array('TYPE' => 'comment'))
6022 )
6023 );
6024 }
6025 }
6026 }
6027 }
6028
6029 return array(
6030 "SOURCE_ID" => $messageID,
6031 "MESSAGE" => (!empty($arFieldsMessage) ? $arFieldsMessage["POST_MESSAGE"] : false),
6032 "RATING_TYPE_ID" => "FORUM_POST",
6033 "RATING_ENTITY_ID" => $messageID,
6034 "ERROR" => $sError,
6035 "NOTES" => $sNote,
6036 "UF" => array(
6037 "FILE" => $ufFileID,
6038 "DOC" => $ufDocID,
6039 "URL_PREVIEW" => $ufUrlPreview
6040 ),
6041 "URL" => false
6042 );
6043 }
6044
6045 public static function GetCommentUrl_Task($arFields)
6046 {
6047 $messageUrl = '';
6048
6049 global $USER;
6050
6051 if (
6052 is_array($arFields)
6053 && !empty($arFields["ENTRY_ID"])
6054 && $USER->IsAuthorized()
6055 && CModule::IncludeModule('tasks')
6056 )
6057 {
6058 $messageUrl = CTaskNotifications::getNotificationPath(
6059 array('ID' => $USER->GetId()),
6060 $arFields["ENTRY_ID"],
6061 false
6062 );
6063 $messageUrl .= (mb_strpos($messageUrl, '?') !== false ? '&' : '?').'MID=#ID#';
6064
6065 if (!empty($arFields["COMMENT_ID"]))
6066 {
6067 $messageUrl = str_replace('#ID#', intval($arFields["COMMENT_ID"]), $messageUrl);
6068 }
6069 }
6070
6071 return $messageUrl;
6072 }
6073
6074 public static function UpdateComment_Task($arFields)
6075 {
6076 global $USER_FIELD_MANAGER;
6077
6078 if (!CModule::IncludeModule("forum") || !CModule::IncludeModule("tasks"))
6079 {
6080 return false;
6081 }
6082
6083 if (
6084 !isset($arFields["SOURCE_ID"])
6085 || intval($arFields["SOURCE_ID"]) <= 0
6086 )
6087 {
6088 return false;
6089 }
6090
6091 $messageId = intval($arFields["SOURCE_ID"]);
6092
6093 $sError = '';
6094
6095 $ufFileID = array();
6096 $ufDocID = array();
6097
6098 $arFields["LOG_ID"] = intval($arFields["LOG_ID"]);
6099
6100 if ($arFields["LOG_ID"] && ($arForumMessage = CForumMessage::GetByID($messageId)))
6101 {
6102 $arFieldsMessage = array(
6103 "POST_MESSAGE" => $arFields["TEXT_MESSAGE"],
6104 "USE_SMILES" => "Y",
6105 "APPROVED" => "Y",
6106 "SONET_PERMS" => array("bCanFull" => true)
6107 );
6108
6109 $logItem = CSocNetLog::GetList(
6110 array(),
6111 array("ID" => $arFields["LOG_ID"]),
6112 false,
6113 false,
6114 array("ID", "SOURCE_ID", "SITE_ID")
6115 )->fetch();
6116
6117 $arTmp = array();
6118 $USER_FIELD_MANAGER->EditFormAddFields("SONET_COMMENT", $arTmp);
6119 if (is_array($arTmp) && $logItem)
6120 {
6121 if (array_key_exists("UF_SONET_COM_DOC", $arTmp))
6122 {
6123 $GLOBALS["UF_FORUM_MESSAGE_DOC"] = $arTmp["UF_SONET_COM_DOC"];
6124 }
6125 elseif (array_key_exists("UF_SONET_COM_FILE", $arTmp))
6126 {
6127 $arFieldsMessage["FILES"] = array();
6128 foreach($arTmp["UF_SONET_COM_FILE"] as $file_id)
6129 {
6130 $arFieldsMessage["FILES"][$file_id] = array("FILE_ID" => $file_id);
6131 }
6132 if (!empty($arFieldsMessage["FILES"]))
6133 {
6134 $arFileParams = array("FORUM_ID" => $arForumMessage["FORUM_ID"], "TOPIC_ID" => $arForumMessage["TOPIC_ID"]);
6135 if(CForumFiles::CheckFields($arFieldsMessage["FILES"], $arFileParams, "NOT_CHECK_DB"))
6136 {
6137 CForumFiles::Add(array_keys($arFieldsMessage["FILES"]), $arFileParams);
6138 }
6139 }
6140 }
6141 }
6142
6143 $taskId = intval($logItem["SOURCE_ID"]);
6144
6145 $feed = new \Bitrix\Forum\Comments\Feed(
6146 $arForumMessage["FORUM_ID"],
6147 array(
6148 "type" => 'TK',
6149 "id" => $taskId,
6150 "xml_id" => "TASK_".$taskId
6151 )
6152 );
6153
6154 \Bitrix\Tasks\Integration\SocialNetwork::disable(); // disable socnet on comment add to avoid recursion
6155 $message = $feed->edit($messageId, $arFieldsMessage);
6156 \Bitrix\Tasks\Integration\SocialNetwork::enable(); // enable it back
6157
6158 $messageID = false;
6159 if(is_array($message))
6160 {
6161 $messageID = $message['ID'];
6162 }
6163 else
6164 {
6165 foreach($feed->getErrors() as $error)
6166 {
6167 $sError .= $error->getMessage();
6168 }
6169 }
6170
6171 unset($GLOBALS["UF_FORUM_MESSAGE_DOC"]);
6172
6173 // get UF DOC value and FILE_ID there
6174 if ($messageID > 0)
6175 {
6176 $dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $messageID));
6177 while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch())
6178 {
6179 $ufFileID[] = $arAddedMessageFiles["FILE_ID"];
6180 }
6181
6182 $ufDocID = $USER_FIELD_MANAGER->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $messageID, LANGUAGE_ID);
6183 }
6184 }
6185 else
6186 {
6187 $sError = GetMessage("SONET_UPDATE_COMMENT_SOURCE_ERROR");
6188 }
6189
6190 return array(
6191 "ERROR" => $sError,
6192 "NOTES" => '',
6193 "UF" => array(
6194 "FILE" => $ufFileID,
6195 "DOC" => $ufDocID
6196 )
6197 );
6198 }
6199
6200 public static function DeleteComment_Task($arFields)
6201 {
6202 $arRes = array();
6203
6204 $messageId = (int)$arFields["SOURCE_ID"];
6205 $forumId = COption::GetOptionString("tasks", "task_forum_id", 0, '');
6206
6207 if (
6208 !empty($arFields)
6209 && !empty($arFields["LOG_SOURCE_ID"])
6210 && (int)$arFields["LOG_SOURCE_ID"] > 0
6211 && intval($forumId) > 0
6212 && CModule::IncludeModule('forum')
6213 )
6214 {
6215 $feed = new \Bitrix\Forum\Comments\Feed(
6216 (int)$forumId,
6217 array(
6218 "type" => 'TK',
6219 "id" => intval($arFields["LOG_SOURCE_ID"]),
6220 "xml_id" => "TASK_".$arFields["LOG_SOURCE_ID"]
6221 )
6222 );
6223
6224 \Bitrix\Tasks\Integration\SocialNetwork::disable(); // disable socnet on comment add to avoid recursion
6225 $result = $feed->delete($messageId);
6226 \Bitrix\Tasks\Integration\SocialNetwork::enable(); // enable it back
6227
6228 if (!$result)
6229 {
6230 $arRes["ERROR"] = "";
6231 foreach($feed->getErrors() as $error)
6232 {
6233 $arRes["ERROR"] .= $error->getMessage();
6234 }
6235 }
6236 else
6237 {
6238 $arRes["NOTES"] = GetMessage("SONET_DELETE_COMMENT_SOURCE_SUCCESS");
6239 }
6240 }
6241 else
6242 {
6243 $arRes["ERROR"] = GetMessage("SONET_DELETE_COMMENT_SOURCE_ERROR");
6244 }
6245
6246 return $arRes;
6247 }
6248
6249 public static function CanEditComment_Task($arParams)
6250 {
6251 $res = false;
6252
6253 $forumId = COption::GetOptionString("tasks", "task_forum_id", 0, '');
6254
6255 if (
6256 !empty($arParams)
6257 && !empty($arParams["LOG_SOURCE_ID"])
6258 && (int)$arParams["LOG_SOURCE_ID"] > 0
6259 && !empty($arParams["USER_ID"])
6260 && (int)$arParams["USER_ID"] > 0
6261 && (int)$forumId > 0
6262 && CModule::IncludeModule('forum')
6263 )
6264 {
6265 try
6266 {
6267 $feed = new \Bitrix\Forum\Comments\Feed(
6268 (int)$forumId,
6269 array(
6270 "type" => 'TK',
6271 "id" => (int)$arParams["LOG_SOURCE_ID"],
6272 "xml_id" => "TASK_".$arParams["LOG_SOURCE_ID"]
6273 )
6274 );
6275 $res = $feed->getEntity()->canEdit((int)$arParams["USER_ID"]);
6276 }
6277 catch (Exception $e)
6278 {
6279 }
6280 }
6281
6282 return $res;
6283 }
6284
6285 public static function CanEditOwnComment_Task($arParams)
6286 {
6287 $res = false;
6288
6289 $forumId = COption::GetOptionString("tasks", "task_forum_id", 0, '');
6290
6291 if (
6292 !empty($arParams)
6293 && !empty($arParams["LOG_SOURCE_ID"])
6294 && (int)$arParams["LOG_SOURCE_ID"] > 0
6295 && !empty($arParams["USER_ID"])
6296 && (int)$arParams["USER_ID"] > 0
6297 && (int)$forumId > 0
6298 && CModule::IncludeModule('forum')
6299 )
6300 {
6301 try
6302 {
6303 $feed = new \Bitrix\Forum\Comments\Feed(
6304 (int)$forumId,
6305 array(
6306 "type" => 'TK',
6307 "id" => (int)$arParams["LOG_SOURCE_ID"],
6308 "xml_id" => "TASK_".$arParams["LOG_SOURCE_ID"]
6309 )
6310 );
6311 $res = $feed->getEntity()->canEditOwn(intval($arParams["USER_ID"]));
6312 }
6313 catch (Exception $e)
6314 {
6315 }
6316 }
6317
6318 return $res;
6319 }
6320
6321 public static function getResizedAvatarUrl(array $params = [])
6322 {
6323 $result = '';
6324
6325 $fileId = (isset($params['fileId']) ? (int)$params['fileId'] : 0);
6326 $avatarSize = (isset($params['avatarSize']) ? (int)$params['avatarSize'] : 100);
6327
6328 if ($fileId <= 0)
6329 {
6330 return $result;
6331 }
6332
6333 if ($imageFile = \CFile::getFileArray($fileId))
6334 {
6335 $resizedFile = \CFile::resizeImageGet(
6336 $imageFile,
6337 [
6338 'width' => $avatarSize,
6339 'height' => $avatarSize
6340 ],
6342 false
6343 );
6344 $result = $resizedFile['src'];
6345 }
6346
6347 return $result;
6348 }
6349}
6350
6352{
6353 var $matchNum = 0;
6354 var $matchNum2 = 0;
6355
6356 public $MaxStringLen = 0;
6357
6358 function sonet_sortlen($a, $b)
6359 {
6360 if (mb_strlen($a["TYPING"]) == mb_strlen($b["TYPING"]))
6361 return 0;
6362
6363 return (mb_strlen($a["TYPING"]) > mb_strlen($b["TYPING"])) ? -1 : 1;
6364 }
6365
6366 public function __construct($strLang = False, $pathToSmile = false)
6367 {
6368 parent::__construct();
6369
6370 if ($strLang === False)
6371 {
6372 $strLang = LANGUAGE_ID;
6373 }
6374 }
6375
6376 function convert($text, $arImages = array(), $allow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "TABLE" => "Y", "CUT_ANCHOR" => "N", "SHORT_ANCHOR" => "N"), $arParams = Array())
6377 {
6378 $this->allow = array(
6379 "HTML" => ($allow["HTML"] === "Y" ? "Y" : "N"),
6380 "NL2BR" => ($allow["NL2BR"] === "Y" ? "Y" : "N"),
6381 "LOG_NL2BR" => (($allow["LOG_NL2BR"] ?? null) === "N" ? "N" : "Y"),
6382 "MULTIPLE_BR" => (($allow["MULTIPLE_BR"] ?? null) === "N" ? "N" : "Y"),
6383 "CODE" => ($allow["CODE"] === "N" ? "N" : "Y"),
6384 "LOG_CODE" => (isset($allow["LOG_CODE"]) && $allow["LOG_CODE"] === "N" ? "N" : "Y"),
6385 "VIDEO" => ($allow["VIDEO"] === "N" ? "N" : "Y"),
6386 "LOG_VIDEO" => ($allow["LOG_VIDEO"] === "N" ? "N" : "Y"),
6387 "ANCHOR" => ($allow["ANCHOR"] === "N" ? "N" : "Y"),
6388 "LOG_ANCHOR" => (isset($allow["LOG_ANCHOR"]) && $allow["LOG_ANCHOR"] === "N" ? "N" : "Y"),
6389 "BIU" => ($allow["BIU"] === "N" ? "N" : "Y"),
6390 "IMG" => ($allow["IMG"] === "N" ? "N" : "Y"),
6391 "LOG_IMG" => (isset($allow["LOG_IMG"]) && $allow["LOG_IMG"] === "N" ? "N" : "Y"),
6392 "QUOTE" => ($allow["QUOTE"] === "N" ? "N" : "Y"),
6393 "LOG_QUOTE" => (isset($allow["LOG_QUOTE"]) && $allow["LOG_QUOTE"] === "N" ? "N" : "Y"),
6394 "FONT" => ($allow["FONT"] === "N" ? "N" : "Y"),
6395 "LOG_FONT" => (isset($allow["LOG_FONT"]) && $allow["LOG_FONT"] === "N" ? "N" : "Y"),
6396 "LIST" => ($allow["LIST"] === "N" ? "N" : "Y"),
6397 "SMILES" => ($allow["SMILES"] === "N" ? "N" : "Y"),
6398 "TABLE" => (isset($allow["TABLE"]) && $allow["TABLE"] === "N" ? "N" : "Y"),
6399 "ALIGN" => (isset($allow["ALIGN"]) && $allow["ALIGN"] === "N" ? "N" : "Y"),
6400 "CUT_ANCHOR" => (($allow["CUT_ANCHOR"] ?? null) === "Y" ? "Y" : "N"),
6401 "SHORT_ANCHOR" => (isset($allow["SHORT_ANCHOR"]) && $allow["SHORT_ANCHOR"] === "Y" ? "Y" : "N"),
6402 "HEADER" => (isset($allow["HEADER"]) && $allow["HEADER"] === "N" ? "N" : "Y"),
6403 "USERFIELDS" => (isset($allow["USERFIELDS"]) && $allow["USERFIELDS"] ? $allow["USERFIELDS"] : "N"),
6404 "USER" => (isset($allow["USER"]) && $allow["USER"] === "N" ? "N" : "Y")
6405 );
6406
6407 if ($this->allow["HTML"] !== "Y")
6408 {
6409 $text = preg_replace("#(<br[\s]*\/>)#isu", "", $text);
6410
6411 $text = preg_replace(
6412 array(
6413 "#<a[^>]+href\s*=\s*('|\")(.+?)(?:\\1)[^>]*>(.*?)</a[^>]*>#isu",
6414 "#<a[^>]+href(\s*=\s*)([^'\">])+>(.*?)</a[^>]*>#isu"),
6415 "[url=\\2]\\3[/url]", $text);
6416
6417 $replaced = 0;
6418 do
6419 {
6420 $text = preg_replace(
6421 "/<([busi])[^>a-z]*>(.+?)<\\/(\\1)[^>a-z]*>/isu",
6422 "[\\1]\\2[/\\1]",
6423 $text, -1, $replaced);
6424 }
6425 while($replaced > 0);
6426
6427 $text = preg_replace(
6428 "#<img[^>]+src\s*=[\s'\"]*(((http|https|ftp)://[.-_:a-z0-9@]+)*(\/[-_/=:.a-z0-9@{}&?%]+)+)[\s'\"]*[^>]*>#isu",
6429 "[img]\\1[/img]", $text);
6430
6431 $text = preg_replace(
6432 array(
6433 "/<font[^>]+size\s*=[\s'\"]*([0-9]+)[\s'\"]*[^>]*>(.+?)<\/font[^>]*>/isu",
6434 "/<font[^>]+color\s*=[\s'\"]*(\#[a-f0-9]{6})[^>]*>(.+?)<\/font[^>]*>/isu",
6435 "/<font[^>]+face\s*=[\s'\"]*([a-z\s\-]+)[\s'\"]*[^>]*>(.+?)<\/font[^>]*>/isu"),
6436 array(
6437 "[size=\\1]\\2[/size]",
6438 "[color=\\1]\\2[/color]",
6439 "[font=\\1]\\2[/font]"),
6440 $text);
6441
6442 $text = preg_replace(
6443 array(
6444 "/<ul((\s[^>]*)|(\s*))>(.+?)<\/ul([^>]*)>/isu",
6445 "/<ol((\s[^>]*)|(\s*))>(.+?)<\/ol([^>]*)>/isu",
6446 "/<li((\s[^>]*)|(\s*))>/isu",
6447 ),
6448 array(
6449 "[list]\\4[/list]",
6450 "[list=1]\\4[/list]",
6451 "[*]",
6452 ),
6453 $text);
6454
6455 $text = preg_replace(
6456 array(
6457 "/<table((\s[^>]*)|(\s*))>(.+?)<\/table([^>]*)>/isu",
6458 "/<tr((\s[^>]*)|(\s*))>(.*?)<\/tr([^>]*)>/isu",
6459 "/<td((\s[^>]*)|(\s*))>(.*?)<\/td([^>]*)>/isu",
6460 ),
6461 array(
6462 "[table]\\4[/table]",
6463 "[tr]\\4[/tr]",
6464 "[td]\\4[/td]",
6465 ),
6466 $text);
6467
6468 if ($this->allow["QUOTE"] === "Y")
6469 $text = preg_replace("#<(/?)quote(.*?)>#is", "[\\1quote]", $text);
6470
6471 }
6472 if ($this->allow["LOG_IMG"] === "N")
6473 $text = preg_replace("/(\[file([^\]]*)id\s*=\s*([0-9]+)([^\]]*)\])/is", "", $text);
6474
6475 if ($this->allow["LOG_NL2BR"] === "Y")
6476 {
6477 $text = str_replace("<br />", "\n", $text);
6478 }
6479 $text = $this->convertText($text);
6480 if ($this->allow["LOG_NL2BR"] === "Y")
6481 {
6482 $text = str_replace("\n", "<br />", $text);
6483 }
6484
6485 $text = preg_replace("#^(<br[\s]*\/>[\s\n]*)+#isu", "", $text);
6486 $text = preg_replace("#(<br[\s]*\/>[\s\n]*)+$#isu", "", $text);
6487
6488 if ($this->allow["MULTIPLE_BR"] === "N")
6489 $text = preg_replace("#(<br[\s]*\/>[\s\n]*)+#isu", "<br />", $text);
6490
6491 return trim($text);
6492 }
6493
6494 function convert_anchor_tag($url, $text, $attributes = [])
6495 {
6496 if ($this->allow["LOG_ANCHOR"] === "N")
6497 return "[URL]".$text."[/URL]";
6498 else
6499 return parent::convert_anchor_tag($url, $text, $attributes);
6500 }
6501
6502 function convert_image_tag($url = "", $params = "")
6503 {
6504 if ($this->allow["LOG_IMG"] === "N")
6505 {
6506// use thumbnail?
6507 return "";
6508 }
6509 else
6510 return parent::convert_image_tag($url, $params);
6511 }
6512
6514 {
6515 if ($text == '') return;
6516
6517 $text = str_replace("\\\"", "\"", $text);
6518
6519 $word_separator = str_replace("\]", "", $this->word_separator);
6520 $text = preg_replace("'(?<=^|[".$word_separator."]|\s)((http|https|news|ftp|aim|mailto)://[\.\-\_\:a-z0-9\@]([^\s\'\"\[\]\{\}])*)'is",
6521 "[nomodify]\\1[/nomodify]", $text);
6522
6523 return $text;
6524 }
6525
6527 {
6528 $text = preg_replace("#(<br[\s]*\/>)#isu", "", $text);
6529 if ($this->allow["LOG_CODE"] === "N")
6530 {
6531 $text = str_replace(Array("[nomodify]", "[/nomodify]"), Array("", ""), $text);
6532 return $text;
6533 }
6534 else
6535 return parent::convert_code_tag($text);
6536 }
6537
6539 {
6540 if ($this->allow["LOG_QUOTE"] === "N")
6541 {
6542 return preg_replace(
6543 array(
6544 "/\[quote([^\]<>])*\]/iu",
6545 "/\[\/quote([^\]<>])*\]/iu",
6546 ),
6547 "",
6548 $text);
6549 }
6550
6551 return parent::convert_quote_tag($text);
6552 }
6553
6554 function convert_font_attr($attr, $value = "", $text = "")
6555 {
6556 if ($text == '') return "";
6557 $text = str_replace("\\\"", "\"", $text);
6558 if ($value == '') return $text;
6559
6560 if ($this->allow["LOG_FONT"] === "N")
6561 {
6562 return $text;
6563 }
6564
6565 return parent::convert_font_attr($attr, $value, $text);
6566 }
6567
6569 {
6570 if ($this->allow["LOG_VIDEO"] === "N")
6571 {
6572 return '<a href="'.$params['PATH'].'">'.$params['PATH'].'</a>';
6573 }
6574
6575 return parent::convert_video($params);
6576 }
6577}
6578
6580{
6581 private $arItems = null;
6582
6583 public function __construct($params)
6584 {
6585 $this->arItems = $params["arItems"];
6586 }
6587
6588 public function OnBeforeSonetLogFilterFill(&$arPageParamsToClear, &$arItemsTop, &$arItems)
6589 {
6590 $arItems = $this->arItems;
6591 }
6592
6593 public static function ConvertPresetToFilters(array $arPreset, ?int $groupId): array
6594 {
6595 global $USER;
6596
6597 static
6598 $inited = false,
6599 $isExtranetAvailable = false,
6600 $isExtranetSite = false,
6601 $isTasksAvailable = false,
6602 $isCrmAvailable = false,
6603 $isListsAvailable = false,
6604 $isTimemanAvailable = false;
6605
6606 $filters = [];
6607
6608 if (!$inited)
6609 {
6610 $isExtranetAvailable = ModuleManager::isModuleInstalled('extranet');
6611 $isExtranetSite = (
6612 $isExtranetAvailable
6613 && Loader::includeModule('extranet')
6614 && CExtranet::isExtranetSite()
6615 );
6616 $isTasksAvailable = ModuleManager::isModuleInstalled('tasks');
6617 $isCrmAvailable = ModuleManager::isModuleInstalled('crm');
6618 $isListsAvailable = (
6619 ModuleManager::isModuleInstalled('lists')
6620 && ModuleManager::isModuleInstalled('bizproc')
6621 && ModuleManager::isModuleInstalled('intranet')
6622 );
6623 $isTimemanAvailable = ModuleManager::isModuleInstalled('timeman');
6624 $inited = true;
6625 }
6626
6627 foreach ($arPreset as $key => $arPresetFilterTmp)
6628 {
6629 $bCorrect = true;
6630
6631 if (!empty($arPresetFilterTmp["ID"]))
6632 {
6633 if (
6634 $arPresetFilterTmp["ID"] == "extranet"
6635 && (
6636 !$isExtranetAvailable
6637 || $isExtranetSite
6638 )
6639 )
6640 {
6641 unset($arPresetFilterTmp["ID"]);
6642 }
6643 elseif
6644 (
6645 $arPresetFilterTmp["ID"] === "work"
6646 && $isCrmAvailable
6647 && \Bitrix\Main\Config\Option::get("crm", "enable_livefeed_merge", "N") === "Y"
6648 && !empty($arPresetFilterTmp["FILTER"])
6649 && is_array($arPresetFilterTmp["FILTER"]["EVENT_ID"])
6650 )
6651 {
6652 $arPreset[$key] = $arPresetFilterTmp["FILTER"]["EVENT_ID"] = array_unique(array_merge($arPresetFilterTmp["FILTER"]["EVENT_ID"], array("crm_activity_add")));
6653 }
6654
6655 if (empty($arPresetFilterTmp["ID"]))
6656 {
6657 continue;
6658 }
6659 }
6660
6661 if (
6662 !empty($arPresetFilterTmp["FILTER"])
6663 && !empty($arPresetFilterTmp["EVENT_ID"])
6664 )
6665 {
6666 foreach ($arPresetFilterTmp["FILTER"]["EVENT_ID"] as $eventKey => $eventId)
6667 {
6668 if (
6669 ($eventId === "tasks" && !$isTasksAvailable)
6670 || (in_array($eventId, array("timeman_entry", "report")) && !$isTimemanAvailable)
6671 )
6672 {
6673 unset($arPresetFilterTmp["FILTER"]["EVENT_ID"][$eventKey]);
6674 }
6675 }
6676
6677 if (empty($arPresetFilterTmp["FILTER"]["EVENT_ID"]))
6678 {
6679 continue;
6680 }
6681 }
6682
6683 if (
6684 !empty($arPresetFilterTmp["FILTER"])
6685 && !empty($arPresetFilterTmp["FILTER"]["EXACT_EVENT_ID"])
6686 )
6687 {
6688 if (
6689 (
6690 $arPresetFilterTmp["FILTER"]["EXACT_EVENT_ID"] === "lists_new_element"
6691 && (
6692 (
6693 $groupId !== null
6694 && $groupId > 0
6695 )
6696 || !$isListsAvailable
6697 || $isExtranetSite
6698 )
6699 )
6700 )
6701 {
6702 unset($arPresetFilterTmp["FILTER"]["EXACT_EVENT_ID"]);
6703 }
6704
6705 if (empty($arPresetFilterTmp["FILTER"]["EXACT_EVENT_ID"]))
6706 {
6707 continue;
6708 }
6709 }
6710
6711 if (array_key_exists("NAME", $arPresetFilterTmp))
6712 {
6713 switch(mb_strtoupper($arPresetFilterTmp["NAME"]))
6714 {
6715 case "#WORK#":
6716 $arPresetFilterTmp["NAME"] = GetMessage("SONET_INSTALL_LOG_PRESET_WORK"); // lang/include.php
6717 break;
6718 case "#FAVORITES#":
6719 $arPresetFilterTmp["NAME"] = GetMessage("SONET_INSTALL_LOG_PRESET_FAVORITES");
6720 break;
6721 case "#IMPORTANT#":
6722 $arPresetFilterTmp["NAME"] = GetMessage("SONET_INSTALL_LOG_PRESET_IMPORTANT");
6723 break;
6724 case "#MY#":
6725 $arPresetFilterTmp["NAME"] = GetMessage("SONET_INSTALL_LOG_PRESET_MY");
6726 break;
6727 case "#BIZPROC#":
6728 $arPresetFilterTmp["NAME"] = GetMessage("SONET_INSTALL_LOG_PRESET_BIZPROC");
6729 break;
6730 case "#EXTRANET#":
6731 $arPresetFilterTmp["NAME"] = GetMessage("SONET_INSTALL_LOG_PRESET_EXTRANET");
6732 break;
6733 }
6734 }
6735
6736 if (
6737 array_key_exists("FILTER", $arPresetFilterTmp)
6738 && is_array($arPresetFilterTmp["FILTER"])
6739 )
6740 {
6741 foreach ($arPresetFilterTmp["FILTER"] as $tmp_id_2 => $filterTmp)
6742 {
6743 if (
6744 (
6745 !is_array($filterTmp)
6746 && $filterTmp === "#CURRENT_USER_ID#"
6747 )
6748 || (
6749 is_array($filterTmp)
6750 && in_array("#CURRENT_USER_ID#", $filterTmp, true)
6751 )
6752 )
6753 {
6754 if (!$USER->isAuthorized())
6755 {
6756 $bCorrect = false;
6757 break;
6758 }
6759 elseif (!is_array($filterTmp))
6760 {
6761 $arPresetFilterTmp["FILTER"][$tmp_id_2] = $USER->getId();
6762 }
6763 elseif (is_array($filterTmp))
6764 {
6765 foreach($filterTmp as $tmp_id_3 => $valueTmp)
6766 {
6767 if ($valueTmp === "#CURRENT_USER_ID#")
6768 {
6769 $arPresetFilterTmp["FILTER"][$tmp_id_2][$tmp_id_3] = $USER->getId();
6770 }
6771 }
6772 }
6773 }
6774 elseif (
6775 (
6776 !is_array($filterTmp)
6777 && $filterTmp === "#EXTRANET_SITE_ID#"
6778 )
6779 || (
6780 is_array($filterTmp)
6781 && in_array("#EXTRANET_SITE_ID#", $filterTmp)
6782 )
6783 )
6784 {
6785 if (
6786 !ModuleManager::isModuleInstalled("extranet")
6787 || !COption::GetOptionString("extranet", "extranet_site", false)
6788 )
6789 {
6790 $bCorrect = false;
6791 break;
6792 }
6793
6794 if (!is_array($filterTmp))
6795 {
6796 $arPresetFilterTmp["FILTER"][$tmp_id_2] = COption::GetOptionString("extranet", "extranet_site");
6797 }
6798 else
6799 {
6800 foreach($filterTmp as $tmp_id_3 => $valueTmp)
6801 {
6802 if ($valueTmp === "#EXTRANET_SITE_ID#")
6803 {
6804 $arPresetFilterTmp["FILTER"][$tmp_id_2][$tmp_id_3] = COption::GetOptionString("extranet", "extranet_site");
6805 }
6806 }
6807 }
6808 }
6809 }
6810 }
6811
6812 if ($bCorrect)
6813 {
6814 $arFilter[$arPresetFilterTmp["ID"]] = $arPresetFilterTmp;
6815 }
6816 }
6817
6818 return $arFilter;
6819 }
6820
6821 public static function OnSonetLogFilterProcess($preset_filter_top_id, $preset_filter_id, $arResultPresetFiltersTop, $arResultPresetFilters)
6822 {
6823 $arResult = array();
6824
6825 if (
6826 $preset_filter_id <> ''
6827 && array_key_exists($preset_filter_id, $arResultPresetFilters)
6828 && isset($arResultPresetFilters[$preset_filter_id]["FILTER"])
6829 && is_array($arResultPresetFilters[$preset_filter_id]["FILTER"])
6830 )
6831 {
6832 if (array_key_exists("EXACT_EVENT_ID", $arResultPresetFilters[$preset_filter_id]["FILTER"]))
6833 {
6834 $arResult["PARAMS"]["EXACT_EVENT_ID"] = $arResultPresetFilters[$preset_filter_id]["FILTER"]["EXACT_EVENT_ID"];
6835 $arResult["GET_COMMENTS"] = false;
6836 }
6837
6838 if (array_key_exists("!EXACT_EVENT_ID", $arResultPresetFilters[$preset_filter_id]["FILTER"]))
6839 {
6840 $arResult["PARAMS"]["!EXACT_EVENT_ID"] = $arResultPresetFilters[$preset_filter_id]["FILTER"]["!EXACT_EVENT_ID"];
6841 $arResult["GET_COMMENTS"] = false;
6842 }
6843
6844 if (array_key_exists("EVENT_ID", $arResultPresetFilters[$preset_filter_id]["FILTER"]))
6845 {
6846 $arResult["PARAMS"]["EVENT_ID"] = $arResultPresetFilters[$preset_filter_id]["FILTER"]["EVENT_ID"];
6847 $arResult["GET_COMMENTS"] = false;
6848 }
6849
6850 if (array_key_exists("CREATED_BY_ID", $arResultPresetFilters[$preset_filter_id]["FILTER"]))
6851 {
6852 $arResult["PARAMS"]["CREATED_BY_ID"] = $arResultPresetFilters[$preset_filter_id]["FILTER"]["CREATED_BY_ID"];
6853 }
6854
6855 if (
6856 array_key_exists("FAVORITES_USER_ID", $arResultPresetFilters[$preset_filter_id]["FILTER"])
6857 && $arResultPresetFilters[$preset_filter_id]["FILTER"]["FAVORITES_USER_ID"] === "Y"
6858 )
6859 {
6860 $arResult["PARAMS"]["FAVORITES"] = "Y";
6861 $arResult["GET_COMMENTS"] = false;
6862 }
6863
6864 $arResult["PARAMS"]["SET_LOG_COUNTER"] = $arParams["SET_LOG_PAGE_CACHE"] = "N";
6865 $arResult["PARAMS"]["USE_FOLLOW"] = "N";
6866
6867 if (array_key_exists("SITE_ID", $arResultPresetFilters[$preset_filter_id]["FILTER"]))
6868 {
6869 $arResult["PARAMS"]["FILTER_SITE_ID"] = $arResultPresetFilters[$preset_filter_id]["FILTER"]["SITE_ID"];
6870 }
6871 }
6872
6873 return $arResult;
6874 }
6875
6876 public static function GetSiteByDepartmentId($arDepartmentId)
6877 {
6878 if (!is_array($arDepartmentId))
6879 {
6880 $arDepartmentId = array($arDepartmentId);
6881 }
6882
6883 $bFound = $arResult = false;
6884
6885 $dbSitesList = CSite::GetList("SORT", "asc", array("ACTIVE" => "Y")); // cache used
6886 while ($arSite = $dbSitesList->GetNext())
6887 {
6888 $siteRootDepartmentId = COption::GetOptionString("main", "wizard_departament", false, $arSite["LID"], true);
6889 if ($siteRootDepartmentId)
6890 {
6891 if (in_array($siteRootDepartmentId, $arDepartmentId))
6892 {
6893 $arResult = $arSite;
6894 $bFound = true;
6895 }
6896 else
6897 {
6898 $arSubStructure = CIntranetUtils::getSubStructure($siteRootDepartmentId);
6899 $arSiteDepartmentId = array_keys($arSubStructure["DATA"] ?? []);
6900
6901 foreach($arDepartmentId as $userDepartmentId)
6902 {
6903 if(in_array($userDepartmentId, $arSiteDepartmentId))
6904 {
6905 $arResult = $arSite;
6906 $bFound = true;
6907 break;
6908 }
6909 }
6910 }
6911
6912 if($bFound)
6913 {
6914 break;
6915 }
6916 }
6917 }
6918
6919 if (!$bFound)
6920 {
6921 if ($defSiteId = \CSite::getDefSite())
6922 {
6923 $res = CSite::getByID($defSiteId);
6924 $arResult = $res->fetch();
6925 }
6926 }
6927
6928 return $arResult;
6929 }
6930
6931 public static function saveRawFilesToUF($arAttachedFilesRaw, $ufCode, &$arFields)
6932 {
6933 if (empty($arFields[$ufCode]))
6934 {
6935 $arFields[$ufCode] = array();
6936 }
6937
6938 $arRelation = array();
6939 $type = false;
6940
6941 foreach ($arAttachedFilesRaw as $attachedFileRow)
6942 {
6943 if (
6944 !empty($attachedFileRow["base64"])
6945 && !empty($attachedFileRow["url"])
6946 )
6947 {
6948 $fileContent = base64_decode($attachedFileRow["base64"]);
6949 $arUri = parse_url($attachedFileRow["url"]);
6950 if (
6951 !empty($arUri)
6952 && !empty($arUri["path"])
6953 )
6954 {
6955 $fileName = $arUri["path"];
6956 }
6957
6958 if (
6959 !empty($fileContent)
6960 && !empty($fileName)
6961 )
6962 {
6963 $fileName = CTempFile::GetFileName($fileName);
6964
6966 {
6967 file_put_contents($fileName, $fileContent);
6968 $arFile = CFile::MakeFileArray($fileName);
6969
6970 $resultId = self::saveFileToUF($arFile, $type, false);
6971
6972 if ($resultId)
6973 {
6974 $arFields[$ufCode][] = $resultId;
6975 }
6976
6977 if (!empty($attachedFileRow["id"]))
6978 {
6979 $arRelation[$attachedFileRow["id"]] = $resultId;
6980 }
6981 }
6982 }
6983 }
6984 }
6985
6986 if (!empty($arRelation))
6987 {
6988 $arFields["DETAIL_TEXT"] = preg_replace_callback(
6989 "/\[DISK\s+FILE\s+ID\s*=\s*pseudo@([\d]+)\]/isu",
6990 function ($matches) use ($arRelation, $type)
6991 {
6992 if (isset($arRelation[intval($matches[1])]))
6993 {
6994 if ($type === "disk")
6995 {
6996 return "[DISK FILE ID=".$arRelation[intval($matches[1])]."]";
6997 }
6998 elseif ($type === "webdav")
6999 {
7000 return "[DOCUMENT ID=".intval($arRelation[intval($matches[1])])."]";
7001 }
7002 else
7003 {
7004 return "[DISK FILE ID=pseudo@".$matches[1]."]";
7005 }
7006 }
7007 else
7008 {
7009 return "[DISK FILE ID=pseudo@".$matches[1]."]";
7010 }
7011 },
7012 $arFields["DETAIL_TEXT"]
7013 );
7014 }
7015 }
7016
7017 public static function saveFileToUF($arFile = array(), &$type = null, $userId = false)
7018 {
7019 global $USER, $DB, $USER_FIELD_MANAGER;
7020
7021 static $isDiskEnabled = false;
7022 static $isWebDavEnabled = false;
7023
7024 static $arDiskData = array();
7025 static $arWebDavData = array();
7026
7027 $resultId = false;
7028
7029 if (
7030 !$userId
7031 || (int)$userId <= 0
7032 )
7033 {
7034 $userId = $USER->GetID();
7035 }
7036
7037 if ($isDiskEnabled === false)
7038 {
7039 $isDiskEnabled = (
7040 \Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false)
7041 && CModule::includeModule('disk')
7042 ? 'Y'
7043 : 'N'
7044 );
7045 }
7046
7047 if ($isWebDavEnabled === false)
7048 {
7049 $isWebDavEnabled = (
7050 $isDiskEnabled === 'N'
7051 && CModule::includeModule('webdav')
7052 ? "Y"
7053 : "N"
7054 );
7055 }
7056
7057 if (!isset($arDiskData[$userId]))
7058 {
7059 $arDiskData[$userId] = array(
7060 "ENABLED" => "N"
7061 );
7062
7063 if ($isDiskEnabled === "Y")
7064 {
7065 if (
7066 ($storage = \Bitrix\Disk\Driver::getInstance()->getStorageByUserId($userId))
7067 && ($folder = $storage->getFolderForUploadedFiles($userId))
7068 )
7069 {
7070 $arDiskData[$userId] = array(
7071 "ENABLED" => "Y",
7072 "STORAGE" => $storage,
7073 "FOLDER" => $folder
7074 );
7075 }
7076 }
7077 }
7078
7079 if (!isset($arWebDavData[$userId]))
7080 {
7081 $arWebDavData[$userId] = array(
7082 "ENABLED" => "N"
7083 );
7084
7085 if ($isWebDavEnabled === "Y" && $USER instanceof \CUser)
7086 {
7087 $webDavData = CWebDavIblock::getRootSectionDataForUser($userId);
7088
7089 if (is_array($webDavData))
7090 {
7091 $webDavObject = new CWebDavIblock(
7092 $webDavData["IBLOCK_ID"],
7093 "",
7094 array(
7095 "ROOT_SECTION_ID" => $webDavData["SECTION_ID"],
7096 "DOCUMENT_TYPE" => array("webdav", 'CIBlockDocumentWebdavSocnet', 'iblock_'.$webDavData['SECTION_ID'].'_user_'.$userId)
7097 )
7098 );
7099
7100 if ($webDavObject)
7101 {
7102 $arParent = $webDavObject->GetObject(
7103 array(
7104 "section_id" => $webDavObject->GetMetaID("DROPPED")
7105 )
7106 );
7107
7108 if (!$arParent["not_found"])
7109 {
7110 $path = $webDavObject->_get_path($arParent["item_id"], false);
7111 $tmpName = str_replace(array(":", ".", "/", "\\"), "_", ConvertTimeStamp(time(), "FULL"));
7112 $tmpOptions = array("path" => str_replace("//", "/", $path."/".$tmpName));
7113 $arParent = $webDavObject->GetObject($tmpOptions);
7114 if ($arParent["not_found"])
7115 {
7116 $rMKCOL = $webDavObject->MKCOL($tmpOptions);
7117 if ((int)$rMKCOL == 201)
7118 {
7119 $webDavData["SECTION_ID"] = $webDavObject->arParams["changed_element_id"];
7120 }
7121 }
7122 else
7123 {
7124 $webDavData["SECTION_ID"] = $arParent['item_id'];
7125 if (!$webDavObject->CheckUniqueName($tmpName, $webDavData["SECTION_ID"], $tmpRes))
7126 {
7127 $path = $webDavObject->_get_path($webDavData["SECTION_ID"], false);
7128 $tmpName = randString(6);
7129 $tmpOptions = array("path" => str_replace("//", "/", $path."/".$tmpName));
7130 $rMKCOL = $webDavObject->MKCOL($tmpOptions);
7131 if (intval($rMKCOL) == 201)
7132 {
7133 $webDavData["SECTION_ID"] = $webDavData->arParams["changed_element_id"];
7134 }
7135 }
7136 }
7137
7138 $arWebDavData[$userId] = array(
7139 "ENABLED" => "Y",
7140 "OBJECT" => $webDavObject,
7141 "DATA" => $webDavData
7142 );
7143 }
7144 }
7145 }
7146 }
7147 }
7148
7149 if(is_array($arFile))
7150 {
7151 $resultId = false;
7152 if ($arDiskData[$userId]["ENABLED"] === "Y")
7153 {
7154 $type = "disk";
7155 $file = $arDiskData[$userId]["FOLDER"]->uploadFile(
7156 $arFile, // file array
7157 array(
7158 'NAME' => $arFile["name"],
7159 'CREATED_BY' => $userId
7160 ),
7161 array(),
7162 true
7163 );
7164
7165 if ($file)
7166 {
7167 $resultId = \Bitrix\Disk\Uf\FileUserType::NEW_FILE_PREFIX.$file->getId();
7168 }
7169 }
7170 elseif ($arWebDavData[$userId]["ENABLED"] == "Y")
7171 {
7172 $type = "webdav";
7173 $options = array(
7174 "new" => true,
7175 'dropped' => true,
7176 "arFile" => $arFile,
7177 "arDocumentStates" => false,
7178 "arUserGroups" => array_merge($arWebDavData[$userId]["OBJECT"]->USER["GROUPS"], array("Author")),
7179 "FILE_NAME" => $arFile["name"],
7180 "IBLOCK_ID" => $arWebDavData[$userId]["DATA"]["IBLOCK_ID"],
7181 "IBLOCK_SECTION_ID" => $arWebDavData[$userId]["DATA"]["SECTION_ID"],
7182 "USER_FIELDS" => array()
7183 );
7184
7185 $USER_FIELD_MANAGER->EditFormAddFields($arWebDavData[$userId]["OBJECT"]->GetUfEntity(), $options['USER_FIELDS']);
7186
7187 $DB->StartTransaction();
7188
7189 if (!$arWebDavData[$userId]["OBJECT"]->put_commit($options))
7190 {
7191 $DB->Rollback();
7192 }
7193 else
7194 {
7195 $DB->Commit();
7196 $resultId = $options['ELEMENT_ID'];
7197 }
7198
7199 }
7200 else // for main
7201 {
7202 $type = "main";
7203 $resultId = CFile::SaveFile($arFile, $arFile["MODULE_ID"]);
7204 }
7205 }
7206
7207 return $resultId;
7208 }
7209
7210 public static function checkEmptyUFValue($fieldName)
7211 {
7212 if (
7213 isset($GLOBALS[$fieldName])
7214 && is_array($GLOBALS[$fieldName])
7215 && count($GLOBALS[$fieldName]) == 1
7216 && $GLOBALS[$fieldName][0] === 'empty'
7217 )
7218 {
7219 $GLOBALS[$fieldName] = array();
7220 }
7221 }
7222
7223 public static function isSetTrafficNeeded($arParams)
7224 {
7225 if (
7226 !isset($arParams["TRAFFIC_SET_PERIOD"])
7227 || (int)$arParams["TRAFFIC_SET_PERIOD"] <= 0
7228 )
7229 {
7230 $arParams["TRAFFIC_SET_PERIOD"] = 60*60*24;
7231 }
7232
7233 return (
7234 (int)$arParams["PAGE_NUMBER"] == 1
7235 && $arParams["GROUP_CODE"] === '**'
7236 && (time() - $arParams['TRAFFIC_LAST_DATE_TS']) > $arParams["TRAFFIC_SET_PERIOD"]
7237 );
7238 }
7239
7240 public static function processDateTimeFormatParams(&$arParams = array())
7241 {
7242 global $DB;
7243
7244 if (
7245 !is_array($arParams)
7246 || empty($arParams)
7247 )
7248 {
7249 return;
7250 }
7251
7252 $arParams["DATE_TIME_FORMAT"] = trim(
7253 !empty($arParams['DATE_TIME_FORMAT'])
7254 ? ($arParams['DATE_TIME_FORMAT'] === 'FULL'
7255 ? CDatabase::DateFormatToPHP(FORMAT_DATETIME)
7256 : $arParams['DATE_TIME_FORMAT']
7257 )
7258 : CDatabase::DateFormatToPHP(FORMAT_DATETIME)
7259 );
7260 $arParams["DATE_TIME_FORMAT"] = preg_replace('/[\/.,\s:][s]/', '', $arParams["DATE_TIME_FORMAT"]);
7261 $arParams["DATE_TIME_FORMAT_WITHOUT_YEAR"] = (
7262 isset($arParams["DATE_TIME_FORMAT_WITHOUT_YEAR"])
7263 ? $arParams["DATE_TIME_FORMAT_WITHOUT_YEAR"]
7264 : preg_replace('/[\/.,\s-][Yyo]/', '', $arParams["DATE_TIME_FORMAT"])
7265 );
7266 $arParams["TIME_FORMAT"] = (
7267 isset($arParams["TIME_FORMAT"])
7268 ? $arParams["TIME_FORMAT"]
7269 : preg_replace('/[\/.,\s]+$/', '', preg_replace('/^[\/.,\s]+/', '', preg_replace('/[dDjlFmMnYyo]/', '', $arParams["DATE_TIME_FORMAT"])))
7270 );
7271 $arParams["DATE_FORMAT"] = (
7272 isset($arParams["DATE_FORMAT"])
7273 ? $arParams["DATE_FORMAT"]
7274 : preg_replace('/[\/.,:\s]+$/', '', preg_replace('/^[\/.,\s]+/', '', preg_replace('/[aABgGhHisuveIOPTZ]/', '', $arParams["DATE_TIME_FORMAT"])))
7275 );
7276 }
7277
7278 public static function getDateTimeFormatted($timestamp, $arFormatParams)
7279 {
7280 return \CComponentUtil::getDateTimeFormatted($timestamp, $arFormatParams["DATE_TIME_FORMAT"], CTimeZone::GetOffset());
7281 }
7282
7283 public static function getCommentRights($arParams)
7284 {
7285 global $USER;
7286
7287 $isAuthorized = ($USER && is_object($USER) && $USER->IsAuthorized());
7288
7289 $arResult = array(
7290 "COMMENT_RIGHTS_EDIT" => "N",
7291 "COMMENT_RIGHTS_DELETE" => "N"
7292 );
7293
7294 $logEventId = (
7295 isset($arParams["EVENT_ID"])
7296 && $arParams["EVENT_ID"] <> ''
7297 ? $arParams["EVENT_ID"]
7298 : false
7299 );
7300
7301 $logSourceId = (
7302 isset($arParams["SOURCE_ID"])
7303 && (int)$arParams["SOURCE_ID"] > 0
7304 ? (int)$arParams["SOURCE_ID"]
7305 : false
7306 );
7307
7308 $bCheckAdminSession = (
7309 !isset($arParams["CHECK_ADMIN_SESSION"])
7310 || $arParams["CHECK_ADMIN_SESSION"] !== "N"
7311 );
7312
7313 $arCommentEventMeta = CSocNetLogTools::FindLogCommentEventByLogEventID($logEventId);
7314
7315 $bHasEditCallback = (
7316 is_array($arCommentEventMeta)
7317 && isset($arCommentEventMeta["UPDATE_CALLBACK"])
7318 && (
7319 $arCommentEventMeta["UPDATE_CALLBACK"] === "NO_SOURCE"
7320 || is_callable($arCommentEventMeta["UPDATE_CALLBACK"])
7321 )
7322 );
7323
7324 $bHasDeleteCallback = (
7325 is_array($arCommentEventMeta)
7326 && isset($arCommentEventMeta["DELETE_CALLBACK"])
7327 && (
7328 $arCommentEventMeta["DELETE_CALLBACK"] === "NO_SOURCE"
7329 || is_callable($arCommentEventMeta["DELETE_CALLBACK"])
7330 )
7331 );
7332
7333 if (
7334 $bHasEditCallback
7335 || $bHasDeleteCallback
7336 )
7337 {
7338 $arEventMeta = CSocNetLogTools::FindLogEventByID($logEventId);
7339
7340 if (
7341 !empty($arEventMeta)
7342 && !empty($arEventMeta["COMMENT_EVENT"])
7343 && !empty($arEventMeta["COMMENT_EVENT"]["METHOD_CANEDIT"])
7344 )
7345 {
7346 $res = call_user_func($arEventMeta["COMMENT_EVENT"]["METHOD_CANEDIT"], array(
7347 "LOG_SOURCE_ID" => $logSourceId,
7348 "USER_ID" => (int)$arParams["USER_ID"]
7349 ));
7350
7351 if ($res)
7352 {
7353 $arResult["COMMENT_RIGHTS_EDIT"] = ($bHasEditCallback ? "ALL" : "N");
7354 $arResult["COMMENT_RIGHTS_DELETE"] = ($bHasDeleteCallback ? "ALL" : "N");
7355 }
7356 else
7357 {
7358 if (!empty($arEventMeta["COMMENT_EVENT"]["METHOD_CANEDITOWN"]))
7359 {
7360 $res = call_user_func($arEventMeta["COMMENT_EVENT"]["METHOD_CANEDITOWN"], array(
7361 "LOG_SOURCE_ID" => $logSourceId,
7362 "USER_ID" => (int)$arParams["USER_ID"]
7363 ));
7364
7365 if ($res)
7366 {
7367 $arResult["COMMENT_RIGHTS_EDIT"] = ($bHasEditCallback ? "OWN" : "N");
7368 $arResult["COMMENT_RIGHTS_DELETE"] = ($bHasDeleteCallback ? "OWN" : "N");
7369 }
7370 }
7371 elseif ($isAuthorized)
7372 {
7373 $arResult["COMMENT_RIGHTS_EDIT"] = ($bHasEditCallback ? "OWN" : "N");
7374 $arResult["COMMENT_RIGHTS_DELETE"] = ($bHasDeleteCallback ? "OWN" : "N");
7375 }
7376 }
7377 }
7378 elseif (CSocNetUser::IsCurrentUserModuleAdmin(SITE_ID, $bCheckAdminSession))
7379 {
7380 $arResult["COMMENT_RIGHTS_EDIT"] = ($bHasEditCallback ? "ALL" : "N");
7381 $arResult["COMMENT_RIGHTS_DELETE"] = ($bHasDeleteCallback ? "ALL" : "N");
7382 }
7383 elseif ($isAuthorized)
7384 {
7385 $arResult["COMMENT_RIGHTS_EDIT"] = ($bHasEditCallback ? "OWN" : "N");
7386 $arResult["COMMENT_RIGHTS_DELETE"] = ($bHasDeleteCallback ? "OWN" : "N");
7387 }
7388 }
7389
7390 return $arResult;
7391 }
7392
7393 public static function canUserChangeComment($arParams)
7394 {
7395 global $USER;
7396
7397 $res = false;
7398
7399 if (!is_array($arParams))
7400 {
7401 $arParams = array();
7402 }
7403
7404 if (empty($arParams["LOG_EVENT_ID"]))
7405 {
7406 return $res;
7407 }
7408
7409 if (
7410 !isset($arParams["USER_ID"])
7411 || (int)$arParams["USER_ID"] <= 0
7412 )
7413 {
7414 $arParams["USER_ID"] = $USER->GetId();
7415 }
7416
7417 if (!isset($arParams["ACTION"]))
7418 {
7419 $arParams["ACTION"] = "edit";
7420 }
7421
7422 $arParams["ACTION"] = mb_strtoupper($arParams["ACTION"]);
7423
7425 "EVENT_ID" => $arParams["LOG_EVENT_ID"],
7426 "SOURCE_ID" => (isset($arParams["LOG_SOURCE_ID"]) ? intval($arParams["LOG_SOURCE_ID"]) : false),
7427 "CHECK_ADMIN_SESSION" => (isset($arParams["CHECK_ADMIN_SESSION"]) && $arParams["CHECK_ADMIN_SESSION"] == "N" ? "N" : "Y"),
7428 "USER_ID" => $arParams["USER_ID"]
7429 ));
7430
7431 $key = ($arParams["ACTION"] === "EDIT" ? "COMMENT_RIGHTS_EDIT" : "COMMENT_RIGHTS_DELETE");
7432
7433 if (
7434 $rights[$key] === "ALL"
7435 || (
7436 $rights[$key] === "OWN"
7437 && !empty($arParams["COMMENT_USER_ID"])
7438 && (int)$arParams["COMMENT_USER_ID"] > 0
7439 && (int)$arParams["COMMENT_USER_ID"] === (int)$arParams["USER_ID"]
7440 )
7441 )
7442 {
7443 $res = true;
7444 }
7445
7446 return $res;
7447 }
7448
7449 public static function getExtranetRedirectSite($extranetSiteId)
7450 {
7451 global $USER;
7452
7453 $arRedirectSite = false;
7454
7455 if ($USER->IsAuthorized())
7456 {
7457 $rsCurrentUser = CUser::GetById($USER->GetId());
7458 if ($arCurrentUser = $rsCurrentUser->Fetch())
7459 {
7460 $bCurrentUserIntranet = (
7461 !empty($arCurrentUser["UF_DEPARTMENT"])
7462 && is_array($arCurrentUser["UF_DEPARTMENT"])
7463 && intval($arCurrentUser["UF_DEPARTMENT"][0]) > 0
7464 );
7465
7466 if (
7467 SITE_ID == $extranetSiteId
7468 && $bCurrentUserIntranet
7469 && !CSocNetUser::IsCurrentUserModuleAdmin()
7470 ) // extranet -> intranet
7471 {
7472 $arRedirectSite = CSocNetLogComponent::GetSiteByDepartmentId($arCurrentUser["UF_DEPARTMENT"]);
7473 if ($arRedirectSite["LID"] == SITE_ID)
7474 {
7475 $arRedirectSite = false;
7476 }
7477 }
7478 elseif (
7479 SITE_ID != $extranetSiteId
7480 && !$bCurrentUserIntranet
7481 && !CSocNetUser::IsCurrentUserModuleAdmin(SITE_ID, false)
7482 ) // intranet -> extranet
7483 {
7484 $rsRedirectSite = CSite::GetList("SORT", "asc", array("ACTIVE" => "Y", "LID" => $extranetSiteId)); // cache used
7485 $arRedirectSite = $rsRedirectSite->Fetch();
7486 }
7487 }
7488 }
7489
7490 return $arRedirectSite;
7491 }
7492
7493 public static function redirectExtranetSite($arRedirectSite, $componentPage, $arVariables, $arDefaultUrlTemplates404, $entity = "user")
7494 {
7495 if ($entity !== "user")
7496 {
7497 $entity = "workgroup";
7498 }
7499
7500 $url = (
7501 trim($arRedirectSite["SERVER_NAME"]) <> ''
7502 && $arRedirectSite["SERVER_NAME"] != SITE_SERVER_NAME
7503 ? (CMain::IsHTTPS() ? "https" : "http")."://".$arRedirectSite["SERVER_NAME"]
7504 : ''
7505 ).
7506 COption::GetOptionString("socialnetwork", ($entity === "user" ? "user_page" : "workgroups_page"), false, $arRedirectSite["LID"]).
7507 CComponentEngine::MakePathFromTemplate(
7508 $arDefaultUrlTemplates404[$componentPage],
7509 $arVariables
7510 );
7511
7512 if (!empty($_GET["MID"]))
7513 {
7514 $url .= (mb_strpos($url, '?') === false ? '?' : '&').'MID=' . (int)$_GET["MID"];
7515 }
7516
7518 }
7519
7520 public static function getCommentByRequest($commentId, $postId, $action = false, $checkPerms = true, $checkAdminSession = true)
7521 {
7522 global $USER_FIELD_MANAGER;
7523
7524 $commentId = (int)$commentId;
7525 $postId = (int)$postId;
7526
7527 $arOrder = array();
7528
7529 $rsLog = CSocNetLog::GetList(
7530 array(),
7531 array(
7532 "ID" => $postId
7533 ),
7534 false,
7535 false,
7536 array("EVENT_ID", "SOURCE_ID", "ENTITY_ID")
7537 );
7538
7539 if ($arLog = $rsLog->Fetch())
7540 {
7541 $hasSource = ComponentHelper::hasCommentSource(array(
7542 "LOG_EVENT_ID" => $arLog["EVENT_ID"],
7543 "LOG_ENTITY_ID" => $arLog["ENTITY_ID"]
7544 ));
7545
7546 $arCommentEvent = CSocNetLogTools::FindLogCommentEventByLogEventID($arLog["EVENT_ID"]);
7547
7548 $arFilter = array(
7549 "EVENT_ID" => $arCommentEvent["EVENT_ID"]
7550 );
7551
7552 if ($hasSource)
7553 {
7554 $arFilter["SOURCE_ID"] = $commentId; // forum etc.
7555 }
7556 else
7557 {
7558 $arFilter["ID"] = $commentId; // socialnetwork
7559 }
7560
7562 $arOrder,
7563 $arFilter,
7564 false,
7565 false,
7566 array("ID", "EVENT_ID", "MESSAGE", "USER_ID", "SOURCE_ID", "LOG_SOURCE_ID", "UF_*")
7567 );
7568
7569 if ($arRes = $dbRes->Fetch())
7570 {
7571 $arRes['MESSAGE'] = Emoji::decode($arRes['MESSAGE']);
7572
7573 if ($checkPerms)
7574 {
7576 "ACTION" => $action,
7577 "LOG_ID" => $postId,
7578 "LOG_EVENT_ID" => $arLog["EVENT_ID"],
7579 "LOG_SOURCE_ID" => $arLog["SOURCE_ID"],
7580 "COMMENT_ID" => $arRes["ID"],
7581 "COMMENT_USER_ID" => $arRes["USER_ID"],
7582 "CHECK_ADMIN_SESSION" => ($checkAdminSession ? "Y" : "N")
7583 ));
7584 }
7585 else
7586 {
7587 $bAllow = true;
7588 }
7589
7590 if (!$bAllow)
7591 {
7592 $arRes = false;
7593 }
7594 else
7595 {
7596 if ($action === "edit") // data needed only for edit
7597 {
7598 $arUFMeta = $USER_FIELD_MANAGER->GetUserFields("SONET_COMMENT", 0, LANGUAGE_ID);
7599 $arRes["UF"] = array();
7600
7601 foreach($arUFMeta as $field_name => $arUF)
7602 {
7603 if (
7604 array_key_exists($field_name, $arRes)
7605 && !empty($arRes[$field_name])
7606 )
7607 {
7608 $arRes["UF"][$field_name] = $arUFMeta[$field_name];
7609 $arRes["UF"][$field_name]["VALUE"] = $arRes[$field_name];
7610 $arRes["UF"][$field_name]["ENTITY_VALUE_ID"] = $arRes["ID"];
7611 unset($arRes[$field_name]);
7612 }
7613 }
7614 }
7615 }
7616 }
7617
7618 return $arRes;
7619 }
7620
7621 return false;
7622 }
7623
7624 public static function getCommentRatingType($logEventId, $logId = false)
7625 {
7626 $res = "LOG_COMMENT";
7627
7628 $arCommentEventMeta = CSocNetLogTools::FindLogCommentEventByLogEventID($logEventId);
7629 if (
7630 $arCommentEventMeta
7631 && isset($arCommentEventMeta["RATING_TYPE_ID"])
7632 )
7633 {
7634 $res = $arCommentEventMeta["RATING_TYPE_ID"];
7635 }
7636 elseif (
7637 $logEventId === "photo_photo"
7638 && (int)$logId > 0
7639 )
7640 {
7641 $commentType = CSocNetPhotoCommentEvent::FindLogType($logId);
7642 if (
7643 $commentType
7644 && isset($commentType["TYPE"])
7645 )
7646 {
7647 if ($commentType["TYPE"] === "FORUM")
7648 {
7649 $res = "FORUM_POST";
7650 }
7651 elseif ($commentType["TYPE"] === "BLOG")
7652 {
7653 $res = "BLOG_COMMENT";
7654 }
7655 }
7656 }
7657 elseif (in_array($logEventId, array("wiki", "calendar", "news", "lists_new_element", "timeman_entry", "report")))
7658 {
7659 $res = "FORUM_POST";
7660 }
7661 elseif ($logEventId === "idea")
7662 {
7663 $res = "BLOG_COMMENT";
7664 }
7665
7666 return $res;
7667 }
7668}
$arParams
Определения access_dialog.php:21
$path
Определения access_edit.php:21
$count
Определения admin_tab.php:4
$type
Определения options.php:106
const BLOG_PERMS_MODERATE
Определения include.php:9
const BLOG_PUBLISH_STATUS_READY
Определения include.php:46
const BLOG_PERMS_DENY
Определения include.php:5
const BLOG_PERMS_WRITE
Определения include.php:8
const BLOG_PERMS_READ
Определения include.php:6
const BLOG_PERMS_FULL
Определения include.php:10
const BLOG_PERMS_PREMODERATE
Определения include.php:7
$db_res
Определения options_user_settings.php:8
if(! $messageFields||!isset($messageFields['message_id'])||!isset($messageFields['status'])||!CModule::IncludeModule("messageservice")) $messageId
Определения callback_ismscenter.php:26
global $APPLICATION
Определения include.php:80
$arResult
Определения generate_coupon.php:16
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static get($moduleId, $name, $default="", $siteId=false)
Определения option.php:30
Определения loader.php:13
static getList(array $parameters=array())
Определения datamanager.php:431
Определения emoji.php:10
static get(int $groupId, null|string|Type $groupType=null, array $parameters=[])
Определения GroupUrl.php:13
static GetByID($ID)
Определения blog.php:931
static GetPostID($postID, $code, $allowCode=false)
Определения blog_post.php:1219
static GetUserIP()
Определения blog_user.php:617
static Filter($message)
Определения filter_dictionary.php:590
static GetByID($ID, $arAddParams=array())
Определения message.php:591
static GetByID($ID)
Определения forum_new.php:1399
static Delete($ID)
Определения topic.php:413
static Add($arFields)
Определения topic.php:213
static GetByID($ID, $arAddParams=array())
Определения topic.php:431
static GetSite($log_id)
Определения log.php:1025
static Add($arFields)
Определения blog_category.php:8
static Add($arFields, $bSearchIndex=true)
Определения blog_comment.php:8
static GetList($arOrder=Array("ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения blog_comment.php:334
static GetList($arOrder=Array("ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения blog_image.php:122
static Add($arFields)
Определения blog_post.php:8
static GetByID($ID)
Определения blog_post.php:511
static GetList( $arOrder=["ID"=> "DESC"], $arFilter=[], $arGroupBy=false, $arNavStartParams=false, $arSelectFields=[])
Определения blog_post.php:554
static GetList($arOrder=Array("ID"=>"ASC"), $arFilter=Array(), $iNum=0, $arAddParams=array())
Определения message.php:884
static GetList($arOrder=Array("ID"=>"ASC"), $arFilter=Array(), $bCount=false, $iNum=0, $arAddParams=array())
Определения message.php:193
static Add($arFields, $strUploadDir=false, $arParams=array())
Определения message.php:7
static GetListEx($arOrder=Array("ID"=>"ASC"), $arFilter=Array())
Определения user.php:258
Определения iblockelement.php:9
Определения cache.php:11
static GetList($arOrder=Array("ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array(), $arParams=array())
Определения log_comments.php:519
static checkEmptyUFValue($fieldName)
Определения log_tools.php:7210
static getDateTimeFormatted($timestamp, $arFormatParams)
Определения log_tools.php:7278
OnBeforeSonetLogFilterFill(&$arPageParamsToClear, &$arItemsTop, &$arItems)
Определения log_tools.php:6588
static redirectExtranetSite($arRedirectSite, $componentPage, $arVariables, $arDefaultUrlTemplates404, $entity="user")
Определения log_tools.php:7493
static ConvertPresetToFilters(array $arPreset, ?int $groupId)
Определения log_tools.php:6593
static OnSonetLogFilterProcess($preset_filter_top_id, $preset_filter_id, $arResultPresetFiltersTop, $arResultPresetFilters)
Определения log_tools.php:6821
static getCommentRights($arParams)
Определения log_tools.php:7283
static saveRawFilesToUF($arAttachedFilesRaw, $ufCode, &$arFields)
Определения log_tools.php:6931
static processDateTimeFormatParams(&$arParams=array())
Определения log_tools.php:7240
static saveFileToUF($arFile=array(), &$type=null, $userId=false)
Определения log_tools.php:7017
static canUserChangeComment($arParams)
Определения log_tools.php:7393
__construct($params)
Определения log_tools.php:6583
static GetSiteByDepartmentId($arDepartmentId)
Определения log_tools.php:6876
static getCommentByRequest($commentId, $postId, $action=false, $checkPerms=true, $checkAdminSession=true)
Определения log_tools.php:7520
static getCommentRatingType($logEventId, $logId=false)
Определения log_tools.php:7624
static isSetTrafficNeeded($arParams)
Определения log_tools.php:7223
static getExtranetRedirectSite($extranetSiteId)
Определения log_tools.php:7449
static GetList($arOrder=Array("ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array(), $arParams=array())
Определения log.php:338
static Update($ID, $arFields)
Определения log.php:151
static GetList($aSort=array(), $aFilter=array())
Определения log_rights.php:256
Определения log_tools.php:14
static FormatComment_Blog($arFields, $arParams, $bMail=false, $arLog=array())
Определения log_tools.php:908
static FormatEvent_GetCreatedBy($arFields, $arParams, $bMail, $bFirstCaps=false)
Определения log_tools.php:534
static AddComment_Review_CheckIBlock($arElement)
Определения log_tools.php:4049
static FormatEvent_PhotoPhoto($arFields, $arParams, $bMail=false)
Определения log_tools.php:1878
static GetDataFromRatingEntity($rating_entity_type_id, $rating_entity_id, $bCheckRights=true)
Определения log_tools.php:5391
static FormatEvent_Task2($arFields, $arParams)
Определения log_tools.php:2475
static AddComment_Review_CreateRoot_Blog($arElement, $blogID)
Определения log_tools.php:4269
static FormatEvent_GetURL($arFields, $bAbsolute=false)
Определения log_tools.php:661
static AddComment_Review_UpdateElement_Blog($arElement, $postID, $blogID, $bNewPost)
Определения log_tools.php:4335
static FormatComment_Files($arFields, $arParams, $bMail=false, $arLog=array())
Определения log_tools.php:2330
static AddComment_Forum($arFields)
Определения log_tools.php:3170
static FormatEvent_System($arFields, $arParams, $bMail=false)
Определения log_tools.php:2842
static OnAfterSectionDrop($ID, $arFields, $arComponentParams, $arComponentResult)
Определения log_tools.php:4379
static FindLogEventByCommentID($event_id)
Определения log_tools.php:174
static FindFeatureByEventID($event_id)
Определения log_tools.php:15
static FormatEvent_Files($arFields, $arParams, $bMail=false)
Определения log_tools.php:2200
static OnAfterPhotoDrop($arFields, $arComponentParams)
Определения log_tools.php:4369
static FormatComment_PhotoAlbum($arFields, $arParams, $bMail=false, $arLog=array())
Определения log_tools.php:2121
static AddComment_Photo_Forum($arFields, $FORUM_ID, $arLog)
Определения log_tools.php:5605
static AddComment_Review_CreateRoot($arElement, $forumID, $bPostFirstMessage=false, $strFirstMessage="")
Определения log_tools.php:4164
static AddComment_Photo_Blog($arFields, $BLOG_ID, $arLog)
Определения log_tools.php:5610
static logUFfileShow($arResult, $arParams)
Определения log_tools.php:5615
static AddComment_Review_CreateRoot_Forum($arElement, $forumID, $bPostFirstMessage=false, $strFirstMessage="")
Определения log_tools.php:4169
static FormatComment_Forum($arFields, $arParams, $bMail=false, $arLog=array())
Определения log_tools.php:1446
static FormatEvent_GetEntity($arFields, $arParams, $bMail)
Определения log_tools.php:586
static AddComment_Review_CheckIBlock_Blog($arElement)
Определения log_tools.php:4109
static ShowSourceType($source_type=false, $bMobile=false)
Определения log_tools.php:5375
static SetUserCache( $type="log", $user_id=null, $max_id=null, $max_viewed_id=null, $count=null, $bSetViewTime=false, $LastViewTS=0)
Определения log_tools.php:3123
static OnAfterPhotoUpload($arFields, $arComponentParams, $arComponentResult)
Определения log_tools.php:4364
static AddComment_Review_UpdateElement_Forum($arElement, $topicID, $bNewTopic)
Определения log_tools.php:4320
static AddComment_Blog($arFields)
Определения log_tools.php:3631
static OnAfterSectionEdit($arFields, $arComponentParams, $arComponentResult)
Определения log_tools.php:4384
static SetUFRights($files, $rights)
Определения log_tools.php:5673
static GetForumCommentMetaData($logEventId)
Определения log_tools.php:5846
static FormatEvent_SystemGroups($arFields, $arParams, $bMail=false)
Определения log_tools.php:2485
static FindFullSetEventIDByEventID($event_id)
Определения log_tools.php:274
static AddComment_Review_CheckIBlock_Forum($arElement)
Определения log_tools.php:4054
static CanEditComment_Task($arParams)
Определения log_tools.php:6249
static GetAvailableGroups($isExtranetUser=false, $isExtranetSite=false)
Определения log_tools.php:5764
static FindLogCommentEventByID($event_id)
Определения log_tools.php:95
static GetSiteData()
Определения log_tools.php:5346
static FindLogCommentEventByLogEventID($log_event_id)
Определения log_tools.php:142
static FormatEvent_Blog($arFields, $arParams, $bMail=false)
Определения log_tools.php:727
static ShowGroup($arEntityDesc, $strEntityURL, $arParams)
Определения log_tools.php:320
static SetCacheLastLogID($type="log", $id=0)
Определения log_tools.php:3102
static UpdateComment_Task($arFields)
Определения log_tools.php:6074
static UpdateComment_Forum($arFields)
Определения log_tools.php:3397
static GetDestinationFromRights($arRights, $arParams)
Определения log_tools.php:5151
static DeleteComment_Task($arFields)
Определения log_tools.php:6200
static FormatDestinationFromRights($arRights, $arParams, &$iMoreCount=false)
Определения log_tools.php:4389
static FormatEvent_Microblog($arFields, $arParams, $bMail=false)
Определения log_tools.php:1034
static AddComment_Files($arFields)
Определения log_tools.php:3927
static FormatEvent_CreateAvatar($arFields, $arParams, $source="CREATED_BY_", $site_id=SITE_ID)
Определения log_tools.php:418
static AddComment_Photo($arFields)
Определения log_tools.php:5600
static AddComment_Review_UpdateElement($arElement, $topicID, $bNewTopic)
Определения log_tools.php:4315
static ShowUser($arEntityDesc, $strEntityURL, $arParams)
Определения log_tools.php:330
static GetCommentUrl_Task($arFields)
Определения log_tools.php:6045
static GetUserCache($type="log", $user_id=0)
Определения log_tools.php:3152
static FormatComment_Photo($arFields, $arParams, $bMail=false, $arLog=array())
Определения log_tools.php:1978
static GetCacheLastLogID($type="log")
Определения log_tools.php:3112
static FormatEvent_Forum($arFields, $arParams, $bMail=false)
Определения log_tools.php:1224
static FormatEvent_Photo($arFields, $arParams, $bMail=false)
Определения log_tools.php:1675
static ProcessPath($arUrl, $user_id, $explicit_site_id=false)
Определения log_tools.php:5283
static FormatEvent_IsMessageShort($message, $short_message=false)
Определения log_tools.php:514
static FormatComment_Microblog($arFields, $arParams, $bMail=false, $arLog=array())
Определения log_tools.php:1136
static FindLogEventByID($event_id, $entity_type=false)
Определения log_tools.php:51
static getResizedAvatarUrl(array $params=[])
Определения log_tools.php:6321
static OnBeforeSectionDrop($sectionID, $arComponentParams, $arComponentResult, &$arSectionID, &$arElementID)
Определения log_tools.php:4374
static FormatEvent_FillTooltip($arFields, $arParams)
Определения log_tools.php:394
static AddComment_Microblog($arFields)
Определения log_tools.php:3779
static FormatEvent_CreateAvatarGroup($arFields, $arParams)
Определения log_tools.php:482
static AddComment_Tasks($arFields)
Определения log_tools.php:5876
static FormatEvent_Task($arFields, $arParams, $bMail=false)
Определения log_tools.php:2412
static DeleteComment_Forum($arFields)
Определения log_tools.php:3484
static CanEditOwnComment_Task($arParams)
Определения log_tools.php:6285
static FindFullSetByEventID($event_id)
Определения log_tools.php:223
static HasLogEventCreatedBy($event_id)
Определения log_tools.php:367
static FormatEvent_SystemFriends($arFields, $arParams, $bMail=false)
Определения log_tools.php:2662
static OnAfterSectionDrop($ID, $arFields, $arComponentParams, $arComponentResult)
Определения log_tools_photo.php:446
static OnAfterPhotoDrop($arFields, $arComponentParams)
Определения log_tools_photo.php:288
static OnAfterPhotoUpload($arFields, $arComponentParams, $arComponentResult)
Определения log_tools_photo.php:9
static OnAfterSectionEdit($arFields, $arComponentParams, $arComponentResult)
Определения log_tools_photo.php:526
static OnBeforeSectionDrop($sectionID, $arComponentParams, $arComponentResult, &$arSectionID, &$arElementID)
Определения log_tools_photo.php:396
static AddComment_Photo_Forum($arFields, $FORUM_ID, $arLog)
Определения log_tools_photo.php:919
static AddComment_Photo_Blog($arFields, $BLOG_ID, $arLog)
Определения log_tools_photo.php:1032
static FindLogType($logID)
Определения log_tools_photo.php:813
static AddComment_Photo($arFields)
Определения log_tools_photo.php:876
Определения textparser.php:21
convertText($text, $attributes=[])
Определения textparser.php:213
$allow
Определения textparser.php:40
$pathToSmile
Определения textparser.php:110
Определения user.php:6037
Определения functions.php:6
Определения functions.php:18
Определения log_tools.php:6352
pre_convert_code_tag($text="")
Определения log_tools.php:6513
$MaxStringLen
Определения log_tools.php:6356
convert_image_tag($url="", $params="")
Определения log_tools.php:6502
convert_anchor_tag($url, $text, $attributes=[])
Определения log_tools.php:6494
convert_quote_tag($text="")
Определения log_tools.php:6538
sonet_sortlen($a, $b)
Определения log_tools.php:6358
convert($text, $arImages=array(), $allow=array("HTML"=> "N", "ANCHOR"=> "Y", "BIU"=> "Y", "IMG"=> "Y", "QUOTE"=> "Y", "CODE"=> "Y", "FONT"=> "Y", "LIST"=> "Y", "SMILES"=> "Y", "NL2BR"=> "N", "VIDEO"=> "Y", "TABLE"=> "Y", "CUT_ANCHOR"=> "N", "SHORT_ANCHOR"=> "N"), $arParams=Array())
Определения log_tools.php:6376
$matchNum
Определения log_tools.php:6353
convert_code_tag($text="")
Определения log_tools.php:6526
__construct($strLang=False, $pathToSmile=false)
Определения log_tools.php:6366
convert_video($params)
Определения log_tools.php:6568
$matchNum2
Определения log_tools.php:6354
convert_font_attr($attr, $value="", $text="")
Определения log_tools.php:6554
global $CACHE_MANAGER
Определения clear_component_cache.php:7
$right
Определения options.php:8
$options
Определения commerceml2.php:49
if(!is_array($prop["VALUES"])) $tmp
Определения component_props.php:203
$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
$fileContent
Определения file_property.php:47
$rsSites
Определения options.php:477
$res
Определения filter_act.php:7
ForumClearComponentCache($components)
Определения include.php:1763
ForumActions($action, $arFields, &$strErrorMessage, &$strOKMessage)
Определения include.php:1592
ForumAddMessage( $MESSAGE_TYPE, $FID, $TID, $MID, $arFieldsG, &$strErrorMessage, &$strOKMessage, $iFileSize=false, $captcha_word="", $captcha_sid=0, $captcha_code="")
Определения include.php:317
global $USER_FIELD_MANAGER
Определения attempt.php:6
$result
Определения get_property_values.php:14
$bFound
Определения get_search.php:40
if($ajaxMode) $ID
Определения get_user.php:27
$entity
$dbMessage
Определения group_wiki_post_comment.php:12
$protocol
Определения .description.php:9
$iblockId
Определения iblock_catalog_edit.php:30
$select
Определения iblock_catalog_list.php:194
const IM_MESSAGE_SYSTEM
Определения include.php:21
const IM_NOTIFY_FROM
Определения include.php:37
$strError
Определения options_user_settings.php:4
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $DB
Определения cron_frame.php:29
$siteID
Определения cron_frame.php:12
global $USER
Определения csv_new_run.php:40
endif
Определения csv_new_setup.php:990
const BX_RESIZE_IMAGE_EXACT
Определения constants.php:12
const FORMAT_DATETIME
Определения include.php:64
$arTasks
Определения options.php:777
$arCodes
Определения options.php:154
CheckDirPath($path)
Определения tools.php:2707
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения tools.php:5214
htmlspecialcharsback($str)
Определения tools.php:2693
htmlspecialcharsEx($str)
Определения tools.php:2685
HTMLToTxt($str, $strSiteUrl="", $aDelete=[], $maxlen=70)
Определения tools.php:2587
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
Определения tools.php:5177
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
BXClearCache($full=false, $initdir='')
Определения tools.php:5150
randString($pass_len=10, $pass_chars=false)
Определения tools.php:2154
LocalRedirect($url, $skip_security_check=false, $status="302 Found")
Определения tools.php:4005
TruncateText($strText, $intLen)
Определения tools.php:2185
$name
Определения menu_edit.php:35
$entityId
Определения payment.php:4
$message
Определения payment.php:8
if(intval($iTestTransaction) > 0) $arTmp
Определения payment.php:22
$arFiles
Определения options.php:60
return false
Определения prolog_main_admin.php:185
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$fileName
Определения quickway.php:305
if(empty($signedUserToken)) $key
Определения quickway.php:257
if(empty($decryptedData)) $storage
Определения quickway.php:270
$text
Определения template_pdf.php:79
$i
Определения factura.php:643
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
else $a
Определения template.php:137
$title
Определения pdf.php:123
$strErrorMessage
Определения action.php:25
$matches
Определения index.php:22
const SONET_ROLES_USER
Определения include.php:31
const SONET_SUBSCRIBE_ENTITY_USER
Определения include.php:121
const SONET_ENTITY_GROUP
Определения include.php:117
const SONET_SUBSCRIBE_ENTITY_GROUP
Определения include.php:120
const SONET_ENTITY_USER
Определения include.php:118
const SONET_ROLES_MODERATOR
Определения include.php:30
const SONET_ROLES_OWNER
Определения include.php:29
if( $_SERVER $arSocNetFeaturesSettings['REQUEST_METHOD']=="GET" &&($RestoreDefaults ?? null)<> '' && $SONET_RIGHT=="W" &&check_bitrix_sessid())
Определения options.php:35
$arRes
Определения options.php:104
$site_id
Определения sonet_set_content_view.php:9
const SITE_ID
Определения sonet_set_content_view.php:12
$error
Определения subscription_card_product.php:20
$k
Определения template_pdf.php:567
$action
Определения file_dialog.php:21
$GLOBALS['_____370096793']
Определения update_client.php:1
$dbResult
Определения updtr957.php:3
$arFilter
Определения user_search.php:106
$rights
Определения options.php:4
$url
Определения iframe.php:7
$dbRes
Определения yandex_detail.php:168