1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
log_tools_photo.php
См. документацию.
1<?
2
4
6
8{
9 public static function OnAfterPhotoUpload($arFields, $arComponentParams, $arComponentResult)
10 {
11 global $USER, $DB;
12
13 static $arSiteWorkgroupsPage;
14
15 if (!CModule::IncludeModule("iblock"))
16 {
17 return;
18 }
19
20 if (
21 !array_key_exists("IS_SOCNET", $arComponentParams)
22 || $arComponentParams["IS_SOCNET"] != "Y"
23 )
24 {
25 return;
26 }
27
28 $bPassword = false;
29 $arComponentResult["SECTION"]["PATH"] = array();
30
31 $rsSectionAlbum = CIBlockSection::GetList(
32 array(),
33 array(
34 "ID" => intval($arFields["IBLOCK_SECTION"])
35 ),
36 false,
37 array("ID", "LEFT_MARGIN", "RIGHT_MARGIN", "DEPTH_LEVEL")
38 );
39
40 if ($arSectionAlbum = $rsSectionAlbum->Fetch())
41 {
42 $dbSection = CIBlockSection::GetList(
43 array("LEFT_MARGIN" => "ASC"),
44 array(
45 "IBLOCK_ID" => intval($arComponentParams["IBLOCK_ID"]),
46 "<=LEFT_BORDER" => intval($arSectionAlbum["LEFT_MARGIN"]),
47 ">=RIGHT_BORDER" => intval($arSectionAlbum["RIGHT_MARGIN"]),
48 "<=DEPTH_LEVEL" => intval($arSectionAlbum["DEPTH_LEVEL"]),
49 ),
50 false,
51 array("ID", "IBLOCK_ID", "NAME", "CREATED_BY", "DEPTH_LEVEL", "LEFT_MARGIN", "RIGHT_MARGIN", "UF_PASSWORD")
52 );
53
54 while ($arPath = $dbSection->Fetch())
55 {
56 $arComponentResult["SECTION"]["PATH"][] = $arPath;
57 }
58 }
59
60 foreach($arComponentResult["SECTION"]["PATH"] as $arPathSection)
61 {
62 if (trim($arPathSection["UF_PASSWORD"] ?? '') <> '')
63 {
64 $bPassword = true;
65 break;
66 }
67 }
68
69 if (
70 array_key_exists("USER_ALIAS", $arComponentParams)
71 && $arComponentParams["USER_ALIAS"] <> ''
72 )
73 {
74 $arTmp = explode("_", $arComponentParams["USER_ALIAS"]);
75 if (
76 is_array($arTmp)
77 && count($arTmp) == 2
78 )
79 {
80 $entity_type = $arTmp[0];
81 $entity_id = $arTmp[1];
82
83 if ($entity_type == "group")
84 $entity_type = SONET_ENTITY_GROUP;
85 elseif ($entity_type == "user")
86 $entity_type = SONET_ENTITY_USER;
87 }
88
89 if (
90 (
91 !in_array($entity_type, array(SONET_ENTITY_GROUP, SONET_ENTITY_USER))
92 || intval($entity_id) <= 0
93 )
94 && count($arComponentResult["SECTION"]["PATH"]) > 0
95 )
96 {
97 $entity_type = SONET_ENTITY_USER;
98 $entity_id = $arComponentResult["SECTION"]["PATH"][0]["CREATED_BY"];
99 }
100 }
101
102 if (
103 !in_array($entity_type, array(SONET_ENTITY_GROUP, SONET_ENTITY_USER))
104 || intval($entity_id) <= 0
105 )
106 return;
107
108 if (!$arSiteWorkgroupsPage && IsModuleInstalled("extranet") && $entity_type == SONET_ENTITY_GROUP)
109 {
110 $rsSite = CSite::GetList("sort", "desc", Array("ACTIVE" => "Y"));
111 while($arSite = $rsSite->Fetch())
112 $arSiteWorkgroupsPage[$arSite["ID"]] = COption::GetOptionString("socialnetwork", "workgroups_page", $arSite["DIR"]."workgroups/", $arSite["ID"]);
113 }
114
115 if (is_set($arComponentParams["DETAIL_URL"]) && is_array($arSiteWorkgroupsPage) && $entity_type == SONET_ENTITY_GROUP)
116 foreach($arSiteWorkgroupsPage as $groups_page)
117 if (mb_strpos($arComponentParams["DETAIL_URL"], $groups_page) === 0)
118 $arComponentParams["DETAIL_URL"] = "#GROUPS_PATH#".mb_substr($arComponentParams["DETAIL_URL"], mb_strlen($groups_page), mb_strlen($arComponentParams["DETAIL_URL"]) - mb_strlen($groups_page));
119
121 array(),
122 array(
123 "ENTITY_TYPE" => $entity_type,
124 "ENTITY_ID" => $entity_id,
125 "EVENT_ID" => "photo",
126 "EXTERNAL_ID" => $arFields["IBLOCK_SECTION"]."_".$arFields["MODIFIED_BY"],
127 ">=LOG_UPDATE" => ConvertTimeStamp(AddToTimeStamp(array("MI" => -30))+CTimeZone::GetOffset(), "FULL")
128 )
129 );
130
131 if (
132 array_key_exists("SECTION", $arComponentResult)
133 && array_key_exists("NAME", $arComponentResult["SECTION"])
134 )
135 $strSectionName = $arComponentResult["SECTION"]["NAME"];
136 else
137 $strSectionName = $arComponentResult["SECTION"]["PATH"][count($arComponentResult["SECTION"]["PATH"])-1]["NAME"] ?? '';
138
139 if (
140 array_key_exists("URL", $arComponentResult)
141 && array_key_exists("SECTION_EMPTY", $arComponentResult["URL"])
142 )
143 $strSectionUrl = $arComponentResult["URL"]["SECTION_EMPTY"];
144 else
145 $strSectionUrl = $arComponentResult["SECTION_URL"] ?? '';
146
147 $strSectionUrl = str_replace(
148 array("#SECTION_ID#", "#section_id#"),
149 $arFields["IBLOCK_SECTION"],
150 $strSectionUrl
151 );
152
153 if ($db_res && $res = $db_res->Fetch())
154 {
155 if ($res["PARAMS"] <> '')
156 {
157 $arResParams = unserialize($res["PARAMS"], [ 'allowed_classes' => false ]);
158 array_push($arResParams["arItems"], $arFields["ID"]);
159 }
160 else
161 return;
162
163 $arLogParams = array(
164 "COUNT" => $arResParams["COUNT"]+1,
165 "IBLOCK_TYPE" => $arComponentParams["IBLOCK_TYPE"],
166 "IBLOCK_ID" => $arComponentParams["IBLOCK_ID"],
167 "ALIAS" => $arComponentParams["USER_ALIAS"],
168 "DETAIL_URL" => $arResParams["DETAIL_URL"],
169 "arItems" => $arResParams["arItems"]
170 );
171
172 $arSonetFields = array(
173 "=LOG_UPDATE" => $DB->CurrentTimeFunction(),
174 "PARAMS" => serialize($arLogParams)
175 );
176
177 CSocNetLog::Update($res["ID"], $arSonetFields);
178 if (!$bPassword)
179 {
180 CSocNetLogRights::SetForSonet($res["ID"], $entity_type, $entity_id, "photo", "view");
181 }
182
183 $logID = $res["ID"];
184 }
185 else
186 {
187 $arLogParams = array(
188 "COUNT" => 1,
189 "IBLOCK_TYPE" => $arComponentParams["IBLOCK_TYPE"],
190 "IBLOCK_ID" => $arComponentParams["IBLOCK_ID"],
191 "DETAIL_URL" => $arComponentParams["DETAIL_URL"],
192 "ALIAS" => $arComponentParams["USER_ALIAS"],
193 "arItems" => array($arFields["ID"])
194 );
195
196 $sAuthorName = GetMessage("SONET_PHOTO_LOG_GUEST");
197 if ($USER->IsAuthorized())
198 {
199 $sAuthorName = trim($USER->GetFullName());
200 $sAuthorName = (empty($sAuthorName) ? $USER->GetLogin() : $sAuthorName);
201 }
202
203 $arSonetFields = array(
204 "ENTITY_TYPE" => $entity_type,
205 "ENTITY_ID" => $entity_id,
206 "EVENT_ID" => "photo",
207 "=LOG_DATE" => $DB->CurrentTimeFunction(),
208 "TITLE_TEMPLATE" => str_replace("#AUTHOR_NAME#", $sAuthorName, GetMessage("SONET_PHOTO_LOG_1")),
209 "TITLE" => str_replace("#COUNT#", "1", GetMessage("SONET_PHOTO_LOG_2")),
210 "MESSAGE" => "",
211 "URL" => $strSectionUrl,
212 "MODULE_ID" => false,
213 "CALLBACK_FUNC" => false,
214 "EXTERNAL_ID" => $arFields["IBLOCK_SECTION"]."_".$arFields["MODIFIED_BY"],
215 "PARAMS" => serialize($arLogParams),
216 "SOURCE_ID" => $arFields["IBLOCK_SECTION"]
217 );
218
219 $arSonetFields["TEXT_MESSAGE"] = str_replace(array("#TITLE#"),
220 array($strSectionName),
221 GetMessage("SONET_PHOTO_LOG_MAIL_TEXT"));
222
223 if ($USER->IsAuthorized())
224 $arSonetFields["USER_ID"] = $USER->GetID();
225
226 $logID = CSocNetLog::Add($arSonetFields, false);
227 if (intval($logID) > 0)
228 {
229 $randomGenerator = new \Bitrix\Main\Type\RandomSequence('IBLOCK_SECTION' . $logID);
230
232 "TMP_ID" => $logID,
233 "RATING_TYPE_ID" => "IBLOCK_SECTION",
234 "RATING_ENTITY_ID" => $randomGenerator->rand(1, 2147483647)
235 ));
236
237 if ($bPassword)
238 {
240 CSocNetLogRights::Add($logID, array("U".$USER->GetID(), "SA"));
241 }
242 else
243 {
244 CSocNetLogRights::SetForSonet($logID, $entity_type, $entity_id, "photo", "view", true);
245 }
246
248 }
249 }
250
251 if ($entity_type == SONET_ENTITY_GROUP)
252 {
253 $dbRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $logID));
254 while ($arRight = $dbRight->Fetch())
255 {
256 if ($arRight["GROUP_CODE"] == "SG".$entity_id."_".SONET_ROLES_USER)
257 {
258 $title_tmp = str_replace(Array("\r\n", "\n"), " ", $strSectionName);
259 $title = TruncateText($title_tmp, 100);
260 $title_out = TruncateText($title_tmp, 255);
261
262 $arNotifyParams = array(
263 "LOG_ID" => $logID,
264 "GROUP_ID" => array($entity_id),
265 "NOTIFY_MESSAGE" => "",
266 "FROM_USER_ID" => $arFields["MODIFIED_BY"],
267 "URL" => $strSectionUrl,
268 "MESSAGE" => fn (?string $languageId = null) => Loc::getMessage(
269 "SONET_IM_NEW_PHOTO",
270 Array("#title#" => "<a href=\"#URL#\" class=\"bx-notifier-item-action\">".$title."</a>",),
271 $languageId
272 ),
273 "MESSAGE_OUT" => fn (?string $languageId = null) => Loc::getMessage(
274 "SONET_IM_NEW_PHOTO",
275 Array("#title#" => $title_out),
276 $languageId
277 ) ." (#URL#)",
278 "EXCLUDE_USERS" => array($arFields["MODIFIED_BY"])
279 );
280
281 CSocNetSubscription::NotifyGroup($arNotifyParams);
282 break;
283 }
284 }
285 }
286 }
287
288 public static function OnAfterPhotoDrop($arFields, $arComponentParams)
289 {
290 if (
291 array_key_exists("IS_SOCNET", $arComponentParams)
292 && $arComponentParams["IS_SOCNET"] == "Y"
293 && array_key_exists("USER_ALIAS", $arComponentParams)
294 && $arComponentParams["USER_ALIAS"] <> ''
295 )
296 {
297 $arTmp = explode("_", $arComponentParams["USER_ALIAS"]);
298 if (
299 is_array($arTmp)
300 && count($arTmp) == 2
301 )
302 {
303 $entity_type = $arTmp[0];
304 $entity_id = $arTmp[1];
305
306 if ($entity_type == "group")
307 $entity_type = SONET_ENTITY_GROUP;
308 elseif ($entity_type == "user")
309 $entity_type = SONET_ENTITY_USER;
310 }
311
312 if (
313 (
314 !in_array($entity_type, array(SONET_ENTITY_GROUP, SONET_ENTITY_USER))
315 || intval($entity_id) <= 0
316 )
317 && intval($arFields["SECTION_ID"]) > 0
318 )
319 {
320 $rsPath = CIBlockSection::GetNavChain(intval($arFields["IBLOCK_ID"]), $arFields["SECTION_ID"]);
321 if($arPath = $rsPath->Fetch())
322 {
323 $entity_type = SONET_ENTITY_USER;
324 $entity_id = $arPath["CREATED_BY"];
325 }
326 }
327
328 if (
329 !in_array($entity_type, array(SONET_ENTITY_GROUP, SONET_ENTITY_USER))
330 || intval($entity_id) <= 0
331 )
332 return;
333 }
334 else
335 return;
336
338 array(),
339 array(
340 "ENTITY_TYPE" => $entity_type,
341 "ENTITY_ID" => $entity_id,
342 "EVENT_ID" => "photo",
343 "SOURCE_ID" => $arFields["SECTION_ID"]
344 )
345 );
346 while ($db_res && $res = $db_res->Fetch())
347 {
348 if ($res["PARAMS"] <> '')
349 {
350 $arResParams = unserialize($res["PARAMS"], [ 'allowed_classes' => false ]);
351 }
352 else
353 {
354 continue;
355 }
356
357 if (is_array($arResParams) && in_array($arFields["ID"], $arResParams["arItems"]))
358 {
359 $arResParams["arItems"] = array_diff($arResParams["arItems"], array($arFields["ID"]));
360 }
361 else
362 {
363 continue;
364 }
365
366 if (count($arResParams["arItems"]) <= 0)
367 {
369 }
370 else
371 {
372 $arResParams["COUNT"]--;
373 $arSonetFields = array(
374 "PARAMS" => serialize($arResParams),
375 "LOG_UPDATE" => $res["LOG_UPDATE"]
376 );
377
378 CSocNetLog::Update($res["ID"], $arSonetFields);
379// CSocNetLogRights::SetForSonet($res["ID"], $entity_type, $entity_id, "photo", "view");
380 }
381 }
382
384 array(),
385 array(
386 "ENTITY_TYPE" => $entity_type,
387 "ENTITY_ID" => $entity_id,
388 "EVENT_ID" => "photo_photo",
389 "SOURCE_ID" => $arFields["ID"]
390 )
391 );
392 while ($db_res && $res = $db_res->Fetch())
394 }
395
396 public static function OnBeforeSectionDrop($sectionID, $arComponentParams, $arComponentResult, &$arSectionID, &$arElementID)
397 {
398 if (!CModule::IncludeModule("iblock"))
399 return;
400
401 if (
402 array_key_exists("IS_SOCNET", $arComponentParams)
403 && $arComponentParams["IS_SOCNET"] == "Y"
404 && array_key_exists("USER_ALIAS", $arComponentParams)
405 && $arComponentParams["USER_ALIAS"] <> ''
406 && array_key_exists("IBLOCK_ID", $arComponentParams)
407 )
408 {
409 $dbElement = CIBlockElement::GetList(
410 array(),
411 array(
412 "IBLOCK_ID" => $arComponentParams["IBLOCK_ID"],
413 "SECTION_ID" => $sectionID,
414 "INCLUDE_SUBSECTIONS" => "Y"
415 ),
416 false,
417 false,
418 array("ID")
419 );
420
421 $arElementID = array();
422 while ($arElement = $dbElement->Fetch())
423 $arElementID[] = $arElement["ID"];
424
425 $dbSection = CIBlockSection::GetList(
426 array("BS.LEFT_MARGIN" => "ASC"),
427 array(
428 "IBLOCK_ID" => $arComponentParams["IBLOCK_ID"],
429 ">=LEFT_MARGIN" => $arComponentResult["SECTION"]["LEFT_MARGIN"],
430 "<=RIGHT_MARGIN" => $arComponentResult["SECTION"]["RIGHT_MARGIN"],
431 ),
432 false,
433 array("ID")
434 );
435
436 $arSectionID = array();
437 while ($arSection = $dbSection->Fetch())
438 $arSectionID[] = $arSection["ID"];
439 }
440 else
441 {
442 return;
443 }
444 }
445
446 public static function OnAfterSectionDrop($ID, $arFields, $arComponentParams, $arComponentResult)
447 {
448 if (
449 array_key_exists("IS_SOCNET", $arComponentParams)
450 && $arComponentParams["IS_SOCNET"] == "Y"
451 && array_key_exists("USER_ALIAS", $arComponentParams)
452 && $arComponentParams["USER_ALIAS"] <> ''
453 )
454 {
455 $arTmp = explode("_", $arComponentParams["USER_ALIAS"]);
456 if (
457 is_array($arTmp)
458 && count($arTmp) == 2
459 )
460 {
461 $entity_type = $arTmp[0];
462 $entity_id = $arTmp[1];
463
464 if ($entity_type == "group")
465 $entity_type = SONET_ENTITY_GROUP;
466 elseif ($entity_type == "user")
467 $entity_type = SONET_ENTITY_USER;
468 }
469
470 if (
471 !in_array($entity_type, array(SONET_ENTITY_GROUP, SONET_ENTITY_USER))
472 || intval($entity_id) <= 0
473 )
474 {
475 $entity_type = SONET_ENTITY_USER;
476 $entity_id = $arComponentResult["GALLERY"]["CREATED_BY"];
477 }
478
479 if (
480 !in_array($entity_type, array(SONET_ENTITY_GROUP, SONET_ENTITY_USER))
481 || intval($entity_id) <= 0
482 )
483 return;
484
485 }
486 else
487 return;
488
489 if (array_key_exists("SECTIONS_IN_TREE", $arFields))
490 {
491 foreach ($arFields["SECTIONS_IN_TREE"] as $sectionID)
492 {
494 array(),
495 array(
496 "ENTITY_TYPE" => $entity_type,
497 "ENTITY_ID" => $entity_id,
498 "EVENT_ID" => "photo",
499 "SOURCE_ID" => $sectionID
500 )
501 );
502 while ($db_res && $res = $db_res->Fetch())
504 }
505 }
506
507 if (array_key_exists("ELEMENTS_IN_TREE", $arFields))
508 {
509 foreach ($arFields["ELEMENTS_IN_TREE"] as $elementID)
510 {
512 array(),
513 array(
514 "ENTITY_TYPE" => $entity_type,
515 "ENTITY_ID" => $entity_id,
516 "EVENT_ID" => "photo_photo",
517 "SOURCE_ID" => $elementID
518 )
519 );
520 while ($db_res && $res = $db_res->Fetch())
522 }
523 }
524 }
525
526 public static function OnAfterSectionEdit($arFields, $arComponentParams, $arComponentResult)
527 {
528 if (!CModule::IncludeModule("iblock"))
529 return;
530
531 if (
532 array_key_exists("IS_SOCNET", $arComponentParams)
533 && $arComponentParams["IS_SOCNET"] == "Y"
534 && array_key_exists("USER_ALIAS", $arComponentParams)
535 && $arComponentParams["USER_ALIAS"] <> ''
536 )
537 {
538 $arTmp = explode("_", $arComponentParams["USER_ALIAS"]);
539 if (
540 is_array($arTmp)
541 && count($arTmp) == 2
542 )
543 {
544 $entity_type = $arTmp[0];
545 $entity_id = $arTmp[1];
546
547 if ($entity_type == "group")
548 $entity_type = SONET_ENTITY_GROUP;
549 elseif ($entity_type == "user")
550 $entity_type = SONET_ENTITY_USER;
551 }
552
553 if (
554 !in_array($entity_type, array(SONET_ENTITY_GROUP, SONET_ENTITY_USER))
555 || intval($entity_id) <= 0
556 )
557 {
558 $rsPath = CIBlockSection::GetNavChain(intval($arFields["IBLOCK_ID"]), $arComponentResult["SECTION"]["ID"]);
559 if($arPath = $rsPath->Fetch())
560 {
561 $entity_type = SONET_ENTITY_USER;
562 $entity_id = $arPath["CREATED_BY"];
563 }
564 }
565
566 if (
567 !in_array($entity_type, array(SONET_ENTITY_GROUP, SONET_ENTITY_USER))
568 || intval($entity_id) <= 0
569 )
570 return;
571 }
572 else
573 return;
574
575 if (
576 trim($arComponentResult["SECTION"]["PASSWORD"] ?? '') == ''
577 && $arFields["UF_PASSWORD"] <> ''
578 )
579 {
580 // hide photos
581
582 $dbSection = CIBlockSection::GetList(
583 array("BS.LEFT_MARGIN"=>"ASC"),
584 array(
585 "IBLOCK_ID" => $arFields["IBLOCK_ID"],
586 ">=LEFT_MARGIN" => $arComponentResult["SECTION"]["LEFT_MARGIN"],
587 "<=RIGHT_MARGIN" => $arComponentResult["SECTION"]["RIGHT_MARGIN"],
588 ),
589 false,
590 array("ID", "CREATED_BY")
591 );
592
593 while ($arSection = $dbSection->Fetch())
594 {
596 array(),
597 array(
598 "ENTITY_TYPE" => $entity_type,
599 "ENTITY_ID" => $entity_id,
600 "EVENT_ID" => "photo",
601 "SOURCE_ID" => $arSection["ID"]
602 )
603 );
604 while ($db_res && $res = $db_res->Fetch())
605 {
607 CSocNetLogRights::Add($res["ID"], array("U".$arSection["CREATED_BY"], "SA"));
608 }
609 }
610
611 $dbElement = CIBlockElement::GetList(
612 array(),
613 array(
614 "IBLOCK_ID" => $arFields["IBLOCK_ID"],
615 "SECTION_ID" => $arComponentResult["SECTION"]["ID"],
616 "INCLUDE_SUBSECTIONS" => "Y"
617 ),
618 false,
619 false,
620 array("ID", "CREATED_BY")
621 );
622
623 while ($arElement = $dbElement->Fetch())
624 {
626 array(),
627 array(
628 "EVENT_ID" => "photo_photo",
629 "SOURCE_ID" => $arElement["ID"]
630 )
631 );
632 while ($db_res && $res = $db_res->Fetch())
633 {
635 CSocNetLogRights::Add($res["ID"], array("U".$arElement["CREATED_BY"], "SA"));
636 }
637 }
638 }
639 elseif (
640 trim($arComponentResult["SECTION"]["PASSWORD"] ?? '') <> ''
641 && $arFields["UF_PASSWORD"] == ''
642 )
643 {
644 // show photos
645
646 $dbSection = CIBlockSection::GetList(
647 array("BS.LEFT_MARGIN"=>"ASC"),
648 array(
649 "IBLOCK_ID" => $arFields["IBLOCK_ID"],
650 ">=LEFT_MARGIN" => $arComponentResult["SECTION"]["LEFT_MARGIN"],
651 "<=RIGHT_MARGIN" => $arComponentResult["SECTION"]["RIGHT_MARGIN"],
652 ),
653 false,
654 array("ID", "CREATED_BY")
655 );
656
657 while ($arSection = $dbSection->Fetch())
658 {
660 array(),
661 array(
662 "ENTITY_TYPE" => $entity_type,
663 "ENTITY_ID" => $entity_id,
664 "EVENT_ID" => "photo",
665 "SOURCE_ID" => $arSection["ID"]
666 )
667 );
668 while ($db_res && $res = $db_res->Fetch())
669 {
671 CSocNetLogRights::SetForSonet($res["ID"], $entity_type, $entity_id, "photo", "view");
672 }
673 }
674
675 $dbElement = CIBlockElement::GetList(
676 array(),
677 array(
678 "IBLOCK_ID" => $arFields["IBLOCK_ID"],
679 "SECTION_ID" => $arComponentResult["SECTION"]["ID"],
680 "INCLUDE_SUBSECTIONS" => "Y"
681 ),
682 false,
683 false,
684 array("ID", "CREATED_BY")
685 );
686
687 while ($arElement = $dbElement->Fetch())
688 {
690 array(),
691 array(
692 "EVENT_ID" => "photo_photo",
693 "SOURCE_ID" => $arElement["ID"]
694 )
695 );
696 while ($db_res && $res = $db_res->Fetch())
697 {
699 CSocNetLogRights::SetForSonet($res["ID"], $entity_type, $entity_id, "photo", "view");
700 }
701 }
702 }
703 else
704 {
705 return;
706 }
707 }
708}
709
711{
712 public $IsSocnet = false;
713 public $arPath = [];
714 public $ForumID = '';
715
716 public $bIsGroup = false;
717 public $entity_type = false;
718 public $entity_id = false;
719
721 {
722 global $USER;
723
725 array(),
726 array(
727 "EVENT_ID" => array("photo"),
728 "ID" => $arFields["LOG_ID"]
729 ),
730 false,
731 false,
732 array("ID", "SOURCE_ID", "USER_ID", "TITLE", "URL", "PARAMS")
733 );
734
735 $arLog = $dbResult->Fetch();
736 if (!$arLog)
737 $sError = GetMessage("SONET_PHOTO_ADD_COMMENT_SOURCE_ERROR");
738
739 if (
740 !$sError
741 && intval($arLog["USER_ID"]) > 0
742 && intval($arLog["SOURCE_ID"]) > 0
743 && $arLog["USER_ID"] != $USER->GetID()
744 && CModule::IncludeModule("im")
745 && CModule::IncludeModule("iblock")
746 )
747 {
748 $rsUnFollower = CSocNetLogFollow::GetList(
749 array(
750 "USER_ID" => $arLog["USER_ID"],
751 "CODE" => "L".$arLog["ID"],
752 "TYPE" => "N"
753 ),
754 array("USER_ID")
755 );
756
757 $arUnFollower = $rsUnFollower->Fetch();
758 if (!$arUnFollower)
759 {
760 $rsSection = CIBlockSection::GetByID($arLog["SOURCE_ID"]);
761 if ($arSection = $rsSection->GetNext())
762 {
763 $arMessageFields = array(
764 "MESSAGE_TYPE" => IM_MESSAGE_SYSTEM,
765 "TO_USER_ID" => $arLog["USER_ID"],
766 "FROM_USER_ID" => $USER->GetID(),
767 "NOTIFY_TYPE" => IM_NOTIFY_FROM,
768 "NOTIFY_MODULE" => "photogallery",
769 "NOTIFY_EVENT" => "comment",
770 "LOG_ID" => $arLog["ID"],
771 );
772
773 $arTmp = CSocNetLogTools::ProcessPath(array("SECTION_URL" => $arLog["URL"]), $arLog["USER_ID"]);
774 $serverName = $arTmp["SERVER_NAME"];
775 $arLog["URL"] = $arTmp["URLS"]["SECTION_URL"];
776
777 $arMessageFields["NOTIFY_TAG"] = "PHOTOALBUM|COMMENT|".$arLog["SOURCE_ID"];
778 $arMessageFields["NOTIFY_MESSAGE"] = fn (?string $languageId = null) => Bitrix\Main\Localization\Loc::getMessage(
779 "SONET_PHOTOALBUM_IM_COMMENT",
780 [
781 "#album_title#" => "<a href=\"".$arLog["URL"]."\" class=\"bx-notifier-item-action\">".$arSection["NAME"]."</a>"
782 ],
783 $languageId
784 );
785 $arMessageFields["NOTIFY_MESSAGE_OUT"] = fn (?string $languageId = null) =>
787 "SONET_PHOTOALBUM_IM_COMMENT",
788 [
789 "#album_title#" => $arSection["NAME"]
790 ],
791 $languageId
792 )
793 ." (".$serverName.$arLog["URL"].")#BR##BR#".$arFields["TEXT_MESSAGE"]
794 ;
795
796 $ID = CIMNotify::Add($arMessageFields);
797
798 if(!empty($arFields["MENTION_ID"]))
799 {
800 //
801 }
802 }
803 }
804 }
805
806 return array(
807 "NO_SOURCE" => "Y",
808 "ERROR" => $sError,
809 "NOTES" => ""
810 );
811 }
812
813 public static function FindLogType($logID)
814 {
816 array(),
817 array("ID" => $logID),
818 false,
819 false,
820 array("ID", "SOURCE_ID", "USER_ID", "TITLE", "URL", "PARAMS")
821 );
822
823 if ($arLog = $dbResult->Fetch())
824 {
825 if ($arLog["PARAMS"] <> '')
826 {
827 $arTmp = unserialize(htmlspecialcharsback($arLog["PARAMS"]), [ 'allowed_classes' => false ]);
828 if ($arTmp)
829 {
830 $FORUM_ID = $arTmp["FORUM_ID"];
831 $BLOG_ID = $arTmp["BLOG_ID"];
832
833 if (
834 array_key_exists("SECTION_NAME", $arTmp)
835 && $arTmp["SECTION_NAME"] <> ''
836 )
837 {
838 $log_section_name = $arTmp["SECTION_NAME"];
839 }
840
841 if (
842 array_key_exists("SECTION_URL", $arTmp)
843 && $arTmp["SECTION_URL"] <> ''
844 )
845 {
846 $log_section_url = $arTmp["SECTION_URL"];
847 }
848 }
849 }
850
851 if (
852 $FORUM_ID > 0
853 && intval($arLog["SOURCE_ID"]) > 0
854 )
855 {
856 $bFoundForum = true;
857 }
858 elseif (
859 $BLOG_ID > 0
860 && intval($arLog["SOURCE_ID"]) > 0
861 )
862 {
863 $bFoundBlog = true;
864 }
865 }
866
867 return array(
868 "TYPE" => ($bFoundForum ? "FORUM" : ($bFoundBlog ? "BLOG" : false)),
869 "ENTITY_ID" => ($bFoundForum ? $FORUM_ID : ($bFoundBlog ? $BLOG_ID : false)),
870 "SECTION_NAME" => $log_section_name,
871 "SECTION_URL" => $log_section_url,
872 "LOG" => $arLog
873 );
874 }
875
876 public static function AddComment_Photo($arFields)
877 {
878 global $USER;
879
880 $arLogType = self::FindLogType($arFields["LOG_ID"]);
881
882 if ($arLogType["TYPE"] == "FORUM")
883 {
884 $arReturn = CSocNetPhotoCommentEvent::AddComment_Photo_Forum($arFields, $arLogType["ENTITY_ID"], $arLogType["LOG"]);
885 }
886 elseif ($arLogType["TYPE"] == "BLOG")
887 {
888 $arReturn = CSocNetPhotoCommentEvent::AddComment_Photo_Blog($arFields, $arLogType["ENTITY_ID"], $arLogType["LOG"]);
889 }
890 else
891 {
892 $arReturn = array(
893 "SOURCE_ID" => false,
894 "ERROR" => GetMessage("SONET_PHOTO_ADD_COMMENT_SOURCE_ERROR"),
895 "NOTES" => ""
896 );
897 }
898
899 if (
900 $arLogType["TYPE"]
901 && !empty($arReturn["IM_MESSAGE"])
902 )
903 {
904 $arFieldsIM = Array(
905 "TYPE" => "COMMENT",
906 "TITLE" => $arLogType["LOG"]["TITLE"],
907 "MESSAGE" => $arReturn["IM_MESSAGE"],
908 "URL" => $arLogType["LOG"]["URL"],
909 "ID" => $arLogType["LOG"]["SOURCE_ID"],
910 "PHOTO_AUTHOR_ID" => $arLogType["LOG"]["USER_ID"],
911 "COMMENT_AUTHOR_ID" => $USER->GetID(),
912 );
914 }
915
916 return $arReturn;
917 }
918
919 public static function AddComment_Photo_Forum($arFields, $FORUM_ID, $arLog)
920 {
921 global $USER_FIELD_MANAGER;
922
923 if (!CModule::IncludeModule("forum"))
924 return false;
925
926 if (!CModule::IncludeModule("iblock"))
927 return false;
928
929 $ufFileID = array();
930 $ufDocID = array();
931
932 $arElement = false;
933 $arFilteredText = array();
934
935 $arFilter = array("ID" => $arLog["SOURCE_ID"]);
936 $arSelectedFields = array("IBLOCK_ID", "ID", "NAME", "TAGS", "CODE", "IBLOCK_SECTION_ID", "DETAIL_PAGE_URL",
937 "CREATED_BY", "PREVIEW_PICTURE", "PREVIEW_TEXT", "PROPERTY_FORUM_TOPIC_ID", "PROPERTY_FORUM_MESSAGE_CNT");
938 $db_res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelectedFields);
939 if ($db_res && $res = $db_res->GetNext())
940 $arElement = $res;
941
942 if ($arElement)
943 {
944 // check iblock properties
946
948 array(),
949 array(
950 "PARAM2" => $arElement["ID"]
951 )
952 );
953
954 if (!$arMessage = $dbMessage->Fetch())
955 {
956 // Add Topic
957 $TOPIC_ID = CSocNetLogTools::AddComment_Review_CreateRoot_Forum($arElement, $FORUM_ID);
958 $bNewTopic = true;
959 }
960 else
961 $TOPIC_ID = $arMessage["TOPIC_ID"];
962
963 if(intval($TOPIC_ID) > 0)
964 {
965 if (COption::GetOptionString("forum", "FILTER", "Y") == "Y")
966 {
967 $arFields["TEXT_MESSAGE"] = $arFilteredText["TEXT_MESSAGE"] = CFilterUnquotableWords::Filter($arFields["TEXT_MESSAGE"]);
968 $arFilteredText["MESSAGE"] = CFilterUnquotableWords::Filter($arFields["MESSAGE"]);
969 }
970
971 // Add comment
972 $messageID = false;
973 $arFieldsMessage = array(
974 "POST_MESSAGE" => $arFields["TEXT_MESSAGE"],
975 "USE_SMILES" => "Y",
976 "PARAM2" => $arElement["ID"],
977 "APPROVED" => "Y"
978 );
979
980 $USER_FIELD_MANAGER->EditFormAddFields("SONET_COMMENT", $arTmp);
981 if (is_array($arTmp))
982 {
983 if (array_key_exists("UF_SONET_COM_DOC", $arTmp))
984 $GLOBALS["UF_FORUM_MESSAGE_DOC"] = $arTmp["UF_SONET_COM_DOC"];
985 elseif (array_key_exists("UF_SONET_COM_FILE", $arTmp))
986 {
987 $arFieldsMessage["FILES"] = array();
988 foreach($arTmp["UF_SONET_COM_FILE"] as $file_id)
989 $arFieldsMessage["FILES"][] = array("FILE_ID" => $file_id);
990 }
991 }
992
993 $messageID = ForumAddMessage("REPLY", $FORUM_ID, $TOPIC_ID, 0, $arFieldsMessage, $sError, $sNote);
994
995 if (!$messageID)
996 $strError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
997 else
998 {
999 // get UF DOC value and FILE_ID there
1000 $dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $messageID));
1001 while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch())
1002 $ufFileID[] = $arAddedMessageFiles["FILE_ID"];
1003
1004 $ufDocID = $USER_FIELD_MANAGER->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $messageID, LANGUAGE_ID);
1005
1006 CSocNetLogTools::AddComment_Review_UpdateElement_Forum($arElement, $TOPIC_ID, $bNewTopic);
1007 }
1008 }
1009 else
1010 $strError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
1011 }
1012 else
1013 $strError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
1014
1015 return array_merge(
1016 $arFilteredText,
1017 array(
1018 "SOURCE_ID" => $messageID,
1019 "RATING_TYPE_ID" => "FORUM_POST",
1020 "RATING_ENTITY_ID" => $messageID,
1021 "ERROR" => $strError,
1022 "NOTES" => "",
1023 "UF" => array(
1024 "FILE" => $ufFileID,
1025 "DOC" => $ufDocID
1026 ),
1027 "IM_MESSAGE" => ($messageID ? $arFields["TEXT_MESSAGE"] : false)
1028 )
1029 );
1030 }
1031
1032 public static function AddComment_Photo_Blog($arFields, $BLOG_ID, $arLog)
1033 {
1034 global $USER;
1035
1036 if (!CModule::IncludeModule("blog"))
1037 return false;
1038
1039 if (!CModule::IncludeModule("iblock"))
1040 return false;
1041
1042 $arElement = false;
1043
1044 $arFilter = array("ID" => $arLog["SOURCE_ID"]);
1045 $arSelectedFields = array("IBLOCK_ID", "ID", "NAME", "TAGS", "CODE", "IBLOCK_SECTION_ID", "DETAIL_PAGE_URL",
1046 "CREATED_BY", "PREVIEW_PICTURE", "PREVIEW_TEXT", "PROPERTY_BLOG_POST_ID", "PROPERTY_BLOG_COMMENT_CNT", "PROPERTY_REAL_PICTURE");
1047 $db_res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelectedFields);
1048 if ($db_res && $res = $db_res->GetNext())
1049 $arElement = $res;
1050
1051 if ($arElement)
1052 {
1053 // check iblock properties
1054 $ELEMENT_BLOG_POST_ID = CSocNetLogTools::AddComment_Review_CheckIBlock_Blog($arElement);
1055
1056 if ($ELEMENT_BLOG_POST_ID <= 0)
1057 {
1058 // Add Post
1059 $POST_ID = CSocNetLogTools::AddComment_Review_CreateRoot_Blog($arElement, $BLOG_ID);
1060 $bNewPost = true;
1061 }
1062 else
1063 $POST_ID = $ELEMENT_BLOG_POST_ID;
1064
1065 if(intval($POST_ID) > 0)
1066 {
1067 // Add comment
1068 $commentID = false;
1069
1070 $UserIP = CBlogUser::GetUserIP();
1071 $arFieldsComment = Array(
1072 "POST_ID" => $POST_ID,
1073 "BLOG_ID" => $BLOG_ID,
1074 "POST_TEXT" => trim($arFields["TEXT_MESSAGE"]),
1075 "DATE_CREATE" => ConvertTimeStamp(time()+CTimeZone::GetOffset(), "FULL"),
1076 "AUTHOR_IP" => $UserIP[0],
1077 "AUTHOR_IP1" => $UserIP[1],
1078 "PARENT_ID" => false
1079 );
1080
1081 if($USER->IsAuthorized())
1082 $arFieldsComment["AUTHOR_ID"] = $USER->GetID();
1083
1084 $commentID = CBlogComment::Add($arFieldsComment);
1085 if (!$commentID)
1086 $strError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
1087 else
1088 CSocNetLogTools::AddComment_Review_UpdateElement_Blog($arElement, $POST_ID, $BLOG_ID, $bNewPost);
1089 }
1090 else
1091 $strError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
1092 }
1093 else
1094 $strError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
1095
1096 return array(
1097 "SOURCE_ID" => $commentID,
1098 "RATING_TYPE_ID" => "BLOG_COMMENT",
1099 "RATING_ENTITY_ID" => $commentID,
1100 "ERROR" => $strError,
1101 "NOTES" => "",
1102 "IM_MESSAGE" => ($arFieldsComment ? $arFieldsComment["POST_TEXT"] : false)
1103 );
1104 }
1105
1107 {
1108 $arLogType = self::FindLogType($arFields["LOG_ID"]);
1109
1110 if ($arLogType["TYPE"] == "FORUM")
1111 {
1113 }
1114 elseif ($arLogType["TYPE"] == "BLOG")
1115 {
1116// $arReturn = CSocNetPhotoCommentEvent::UpdateComment_Photo_Blog($arFields, $arLogType["ENTITY_ID"], $arLogType["LOG"]);
1117 }
1118 else
1119 {
1120 $arReturn = array(
1121 "SOURCE_ID" => false,
1122 "ERROR" => GetMessage("SONET_PHOTO_UPDATE_COMMENT_SOURCE_ERROR"),
1123 "NOTES" => ""
1124 );
1125 }
1126
1127 return $arReturn;
1128 }
1129
1131 {
1132 $arLogType = self::FindLogType($arFields["LOG_ID"]);
1133
1134 if ($arLogType["TYPE"] == "FORUM")
1135 {
1137 }
1138 elseif ($arLogType["TYPE"] == "BLOG")
1139 {
1140// $arReturn = CSocNetPhotoCommentEvent::DeleteComment_Photo_Blog($arFields, $arLogType["ENTITY_ID"], $arLogType["LOG"]);
1141 }
1142 else
1143 {
1144 $arReturn = array(
1145 "ERROR" => GetMessage("SONET_PHOTO_DELETE_COMMENT_SOURCE_ERROR"),
1146 "NOTES" => ""
1147 );
1148 }
1149
1150 return $arReturn;
1151 }
1152
1154 {
1155 if (
1156 !array_key_exists("IS_SOCNET", $arParams)
1157 || $arParams["IS_SOCNET"] != "Y"
1158 )
1159 return;
1160 else
1161 $this->IsSocnet = true;
1162
1163 $this->arPath["PATH_TO_SMILE"] = $arParams["PATH_TO_SMILE"];
1164 $this->arPath["DETAIL_URL"] = $arParams["~DETAIL_URL"];
1165 $this->arPath["SECTION_URL"] = $arParams["~SECTION_URL"];
1166
1167 if (mb_strtolower($arParams["COMMENTS_TYPE"]) == "forum")
1168 $this->ForumID = $arParams["FORUM_ID"];
1169 elseif (mb_strtolower($arParams["COMMENTS_TYPE"]) == "blog")
1170 {
1171 $this->PhotoElementID = $arParams["ELEMENT_ID"];
1172 $this->PostID = $arResult["COMMENT_ID"];
1173
1174 if (CModule::IncludeModule("blog"))
1175 if ($arBlog = CBlog::GetByUrl($arParams["BLOG_URL"]))
1176 $this->BlogID = $arBlog["ID"];
1177 }
1178
1179 $this->bIsGroup = false;
1180 $this->entity_type = false;
1181 $this->entity_id = false;
1182 if (
1183 array_key_exists("USER_ALIAS", $arParams)
1184 && $arParams["USER_ALIAS"] <> ''
1185 )
1186 {
1187 $arTmp = explode("_", $arParams["USER_ALIAS"]);
1188 if (
1189 is_array($arTmp)
1190 && count($arTmp) == 2
1191 )
1192 {
1193 $entity_type = $arTmp[0];
1194 $this->entity_id = $arTmp[1];
1195
1196 if ($entity_type == "group")
1197 $this->entity_type = SONET_ENTITY_GROUP;
1198 else
1199 $this->entity_type = SONET_ENTITY_USER;
1200 }
1201 }
1202 }
1203
1205 {
1206 global $USER, $DB;
1207
1208 static $arSiteWorkgroupsPage;
1209
1210 if (!CModule::IncludeModule('iblock'))
1211 return;
1212
1213 if (!$this->IsSocnet)
1214 return;
1215
1216 if (
1217 (
1218 !array_key_exists("PARAM1", $arFields)
1219 || $arFields["PARAM1"] != "IB"
1220 )
1221 && array_key_exists("PARAM2", $arFields)
1222 && intval($arFields["PARAM2"]) > 0
1223 )
1224 {
1225 $bSocNetLogRecordExists = false;
1226
1228 array("ID" => "DESC"),
1229 array(
1230 "EVENT_ID" => "photo_photo",
1231 "SOURCE_ID" => $arFields["PARAM2"] // file photo id
1232 ),
1233 false,
1234 false,
1235 array("ID", "ENTITY_TYPE", "ENTITY_ID", "TMP_ID", "USER_ID", "TITLE", "URL", "PARAMS")
1236 );
1237
1238 if ($arRes = $dbRes->Fetch())
1239 {
1240 $log_id = $arRes["ID"];
1241 $entity_type = $arRes["ENTITY_TYPE"];
1242 $entity_id = $arRes["ENTITY_ID"];
1243 $log_title = $arRes["TITLE"];
1244 $log_url = $arRes["URL"];
1245 $log_user_id = $arRes["USER_ID"];
1246
1247 if ($arRes["PARAMS"] <> '')
1248 {
1249 $arTmp = unserialize($arRes["PARAMS"], [ 'allowed_classes' => false ]);
1250 if ($arTmp)
1251 {
1252 if (
1253 array_key_exists("SECTION_NAME", $arTmp)
1254 && $arTmp["SECTION_NAME"] <> ''
1255 )
1256 $log_section_name = $arTmp["SECTION_NAME"];
1257
1258 if (
1259 array_key_exists("SECTION_URL", $arTmp)
1260 && $arTmp["SECTION_URL"] <> ''
1261 )
1262 $log_section_url = $arTmp["SECTION_URL"];
1263 }
1264 }
1265
1266 $bSocNetLogRecordExists = true;
1267 }
1268 else
1269 {
1270 $rsElement = CIBlockElement::GetByID($arFields["PARAM2"]);
1271 if ($arElement = $rsElement->Fetch())
1272 {
1273 $url = $this->arPath["DETAIL_URL"];
1274
1275 $sAuthorName = GetMessage("SONET_PHOTO_LOG_GUEST");
1276 if (intval($arElement["CREATED_BY"]) > 0)
1277 {
1278 $rsUser = CUser::GetByID($arElement["CREATED_BY"]);
1279 if ($arUser = $rsUser->Fetch())
1280 $sAuthorName = CUser::FormatName(CSite::GetNameFormat(false), $arUser, true, false);
1281 }
1282
1283 if (
1284 in_array( $this->entity_type, array(SONET_ENTITY_USER, SONET_ENTITY_GROUP))
1285 && intval($this->entity_id) > 0
1286 )
1287 {
1290 $alias = ($this->entity_type == SONET_ENTITY_GROUP ? "group" : "user")."_".$this->entity_id;
1291 }
1292
1293 $arLogParams = array(
1294 "FORUM_ID" => intval($this->ForumID)
1295 );
1296
1297 $rsIBlock = CIBlock::GetByID($arElement["IBLOCK_ID"]);
1298 if($arIBlock = $rsIBlock->Fetch())
1299 {
1300 $arLogParams["IBLOCK_ID"] = $arIBlock["ID"];
1301 $arLogParams["IBLOCK_TYPE"] = $arIBlock["IBLOCK_TYPE_ID"];
1302 }
1303
1304 $rsSection = CIBlockSection::GetByID($arElement["IBLOCK_SECTION_ID"]);
1305 if ($arSection = $rsSection->Fetch())
1306 {
1307 $arLogParams["SECTION_ID"] = $arSection["ID"];
1308 $arLogParams["SECTION_NAME"] = $arSection["NAME"];
1309 $arLogParams["SECTION_URL"] = str_replace("#SECTION_ID#", $arSection["ID"], $this->arPath["SECTION_URL"]);
1310
1311 $arSectionPath = array();
1312 $bPassword = false;
1313
1314 $dbSection = CIBlockSection::GetList(
1315 array("LEFT_MARGIN" => "ASC"),
1316 array(
1317 "IBLOCK_ID" => intval($arLogParams["IBLOCK_ID"]),
1318 "<=LEFT_BORDER" => intval($arSection["LEFT_MARGIN"]),
1319 ">=RIGHT_BORDER" => intval($arSection["RIGHT_MARGIN"]),
1320 "<=DEPTH_LEVEL" => intval($arSection["DEPTH_LEVEL"]),
1321 ),
1322 false,
1323 array("ID", "IBLOCK_ID", "NAME", "CODE", "CREATED_BY", "DEPTH_LEVEL", "LEFT_MARGIN", "RIGHT_MARGIN", "UF_PASSWORD")
1324 );
1325
1326 while ($arPath = $dbSection->Fetch())
1327 {
1328 $arSectionPath[] = $arPath;
1329 if (trim($arPath["UF_PASSWORD"]) <> '')
1330 {
1331 $bPassword = true;
1332 break;
1333 }
1334 }
1335
1336 if (!$alias)
1337 {
1339 $entity_id = $arSectionPath[0]["CREATED_BY"];
1340 $alias = $arSectionPath[0]["CODE"];
1341 }
1342
1343 if (!$arSiteWorkgroupsPage && IsModuleInstalled("extranet") && $entity_type == SONET_ENTITY_GROUP)
1344 {
1345 $rsSite = CSite::GetList("sort", "desc", Array("ACTIVE" => "Y"));
1346 while($arSite = $rsSite->Fetch())
1347 $arSiteWorkgroupsPage[$arSite["ID"]] = COption::GetOptionString("socialnetwork", "workgroups_page", $arSite["DIR"]."workgroups/", $arSite["ID"]);
1348 }
1349
1350 if (is_set($arLogParams["SECTION_URL"]) && is_array($arSiteWorkgroupsPage) && $entity_type == SONET_ENTITY_GROUP)
1351 foreach($arSiteWorkgroupsPage as $groups_page)
1352 if (mb_strpos($arLogParams["SECTION_URL"], $groups_page) === 0)
1353 $arLogParams["SECTION_URL"] = "#GROUPS_PATH#".mb_substr($arLogParams["SECTION_URL"], mb_strlen($groups_page), mb_strlen($arLogParams["SECTION_URL"]) - mb_strlen($groups_page));
1354 }
1355
1356 $arLogParams["ALIAS"] = $alias;
1357
1358 $arSonetFields = array(
1359 "ENTITY_TYPE" => $entity_type,
1360 "ENTITY_ID" => $entity_id,
1361 "EVENT_ID" => "photo_photo",
1362 "LOG_DATE" => $arElement["TIMESTAMP_X"],
1363 "TITLE_TEMPLATE" => str_replace("#AUTHOR_NAME#", $sAuthorName, GetMessage("SONET_PHOTOPHOTO_LOG_1")),
1364 "TITLE" => $arElement["NAME"],
1365 "MESSAGE" => "",
1366 "TEXT_MESSAGE" => "",
1367 "URL" => CComponentEngine::MakePathFromTemplate($url, array(
1368 "ELEMENT_ID" => $arElement["ID"],
1369 "element_id" => $arElement["ID"],
1370 "SECTION_ID" => $arElement["IBLOCK_SECTION_ID"],
1371 "section_id" => $arElement["IBLOCK_SECTION_ID"]
1372 )),
1373 "MODULE_ID" => false,
1374 "CALLBACK_FUNC" => false,
1375 "SOURCE_ID" => $arElement["ID"],
1376 "PARAMS" => serialize($arLogParams),
1377 "RATING_TYPE_ID" => "IBLOCK_ELEMENT",
1378 "RATING_ENTITY_ID"=> $arElement["ID"],
1379 );
1380
1381 if (intval($arElement["CREATED_BY"]) > 0)
1382 $arSonetFields["USER_ID"] = $arElement["CREATED_BY"];
1383
1384 $log_id = CSocNetLog::Add($arSonetFields, false);
1385 if (intval($log_id) > 0)
1386 {
1387 $log_title = $arSonetFields["TITLE"];
1388 $log_url = $arSonetFields["URL"];
1389 $log_section_name = $arLogParams["SECTION_NAME"];
1390 $log_section_url = $arLogParams["SECTION_URL"];
1391 $log_user_id = $arSonetFields["USER_ID"];
1392
1393 CSocNetLog::Update($log_id, array("TMP_ID" => $log_id));
1394 if ($bPassword)
1395 {
1397 CSocNetLogRights::Add($log_id, array("U".$USER->GetID(), "SA"));
1398 }
1399 else
1400 {
1401 CSocNetLogRights::SetForSonet($log_id, $entity_type, $entity_id, "photo", "view");
1402 }
1403 }
1404 }
1405 }
1406
1407 if (intval($log_id) > 0)
1408 {
1409 $arForum = CForumNew::GetByID($this->ForumID);
1410
1411 $parser = new forumTextParser(LANGUAGE_ID, $this->arPath["PATH_TO_SMILE"]);
1412 $parser->imageWidth = false;
1413 $parser->imageHeight = false;
1414
1415 $arAllow = array(
1416 "HTML" => "N",
1417 "ANCHOR" => "N",
1418 "BIU" => "N",
1419 "IMG" => "N",
1420 "LIST" => "N",
1421 "QUOTE" => "N",
1422 "CODE" => "N",
1423 "FONT" => "N",
1424 "UPLOAD" => $arForum["ALLOW_UPLOAD"],
1425 "NL2BR" => "N",
1426 "SMILES" => "N",
1427 "VIDEO" => "N"
1428 );
1429
1430 $url = $this->arPath["DETAIL_URL"];
1431
1432 if ($bSocNetLogRecordExists)
1433 {
1434 $arMessage = CForumMessage::GetByIDEx($ID);
1435
1436 $arFieldsForSocnet = array(
1437 "ENTITY_TYPE" => $entity_type,
1438 "ENTITY_ID" => $entity_id,
1439 "EVENT_ID" => "photo_comment",
1440 "=LOG_DATE" => $DB->CurrentTimeFunction(),
1441 "MESSAGE" => $parser->convert(empty($arFields["POST_MESSAGE_FILTER"]) ? $arFields["POST_MESSAGE"] : $arFields["POST_MESSAGE_FILTER"], $arAllow),
1442 "TEXT_MESSAGE" => $parser->convert4mail(empty($arFields["POST_MESSAGE_FILTER"]) ? $arFields["POST_MESSAGE"] : $arFields["POST_MESSAGE_FILTER"]),
1443 "MODULE_ID" => false,
1444 "SOURCE_ID" => $ID,
1445 "LOG_ID" => $log_id,
1446 "RATING_TYPE_ID" => "FORUM_POST",
1447 "RATING_ENTITY_ID" => $ID,
1448 );
1449
1450 if (intval($arMessage["AUTHOR_ID"]) > 0)
1451 $arFieldsForSocnet["USER_ID"] = $arMessage["AUTHOR_ID"];
1452
1453 $comment_id = CSocNetLogComments::Add($arFieldsForSocnet, false, false);
1454 if ($comment_id)
1455 {
1456 CSocNetLog::CounterIncrement($comment_id, false, false, "LC");
1457
1458 $arFieldsIM = Array(
1459 "TYPE" => "COMMENT",
1460 "TITLE" => $log_title,
1461 "MESSAGE" => $arFieldsForSocnet["MESSAGE"],
1462 "URL" => $log_url,
1463 "SECTION_NAME" => $log_section_name,
1464 "SECTION_URL" => $log_section_url,
1465 "ID" => $arFields["PARAM2"],
1466 "PHOTO_AUTHOR_ID" => $log_user_id,
1467 "COMMENT_AUTHOR_ID" => $arMessage["AUTHOR_ID"],
1468 );
1470 }
1471 }
1472 else
1473 {
1474 $dbComments = CForumMessage::GetListEx(
1475 array(),
1476 array('TOPIC_ID' => $arFields["TOPIC_ID"], "NEW_TOPIC" => "N")
1477 );
1478
1479 while ($arComment = $dbComments->GetNext())
1480 {
1481 $arFieldsForSocnet = array(
1482 "ENTITY_TYPE" => $entity_type,
1483 "ENTITY_ID" => $entity_id,
1484 "EVENT_ID" => "photo_comment",
1485 "=LOG_DATE" => $DB->CharToDateFunction($arComment["POST_DATE"], "FULL", SITE_ID),
1486 "MESSAGE" => $parser->convert(empty($arComment["POST_MESSAGE_FILTER"]) ? $arComment["POST_MESSAGE"] : $arComment["POST_MESSAGE_FILTER"], $arAllow),
1487 "TEXT_MESSAGE" => $parser->convert4mail(empty($arComment["POST_MESSAGE_FILTER"]) ? $arComment["POST_MESSAGE"] : $arComment["POST_MESSAGE_FILTER"]),
1488 "MODULE_ID" => false,
1489 "SOURCE_ID" => $arComment["ID"],
1490 "LOG_ID" => $log_id,
1491 "RATING_TYPE_ID" => "FORUM_POST",
1492 "RATING_ENTITY_ID" => $arComment["ID"],
1493 );
1494
1495 if (intval($arComment["AUTHOR_ID"]) > 0)
1496 {
1497 $arFieldsForSocnet["USER_ID"] = $arComment["AUTHOR_ID"];
1498 }
1499
1500 $comment_id = CSocNetLogComments::Add($arFieldsForSocnet, false, false);
1501 if ($comment_id)
1502 {
1503 CSocNetLog::CounterIncrement($comment_id, false, false, "LC");
1504
1505 $arFieldsIM = Array(
1506 "TYPE" => "COMMENT",
1507 "TITLE" => $log_title,
1508 "MESSAGE" => $arFieldsForSocnet["MESSAGE"],
1509 "URL" => $log_url,
1510 "SECTION_NAME" => $log_section_name,
1511 "SECTION_URL" => $log_section_url,
1512 "ID" => $arFields["PARAM2"],
1513 "PHOTO_AUTHOR_ID" => $log_user_id,
1514 "COMMENT_AUTHOR_ID" => $arComment["AUTHOR_ID"],
1515 );
1517 }
1518 }
1519
1520 if ($arElement)
1521 {
1522 self::InheriteAlbumFollow($arElement["IBLOCK_SECTION_ID"], $log_id, (intval($arElement["CREATED_BY"]) > 0 ? $arElement["CREATED_BY"] : false));
1523 }
1524 }
1525 }
1526 }
1527 }
1528
1530 {
1531 global $USER, $DB;
1532
1533 if (!CModule::IncludeModule('iblock'))
1534 return;
1535
1536 if (!$this->IsSocnet)
1537 return;
1538
1539 if (intval($this->PhotoElementID) > 0)
1540 {
1542 array("ID" => "DESC"),
1543 array(
1544 "EVENT_ID" => "photo_photo",
1545 "SOURCE_ID" => $this->PhotoElementID
1546 ),
1547 false,
1548 false,
1549 array("ID", "ENTITY_TYPE", "ENTITY_ID", "TMP_ID", "TITLE", "URL", "USER_ID", "PARAMS")
1550 );
1551
1552 $bSocNetLogRecordExists = false;
1553 if ($arRes = $dbRes->Fetch())
1554 {
1555 $log_id = $arRes["ID"];
1556 $entity_type = $arRes["ENTITY_TYPE"];
1557 $entity_id = $arRes["ENTITY_ID"];
1558 $log_title = $arRes["TITLE"];
1559 $log_url = $arRes["URL"];
1560 $log_user_id = $arRes["USER_ID"];
1561 $bSocNetLogRecordExists = true;
1562
1563 if ($arRes["PARAMS"] <> '')
1564 {
1565 $arTmp = unserialize($arRes["PARAMS"], [ 'allowed_classes' => false ]);
1566 if ($arTmp)
1567 {
1568 if (
1569 array_key_exists("SECTION_NAME", $arTmp)
1570 && $arTmp["SECTION_NAME"] <> ''
1571 )
1572 $log_section_name = $arTmp["SECTION_NAME"];
1573
1574 if (
1575 array_key_exists("SECTION_URL", $arTmp)
1576 && $arTmp["SECTION_URL"] <> ''
1577 )
1578 $log_section_url = $arTmp["SECTION_URL"];
1579 }
1580 }
1581 }
1582 else
1583 {
1584 $rsElement = CIBlockElement::GetByID($this->PhotoElementID);
1585 if ($arElement = $rsElement->Fetch())
1586 {
1587 $url = $this->arPath["DETAIL_URL"];
1588
1589 $sAuthorName = GetMessage("SONET_PHOTO_LOG_GUEST");
1590 if (intval($arElement["CREATED_BY"]) > 0)
1591 {
1592 $rsUser = CUser::GetByID($arElement["CREATED_BY"]);
1593 if ($arUser = $rsUser->Fetch())
1594 $sAuthorName = CUser::FormatName(CSite::GetNameFormat(false), $arUser, true, false);
1595 }
1596
1597 if (
1598 in_array($this->entity_type, array(SONET_ENTITY_USER, SONET_ENTITY_GROUP))
1599 && intval($this->entity_id) > 0
1600 )
1601 {
1604 $alias = ($this->entity_type == SONET_ENTITY_GROUP ? "group" : "user")."_".$this->entity_id;
1605 }
1606
1607 $arLogParams = array(
1608 "BLOG_ID" => intval($this->BlogID)
1609 );
1610
1611 $rsIBlock = CIBlock::GetByID($arElement["IBLOCK_ID"]);
1612 if($arIBlock = $rsIBlock->Fetch())
1613 {
1614 $arLogParams["IBLOCK_ID"] = $arIBlock["ID"];
1615 $arLogParams["IBLOCK_TYPE"] = $arIBlock["IBLOCK_TYPE_ID"];
1616 }
1617
1618 $rsSection = CIBlockSection::GetByID($arElement["IBLOCK_SECTION_ID"]);
1619 if ($arSection = $rsSection->Fetch())
1620 {
1621 $arLogParams["SECTION_ID"] = $arSection["ID"];
1622 $arLogParams["SECTION_NAME"] = $arSection["NAME"];
1623 $arLogParams["SECTION_URL"] = str_replace("#SECTION_ID#", $arSection["ID"], $this->arPath["SECTION_URL"]);
1624
1625 $arSectionPath = array();
1626 $bPassword = false;
1627
1628 $dbSectionPath = CIBlockSection::GetList(
1629 array("LEFT_MARGIN" => "ASC"),
1630 array(
1631 "IBLOCK_ID" => intval($arLogParams["IBLOCK_ID"]),
1632 "<=LEFT_BORDER" => intval($arSection["LEFT_MARGIN"]),
1633 ">=RIGHT_BORDER" => intval($arSection["RIGHT_MARGIN"]),
1634 "<=DEPTH_LEVEL" => intval($arSection["DEPTH_LEVEL"]),
1635 ),
1636 false,
1637 array("ID", "IBLOCK_ID", "NAME", "CREATED_BY", "DEPTH_LEVEL", "LEFT_MARGIN", "RIGHT_MARGIN", "UF_PASSWORD")
1638 );
1639
1640 while ($arPath = $dbSectionPath->Fetch())
1641 {
1642 $arSectionPath[] = $arPath;
1643 if (trim($arPath["UF_PASSWORD"]) <> '')
1644 {
1645 $bPassword = true;
1646 break;
1647 }
1648 }
1649
1650 if (!$alias)
1651 {
1653 $entity_id = $arSectionPath[0]["CREATED_BY"];
1654 $alias = $arSectionPath[0]["CODE"];
1655 }
1656 }
1657
1658 $arLogParams["ALIAS"] = $alias;
1659
1660 $arSonetFields = array(
1661 "ENTITY_TYPE" => $entity_type,
1662 "ENTITY_ID" => $entity_id,
1663 "EVENT_ID" => "photo_photo",
1664 "LOG_DATE" => $arElement["TIMESTAMP_X"],
1665 "TITLE_TEMPLATE" => str_replace("#AUTHOR_NAME#", $sAuthorName, GetMessage("SONET_PHOTOPHOTO_LOG_1")),
1666 "TITLE" => $arElement["NAME"],
1667 "MESSAGE" => "",
1668 "TEXT_MESSAGE" => "",
1669 "URL" => CComponentEngine::MakePathFromTemplate($url, array(
1670 "ELEMENT_ID" => $arElement["ID"],
1671 "element_id" => $arElement["ID"],
1672 "SECTION_ID" => $arElement["IBLOCK_SECTION_ID"],
1673 "section_id" => $arElement["IBLOCK_SECTION_ID"]
1674 )),
1675 "MODULE_ID" => false,
1676 "CALLBACK_FUNC" => false,
1677 "SOURCE_ID" => $arElement["ID"],
1678 "PARAMS" => serialize($arLogParams),
1679 "RATING_TYPE_ID" => "IBLOCK_ELEMENT",
1680 "RATING_ENTITY_ID"=> $arElement["ID"],
1681 );
1682
1683 if (intval($arElement["CREATED_BY"]) > 0)
1684 $arSonetFields["USER_ID"] = $arElement["CREATED_BY"];
1685
1686 $log_id = CSocNetLog::Add($arSonetFields, false);
1687 if (intval($log_id) > 0)
1688 {
1689 $log_title = $arSonetFields["TITLE"];
1690 $log_url = $arSonetFields["URL"];
1691 $log_section_name = $arLogParams["SECTION_NAME"];
1692 $log_section_url = $arLogParams["SECTION_URL"];
1693 $log_user_id = $arSonetFields["USER_ID"];
1694
1695 CSocNetLog::Update($log_id, array("TMP_ID" => $log_id));
1696 if ($bPassword)
1697 {
1699 CSocNetLogRights::Add($log_id, array("U".$USER->GetID(), "SA"));
1700 }
1701 else
1702 {
1703 CSocNetLogRights::SetForSonet($log_id, $entity_type, $entity_id, "photo", "view", true);
1704 }
1705 }
1706 }
1707 }
1708
1709 if (intval($log_id) > 0)
1710 {
1711 $parserBlog = new blogTextParser(false, $this->arPath["PATH_TO_SMILE"]);
1712 $arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "N");
1713
1714 if ($bSocNetLogRecordExists)
1715 {
1716 $text4message = $parserBlog->convert($arFields["POST_TEXT"], true, array(), $arAllow);
1717 $text4mail = $parserBlog->convert4mail($arFields["POST_TEXT"]);
1718
1719 $arFieldsForSocnet = array(
1720 "ENTITY_TYPE" => $entity_type,
1721 "ENTITY_ID" => $entity_id,
1722 "EVENT_ID" => "photo_comment",
1723 "=LOG_DATE" => $DB->CurrentTimeFunction(),
1724 "MESSAGE" => $text4message,
1725 "TEXT_MESSAGE" => $text4mail,
1726 "MODULE_ID" => false,
1727 "SOURCE_ID" => $ID,
1728 "LOG_ID" => $log_id,
1729 "RATING_TYPE_ID" => "BLOG_COMMENT",
1730 "RATING_ENTITY_ID" => $ID,
1731 );
1732
1733 if (intval($arFields["AUTHOR_ID"]) > 0)
1734 $arFieldsForSocnet["USER_ID"] = $arFields["AUTHOR_ID"];
1735
1736 $comment_id = CSocNetLogComments::Add($arFieldsForSocnet, false, false);
1737 if ($comment_id)
1738 {
1739 CSocNetLog::CounterIncrement($comment_id, false, false, "LC");
1740
1741 $arFieldsIM = Array(
1742 "TYPE" => "COMMENT",
1743 "TITLE" => $log_title,
1744 "MESSAGE" => $arFieldsForSocnet["MESSAGE"],
1745 "URL" => $log_url,
1746 "SECTION_NAME" => $log_section_name,
1747 "SECTION_URL" => $log_section_url,
1748 "ID" => $this->PhotoElementID,
1749 "PHOTO_AUTHOR_ID" => $log_user_id,
1750 "COMMENT_AUTHOR_ID" => $arFields["AUTHOR_ID"],
1751 );
1753 }
1754 }
1755 else //socnetlog record didn't exist - adding all comments
1756 {
1757 $dbComments = CBlogComment::GetList(array(),
1758 array(
1759 "BLOG_ID" => intval($this->BlogID),
1760 "POST_ID" => intval($this->PostID)
1761 ),
1762 false,
1763 false,
1764 array("ID", "BLOG_ID", "POST_ID", "AUTHOR_ID", "POST_TEXT", "DATE_CREATE")
1765 );
1766
1767 while ($arComment = $dbComments->GetNext())
1768 {
1769 $text4message = $parserBlog->convert($arComment["POST_TEXT"], true, array(), $arAllow);
1770 $text4mail = $parserBlog->convert4mail($arComment["POST_TEXT"]);
1771
1772 $arFieldsForSocnet = array(
1773 "ENTITY_TYPE" => $entity_type,
1774 "ENTITY_ID" => $entity_id,
1775 "EVENT_ID" => "photo_comment",
1776 "=LOG_DATE" => $DB->CharToDateFunction($arComment["DATE_CREATE"], "FULL", SITE_ID),
1777 "MESSAGE" => $text4message,
1778 "TEXT_MESSAGE" => $text4mail,
1779 "MODULE_ID" => false,
1780 "SOURCE_ID" => intval($arComment["ID"]),
1781 "LOG_ID" => $log_id,
1782 "RATING_TYPE_ID" => "BLOG_COMMENT",
1783 "RATING_ENTITY_ID" => intval($arComment["ID"]),
1784 );
1785
1786 if (intval($arFields["AUTHOR_ID"]) > 0)
1787 $arFieldsForSocnet["USER_ID"] = $arFields["AUTHOR_ID"];
1788
1789 $comment_id = CSocNetLogComments::Add($arFieldsForSocnet, false, false);
1790 if ($comment_id)
1791 {
1792 CSocNetLog::CounterIncrement($comment_id, false, false, "LC");
1793
1794 $arFieldsIM = Array(
1795 "TYPE" => "COMMENT",
1796 "TITLE" => $log_title,
1797 "MESSAGE" => $arFieldsForSocnet["MESSAGE"],
1798 "URL" => $log_url,
1799 "SECTION_NAME" => $log_section_name,
1800 "SECTION_URL" => $log_section_url,
1801 "ID" => $this->PhotoElementID,
1802 "PHOTO_AUTHOR_ID" => $log_user_id,
1803 "COMMENT_AUTHOR_ID" => $arFields["AUTHOR_ID"],
1804 );
1806 }
1807 }
1808
1809 if ($arElement)
1810 {
1811 self::InheriteAlbumFollow($arElement["IBLOCK_SECTION_ID"], $log_id, (intval($arElement["CREATED_BY"]) > 0 ? $arElement["CREATED_BY"] : false));
1812 }
1813 }
1814 }
1815 }
1816 }
1817
1818 function InheriteAlbumFollow($albumId, $logId, $authorId = false)
1819 {
1820 $albumId = intval($albumId);
1821 $logId = intval($logId);
1822
1823 if (
1824 !$albumId
1825 || !$logId
1826 )
1827 {
1828 return false;
1829 }
1830
1831 $dbAlbumLogEntry = CSocNetLog::GetList(
1832 array("ID" => "DESC"),
1833 array(
1834 "EVENT_ID" => "photo",
1835 "SOURCE_ID" => $albumId
1836 ),
1837 false,
1838 false,
1839 array("ID")
1840 );
1841
1842 if ($arAlbumLogEntry = $dbAlbumLogEntry->Fetch())
1843 {
1844 $rsFollower = CSocNetLogFollow::GetList(
1845 array(
1846 "CODE" => "L".$arAlbumLogEntry["ID"],
1847 ),
1848 array("USER_ID", "TYPE")
1849 );
1850
1851 while ($arFollower = $rsFollower->Fetch())
1852 {
1853 if ($arFollower["TYPE"] == 'Y')
1854 {
1855 $subscribeTypeList = array(
1856 'COUNTER_COMMENT_PUSH'
1857 );
1858
1859 if (
1860 !$authorId
1861 || intval($authorId) != $arFollower["USER_ID"]
1862 )
1863 {
1864 $subscribeTypeList[] = 'FOLLOW';
1865 }
1866
1868 'logId' => $logId,
1869 'userId' => $arFollower["USER_ID"],
1870 'typeList' => $subscribeTypeList,
1871 'followDate' => 'CURRENT'
1872 ));
1873 }
1874 elseif (
1875 !$authorId
1876 || intval($authorId) != $arFollower["USER_ID"]
1877 )
1878 {
1879 CSocNetLogFollow::Set($arFollower["USER_ID"], "L".$logId, 'N', ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL", SITE_ID));
1880 }
1881 }
1882 }
1883 }
1884
1886 {
1887 if (!$this->IsSocnet)
1888 return;
1889
1890 if (intval($ID) > 0)
1891 {
1893 array("ID" => "DESC"),
1894 array(
1895 "EVENT_ID" => "photo_comment",
1896 "SOURCE_ID" => $ID
1897 ),
1898 false,
1899 false,
1900 array("ID", "LOG_ID")
1901 );
1902
1903 if ($arRes = $dbRes->Fetch())
1904 {
1906
1907 if ($res)
1908 {
1910 array(),
1911 array("ID" => $arRes["LOG_ID"]),
1912 false,
1913 false,
1914 array("ID", "COMMENTS_COUNT")
1915 );
1916
1917 if ($arLog = $dbResult->Fetch())
1918 {
1919 if ($arLog["COMMENTS_COUNT"] == 0)
1920 CSocNetLog::Delete($arRes["LOG_ID"]);
1921 }
1922 }
1923 }
1924 }
1925 }
1926
1927 public static function NotifyIm($arParams)
1928 {
1929 if(
1930 !CModule::IncludeModule("im")
1931 || intval($arParams["PHOTO_AUTHOR_ID"]) <= 0
1932 || $arParams["PHOTO_AUTHOR_ID"] == intval($arParams["COMMENT_AUTHOR_ID"])
1933 )
1934 return;
1935
1936 if (!array_key_exists("SECTION_NAME", $arParams))
1937 $arParams["SECTION_NAME"] = "";
1938 if (!array_key_exists("SECTION_URL", $arParams))
1939 $arParams["SECTION_URL"] = 0;
1940
1941 $arMessageFields = array(
1942 "MESSAGE_TYPE" => IM_MESSAGE_SYSTEM,
1943 "TO_USER_ID" => $arParams["PHOTO_AUTHOR_ID"],
1944 "FROM_USER_ID" => $arParams["COMMENT_AUTHOR_ID"],
1945 "NOTIFY_TYPE" => IM_NOTIFY_FROM,
1946 "NOTIFY_MODULE" => "photogallery",
1947 "NOTIFY_EVENT" => "comment",
1948 );
1949
1950 $rsLog = CSocNetLog::GetList(
1951 array(),
1952 array(
1953 "EVENT_ID" => array("photo_photo"),
1954 "SOURCE_ID" => $arParams["ID"]
1955 ),
1956 false,
1957 false,
1958 array("ID")
1959 );
1960 if ($arLog = $rsLog->Fetch())
1961 {
1962 $rsUnFollower = CSocNetLogFollow::GetList(
1963 array(
1964 "USER_ID" => $arParams["PHOTO_AUTHOR_ID"],
1965 "CODE" => "L".$arLog["ID"],
1966 "TYPE" => "N"
1967 ),
1968 array("USER_ID")
1969 );
1970 if ($arUnFollower = $rsUnFollower->Fetch())
1971 return;
1972
1973 $arMessageFields["LOG_ID"] = $arLog["ID"];
1974 }
1975
1976 $arParams["TITLE"] = str_replace(Array("\r\n", "\n"), " ", $arParams["TITLE"]);
1977 $arParams["TITLE"] = TruncateText($arParams["TITLE"], 100);
1978 $arParams["TITLE_OUT"] = TruncateText($arParams["TITLE"], 255);
1979
1980 $arTmp = CSocNetLogTools::ProcessPath(array("PHOTO_URL" => $arParams["URL"], "SECTION_URL" => $arParams["SECTION_URL"]), $arParams["PHOTO_AUTHOR_ID"]);
1981 $serverName = $arTmp["SERVER_NAME"];
1982 $arParams["URL"] = $arTmp["URLS"]["PHOTO_URL"];
1983 $arParams["SECTION_URL"] = $arTmp["URLS"]["SECTION_URL"];
1984
1985 $arMessageFields["NOTIFY_TAG"] = "PHOTO|COMMENT|".$arParams["ID"];
1986 $arMessageFields["NOTIFY_MESSAGE"] = fn (?string $languageId = null) => Bitrix\Main\Localization\Loc::getMessage(
1987 "SONET_PHOTO_IM_COMMENT",
1988 [
1989 "#photo_title#" => "<a href=\"".$arParams["URL"]."\" class=\"bx-notifier-item-action\">".htmlspecialcharsbx($arParams["TITLE"])."</a>",
1990 "#album_title#" => "<a href=\"".$arParams["SECTION_URL"]."\" class=\"bx-notifier-item-action\">".htmlspecialcharsbx($arParams["SECTION_NAME"])."</a>"
1991 ],
1992 $languageId
1993 );
1994 $arMessageFields["NOTIFY_MESSAGE_OUT"] = fn (?string $languageId = null) =>
1996 "SONET_PHOTO_IM_COMMENT",
1997 [
1998 "#photo_title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]),
1999 "#album_title#" => htmlspecialcharsbx($arParams["SECTION_NAME"])
2000 ],
2001 $languageId
2002 )
2003 ." (".$serverName.$arParams["URL"].")#BR##BR#".$arParams["MESSAGE"];
2004
2005 $ID = CIMNotify::Add($arMessageFields);
2006
2007 if(!empty($arParams["COMMENT_MENTION_ID"]))
2008 {
2009 //
2010 }
2011 }
2012
2013}
2014
2015?>
$arParams
Определения access_dialog.php:21
$db_res
Определения options_user_settings.php:8
$arResult
Определения generate_coupon.php:16
static getMessage($code, $replace=null, $language=null)
Определения loc.php:30
static userLogSubscribe($params=array())
Определения componenthelper.php:4799
static GetByUrl($BLOG_URL, $arGroup=Array())
Определения blog.php:1026
static GetUserIP()
Определения blog_user.php:617
static Filter($message)
Определения filter_dictionary.php:590
static GetByIDEx($ID, $arAddParams=array())
Определения message.php:641
static GetByID($ID)
Определения forum_new.php:1399
static Delete($ID, $bSetSource=false)
Определения log_comments.php:161
static CounterIncrement( $entityId, $eventId='', $entitiesList=false, $type=CSocNetLogCounter::TYPE_LOG_ENTRY, $forAllAccess=false, $userIdToPushList=[])
Определения log.php:436
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"=>"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 GetListEx($arOrder=Array("ID"=>"ASC"), $arFilter=Array(), $bCount=false, $iNum=0, $arAddParams=array())
Определения message.php:489
static Add($arFields, $bSetSource=false, $bSendEvent=true, $bSetLogUpDate=true)
Определения log_comments.php:16
static GetList($arOrder=Array("ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array(), $arParams=array())
Определения log_comments.php:519
static Delete($ID)
Определения log.php:1294
static Add($arFields, $bSendEvent=true)
Определения log.php:20
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 SetForSonet($logID, $entity_type, $entity_id, $feature, $operation, $bNew=false)
Определения log_rights.php:320
static DeleteByLogID($LOG_ID)
Определения log_rights.php:232
static GetList($aSort=array(), $aFilter=array())
Определения log_rights.php:256
static Add($LOG_ID, $GROUP_CODE, $bShare=false, $followSet=true)
Определения log_rights.php:8
static AddComment_Review_CreateRoot_Blog($arElement, $blogID)
Определения log_tools.php:4269
static AddComment_Review_UpdateElement_Blog($arElement, $postID, $blogID, $bNewPost)
Определения log_tools.php:4335
static AddComment_Review_CreateRoot_Forum($arElement, $forumID, $bPostFirstMessage=false, $strFirstMessage="")
Определения log_tools.php:4169
static AddComment_Review_CheckIBlock_Blog($arElement)
Определения log_tools.php:4109
static AddComment_Review_UpdateElement_Forum($arElement, $topicID, $bNewTopic)
Определения log_tools.php:4320
static AddComment_Review_CheckIBlock_Forum($arElement)
Определения log_tools.php:4054
static UpdateComment_Forum($arFields)
Определения log_tools.php:3397
static ProcessPath($arUrl, $user_id, $explicit_site_id=false)
Определения log_tools.php:5283
static DeleteComment_Forum($arFields)
Определения log_tools.php:3484
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
OnAfterPhotoCommentAddForum($ID, $arFields)
Определения log_tools_photo.php:1204
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
InheriteAlbumFollow($albumId, $logId, $authorId=false)
Определения log_tools_photo.php:1818
static FindLogType($logID)
Определения log_tools_photo.php:813
OnAfterPhotoCommentDeleteBlog($ID)
Определения log_tools_photo.php:1885
UpdateComment_Photo($arFields)
Определения log_tools_photo.php:1106
SetVars($arParams, $arResult)
Определения log_tools_photo.php:1153
static AddComment_Photo($arFields)
Определения log_tools_photo.php:876
AddComment_PhotoAlbum($arFields)
Определения log_tools_photo.php:720
static NotifyIm($arParams)
Определения log_tools_photo.php:1927
OnAfterPhotoCommentAddBlog($ID, $arFields)
Определения log_tools_photo.php:1529
DeleteComment_Photo($arFields)
Определения log_tools_photo.php:1130
Определения functions.php:6
Определения functions.php:18
$arFields
Определения dblapprove.php:5
$arPath
Определения file_edit.php:72
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
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
if($ajaxMode) $ID
Определения get_user.php:27
$dbElement
Определения group_wiki_post_comment.php:22
$elementID
Определения group_wiki_post_comment.php:17
$dbMessage
Определения group_wiki_post_comment.php:12
const IM_MESSAGE_SYSTEM
Определения include.php:21
const IM_NOTIFY_FROM
Определения include.php:37
$strError
Определения options_user_settings.php:4
global $DB
Определения cron_frame.php:29
global $USER
Определения csv_new_run.php:40
htmlspecialcharsback($str)
Определения tools.php:2693
IsModuleInstalled($module_id)
Определения tools.php:5301
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
is_set($a, $k=false)
Определения tools.php:2133
GetMessage($name, $aReplace=null)
Определения tools.php:3397
AddToTimeStamp($arrAdd, $stmp=false)
Определения tools.php:687
TruncateText($strText, $intLen)
Определения tools.php:2185
if(intval($iTestTransaction) > 0) $arTmp
Определения payment.php:22
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
</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
$title
Определения pdf.php:123
const SONET_ROLES_USER
Определения include.php:31
const SONET_ENTITY_GROUP
Определения include.php:117
const SONET_ENTITY_USER
Определения include.php:118
$arRes
Определения options.php:104
const SITE_ID
Определения sonet_set_content_view.php:12
$GLOBALS['_____370096793']
Определения update_client.php:1
$dbResult
Определения updtr957.php:3
$arFilter
Определения user_search.php:106
$url
Определения iframe.php:7
$dbRes
Определения yandex_detail.php:168
$arIBlock['PROPERTY']
Определения yandex_detail.php:172