1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
idea_sonet_notify.php
См. документацию.
1<?
2//Include Lang
4
5//System, not for use
7{
8 private $Notify = NULL;
9 private static $Enable = true;
10
11 public function __construct($parent)
12 {
13 $this->Notify = $parent;
14 }
15
16 public function IsAvailable()
17 {
18 return CModule::IncludeModule('socialnetwork') && CModule::IncludeModule('blog') && NULL!=$this->Notify && self::$Enable;
19 }
20
21 /*
22 * Not for USE Can be changed
23 */
24 public static function AddLogEvent(&$arFields)
25 {
26 $arFields["idea"]= array(
27 'ENTITIES' => array(
29 'TITLE' => GetMessage("IDEA_SONET_NOTIFY_TITLE"),
30 'TITLE_SETTINGS' => GetMessage('IDEA_SONET_GROUP_SETTINGS'),
31 'TITLE_SETTINGS_1' => GetMessage('IDEA_SONET_GROUP_SETTINGS_1'),
32 'TITLE_SETTINGS_2' => GetMessage('IDEA_SONET_GROUP_SETTINGS_2')
33 ),
34 ),
35 'CLASS_FORMAT' => __CLASS__,
36 'METHOD_FORMAT' => 'FormatMessage',
37 'FULL_SET' => array('idea', 'idea_comment'),
38 'COMMENT_EVENT' => array(
39 'EVENT_ID' => 'idea_comment',
40 'CLASS_FORMAT' => __CLASS__,
41 'METHOD_FORMAT' => 'FormatComment',
42 'ADD_CALLBACK' => array(__CLASS__, 'CallBack_AddComment'),
43 'UPDATE_CALLBACK' => array(__CLASS__, 'CallBack_UpdateComment'),
44 'DELETE_CALLBACK' => array(__CLASS__, 'CallBack_DeleteComment'),
45 'RATING_TYPE_ID' => "BLOG_COMMENT"
46 )
47 );
48 }
49
50 /*
51 * Not for USE Can be changed
52 */
53 public static function CallBack_AddComment($arFields)
54 {
55 if(!CModule::IncludeModule('blog'))
56 return false;
57
58 $arResult = array();
59
60 $arLog = CSocNetLog::GetList(
61 array("ID" => "DESC"),
62 array("TMP_ID" => $arFields["LOG_ID"]),
63 false,
64 false,
65 array("ID", "SOURCE_ID", "SITE_ID", "RATING_ENTITY_ID")
66 )->Fetch();
67
68 if($arLog)
69 {
70 $arIdeaPost = CBlogPost::GetById($arLog["SOURCE_ID"]);
71 if($arIdeaPost)
72 {
73 $UserIP = CBlogUser::GetUserIP();
74 $arBlogCommentFields = array(
75 "BLOG_ID" => $arIdeaPost["BLOG_ID"],
76 "POST_ID" => $arIdeaPost["ID"],
77 "AUTHOR_ID" => $arFields["USER_ID"],
78 "POST_TEXT" => $arFields["TEXT_MESSAGE"],
79 "DATE_CREATE" => ConvertTimeStamp(time()+CTimeZone::GetOffset(), "FULL"),
80 "PARENT_ID" => false,
81 "AUTHOR_IP" => $UserIP[0],
82 "AUTHOR_IP1" => $UserIP[1],
83 );
84
85 if (
86 isset($arFields["UF_SONET_COM_DOC"])
87 && is_array($arFields["UF_SONET_COM_DOC"])
88 )
89 {
90 $arBlogCommentFields["UF_BLOG_COMMENT_FILE"] = $arFields["UF_SONET_COM_DOC"];
91 }
92
93 $IdeaCommentId = CBlogComment::Add($arBlogCommentFields);
94
96 "SOURCE_ID" => $IdeaCommentId,
97 );
98 if($arLog["RATING_ENTITY_ID"]>0)
99 {
100 $arResult["RATING_TYPE_ID"] = "BLOG_COMMENT";
101 $arResult["RATING_ENTITY_ID"] = $IdeaCommentId;
102 }
103
104 if(intval($IdeaCommentId)==0)
105 {
106 global $APPLICATION;
107 if($ex = $APPLICATION->GetException())
108 $arResult["ERROR"] = $ex->GetString();
109 }
110 else
111 {
112 //clear cache on succcess
113 BXClearCache(True, "/".SITE_ID."/idea/".$arIdeaPost["BLOG_ID"]."/first_page/");
114 BXClearCache(True, "/".SITE_ID."/idea/".$arIdeaPost["BLOG_ID"]."/pages/");
115 BXClearCache(True, "/".SITE_ID."/idea/".$arIdeaPost["BLOG_ID"]."/comment/".$arIdeaPost["ID"]."/");
116 BXClearCache(True, "/".SITE_ID."/idea/".$arIdeaPost["BLOG_ID"]."/post/".$arIdeaPost["ID"]."/");
117 }
118 }
119 }
120
121 return $arResult;
122 }
123
124 public static function CallBack_UpdateComment($arFields)
125 {
126 if(!CModule::IncludeModule('blog'))
127 {
128 return false;
129 }
130
131 if (
132 !isset($arFields["SOURCE_ID"])
133 || intval($arFields["SOURCE_ID"]) <= 0
134 )
135 {
136 return false;
137 }
138
139 $messageId = intval($arFields["SOURCE_ID"]);
140
141 $ufFileID = array();
142 $ufDocID = array();
143
144 if ($arBlogComment = CBlogComment::GetByID($messageId))
145 {
146 $arBlogCommentFields = array(
147 "POST_TEXT" => $arFields["TEXT_MESSAGE"]
148 );
149
150 $GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("SONET_COMMENT", $arTmp);
151 if (is_array($arTmp))
152 {
153 if (array_key_exists("UF_SONET_COM_DOC", $arTmp))
154 {
155 $arBlogCommentFields["UF_BLOG_COMMENT_FILE"] = $arTmp["UF_SONET_COM_DOC"];
156 }
157 }
158
159 if ($messageId = CBlogComment::Update($messageId, $arBlogCommentFields))
160 {
161 $ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("BLOG_COMMENT", "UF_BLOG_COMMENT_FILE", $messageId, LANGUAGE_ID);
162 $sNote = GetMessage("IDEA_SONET_UPDATE_COMMENT_SOURCE_SUCCESS");
163
164 $cache = new CPHPCache;
165 $cache->CleanDir(SITE_ID."/idea/".$arBlogComment["BLOG_ID"]."/comment/".$arBlogComment["POST_ID"]."/");
166
167 BXClearCache(True, "/".SITE_ID."/idea/".$arBlogComment["BLOG_ID"]."/first_page/");
168 BXClearCache(True, "/".SITE_ID."/idea/".$arBlogComment["BLOG_ID"]."/pages/");
169 BXClearCache(True, "/".SITE_ID."/idea/".$arBlogComment["BLOG_ID"]."/comment/".$arBlogComment["POST_ID"]."/");
170 BXClearCache(True, "/".SITE_ID."/idea/".$arBlogComment["BLOG_ID"]."/post/".$arBlogComment["POST_ID"]."/");
171 }
172 else
173 {
174 if ($ex = $GLOBALS["APPLICATION"]->GetException())
175 {
176 $sError = $ex->GetString();
177 }
178 else
179 {
180 $sError = GetMessage("IDEA_SONET_UPDATE_COMMENT_SOURCE_ERROR");
181 }
182 }
183 }
184 else
185 {
186 $sError = GetMessage("IDEA_SONET_UPDATE_COMMENT_SOURCE_ERROR");
187 }
188
189 return array(
190 "ERROR" => $sError,
191 "NOTES" => $sNote,
192 "UF" => array(
193 "FILE" => $ufFileID,
194 "DOC" => $ufDocID
195 )
196 );
197 }
198
199 public static function CallBack_DeleteComment($arFields)
200 {
201 if (!CModule::IncludeModule("blog"))
202 {
203 return false;
204 }
205
206 if (
207 !isset($arFields["SOURCE_ID"])
208 || intval($arFields["SOURCE_ID"]) <= 0
209 )
210 {
211 return false;
212 }
213
214 $messageId = intval($arFields["SOURCE_ID"]);
215
216 if (
217 ($arBlogComment = CBlogComment::GetByID($messageId))
219 )
220 {
221 $strOKMessage = GetMessage("IDEA_SONET_DELETE_COMMENT_SOURCE_SUCCESS");
222
223 $cache = new CPHPCache;
224 $cache->CleanDir(SITE_ID."/idea/".$arBlogComment["BLOG_ID"]."/comment/".$arBlogComment["POST_ID"]."/");
225
226 BXClearCache(True, "/".SITE_ID."/idea/".$arBlogComment["BLOG_ID"]."/first_page/");
227 BXClearCache(True, "/".SITE_ID."/idea/".$arBlogComment["BLOG_ID"]."/pages/");
228 BXClearCache(True, "/".SITE_ID."/idea/".$arBlogComment["BLOG_ID"]."/comment/".$arBlogComment["POST_ID"]."/");
229 BXClearCache(True, "/".SITE_ID."/idea/".$arBlogComment["BLOG_ID"]."/post/".$arBlogComment["POST_ID"]."/");
230 }
231 else
232 {
233 $strErrorMessage = GetMessage("IDEA_SONET_DELETE_COMMENT_SOURCE_ERROR");
234 }
235
236 return array(
237 "ERROR" => $strErrorMessage,
238 "NOTES" => $strOKMessage
239 );
240 }
241
242 /*
243 * Not for USE Can be changed
244 * Alias
245 */
246 public static function FormatComment($arFields, $arParams, $bMail = false, $arLog = array())
247 {
249 }
250
251 /*
252 * Not for USE Can be changed
253 * Alias
254 */
255 public static function FormatMessage($arFields, $arParams, $bMail = false)
256 {
258 $arResult["EVENT_FORMATTED"]["TITLE_24"] = GetMessage("IDEA_SONET_NOTIFY_TITLE_24");
259 return $arResult;
260 }
261
262 /*
263 * Not for USE Can be changed
264 */
265 private function AddMessage()
266 {
267 global $DB;
268 $arNotification = $this->Notify->getNotification();
269
270 $arNotify = Array(
271 "EVENT_ID" => "idea",
272 "=LOG_DATE" => $DB->CurrentTimeFunction(),
273 "URL" => $arNotification["PATH"],
274 "TITLE" => $arNotification["TITLE"],
275 "TITLE_24" => $arNotification["TITLE_24"],
276 "MESSAGE" => $arNotification["DETAIL_TEXT"],
277 "CALLBACK_FUNC" => false,
278 "SOURCE_ID" => $arNotification["ID"],
279 "SITE_ID" => SITE_ID,
280 "ENABLE_COMMENTS" => "Y",
281 "ENTITY_TYPE" => SONET_ENTITY_USER,
282 "ENTITY_ID" => $arNotification["AUTHOR_ID"],
283 "USER_ID" => $arNotification["AUTHOR_ID"],
284 "MODULE_ID" => 'idea',
285 );
286
287 //Use rating
288 if($arNotification["SHOW_RATING"] == "Y")
289 {
290 $arNotify["RATING_ENTITY_ID"] = $arNotification["ID"];
291 $arNotify["RATING_TYPE_ID"] = "BLOG_POST";
292 }
293
294 if($arNotification["ACTION"] == "ADD")
295 {
296 $LogID = CSocNetLog::Add($arNotify, false);
297 if (intval($LogID) > 0)
298 {
299 CSocNetLog::Update($LogID, array("TMP_ID" => $LogID));
300 CSocNetLogRights::Add($LogID, array("G2")); //G2 - everyone
301 }
302 }
303 elseif($arNotification["ACTION"] == "UPDATE")
304 {
305 $arLog = CSocNetLog::GetList(
306 array("ID" => "DESC"),
307 array(
308 "ENTITY_TYPE" => SONET_ENTITY_USER,
309 "EVENT_ID" => "idea",
310 "SOURCE_ID" => $arNotification["ID"]
311 ),
312 false,
313 false,
314 array("ID")
315 )->Fetch();
316 if($arLog)
317 {
318 $LogID = $arLog["ID"];
319 CSocNetLog::Update($LogID, $arNotify);
320 }
321 }
322
323 return $LogID>0;
324 }
325
326 /*
327 * Not for USE Can be changed
328 */
329 private function AddComment()
330 {
331 global $DB;
332 $arNotification = $this->Notify->getNotification();
333
334 $arLog = CSocNetLog::GetList(
335 array("ID" => "DESC"),
336 array(
337 "ENTITY_TYPE" => SONET_ENTITY_USER,
338 "EVENT_ID" => "idea",
339 "SOURCE_ID" => $arNotification["POST_ID"]),
340 false,
341 false,
342 array("ID", "RATING_ENTITY_ID")
343 )->Fetch();
344
345 if($arLog)
346 {
347 $arNotify = Array(
348 "EVENT_ID" => "idea_comment",
349 "URL" => $arNotification["PATH"],
350 "MESSAGE" => $arNotification["POST_TEXT"],
351 "SOURCE_ID" => $arNotification["ID"],
352 "ENTITY_TYPE" => SONET_ENTITY_USER,
353 "ENTITY_ID" => $arNotification["AUTHOR_ID"],
354 "USER_ID" => $arNotification["AUTHOR_ID"],
355 "MODULE_ID" => 'idea',
356 "LOG_ID" => $arLog["ID"],
357 );
358
359 if (isset($arNotification["LOG_DATE"]))
360 {
361 $arNotify["LOG_DATE"] = $arNotification["LOG_DATE"];
362 }
363 else
364 {
365 $arNotify["=LOG_DATE"] = $DB->CurrentTimeFunction();
366 }
367
368 if($arLog["RATING_ENTITY_ID"]>0)
369 {
370 $arNotify["RATING_ENTITY_ID"] = $arNotification["ID"];
371 $arNotify["RATING_TYPE_ID"] = "BLOG_COMMENT";
372 }
373
374 if($arNotification["ACTION"] == "ADD")
375 {
376 $LogCommentID = CSocNetLogComments::Add($arNotify, false, false);
377 CSocNetLog::CounterIncrement($LogCommentID, false, false, "LC");
378 }
379 elseif($arNotification["ACTION"] == "UPDATE")
380 {
381 $arLogComment = CSocNetLogComments::GetList(
382 array("ID" => "DESC"),
383 array(
384 "ENTITY_TYPE" => SONET_ENTITY_USER,
385 "EVENT_ID" => "idea_comment",
386 "SOURCE_ID" => $arNotification["ID"]),
387 false,
388 false,
389 array("ID")
390 )->Fetch();
391
392 if($arLogComment)
393 {
394 unset($arNotify["USER_ID"]);
395 $LogCommentID = CSocNetLogComments::Update($arLogComment["ID"], $arNotify);
396 }
397 }
398 }
399
400 return $LogCommentID>0;
401 }
402
403 public function Send()
404 {
405 if(!$this->IsAvailable())
406 return false;
407
408 $arNotification = $this->Notify->getNotification();
409 if($arNotification["TYPE"] == 'IDEA')
410 return $this->AddMessage();
411 elseif($arNotification["TYPE"] == 'IDEA_COMMENT')
412 return $this->AddComment();
413
414 return false;
415 }
416
417 public function HideMessage()
418 {
419 if(!$this->IsAvailable())
420 return false;
421
422 $arNotification = $this->Notify->getNotification();
423
424 $oLog = CSocNetLog::GetList(
425 array("ID" => "DESC"),
426 array(
427 "EVENT_ID" => 'idea',
428 "SOURCE_ID" => $arNotification["ID"]
429 ),
430 false,
431 false,
432 array("ID", "USER_ID")
433 );
434 while ($arLog = $oLog->Fetch())
435 {
437 CSocNetLogRights::Add($arLog["ID"], array("SA", "U".$arLog["USER_ID"]));
438 }
439
440 return false;
441 }
442
443 public function ShowMessage()
444 {
445 if(!$this->IsAvailable())
446 return false;
447
448 $arNotification = $this->Notify->getNotification();
449
450 $oLog = CSocNetLog::GetList(
451 array("ID" => "DESC"),
452 array(
453 "EVENT_ID" => 'idea',
454 "SOURCE_ID" => $arNotification["ID"]
455 ),
456 false,
457 false,
458 array("ID")
459 );
460 while ($arLog = $oLog->Fetch())
461 {
463 CSocNetLogRights::Add($arLog["ID"], array("G2"));
464 }
465
466 return false;
467 }
468
469 /*
470 * Not for USE Can be changed
471 */
472 private function RemoveComment($CommentId = false)
473 {
474 $arNotification = $this->Notify->getNotification();
475 $oLogComment = CSocNetLogComments::GetList(
476 array("ID" => "DESC"),
477 array(
478 "ENTITY_TYPE" => SONET_ENTITY_USER,
479 "EVENT_ID" => 'idea_comment',
480 "SOURCE_ID" => $CommentId?$CommentId:$arNotification["ID"]
481 ),
482 false,
483 false,
484 array("ID")
485 );
486 while($arLogComment = $oLogComment->Fetch())
487 CSocNetLogComments::Delete($arLogComment["ID"]);
488 }
489 /*
490 * Not for USE Can be changed
491 */
492 private function RemoveMessage($MessageId = false)
493 {
494 $arNotification = $this->Notify->getNotification();
495
496 //Remove comments
497 $oComment = CBlogComment::GetList(
498 array(),
499 array(
500 "POST_ID" => $MessageId?$MessageId:$arNotification["ID"],
501 ),
502 false,
503 false,
504 array("ID")
505 );
506 while ($arComment = $oComment->Fetch())
507 $this->RemoveComment($arComment["ID"]);
508
509 //Remove message
510 $oLogMessage = CSocNetLog::GetList(
511 array("ID" => "DESC"),
512 array(
513 "ENTITY_TYPE" => SONET_ENTITY_USER,
514 "EVENT_ID" => 'idea',
515 "SOURCE_ID" => $MessageId?$MessageId:$arNotification["ID"]
516 ),
517 false,
518 false,
519 array("ID")
520 );
521 while($arLogMessage = $oLogMessage->Fetch())
522 CSocNetLog::Delete($arLogMessage["ID"]);
523 }
524
525 public function Remove()
526 {
527 if(!$this->IsAvailable())
528 return false;
529
530 $arNotification = $this->Notify->getNotification();
531 if($arNotification["TYPE"] == 'IDEA')
532 {
533 $this->RemoveMessage();
534 return null;
535 }
536 elseif($arNotification["TYPE"] == 'IDEA_COMMENT')
537 {
538 $this->RemoveComment();
539 return null;
540 }
541
542 return false;
543 }
544
545 public function Disable()
546 {
547 self::$Enable = false;
548 }
549
550 public function Enable()
551 {
552 self::$Enable = true;
553 }
554}
555?>
$arParams
Определения access_dialog.php:21
if(! $messageFields||!isset($messageFields['message_id'])||!isset($messageFields['status'])||!CModule::IncludeModule("messageservice")) $messageId
Определения callback_ismscenter.php:26
global $APPLICATION
Определения include.php:80
$arResult
Определения generate_coupon.php:16
static Delete($ID)
Определения blog_comment.php:110
static GetByID($ID)
Определения blog_comment.php:170
static GetUserIP()
Определения blog_user.php:617
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 Update($ID, $arFields, $bSearchIndex=true)
Определения blog_comment.php:177
static GetList($arOrder=Array("ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения blog_comment.php:334
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 Update($ID, $arFields, $bSetSource=false)
Определения log_comments.php:307
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 DeleteByLogID($LOG_ID)
Определения log_rights.php:232
static Add($LOG_ID, $GROUP_CODE, $bShare=false, $followSet=true)
Определения log_rights.php:8
static FormatComment_Blog($arFields, $arParams, $bMail=false, $arLog=array())
Определения log_tools.php:908
static FormatEvent_Blog($arFields, $arParams, $bMail=false)
Определения log_tools.php:727
$arFields
Определения dblapprove.php:5
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
Class CIdeaManagmentSonetNotify
Определения idea_sonet_notify.php:7
Disable()
Определения idea_sonet_notify.php:545
HideMessage()
Определения idea_sonet_notify.php:417
__construct($parent)
Определения idea_sonet_notify.php:11
ShowMessage()
Определения idea_sonet_notify.php:443
Remove()
Определения idea_sonet_notify.php:525
IsAvailable()
Определения idea_sonet_notify.php:16
Send()
Определения idea_sonet_notify.php:403
Enable()
Определения idea_sonet_notify.php:550
global $DB
Определения cron_frame.php:29
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
BXClearCache($full=false, $initdir='')
Определения tools.php:5150
if(intval($iTestTransaction) > 0) $arTmp
Определения payment.php:22
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$strErrorMessage
Определения action.php:25
const SONET_SUBSCRIBE_ENTITY_USER
Определения include.php:121
const SONET_ENTITY_USER
Определения include.php:118
const SITE_ID
Определения sonet_set_content_view.php:12
$GLOBALS['_____370096793']
Определения update_client.php:1