1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
blog_notify_schema.php
См. документацию.
1<?
3
4use \Bitrix\Main\Localization\Loc;
5
7{
8 public function __construct()
9 {
10 }
11
12 public static function OnGetNotifySchema()
13 {
14 $ar = array(
15 "post" => Array(
16 "NAME" => GetMessage('BLG_NS_POST'),
17 "PUSH" => 'Y'
18 ),
19 "post_mail" => Array(
20 "NAME" => GetMessage('BLG_NS_POST_MAIL_MSGBER_1'),
21 "PUSH" => 'Y'
22 ),
23 "comment" => Array(
24 "NAME" => GetMessage('BLG_NS_COMMENT'),
25 "PUSH" => 'N'
26 ),
27 "mention" => Array(
28 "NAME" => GetMessage('BLG_NS_MENTION'),
29 "PUSH" => 'N'
30 ),
31 "mention_comment" => Array(
32 "NAME" => GetMessage('BLG_NS_MENTION_COMMENT'),
33 "PUSH" => 'Y'
34 ),
35 "share" => Array(
36 "NAME" => GetMessage('BLG_NS_SHARE'),
37 "PUSH" => 'N'
38 ),
39 "share2users" => Array(
40 "NAME" => GetMessage('BLG_NS_SHARE2USERS'),
41 "PUSH" => 'Y'
42 )
43 );
44
45 if (IsModuleInstalled('intranet'))
46 {
47 $ar["broadcast_post"] = Array(
48 "NAME" => GetMessage('BLG_NS_BROADCAST_POST_MSGVER_1'),
49 "SITE" => "N",
50 "MAIL" => "Y",
51 "XMPP" => "N",
52 "PUSH" => "Y",
54 );
55 $ar["grat"] = Array(
56 "NAME" => GetMessage('BLG_NS_GRAT'),
57 "PUSH" => "Y"
58 );
59 }
60
61 if (IsModuleInstalled('socialnetwork'))
62 {
63 $ar["moderate_post"] = Array(
64 "NAME" => GetMessage('BLG_NS_MODERATE_POST'),
65 "SITE" => "Y",
66 "MAIL" => "Y",
67 "XMPP" => "N",
68 "PUSH" => "N",
70 );
71 $ar["moderate_comment"] = Array(
72 "NAME" => GetMessage('BLG_NS_MODERATE_COMMENT'),
73 "SITE" => "Y",
74 "MAIL" => "Y",
75 "XMPP" => "N",
76 "PUSH" => "N",
78 );
79 $ar["published_post"] = Array(
80 "NAME" => GetMessage('BLG_NS_PUBLISHED_POST'),
81 "SITE" => "Y",
82 "MAIL" => "Y",
83 "XMPP" => "N",
84 "PUSH" => "N",
86 );
87 $ar["published_comment"] = Array(
88 "NAME" => GetMessage('BLG_NS_PUBLISHED_COMMENT'),
89 "SITE" => "Y",
90 "MAIL" => "Y",
91 "XMPP" => "N",
92 "PUSH" => "N",
94 );
95 }
96
97 return array(
98 "blog" => array(
99 "NAME" => GetMessage('BLG_NS_MSGVER_1'),
100 "NOTIFY" => $ar,
101 ),
102 );
103 }
104
105 public static function CBlogEventsIMCallback($module, $tag, $text, $arNotify)
106 {
107 if ($module == "blog")
108 {
109 $text = trim($text);
110 if (empty($text))
111 {
112 return;
113 }
114
115 global $USER;
116
117 $currentUserId = $USER->getId();
118 $post = false;
119
120 $tagParsed = explode("|", $tag);
121 if (in_array($tagParsed[1], array("POST", "COMMENT", "SHARE", "SHARE2USERS", "POST_MENTION", "COMMENT_MENTION")))
122 {
123 $postId = intval($tagParsed[2]);
124 if ($postId > 0)
125 {
126 $res = \CBlogPost::getList(
127 array(),
128 array(
129 "ID" => $postId
130 ),
131 false,
132 false,
133 array("ID", "BLOG_ID", "AUTHOR_ID", "BLOG_OWNER_ID", "TITLE")
134 );
135
136 $post = $res->fetch();
137 }
138 }
139
140 if (!$post)
141 {
142 return Loc::getMessage('BLG_NS_IM_ANSWER_ERROR');
143 }
144
145 $blog = CBlog::getById($post["BLOG_ID"]);
146
147 $userIP = CBlogUser::GetUserIP();
148 $commentFields = Array(
149 "POST_ID" => $post['ID'],
150 "BLOG_ID" => $post['BLOG_ID'],
151 "TITLE" => '',
152 "POST_TEXT" => $text,
153 "DATE_CREATE" => convertTimeStamp(time() + CTimeZone::getOffset(), "FULL"),
154 "AUTHOR_IP" => $userIP[0],
155 "AUTHOR_IP1" => $userIP[1],
156 "URL" => $blog["URL"],
157 "PARENT_ID" => false,
158 "SEARCH_GROUP_ID" => $blog['GROUP_ID'],
159 "AUTHOR_ID" => $currentUserId
160 );
161
163
164 if($post["AUTHOR_ID"] == $currentUserId)
165 {
167 }
168 else
169 {
170 $postPerm = CBlogPost::getSocNetPostPerms($post["ID"]);
171 if ($postPerm > \Bitrix\Blog\Item\Permissions::DENY)
172 {
173 $perm = CBlogComment::getSocNetUserPerms($post["ID"], $post["AUTHOR_ID"]);
174 }
175 }
176
177 if ($perm == \Bitrix\Blog\Item\Permissions::DENY)
178 {
179 return Loc::getMessage('BLG_NS_IM_ANSWER_ERROR');
180 }
181
182 if (!\Bitrix\Blog\Item\Comment::checkDuplicate(array(
183 'MESSAGE' => $text,
184 'BLOG_ID' => $post['BLOG_ID'],
185 'POST_ID' => $post['ID'],
186 'AUTHOR_ID' => $currentUserId,
187 )))
188 {
189 return Loc::getMessage('BLG_NS_IM_ANSWER_ERROR');
190 }
191
192 if ($perm == \Bitrix\Blog\Item\Permissions::PREMODERATE)
193 {
194 $commentFields["PUBLISH_STATUS"] = BLOG_PUBLISH_STATUS_READY;
195 }
196
197 if ($commentId = CBlogComment::add($commentFields))
198 {
200 'MESSAGE' => $text,
201 'BLOG_ID' => $post["BLOG_ID"],
202 'BLOG_OWNER_ID' => $post["BLOG_OWNER_ID"],
203 'POST_ID' => $post["ID"],
204 'POST_TITLE' => $post["TITLE"],
205 'POST_AUTHOR_ID' => $post["AUTHOR_ID"],
206 'COMMENT_ID' => $commentId,
207 'AUTHOR_ID' => $currentUserId,
208 ));
209
210 return Loc::getMessage('BLG_NS_IM_ANSWER_SUCCESS');
211 }
212 }
213
214 }
215}
const BLOG_PUBLISH_STATUS_READY
Определения include.php:46
static actionsAfter(array $params)
Определения comment.php:153
static GetUserIP()
Определения blog_user.php:617
__construct()
Определения blog_notify_schema.php:8
static CBlogEventsIMCallback($module, $tag, $text, $arNotify)
Определения blog_notify_schema.php:105
static OnGetNotifySchema()
Определения blog_notify_schema.php:12
</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
$perm
Определения options.php:169
const IM_NOTIFY_FEATURE_SITE
Определения include.php:76
const IM_NOTIFY_FEATURE_PUSH
Определения include.php:79
const IM_NOTIFY_FEATURE_XMPP
Определения include.php:77
global $USER
Определения csv_new_run.php:40
IsModuleInstalled($module_id)
Определения tools.php:5301
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$ar
Определения options.php:199
$text
Определения template_pdf.php:79
$post
Определения template.php:8