1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
search.php
См. документацию.
1<?php
2
4{
8
9 /*
10 arParams
11 PATH_TO_GROUP
12
13 PATH_TO_GROUP_BLOG
14 PATH_TO_USER_BLOG
15
16 FORUM_ID
17 PATH_TO_GROUP_FORUM_MESSAGE
18 PATH_TO_USER_FORUM_MESSAGE
19
20 PHOTO_GROUP_IBLOCK_ID
21 PATH_TO_GROUP_PHOTO_ELEMENT
22 PHOTO_USER_IBLOCK_ID
23 PATH_TO_USER_PHOTO_ELEMENT
24
25 CALENDAR_GROUP_IBLOCK_ID
26 PATH_TO_GROUP_CALENDAR_ELEMENT
27
28 PATH_TO_GROUP_TASK_ELEMENT
29 PATH_TO_USER_TASK_ELEMENT
30
31 FILES_PROPERTY_CODE
32 FILES_FORUM_ID
33 FILES_GROUP_IBLOCK_ID
34 PATH_TO_GROUP_FILES_ELEMENT
35 PATH_TO_GROUP_FILES
36 FILES_USER_IBLOCK_ID
37 PATH_TO_USER_FILES_ELEMENT
38 PATH_TO_USER_FILES
39 */
40 public function __construct($user_id, $group_id, $arParams)
41 {
42 $this->_user_id = intval($user_id);
43 $this->_group_id = intval($group_id);
44 $this->_params = $arParams;
45 }
46
47 public static function OnUserRelationsChange($user_id)
48 {
49 if(CModule::IncludeModule('search'))
50 {
52 }
53
55 $provider->DeleteByUser($user_id);
56
58 $provider->DeleteByUser($user_id);
59
61 while ($arFriend = $dbFriend->Fetch())
62 {
63 $friendID = (($user_id == $arFriend["FIRST_USER_ID"]) ? $arFriend["SECOND_USER_ID"] : $arFriend["FIRST_USER_ID"]);
64 $provider->DeleteByUser($friendID);
65 }
66 }
67
68 public static function SetFeaturePermissions($entity_type, $entity_id, $feature, $operation, $new_perm)
69 {
70 if(mb_substr($operation, 0, 4) === "view")//This kind of extremely dangerous optimization
71 {
72 global $arSonetFeaturesPermsCache;
73 unset($arSonetFeaturesPermsCache[$entity_type."_".$entity_id]);
74
75 if(CModule::IncludeModule('search'))
76 {
77 $arGroups = self::GetSearchGroups($entity_type, $entity_id, $feature, $operation);
78 $arParams = self::GetSearchParams($entity_type, $entity_id, $feature, $operation);
79
80 CSearch::ChangePermission(false, $arGroups, false, false, false, false, $arParams);
81 }
82 }
83 if (
84 $feature === "blog"
85 && in_array($operation, Array("view_post", "view_comment"))
86 && CModule::IncludeModule('blog')
87 )
88 {
89 if($operation === "view_post")
90 {
91 CBlogPost::ChangeSocNetPermission($entity_type, $entity_id, $operation);
92 }
93
94 if(CModule::IncludeModule('search'))
95 {
96 if($operation === "view_post")
97 {
98 $arPost = CBlogPost::GetSocNetPostsPerms($entity_type, $entity_id);
99 foreach($arPost as $id => $perms)
100 {
101 CSearch::ChangePermission("blog", $perms["PERMS"], "P".$id);
102 }
103 }
104 else
105 {
106 $arTmpCache = Array();
107 $arPost = CBlogPost::GetSocNetPostsPerms($entity_type, $entity_id);
108 $dbComment = CBlogComment::GetSocNetPostsPerms($entity_type, $entity_id);
109 while($arComment = $dbComment->Fetch())
110 {
111 if(!empty($arPost[$arComment["POST_ID"]]))
112 {
113 if(empty($arPost[$arComment["POST_ID"]]["PERMS_CALC"]))
114 {
115 $arPost[$arComment["POST_ID"]]["PERMS_CALC"] = array();
116 if(is_array($arPost[$arComment["POST_ID"]]["PERMS_FULL"]) && !empty($arPost[$arComment["POST_ID"]]["PERMS_FULL"]))
117 {
118 foreach($arPost[$arComment["POST_ID"]]["PERMS_FULL"] as $e => $v)
119 {
120 if(in_array($v["TYPE"], Array("SG", "U")))
121 {
122 $type = $v["TYPE"] === "SG" ? "G" : "U";
123 if(array_key_exists($type.$v["ID"], $arTmpCache))
124 {
125 $spt = $arTmpCache[$type.$v["ID"]];
126 }
127 else
128 {
129 $spt = CBlogPost::GetSocnetGroups($type, $v["ID"], "view_comment");
130 $arTmpCache[$type.$v["ID"]] = $spt;
131 }
132 foreach($spt as $vv)
133 {
134 if(!in_array($vv, $arPost[$arComment["POST_ID"]]["PERMS_CALC"]))
135 $arPost[$arComment["POST_ID"]]["PERMS_CALC"][] = $vv;
136 }
137 }
138 else
139 {
140 $arPost[$arComment["POST_ID"]]["PERMS_CALC"][] = $e;
141 }
142 }
143 }
144 }
145
146 CSearch::ChangePermission("blog", $arPost[$arComment["POST_ID"]]["PERMS_CALC"], "C".$arComment["ID"]);
147 }
148 }
149 }
150 }
151 }
152 }
153
154 public static function GetSearchParams($entity_type, $entity_id, $feature, $operation)
155 {
156 return array(
157 "feature_id" => "S".$entity_type."_".$entity_id."_".$feature."_".$operation,
158 ($entity_type === "G"? "socnet_group": "socnet_user") => $entity_id,
159 );
160 }
161
162 public static function GetSearchGroups($entity_type, $entity_id, $feature, $operation)
163 {
164 $arResult = array();
165
166 if($entity_type === "G")
167 {
168 $prefix = "SG".$entity_id."_";
169 $letter = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $entity_id, $feature, $operation);
170 switch($letter)
171 {
172 case "N"://All
173 $arResult[] = 'G2';
174 break;
175 case "L"://Authorized
176 $arResult[] = 'AU';
177 break;
178 case "K"://Group members includes moderators and admins
179 $arResult[] = $prefix.'K';
180 $arResult[] = $prefix.'E';
181 $arResult[] = $prefix.'A';
182 break;
183 case "E"://Moderators includes admins
184 $arResult[] = $prefix.'E';
185 $arResult[] = $prefix.'A';
186 break;
187 case "A"://Admins
188 $arResult[] = $prefix.'A';
189 break;
190 }
191 }
192 else
193 {
194 $prefix = "SU".$entity_id."_";
195 $letter = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $entity_id, $feature, $operation);
196 switch($letter)
197 {
198 case "A"://All
199 $arResult[] = 'G2';
200 break;
201 case "C"://Authorized
202 $arResult[] = 'AU';
203 break;
204 case "E"://Friends of friends (has no rights yet) so it counts as
205 case "M"://Friends
206 $arResult[] = $prefix.'M';
207 $arResult[] = $prefix.'Z';
208 break;
209 case "Z"://Personal
210 $arResult[] = $prefix.'Z';
211 break;
212 }
213 }
214
215 return $arResult;
216 }
217
218 public static function OnSearchReindex($NS = Array(), $oCallback = NULL, $callback_method = "")
219 {
220 global $DB;
221 $arResult = array();
222
223 if ($NS["MODULE"] === "socialnetwork" && $NS["ID"] <> '')
224 {
225 $id = (int)$NS["ID"];
226 }
227 else
228 {
229 $id = 0;//very first id
230 }
231
232 $strNSJoin1 = "";
233 $strNSFilter1 = "";
234
235 if($NS["SITE_ID"]!="")
236 {
237 $strNSJoin1 .= " INNER JOIN b_sonet_group_site sgs ON sgs.GROUP_ID=g.ID ";
238 $strNSFilter1 .= " AND sgs.SITE_ID='".$DB->ForSQL($NS["SITE_ID"])."' ";
239 }
240
241 $strSql = "
242 SELECT
243 g.ID
244 ,".$DB->DateToCharFunction("g.DATE_UPDATE")." as DATE_UPDATE
245 ,g.NAME
246 ,g.DESCRIPTION
247 ,g.SUBJECT_ID
248 ,g.KEYWORDS
249 ,g.VISIBLE
250 FROM
251 b_sonet_group g
252 ".$strNSJoin1."
253 WHERE
254 g.ACTIVE = 'Y'
255 ".$strNSFilter1."
256 AND g.ID > ".$id."
257 ORDER BY
258 g.ID
259 ";
260
261 $rs = $DB->Query($strSql);
262 while ($ar = $rs->Fetch())
263 {
264 $arSearchIndexSiteID = array();
265 $rsGroupSite = CSocNetGroup::GetSite($ar["ID"]);
266
267 while($arGroupSite = $rsGroupSite->Fetch())
268 $arSearchIndexSiteID[$arGroupSite["LID"]] = str_replace("#group_id#", $ar["ID"], \Bitrix\Socialnetwork\Helper\Path::get('group_path_template', $arGroupSite['LID']));
269
270 $Result = Array(
271 "ID" => "G".$ar["ID"],
272 "LAST_MODIFIED" => $ar["DATE_UPDATE"],
273 "TITLE" => $ar["NAME"],
274 "BODY" => CSocNetTextParser::killAllTags($ar["DESCRIPTION"]),
275 "SITE_ID" => $arSearchIndexSiteID,
276 "PARAM1" => $ar["SUBJECT_ID"],
277 "PARAM2" => $ar["ID"],
278 "PARAM3" => "GROUP",
279 "PERMISSIONS" => (
280 $ar["VISIBLE"] === "Y"?
281 array('G2')://public
282 array(
283 'SG'.$ar["ID"].'_A',//admins
284 'SG'.$ar["ID"].'_E',//moderators
285 'SG'.$ar["ID"].'_K',//members
286 )
287 ),
288 "PARAMS" =>array(
289 "socnet_group" => $ar["ID"],
290 "entity" => "socnet_group",
291 ),
292 "TAGS" => $ar["KEYWORDS"],
293 );
294
295 if($oCallback)
296 {
297 $res = call_user_func(array(&$oCallback, $callback_method), $Result);
298 if(!$res)
299 return $Result["ID"];
300 }
301 else
302 $arResult[] = $Result;
303 }
304
305 if ($oCallback)
306 return false;
307
308 return $arResult;
309 }
310
311 public static function OnSearchPrepareFilter($strSearchContentAlias, $field, $val)
312 {
313 global $CACHE_MANAGER;
314
315 if(defined("BX_COMP_MANAGED_CACHE") && in_array($field, array("SOCIAL_NETWORK_USER", "SOCIAL_NETWORK_GROUP")))
316 {
317 $tag_val = (is_array($val) ? serialize($val) : $val);
318 $tag_field = ($field === "SOCIAL_NETWORK_GROUP" ? SONET_ENTITY_GROUP : SONET_ENTITY_USER);
319 $CACHE_MANAGER->RegisterTag("sonet_search_".$tag_field."_".$tag_val);
320 }
321 }
322
323 public static function OnSearchCheckPermissions($FIELD)
324 {
325 global $USER;
326
327 $currentUserId = (int)$USER->GetID();
328 $arResult = array();
329
330 if ($currentUserId > 0)
331 {
332 $arResult[] = "SU".$currentUserId."_Z";
334 array(),
335 array(
336 "USER_ID" => $currentUserId,
337 "RELATION" => SONET_RELATIONS_FRIEND
338 ),
339 false,
340 false,
341 array("ID", "FIRST_USER_ID", "SECOND_USER_ID", "DATE_CREATE", "DATE_UPDATE", "INITIATED_BY")
342 );
343 while ($arFriend = $rsFriends->Fetch())
344 {
345 if ((int)$arFriend["FIRST_USER_ID"] !== $currentUserId)
346 {
347 $arResult[] = "SU".$arFriend["FIRST_USER_ID"]."_M";
348 }
349
350 if ((int)$arFriend["SECOND_USER_ID"] !== $currentUserId)
351 {
352 $arResult[] = "SU".$arFriend["SECOND_USER_ID"]."_M";
353 }
354 }
355 }
356
357 $rsGroups = CSocNetUserToGroup::GetList(
358 array(),
359 array("USER_ID" => $currentUserId),
360 false,
361 false,
362 array("GROUP_ID", "ROLE")
363 );
364 while($arGroup = $rsGroups->Fetch())
365 {
366 $arResult[] = "SG".$arGroup["GROUP_ID"]."_".$arGroup["ROLE"];
367 }
368
369 return $arResult;
370 }
371
372 function BeforeIndexForum($arFields, $entity_type, $entity_id, $feature, $operation, $path_template)
373 {
374 global $USER;
375 static $arSiteData;
376
377 $SECTION_ID = "";
378 $ELEMENT_ID = intval($_REQUEST["photo_element_id"] ?? 0);
379 if (empty($ELEMENT_ID))
380 {
381 $ELEMENT_ID = intval($_REQUEST["ELEMENT_ID"] ?? 0);
382 }
383
384 if(
385 $ELEMENT_ID > 0
386 && CModule::IncludeModule('iblock')
387 )
388 {
389 $rsSections = CIBlockElement::GetElementGroups($ELEMENT_ID, true);
390 $arSection = $rsSections->Fetch();
391 if($arSection)
392 {
393 $SECTION_ID = $arSection["ID"];
394 }
395 }
396
397 if (
398 count($arFields["LID"]) > 1
399 && (
400 (
401 $entity_type == SONET_ENTITY_GROUP
402 && CModule::IncludeModule("extranet")
403 )
404 || $entity_type == SONET_ENTITY_USER
405 )
406 )
407 {
408 if (!$arSiteData)
409 {
410 $arSiteData = CSocNetLogTools::GetSiteData();
411 }
412
413 foreach($arSiteData as $arUrl)
414 {
415 if($entity_type === SONET_ENTITY_GROUP
416 && mb_strpos($path_template, $arUrl["GROUPS_PATH"]) === 0)
417 {
418 $path_template = str_replace($arUrl["GROUPS_PATH"], "#GROUP_PATH#", $path_template);
419 break;
420 }
421
422 if (
423 $entity_type === SONET_ENTITY_USER
424 && mb_strpos($path_template, $arUrl["USER_PATH"]) === 0
425 )
426 {
427 $path_template = str_replace($arUrl["USER_PATH"], "#USER_PATH#", $path_template);
428 break;
429 }
430 }
431 }
432
433 foreach($arFields["LID"] as $site_id => $url)
434 {
435 $arFields["URL"] = $arFields["LID"][$site_id] = str_replace(
436 array(
437 "#user_id#",
438 "#group_id#",
439 "#topic_id#",
440 "#message_id#",
441 "#action#",
442 "#user_alias#",
443 "#section_id#",
444 "#element_id#",
445 "#task_id#",
446 "#GROUP_PATH#",
447 "#USER_PATH#"
448 ),
449 array(
450 ($this->_user_id > 0 ? $this->_user_id : $USER->GetID()),
451 $this->_group_id,
452 $arFields["PARAM2"],
453 $arFields["ITEM_ID"],
454 "view",
455 ($entity_type === "G" ? "group_" : "user_") . $entity_id,
456 $SECTION_ID,
457 $ELEMENT_ID,
458 $ELEMENT_ID,
459 ($arSiteData ? $arSiteData[$site_id]["GROUPS_PATH"] : ""),
460 ($arSiteData ? $arSiteData[$site_id]["USER_PATH"] : "")
461 ),
462 $path_template
463 );
464 }
465
466 if (
467 $feature === 'tasks'
468 && $arFields["PARAM1"] == COption::GetOptionString("tasks", "task_forum_id", 0)
469 && CModule::IncludeModule('tasks')
470 )
471 {
472 if (!preg_match('/^EVENT_[0-9]+/', $arFields["TITLE"], $match)) // calendar comments live in the same TASK_FORUM_ID :(
473 {
474 $rsTask = CTasks::GetList(array(), array("FORUM_TOPIC_ID" => $arFields['PARAM2']));
475 if ($arTask = $rsTask->Fetch())
476 {
477 $arFields['PERMISSIONS'] = CTasks::__GetSearchPermissions($arTask);
478 }
479 }
480 }
481 else
482 {
483 $arFields["PERMISSIONS"] = self::GetSearchGroups(
484 $entity_type,
485 $entity_id,
486 $feature,
487 $operation
488 );
489
490 $paramsTmp = self::GetSearchParams(
491 $entity_type,
492 $entity_id,
493 $feature,
494 $operation
495 );
496 $arFields["PARAMS"] = (!empty($arFields["PARAMS"]) ? array_merge($paramsTmp, $arFields["PARAMS"]) : $paramsTmp);
497 }
498
499 return $arFields;
500 }
501
502 function Url($url, $params, $ancor)
503 {
504 $url_params = array();
505 $p = mb_strpos($url, "?");
506 if($p !== false)
507 {
508 $ar = explode("&", mb_substr($url, $p + 1));
509 foreach($ar as $str)
510 {
511 list($name, $value) = explode("=", $str, 2);
512 $url_params[$name] = $name."=".$value;
513 }
514 $url = mb_substr($url, 0, $p);
515 }
516
517 foreach($params as $name => $value)
518 $url_params[$name] = $name."=".$value;
519
520 if(count($url_params))
521 return $url."?".implode("&", $url_params).($ancor <> ''? "#".$ancor : "");
522 else
523 return $url.($ancor <> ''? "#".$ancor : "");
524 }
525
527 {
528 //Check if we in right context
529 if (
530 !isset($this)
531 || !is_object($this)
532 || !is_array($this->_params)
533 )
534 {
535 return $arFields;
536 }
537
538 if (isset($arFields["REINDEX_FLAG"]))
539 {
540 return $arFields;
541 }
542
543 //This was group modification
544 if($this->_group_id)
545 {
546 if(
547 $arFields["MODULE_ID"] === "forum"
548 && (int) $arFields["PARAM1"] === (int) ($this->_params["FORUM_ID"] ?? null)
549 )
550 {
551 // forum feature
552 $arFields["LID"] = array();
553 $rsGroupSite = CSocNetGroup::GetSite($this->_group_id);
554 while($arGroupSite = $rsGroupSite->Fetch())
555 {
556 $arFields["LID"][$arGroupSite["LID"]] = $arFields["URL"];
557 }
558
560 SONET_ENTITY_GROUP, $this->_group_id,
561 "forum", "view",
562 $this->_params["PATH_TO_GROUP_FORUM_MESSAGE"]
563 );
564 }
565 elseif(
566 $arFields["MODULE_ID"] === "forum"
567 && (int) $arFields["PARAM1"] === (int) ($this->_params["FILES_FORUM_ID"] ?? null)
568 && isModuleInstalled("webdav")
569 )
570 {
572 SONET_ENTITY_GROUP, $this->_group_id,
573 "files", "view",
574 $this->Url($this->_params["PATH_TO_GROUP_FILES_ELEMENT"], array("MID"=>"#message_id#"), "message#message_id#")
575 );
576 }
577 elseif(
578 $arFields["MODULE_ID"] === "forum"
579 && (int)$arFields["PARAM1"] === (int)$this->_params["TASK_FORUM_ID"]
580 && !preg_match('/^EVENT_[0-9]+/', $arFields["TITLE"], $match) // calendar comments live in the same TASK_FORUM_ID :(
581 )
582 {
583 }
584 elseif (
585 $arFields["MODULE_ID"] === "forum"
586 && preg_match('/^EVENT_[0-9]+/', $arFields["TITLE"], $match)
587 )
588 {
589 $arFields["TITLE"] = "";
590 $arFields["BODY"] = "";
591 }
592 elseif (
593 $arFields["MODULE_ID"] === "forum"
594 && (int) $arFields["PARAM1"] === (int) ($this->_params["PHOTO_FORUM_ID"] ?? null)
595 )
596 {
598 SONET_ENTITY_GROUP, $this->_group_id,
599 "photo", "view",
600 $this->Url($this->_params["PATH_TO_GROUP_PHOTO_ELEMENT"], array("MID"=>"#message_id#"), "message#message_id#")
601 );
602 }
603 }
604 elseif($this->_user_id)
605 {
606 if(
607 $arFields["MODULE_ID"] === "forum"
608 && (int) $arFields["PARAM1"] === (int) ($this->_params["FORUM_ID"] ?? null)
609 )
610 {
611 // forum feature
612 $arFields["LID"] = array(SITE_ID => $arFields["URL"]);
613
615 SONET_ENTITY_USER, $this->_user_id,
616 "forum", "view",
617 $this->_params["PATH_TO_USER_FORUM_MESSAGE"]
618 );
619 }
620 elseif(
621 $arFields["MODULE_ID"] === "forum"
622 && (int) $arFields["PARAM1"] === (int) ($this->_params["FILES_FORUM_ID"] ?? null)
623 && isModuleInstalled("webdav")
624 )
625 {
627 SONET_ENTITY_USER, $this->_user_id,
628 "files", "view",
629 $this->Url($this->_params["PATH_TO_USER_FILES_ELEMENT"], array("MID"=>"#message_id#"), "message#message_id#")
630 );
631 }
632 elseif(
633 $arFields["MODULE_ID"] === "forum"
634 && (int) $arFields["PARAM1"] === (int) ($this->_params["TASK_FORUM_ID"] ?? null)
635 )
636 {
637 }
638 elseif(
639 $arFields["MODULE_ID"] === "forum"
640 && preg_match('/^EVENT_[0-9]+/', $arFields["TITLE"], $match)
641 ) // don't index calendar comments!
642 {
643 $arFields["TITLE"] = "";
644 $arFields["BODY"] = "";
645 }
646 elseif(
647 $arFields["MODULE_ID"] === "forum"
648 && (int) $arFields["PARAM1"] === (int) ($this->_params["PHOTO_FORUM_ID"] ?? null)
649 )
650 {
652 $arFields,
654 $this->_user_id,
655 "photo",
656 "view",
657 $this->Url(
658 $this->_params["PATH_TO_USER_PHOTO_ELEMENT"],
659 array("MID"=>"#message_id#"),
660 "message#message_id#"
661 )
662 );
663 }
664 elseif(
665 $arFields["MODULE_ID"] === "blog"
666 && (
667 ($arFields["PARAM1"] ?? null) === "POST"
668 || ($arFields["PARAM1"] ?? null) === "MICROBLOG"
669 )
670 )
671 {
672 $paramsTmp = self::GetSearchParams(
673 SONET_ENTITY_USER, $this->_user_id,
674 'blog', 'view_post'
675 );
676 $arFields["PARAMS"] = (
677 !empty($arFields["PARAMS"])
678 ? array_merge($paramsTmp, $arFields["PARAMS"])
679 : $paramsTmp
680 );
681 }
682 elseif(
683 $arFields["MODULE_ID"] === "blog"
684 && ($arFields["PARAM1"] ?? null) === "COMMENT"
685 )
686 {
687 $paramsTmp = self::GetSearchParams(
688 SONET_ENTITY_USER, $this->_user_id,
689 'blog', 'view_comment'
690 );
691 $arFields["PARAMS"] = (
692 !empty($arFields["PARAMS"])
693 ? array_merge($paramsTmp, $arFields["PARAMS"])
694 : $paramsTmp
695 );
696 }
697 }
698
699 foreach(GetModuleEvents("socialnetwork", "BeforeIndexSocNet", true) as $arEvent)
700 {
701 $arEventResult = ExecuteModuleEventEx($arEvent, array($this, $arFields));
702 if(is_array($arEventResult))
703 {
704 $arFields = $arEventResult;
705 }
706 }
707
708 return $arFields;
709 }
710
711 public static function BeforeIndexLast($arFields)
712 {
713 if(
714 $arFields["MODULE_ID"] === "blog"
715 && ($arFields["PARAM1"] ?? null) === "USER"
716 )
717 {
718 $arFields["TITLE"] = "";
719 $arFields["BODY"] = "";
720 }
721
722 return $arFields;
723 }
724
725 function IndexIBlockElement($arFields, $entity_id, $entity_type, $feature, $operation, $path_template, $arFieldList)
726 {
727 global $CACHE_MANAGER;
728
729 $ID = (int)$arFields["ID"];
730 $IBLOCK_ID = (int)$arFields["IBLOCK_ID"];
731 $IBLOCK_SECTION_ID = (is_array($arFields["IBLOCK_SECTION"])) ? $arFields["IBLOCK_SECTION"][0] : $arFields["IBLOCK_SECTION"];
732
733 if($entity_type === "G")
734 {
735 $url = str_replace(
736 array("#group_id#", "#user_alias#", "#section_id#", "#element_id#", "#action#", "#task_id#", "#name#"),
737 array($entity_id, "group_".$entity_id, $IBLOCK_SECTION_ID, $arFields["ID"], "view", $arFields["ID"], rawurlencode($arFields["NAME"])),
738 $path_template
739 );
740 }
741 else
742 {
743 $url = str_replace(
744 array("#user_id#", "#user_alias#", "#section_id#", "#element_id#", "#action#", "#task_id#"),
745 array($entity_id, "user_".$entity_id, $IBLOCK_SECTION_ID, $arFields["ID"], "view", $arFields["ID"]),
746 $path_template
747 );
748 }
749
750 $body = "";
751 if ($feature === "wiki")
752 {
753 $CWikiParser = new CWikiParser();
754 }
755
756 foreach($arFieldList as $field)
757 {
758 if($field === "PREVIEW_TEXT" || $field === "DETAIL_TEXT")
759 {
760 $key = $field . "_TYPE";
761 if (isset($CWikiParser))
762 {
763 $arFields[$field] = HTMLToTxt($CWikiParser->parseForSearch($arFields[$field] ?? ''));
764 }
765 elseif (isset($arFields[$key]) && $arFields[$key] === "html")
766 {
767 $arFields[$field] = HTMLToTxt($arFields[$field]);
768 }
769 }
770
771 $body .= $arFields[$field]."\n\r";
772 }
773
774 if(isset($CWikiParser))
775 $title = preg_replace('/^category:/iu', GetMessage('CATEGORY_NAME').':', $arFields['NAME']);
776 else
777 $title = $arFields["NAME"];
778
779 $arPermissions = self::GetSearchGroups(
780 $entity_type,
781 $entity_id,
782 $feature,
783 $operation
784 );
785
786 if (CIBlock::GetArrayByID($IBLOCK_ID, "RIGHTS_MODE") === "E")
787 {
788 $obElementRights = new CIBlockElementRights($IBLOCK_ID, $arFields["ID"]);
789 $arPermissions = $obElementRights->GetGroups(array("element_read"));
790 }
791
792 $arSearchIndexParams = self::GetSearchParams(
793 $entity_type,
794 $entity_id,
795 $feature,
796 $operation
797 );
798
799 CSearch::Index("socialnetwork", $ID, array(
800 "LAST_MODIFIED" => ConvertTimeStamp(time()+CTimeZone::GetOffset(), "FULL"),
801 "TITLE" => $title,
802 "BODY" => $body,
803 "SITE_ID" => array(SITE_ID => $url),
804 "PARAM1" => CIBlock::GetArrayByID($IBLOCK_ID, "IBLOCK_TYPE_ID"),
805 "PARAM2" => $IBLOCK_ID,
806 "PARAM3" => $feature,
807 "TAGS" => $arFields["TAGS"] ?? null,
808 "PERMISSIONS" => $arPermissions,
809 "PARAMS" => $arSearchIndexParams,
810 ), true);
811
812 if(defined("BX_COMP_MANAGED_CACHE"))
813 {
814 $CACHE_MANAGER->ClearByTag("sonet_search_".$entity_type."_".$entity_id);
815 }
816 }
817
819 {
820 //Do not index workflow history
821 $WF_PARENT_ELEMENT_ID = intval($arFields["WF_PARENT_ELEMENT_ID"] ?? null);
822 if($WF_PARENT_ELEMENT_ID > 0 && $WF_PARENT_ELEMENT_ID != intval($arFields["ID"]))
823 return;
824
825 if(!CModule::IncludeModule('search'))
826 return;
827
828 //And do not index wf drafts
829 $rsElement = CIBlockElement::GetList(
830 array(),
831 array("=ID"=>$arFields["ID"]),
832 false,
833 false,
834 array(
835 "ID",
836 "NAME",
837 "IBLOCK_SECTION_ID",
838 "WF_PARENT_ELEMENT_ID",
839 "WF_STATUS_ID",
840 )
841 );
842 $dbElement = $rsElement->Fetch();
843 if(!$dbElement)
844 return;
845
846 if(!isset($arFields["NAME"]))
847 $arFields["NAME"] = $dbElement["NAME"];
848
849 if(!isset($arFields["IBLOCK_SECTION"]))
850 $arFields["IBLOCK_SECTION"] = $dbElement["IBLOCK_SECTION_ID"];
851 elseif (is_array($arFields["IBLOCK_SECTION"]) && isset($arFields["IBLOCK_SECTION"][0]))
852 $arFields["IBLOCK_SECTION"] = $arFields["IBLOCK_SECTION"][0];
853
854 switch(intval($arFields["IBLOCK_ID"]))
855 {
856
857 case intval($this->_params["PHOTO_GROUP_IBLOCK_ID"]):
858 $path_template = trim($this->_params["PATH_TO_GROUP_PHOTO_ELEMENT"]);
859 if($path_template <> '')
860 {
861 $this->IndexIBlockElement($arFields, $this->_group_id, "G", "photo", "view", $path_template, array("PREVIEW_TEXT"));
862 }
863 break;
864
865 case intval($this->_params["PHOTO_USER_IBLOCK_ID"]):
866 $path_template = trim($this->_params["PATH_TO_USER_PHOTO_ELEMENT"]);
867 if($path_template <> '')
868 {
869 $this->IndexIBlockElement($arFields, $this->_user_id, "U", "photo", "view", $path_template, array("PREVIEW_TEXT"));
870 }
871 break;
872
873 case intval($this->_params["CALENDAR_GROUP_IBLOCK_ID"]):
874 $path_template = trim($this->_params["PATH_TO_GROUP_CALENDAR_ELEMENT"]);
875 if($path_template <> '')
876 {
877 $this->IndexIBlockElement($arFields, $this->_group_id, "G", "calendar", "view", $path_template, array("DETAIL_TEXT"));
878 }
879 break;
880
881 case intval($this->_params["FILES_GROUP_IBLOCK_ID"] ?? null):
882 $path_template = trim($this->_params["PATH_TO_GROUP_FILES_ELEMENT"]);
883 if($path_template <> '')
884 {
885 $property = mb_strtoupper(trim($this->_params["FILES_PROPERTY_CODE"]));
886 if($property == '')
887 {
888 $property = "FILE";
889 }
890
891 $rsFile = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $arFields["ID"], "sort", "asc", array("CODE" => $property, "EMPTY" => "N"));
892 $arFile = $rsFile->Fetch();
893 if($arFile)
894 {
895 $arFile = CIBlockElement::__GetFileContent($arFile["VALUE"]);
896 if(is_array($arFile))
897 {
898 $arFields["FILE_CONTENT"] = $arFile["CONTENT"];
899 if($arFields["TAGS"] <> '')
900 {
901 $arFields["TAGS"] .= ",".$arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")];
902 }
903 else
904 {
905 $arFields["TAGS"] = $arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")];
906 }
907 }
908 }
909 $this->IndexIBlockElement($arFields, $this->_group_id, "G", "files", "view", $path_template, array("FILE_CONTENT", "DETAIL_TEXT"));
910 }
911 break;
912
913 case intval($this->_params["FILES_USER_IBLOCK_ID"] ?? null):
914 $path_template = trim($this->_params["PATH_TO_USER_FILES_ELEMENT"]);
915 if($path_template <> '')
916 {
917 $property = mb_strtoupper(trim($this->_params["FILES_PROPERTY_CODE"]));
918 if($property == '')
919 {
920 $property = "FILE";
921 }
922
923 $rsFile = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $arFields["ID"], "sort", "asc", array("CODE" => $property, "EMPTY" => "N"));
924 $arFile = $rsFile->Fetch();
925 if($arFile)
926 {
927 $arFile = CIBlockElement::__GetFileContent($arFile["VALUE"]);
928 if(is_array($arFile))
929 {
930 $arFields["FILE_CONTENT"] = $arFile["CONTENT"];
931 if($arFields["TAGS"] <> '')
932 {
933 $arFields["TAGS"] .= ",".$arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")];
934 }
935 else
936 {
937 $arFields["TAGS"] = $arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")];
938 }
939 }
940 }
941 $this->IndexIBlockElement($arFields, $this->_user_id, "U", "files", "view", $path_template, array("FILE_CONTENT", "DETAIL_TEXT"));
942 }
943 break;
944 case intval(COption::GetOptionInt("wiki", "socnet_iblock_id")):
945 if(CModule::IncludeModule("wiki"))
946 $this->IndexIBlockElement($arFields, $this->_group_id, "G", "wiki", "view", $this->_params["PATH_TO_GROUP"]."wiki/#name#/", array("DETAIL_TEXT"));
947 break;
948 }
949 }
950
951 public static function IBlockElementDelete($zr)
952 {
953 if(CModule::IncludeModule("search"))
954 {
955 CSearch::DeleteIndex("socialnetwork", intval($zr["ID"]));
956 }
957 }
958
959 function IndexIBlockSection($arFields, $entity_id, $entity_type, $feature, $operation, $path_template)
960 {
961 global $CACHE_MANAGER;
962
963 $path = array();
964 $rsPath = CIBlockSection::GetNavChain($arFields["IBLOCK_ID"], $arFields['ID']);
965 while ($arPath = $rsPath->Fetch())
966 {
967 $path[] = $arPath['NAME'];
968 }
969 $path = implode("/", array_slice($path, 1));
970
971 $ID = (int)$arFields["ID"];
972 $IBLOCK_ID = (int)$arFields["IBLOCK_ID"];
973
974 if($entity_type === "G")
975 $url = str_replace(
976 array("#group_id#", "#user_alias#", "#section_id#", "#element_id#", "#action#", "#task_id#", "#name#", "#path#"),
977 array($entity_id, "group_".$entity_id, $arFields["IBLOCK_SECTION"], $arFields["ID"], "view", $arFields["ID"], rawurlencode($arFields["NAME"]), $path),
978 $path_template
979 );
980 else
981 $url = str_replace(
982 array("#user_id#", "#user_alias#", "#section_id#", "#element_id#", "#action#", "#task_id#", "#path#"),
983 array($entity_id, "user_".$entity_id, $arFields["IBLOCK_SECTION"], $arFields["ID"], "view", $arFields["ID"], $path),
984 $path_template
985 );
986
987 $body = "";
988
989 $title = $arFields["NAME"];
990
991 $arPermissions = self::GetSearchGroups(
992 $entity_type,
993 $entity_id,
994 $feature,
995 $operation
996 );
997
998 if (CIBlock::GetArrayByID($IBLOCK_ID, "RIGHTS_MODE") === "E")
999 {
1000 $obSectionRights = new CIBlockSectionRights($IBLOCK_ID, $arFields["ID"]);
1001 $arPermissions = $obSectionRights->GetGroups(array("section_read"));
1002 }
1003
1004 $arSearchIndexParams = self::GetSearchParams(
1005 $entity_type,
1006 $entity_id,
1007 $feature,
1008 $operation
1009 );
1010
1011 CSearch::Index("socialnetwork", 'S'.$ID, array(
1012 "LAST_MODIFIED" => ConvertTimeStamp(time()+CTimeZone::GetOffset(), "FULL"),
1013 "TITLE" => $title,
1014 "BODY" => $body,
1015 "SITE_ID" => array(SITE_ID => $url),
1016 "PARAM1" => CIBlock::GetArrayByID($IBLOCK_ID, "IBLOCK_TYPE_ID"),
1017 "PARAM2" => $IBLOCK_ID,
1018 "PARAM3" => $feature,
1019 "TAGS" => "",
1020 "PERMISSIONS" => $arPermissions,
1021 "PARAMS" => $arSearchIndexParams,
1022 ), true);
1023
1024 if(defined("BX_COMP_MANAGED_CACHE"))
1025 {
1026 $CACHE_MANAGER->ClearByTag("sonet_search_".$entity_type."_".$entity_id);
1027 }
1028 }
1029
1031 {
1032 if(!CModule::IncludeModule('search'))
1033 return;
1034
1035 switch(intval($arFields["IBLOCK_ID"]))
1036 {
1037 case intval($this->_params["FILES_USER_IBLOCK_ID"] ?? null):
1038 $path_template = trim($this->_params["PATH_TO_USER_FILES"]);
1039 if($path_template <> '')
1040 {
1041 $this->IndexIBlockSection($arFields, $this->_user_id, "U", "files", "view", $path_template);
1042 }
1043 break;
1044
1045 case intval($this->_params["FILES_GROUP_IBLOCK_ID"] ?? null):
1046 $path_template = trim($this->_params["PATH_TO_GROUP_FILES"]);
1047 if($path_template <> '')
1048 {
1049 $this->IndexIBlockSection($arFields, $this->_group_id, "G", "files", "view", $path_template);
1050 }
1051 break;
1052 }
1053 }
1054
1056 {
1057 if(CModule::IncludeModule("search"))
1058 {
1059 CSearch::DeleteIndex("socialnetwork", 'S'.intval($zr["ID"]));
1060 }
1061 }
1062
1063
1064 public static function OnBeforeIndexUpdate($ID, $arFields)
1065 {
1066 if (
1067 isset($arFields["PARAMS"])
1068 && isset($arFields["PARAMS"]["socnet_group"])
1069 )
1070 {
1071 CBitrixComponent::clearComponentCache("bitrix:search.tags.cloud");
1072 }
1073 }
1074
1075 public static function OnAfterIndexAdd($ID, $arFields)
1076 {
1077 if (
1078 isset($arFields["PARAMS"])
1079 && isset($arFields["PARAMS"]["socnet_group"])
1080 )
1081 {
1082 CBitrixComponent::clearComponentCache("bitrix:search.tags.cloud");
1083 }
1084 }
1085}
$arParams
Определения access_dialog.php:21
$path
Определения access_edit.php:21
$type
Определения options.php:106
if(!Loader::includeModule('messageservice')) $provider
Определения callback_ednaruimhpx.php:21
$arResult
Определения generate_coupon.php:16
static GetSocNetPostsPerms($entity_type, $entity_id)
Определения blog_comment.php:614
static ChangeSocNetPermission($entity_type, $entity_id, $operation)
Определения blog_post.php:1572
static GetSocNetPostsPerms($entity_type, $entity_id)
Определения blog_post.php:1596
static ChangePermission($MODULE_ID, $arGroups, $ITEM_ID=false, $PARAM1=false, $PARAM2=false, $SITE_ID=false, $PARAMS=false)
Определения search.php:3097
static DeleteIndex($MODULE_ID, $ITEM_ID=false, $PARAM1=false, $PARAM2=false, $SITE_ID=false)
Определения search.php:2922
static Index($MODULE_ID, $ITEM_ID, $arFields, $bOverWrite=false, $SEARCH_SESS_ID='')
Определения search.php:1302
static GetRelatedUsers($userID, $relation, $arNavStartParams=false, $bActiveOnly="N")
Определения user_relations.php:215
static DeleteByUserID($USER_ID)
Определения user.php:21
static GetSiteData()
Определения log_tools.php:5346
Определения search.php:4
static OnSearchCheckPermissions($FIELD)
Определения search.php:323
__construct($user_id, $group_id, $arParams)
Определения search.php:40
IndexIBlockElement($arFields, $entity_id, $entity_type, $feature, $operation, $path_template, $arFieldList)
Определения search.php:725
static OnUserRelationsChange($user_id)
Определения search.php:47
static OnSearchReindex($NS=Array(), $oCallback=NULL, $callback_method="")
Определения search.php:218
static GetSearchGroups($entity_type, $entity_id, $feature, $operation)
Определения search.php:162
$_user_id
Определения search.php:6
IBlockSectionDelete($zr)
Определения search.php:1055
IndexIBlockSection($arFields, $entity_id, $entity_type, $feature, $operation, $path_template)
Определения search.php:959
BeforeIndex($arFields)
Определения search.php:526
static OnSearchPrepareFilter($strSearchContentAlias, $field, $val)
Определения search.php:311
static IBlockElementDelete($zr)
Определения search.php:951
Url($url, $params, $ancor)
Определения search.php:502
static OnBeforeIndexUpdate($ID, $arFields)
Определения search.php:1064
static SetFeaturePermissions($entity_type, $entity_id, $feature, $operation, $new_perm)
Определения search.php:68
static BeforeIndexLast($arFields)
Определения search.php:711
static GetSearchParams($entity_type, $entity_id, $feature, $operation)
Определения search.php:154
BeforeIndexForum($arFields, $entity_type, $entity_id, $feature, $operation, $path_template)
Определения search.php:372
IBlockElementUpdate(&$arFields)
Определения search.php:818
IBlockSectionUpdate(&$arFields)
Определения search.php:1030
$_group_id
Определения search.php:7
static OnAfterIndexAdd($ID, $arFields)
Определения search.php:1075
$_params
Определения search.php:5
static killAllTags($text)
Определения functions.php:428
static GetList($arOrder=Array("ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения user_relations.php:156
Определения wiki_parser.php:6
global $CACHE_MANAGER
Определения clear_component_cache.php:7
$str
Определения commerceml2.php:63
$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
$arGroups
Определения options.php:1766
$res
Определения filter_act.php:7
$zr
Определения options.php:5
$_REQUEST["admin_mnu_menu_id"]
Определения get_menu.php:8
if($ajaxMode) $ID
Определения get_user.php:27
$p
Определения group_list_element_edit.php:23
$dbElement
Определения group_wiki_post_comment.php:22
$rsGroups
Определения options.php:36
global $DB
Определения cron_frame.php:29
$IBLOCK_ID
Определения csv_new_run.php:168
global $USER
Определения csv_new_run.php:40
if(!defined('NOT_CHECK_PERMISSIONS')) $NS
Определения backup.php:24
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения tools.php:5214
HTMLToTxt($str, $strSiteUrl="", $aDelete=[], $maxlen=70)
Определения tools.php:2587
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
Определения tools.php:5177
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$name
Определения menu_edit.php:35
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$ar
Определения options.php:199
if(empty($signedUserToken)) $key
Определения quickway.php:257
</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
$title
Определения pdf.php:123
$val
Определения options.php:1793
const SONET_ENTITY_GROUP
Определения include.php:117
const SONET_ENTITY_USER
Определения include.php:118
const SONET_RELATIONS_FRIEND
Определения include.php:24
$site_id
Определения sonet_set_content_view.php:9
const SITE_ID
Определения sonet_set_content_view.php:12
$rs
Определения action.php:82
$url
Определения iframe.php:7