Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
message.php
1<?php
2
3
5
6
10
12{
13 public static function index(Forum\Forum $forum, Forum\Topic $topic, array $message)
14 {
15 if (!Main\Loader::includeModule("search") || $message["SERVICE_TYPE"] > 0)
16 {
17 return;
18 }
19
20 if (Main\Config\Option::get("forum", "FILTER", "Y") == "Y" && $message["POST_MESSAGE_FILTER"] !== null)
21 {
22 $message["POST_MESSAGE"] = $message["POST_MESSAGE_FILTER"];
23 }
24
25 $arParams = [
26 "PERMISSION" => [1],
27 "SITE" => $forum->getSites(),
28 "DEFAULT_URL" => "/"
29 ];
30
31 foreach ($forum->getPermissions() as $groupId => $permission)
32 {
33 if (
34 $message["APPROVED"] == "Y" && $permission >= Permission::CAN_READ
35 ||
36 $message["APPROVED"] != "Y" && $permission >= Permission::CAN_MODERATE
37 )
38 {
39 $arParams["PERMISSION"][] = $groupId;
40 }
41 }
42
43
44 $arSearchInd = array(
45 "LID" => array(),
46 "LAST_MODIFIED" => $message["POST_DATE"],
47 "PARAM1" => $message["FORUM_ID"],
48 "PARAM2" => $message["TOPIC_ID"],
49 "ENTITY_TYPE_ID" => ($message["NEW_TOPIC"] == "Y"? "FORUM_TOPIC": "FORUM_POST"),
50 "ENTITY_ID" => ($message["NEW_TOPIC"] == "Y"? $message["TOPIC_ID"]: $message["ID"]),
51 "USER_ID" => $message["AUTHOR_ID"],
52 "PERMISSIONS" => $arParams["PERMISSION"],
53 "TITLE" => $topic["TITLE"].( $message["NEW_TOPIC"] == "Y" && !empty($topic["DESCRIPTION"]) ? ", ".$topic["DESCRIPTION"] : ""),
54 "TAGS" => ($message["NEW_TOPIC"] == "Y" ? $topic["TAGS"] : ""),
55 "BODY" => GetMessage("AVTOR_PREF")." ".$message["AUTHOR_NAME"].". ".(\CSearch::KillTags(\forumTextParser::clearAllTags($message["POST_MESSAGE"]))),
56 "URL" => "",
57 "INDEX_TITLE" => $message["NEW_TOPIC"] == "Y",
58 );
59
60 // get mentions
61 $arMentionedUserID = \CForumMessage::GetMentionedUserID($message["POST_MESSAGE"]);
62 if (!empty($arMentionedUserID))
63 {
64 $arSearchInd["PARAMS"] = array(
65 "mentioned_user_id" => $arMentionedUserID
66 );
67 }
68
69 $urlPatterns = array(
70 "FORUM_ID" => $message["FORUM_ID"],
71 "TOPIC_ID" => $message["TOPIC_ID"],
72 "TITLE_SEO" => $topic["TITLE_SEO"],
73 "MESSAGE_ID" => $message["ID"],
74 "SOCNET_GROUP_ID" => $topic["SOCNET_GROUP_ID"],
75 "OWNER_ID" => $topic["OWNER_ID"],
76 "PARAM1" => $message["PARAM1"],
77 "PARAM2" => $message["PARAM2"]);
78 foreach ($arParams["SITE"] as $key => $val)
79 {
80 $arSearchInd["LID"][$key] = \CForumNew::PreparePath2Message($val, $urlPatterns);
81 if (empty($arSearchInd["URL"]) && !empty($arSearchInd["LID"][$key]))
82 $arSearchInd["URL"] = $arSearchInd["LID"][$key];
83 }
84
85 if (empty($arSearchInd["URL"]) && ($res = \CLang::GetByID(SITE_ID)->fetch()))
86 {
87 $arParams["DEFAULT_URL"] .= $res["DIR"].
88 Main\Config\Option::get("forum", "REL_FPATH", "").
89 "forum/read.php?FID=#FID#&TID=#TID#&MID=#MID##message#MID#";
90 $arSearchInd["URL"] = \CForumNew::PreparePath2Message($arParams["DEFAULT_URL"], $urlPatterns);
91 }
92 /***************** Events onMessageIsIndexed ***********************/
93 $index = true;
94 foreach(GetModuleEvents("forum", "onMessageIsIndexed", true) as $arEvent)
95 {
96 if (ExecuteModuleEventEx($arEvent, array($message["ID"], $message, &$arSearchInd)) === false)
97 {
98 $index = false;
99 break;
100 }
101 }
102 /***************** /Events *****************************************/
103 if ($index == true)
104 {
105 \CSearch::Index("forum", $message["ID"], $arSearchInd, true);
106 }
107 }
108
109 public static function deleteIndex(array $message)
110 {
111 if (Main\Loader::includeModule("search"))
112 {
113 \CSearch::DeleteIndex("forum", $message['ID']);
114 }
115 }
116}
static index(Forum\Forum $forum, Forum\Topic $topic, array $message)
Definition message.php:13
static deleteIndex(array $message)
Definition message.php:109