1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
log_events.php
См. документацию.
1<?php
2
4
6{
7 /***************************************/
8 /******** DATA MODIFICATION **********/
9 /***************************************/
10 public static function CheckFields($ACTION, &$arFields, $ID = 0)
11 {
13
14 $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
15 $arSocNetLogEvents = CSocNetAllowed::GetAllowedLogEvents();
16
17 if ($ACTION != "ADD" && intval($ID) <= 0)
18 {
19 $GLOBALS["APPLICATION"]->ThrowException("System error 870164", "ERROR");
20 return false;
21 }
22
23 if ((is_set($arFields, "ENTITY_TYPE") || $ACTION=="ADD") && $arFields["ENTITY_TYPE"] == '')
24 {
25 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_LE_EMPTY_ENTITY_TYPE"), "EMPTY_ENTITY_TYPE");
26 return false;
27 }
28 elseif (is_set($arFields, "ENTITY_TYPE"))
29 {
30 if (!in_array($arFields["ENTITY_TYPE"], CSocNetAllowed::GetAllowedEntityTypes()))
31 {
32 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_LE_ERROR_NO_ENTITY_TYPE"), "ERROR_NO_ENTITY_TYPE");
33 return false;
34 }
35 }
36
37 if (is_set($arFields, "ENTITY_ID"))
38 {
39 $type = "";
40 if (is_set($arFields, "ENTITY_TYPE"))
41 {
42 $type = $arFields["ENTITY_TYPE"];
43 }
44 elseif ($ACTION != "ADD")
45 {
47 if ($arRe)
48 $type = $arRe["ENTITY_TYPE"];
49 }
50 if ($type == '')
51 {
52 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_LE_ERROR_CALC_ENTITY_TYPE"), "ERROR_CALC_ENTITY_TYPE");
53 return false;
54 }
55
56 if ($type == SONET_SUBSCRIBE_ENTITY_GROUP && intval($arFields["ENTITY_ID"]) > 0)
57 {
58 $arResult = CSocNetGroup::GetByID($arFields["ENTITY_ID"]);
59 if ($arResult == false)
60 {
61 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_LE_ERROR_NO_ENTITY_ID"), "ERROR_NO_ENTITY_ID");
62 return false;
63 }
64 }
65 elseif (
67 && intval($arFields["ENTITY_ID"]) > 0
68 )
69 {
70 $dbResult = CUser::GetByID($arFields["ENTITY_ID"]);
71 if (!$dbResult->Fetch())
72 {
73 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_LE_ERROR_NO_ENTITY_ID"), "ERROR_NO_ENTITY_ID");
74 return false;
75 }
76 }
77 }
78
79 if ((is_set($arFields, "EVENT_ID") || $ACTION=="ADD") && $arFields["EVENT_ID"] == '')
80 {
81 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_LE_EMPTY_EVENT_ID"), "EMPTY_EVENT_ID");
82 return false;
83 }
84 elseif (is_set($arFields, "EVENT_ID"))
85 {
86 $arFields["EVENT_ID"] = mb_strtolower($arFields["EVENT_ID"]);
87 if (
88 !array_key_exists($arFields["EVENT_ID"], $arSocNetFeaturesSettings)
89 && $arFields["EVENT_ID"] != "all"
90 && !array_key_exists($arFields["EVENT_ID"], $arSocNetLogEvents)
91 )
92 {
93 $bFound = false;
94 foreach($arSocNetFeaturesSettings as $feature_id => $arFeature)
95 {
96 if (
97 array_key_exists("subscribe_events", $arFeature)
98 && array_key_exists($arFields["EVENT_ID"], $arFeature["subscribe_events"])
99 )
100 {
101 $bFound = true;
102 break;
103 }
104 }
105
107 $bFound = true;
108
109 if (!$bFound)
110 {
111 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_LE_ERROR_NO_FEATURE_ID"), "ERROR_NO_FEATURE");
112 return false;
113 }
114 }
115 }
116
117 if (is_set($arFields, "SITE_ID") && $arFields["SITE_ID"] != false)
118 {
119 $dbResult = CSite::GetByID($arFields["SITE_ID"]);
120 if (!$dbResult->Fetch())
121 {
122 $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["SITE_ID"], GetMessage("SONET_LE_ERROR_NO_SITE")), "ERROR_NO_SITE");
123 return false;
124 }
125 }
126
127 if (
128 (is_set($arFields, "MAIL_EVENT") || $ACTION=="ADD")
129 && ($arFields["MAIL_EVENT"] ?? null) != "Y"
130 && ($arFields["MAIL_EVENT"] ?? null) != "N"
131 )
132 {
133 $arFields["MAIL_EVENT"] = "N";
134 }
135
136 if (is_set($arFields, "MAIL_EVENT") && $arFields["MAIL_EVENT"] == "Y")
137 $arFields["TRANSPORT"] = "M";
138
139 return True;
140 }
141
142 public static function Delete($ID)
143 {
144 global $DB;
145
146 $ID = intval($ID);
147 if ($ID <= 0)
148 {
149 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_LE_WRONG_PARAMETER_ID"), "ERROR_NO_ID");
150 return false;
151 }
152
153 $bSuccess = True;
154
155 if ($bSuccess)
156 $bSuccess = $DB->Query("DELETE FROM b_sonet_log_events WHERE ID = ".$ID."", true);
157
158 return $bSuccess;
159 }
160
161 public static function DeleteNoDemand($userID)
162 {
163 global $DB;
164
165 $userID = intval($userID);
166 if ($userID <= 0)
167 return false;
168
169 $DB->Query("DELETE FROM b_sonet_log_events WHERE USER_ID = ".$userID."", true);
170 $DB->Query("DELETE FROM b_sonet_log_events WHERE ENTITY_TYPE = '".SONET_SUBSCRIBE_ENTITY_USER."' AND ENTITY_ID = ".$userID."", true);
171
172 return true;
173 }
174
175 public static function DeleteByUserAndEntity($userID, $entityType, $entityID)
176 {
177 global $DB;
178
179 $userID = intval($userID);
180 if ($userID <= 0)
181 return false;
182
183 $entityType = Trim($entityType);
184
185 if (!in_array($entityType, CSocNetAllowed::GetAllowedEntityTypes()))
186 {
187 return false;
188 }
189
190 $entityID = intval($entityID);
191 if ($entityID <= 0)
192 return false;
193
194 $bSuccess = $DB->Query(
195 "DELETE FROM b_sonet_log_events ".
196 "WHERE USER_ID = ".$userID." ".
197 " AND ENTITY_TYPE = '".$DB->ForSql($entityType, 1)."' ".
198 " AND ENTITY_ID = ".$entityID."",
199 true
200 );
201
202 return $bSuccess;
203 }
204
205 /***************************************/
206 /********** DATA SELECTION ***********/
207 /***************************************/
208 public static function GetByID($ID)
209 {
210 global $DB;
211
212 $ID = intval($ID);
213 if ($ID <= 0)
214 {
215 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_LE_WRONG_PARAMETER_ID"), "ERROR_NO_ID");
216 return false;
217 }
218
219 $dbResult = CSocNetLogEvents::GetList(Array(), Array("ID" => $ID));
220 if ($arResult = $dbResult->GetNext())
221 {
222 return $arResult;
223 }
224
225 return False;
226 }
227
228 /***************************************/
229 /********** UTIL ***********/
230 /***************************************/
231 public static function AutoSubscribe($userID, $entityType, $entityID)
232 {
234 array(),
235 array("USER_ID" => $userID, "ENTITY_TYPE" => $entityType, "ENTITY_ID" => $entityID)
236 );
237 if ($dbRes->Fetch())
238 return;
239
240 $SiteID = false;
241 if ($entityType == SONET_SUBSCRIBE_ENTITY_GROUP)
242 if ($arGroupTmp = CSocNetGroup::GetByID($entityID))
243 $SiteID = $arGroupTmp["SITE_ID"];
244
245 $arLogEvent = array(
246 "USER_ID" => $userID,
247 "ENTITY_TYPE" => $entityType,
248 "ENTITY_ID" => $entityID,
249 "EVENT_ID" => 'system',
250 "SITE_ID" => $SiteID,
251 );
252 CSocNetLogEvents::Add($arLogEvent);
253
254 if ($entityType == SONET_SUBSCRIBE_ENTITY_USER)
255 {
256 $arLogEvent = array(
257 "USER_ID" => $userID,
258 "ENTITY_TYPE" => $entityType,
259 "ENTITY_ID" => $entityID,
260 "EVENT_ID" => 'system_friends',
261 "SITE_ID" => $SiteID,
262 "MAIL_EVENT" => "Y",
263 );
264 CSocNetLogEvents::Add($arLogEvent);
265 }
266
267 $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
268 foreach ($arSocNetFeaturesSettings as $key => $value)
269 {
270 $arLogEvent = array(
271 "USER_ID" => $userID,
272 "ENTITY_TYPE" => $entityType,
273 "ENTITY_ID" => $entityID,
274 "EVENT_ID" => $key,
275 "SITE_ID" => $SiteID,
276 "MAIL_EVENT" => "Y",
277 );
278 CSocNetLogEvents::Add($arLogEvent);
279 }
280 }
281
282 public static function GetSQL($user_id, $arMyEntities, $transport, $visible, $table_alias = "L")
283 {
284 global $DB;
285
286 if (intval($user_id) <= 0)
287 return false;
288
289 if ((!defined("DisableSonetLogVisibleSubscr") || DisableSonetLogVisibleSubscr !== true) && $visible && $visible <> '')
290 {
291 $key_res = CSocNetGroup::GetFilterOperation($visible);
292 $strField = $key_res["FIELD"];
293 $strNegative = $key_res["NEGATIVE"];
294 $strOperation = $key_res["OPERATION"];
295 $visibleFilter = "AND (".($strNegative == "Y" ? " SLE.VISIBLE IS NULL OR NOT " : "")."(SLE.VISIBLE ".$strOperation." '".$DB->ForSql($strField)."'))";
296
297 $transportFilter = "";
298 }
299 else
300 {
301 $visibleFilter = "";
302
303 if ($transport && $transport <> '')
304 {
305 $key_res = CSocNetGroup::GetFilterOperation($transport);
306 $strField = $key_res["FIELD"];
307 $strNegative = $key_res["NEGATIVE"];
308 $strOperation = $key_res["OPERATION"];
309 $transportFilter = "AND (".($strNegative == "Y" ? " SLE.TRANSPORT IS NULL OR NOT " : "")."(SLE.TRANSPORT ".$strOperation." '".$DB->ForSql($strField)."'))";
310 }
311 else
312 $transportFilter = "";
313 }
314
315 $strMyEntities = array();
316 foreach($arMyEntities as $entity_type_tmp => $arMyEntity)
317 {
318 if (is_array($arMyEntity) && count($arMyEntity) > 0)
319 {
320 $strMyEntities[$entity_type_tmp] = $table_alias.".ENTITY_ID IN (".implode(",", $arMyEntity).")";
321 $strNotMyEntities[$entity_type_tmp] = "(".$table_alias.".ENTITY_ID NOT IN (".implode(",", $arMyEntity).") AND ".$table_alias.".ENTITY_TYPE = '".$entity_type_tmp."')";
322 }
323 }
324
325 $arCBFilterEntityType = array();
326 $arSocNetAllowedSubscribeEntityTypesDesc = CSocNetAllowed::GetAllowedEntityTypesDesc();
327
328 foreach($arSocNetAllowedSubscribeEntityTypesDesc as $entity_type_tmp => $arEntityTypeTmp)
329 {
330 if (
331 array_key_exists("USE_CB_FILTER", $arEntityTypeTmp)
332 && $arEntityTypeTmp["USE_CB_FILTER"] == "Y"
333 )
334 {
335 $arCBFilterEntityType[] = "'".$entity_type_tmp."'";
336 }
337 }
338
339 if (is_array($arCBFilterEntityType) && count($arCBFilterEntityType) > 0)
340 {
341 $strCBFilterEntityType = $table_alias.".ENTITY_TYPE IN (".implode(",", $arCBFilterEntityType).") AND ";
342 $strNotCBFilterEntityType = $table_alias.".ENTITY_TYPE NOT IN (".implode(",", $arCBFilterEntityType).") OR ";
343 }
344 else
345 {
346 $strCBFilterEntityType = "";
347 $strNotCBFilterEntityType = "";
348 }
349
350 $strSQL = "
351 EXISTS(
352 SELECT ID
353 FROM b_sonet_log_events SLE
354 WHERE
355 SLE.USER_ID = ".$user_id."
356 AND SLE.ENTITY_TYPE = ".$table_alias.".ENTITY_TYPE
357 AND SLE.ENTITY_CB = 'N'
358 AND SLE.ENTITY_ID = ".$table_alias.".ENTITY_ID
359 AND SLE.EVENT_ID = ".$table_alias.".EVENT_ID
360 ".$transportFilter."
361 ".$visibleFilter."
362 )
363 OR
364 (
365 ".$strCBFilterEntityType."
366 EXISTS(
367 SELECT ID
368 FROM b_sonet_log_events SLE
369 WHERE
370 SLE.USER_ID = ".$user_id."
371 AND SLE.ENTITY_CB = 'Y'
372 AND SLE.ENTITY_ID = ".$table_alias.".USER_ID
373 AND SLE.EVENT_ID = ".$table_alias.".EVENT_ID
374 ".$transportFilter."
375 ".$visibleFilter."
376 )
377 )
378 OR
379 (
380 (
381 NOT EXISTS(
382 SELECT ID
383 FROM b_sonet_log_events SLE
384 WHERE
385 SLE.USER_ID = ".$user_id."
386 AND SLE.ENTITY_TYPE = ".$table_alias.".ENTITY_TYPE
387 AND SLE.ENTITY_CB = 'N'
388 AND SLE.ENTITY_ID = ".$table_alias.".ENTITY_ID
389 AND SLE.EVENT_ID = ".$table_alias.".EVENT_ID
390 )
391 OR
392 EXISTS(
393 SELECT ID
394 FROM b_sonet_log_events SLE
395 WHERE
396 SLE.USER_ID = ".$user_id."
397 AND SLE.ENTITY_TYPE = ".$table_alias.".ENTITY_TYPE
398 AND SLE.ENTITY_CB = 'N'
399 AND SLE.ENTITY_ID = ".$table_alias.".ENTITY_ID
400 AND SLE.EVENT_ID = ".$table_alias.".EVENT_ID
401 AND ".($visibleFilter ? "SLE.VISIBLE = 'I'" : "SLE.TRANSPORT = 'I'")."
402 )
403 )
404 AND
405 (
406 ".$strNotCBFilterEntityType."
407 NOT EXISTS(
408 SELECT ID
409 FROM b_sonet_log_events SLE
410 WHERE
411 SLE.USER_ID = ".$user_id."
412 AND SLE.ENTITY_CB = 'Y'
413 AND SLE.ENTITY_ID = ".$table_alias.".USER_ID
414 AND SLE.EVENT_ID = ".$table_alias.".EVENT_ID
415 )
416 OR
417 EXISTS(
418 SELECT ID
419 FROM b_sonet_log_events SLE
420 WHERE
421 SLE.USER_ID = ".$user_id."
422 AND SLE.ENTITY_CB = 'Y'
423 AND SLE.ENTITY_ID = ".$table_alias.".USER_ID
424 AND SLE.EVENT_ID = ".$table_alias.".EVENT_ID
425 AND ".($visibleFilter ? "SLE.VISIBLE = 'I'" : "SLE.TRANSPORT = 'I'")."
426 )
427
428 )
429 AND
430 (
431 EXISTS(
432 SELECT ID
433 FROM b_sonet_log_events SLE
434 WHERE
435 SLE.USER_ID = ".$user_id."
436 AND SLE.ENTITY_TYPE = ".$table_alias.".ENTITY_TYPE
437 AND SLE.ENTITY_CB = 'N'
438 AND SLE.ENTITY_ID = ".$table_alias.".ENTITY_ID
439 AND SLE.EVENT_ID = 'all'
440 ".$transportFilter."
441 ".$visibleFilter."
442 )
443 OR
444 (
445 ".$strCBFilterEntityType."
446 EXISTS(
447 SELECT ID
448 FROM b_sonet_log_events SLE
449 WHERE
450 SLE.USER_ID = ".$user_id."
451 AND SLE.ENTITY_CB = 'Y'
452 AND SLE.ENTITY_ID = ".$table_alias.".USER_ID
453 AND SLE.EVENT_ID = 'all'
454 ".$transportFilter."
455 ".$visibleFilter."
456 )
457 )
458 OR
459 (
460 (
461 NOT EXISTS(
462 SELECT ID
463 FROM b_sonet_log_events SLE
464 WHERE
465 SLE.USER_ID = ".$user_id."
466 AND SLE.ENTITY_TYPE = ".$table_alias.".ENTITY_TYPE
467 AND SLE.ENTITY_CB = 'N'
468 AND SLE.ENTITY_ID = ".$table_alias.".ENTITY_ID
469 AND SLE.EVENT_ID = 'all'
470 )
471 OR
472 EXISTS(
473 SELECT ID
474 FROM b_sonet_log_events SLE
475 WHERE
476 SLE.USER_ID = ".$user_id."
477 AND SLE.ENTITY_TYPE = ".$table_alias.".ENTITY_TYPE
478 AND SLE.ENTITY_CB = 'N'
479 AND SLE.ENTITY_ID = ".$table_alias.".ENTITY_ID
480 AND SLE.EVENT_ID = 'all'
481 AND ".($visibleFilter ? "SLE.VISIBLE = 'I'" : "SLE.TRANSPORT = 'I'")."
482 )
483 )
484 AND
485 (
486 ".$strNotCBFilterEntityType."
487 NOT EXISTS(
488 SELECT ID
489 FROM b_sonet_log_events SLE
490 WHERE
491 SLE.USER_ID = ".$user_id."
492 AND SLE.ENTITY_CB = 'Y'
493 AND SLE.ENTITY_ID = ".$table_alias.".USER_ID
494 AND SLE.EVENT_ID = 'all'
495 )
496 OR
497 EXISTS(
498 SELECT ID
499 FROM b_sonet_log_events SLE
500 WHERE
501 SLE.USER_ID = ".$user_id."
502 AND SLE.ENTITY_CB = 'Y'
503 AND SLE.ENTITY_ID = ".$table_alias.".USER_ID
504 AND SLE.EVENT_ID = 'all'
505 AND ".($visibleFilter ? "SLE.VISIBLE = 'I'" : "SLE.TRANSPORT = 'I'")."
506 )
507 )
508 AND
509 (
510 ";
511
512 if (count($strMyEntities) > 0)
513 {
514 foreach ($strMyEntities as $entity_type_tmp => $strMyEntity)
515 {
516 $strSQL .= ($strMyEntity <> '' ? "
517 (
518 ".$strMyEntity."
519 AND
520 (
521 EXISTS(
522 SELECT ID
523 FROM b_sonet_log_events SLE
524 WHERE
525 SLE.USER_ID = ".$user_id."
526 AND SLE.ENTITY_TYPE = '".$entity_type_tmp."'
527 AND SLE.ENTITY_TYPE = ".$table_alias.".ENTITY_TYPE
528 AND SLE.ENTITY_ID = 0
529 AND SLE.ENTITY_MY = 'Y'
530 AND SLE.EVENT_ID = ".$table_alias.".EVENT_ID
531 ".$transportFilter."
532 ".$visibleFilter."
533 )
534 OR
535 (
536 (
537 EXISTS(
538 SELECT ID
539 FROM b_sonet_log_events SLE
540 WHERE
541 SLE.USER_ID = ".$user_id."
542 AND SLE.ENTITY_TYPE = '".$entity_type_tmp."'
543 AND SLE.ENTITY_TYPE = ".$table_alias.".ENTITY_TYPE
544 AND SLE.ENTITY_ID = 0
545 AND SLE.ENTITY_MY = 'Y'
546 AND SLE.EVENT_ID = ".$table_alias.".EVENT_ID
547 AND ".($visibleFilter ? "SLE.VISIBLE = 'I'" : "SLE.TRANSPORT = 'I'")."
548 )
549 OR
550 NOT EXISTS(
551 SELECT ID
552 FROM b_sonet_log_events SLE
553 WHERE
554 SLE.USER_ID = ".$user_id."
555 AND SLE.ENTITY_TYPE = '".$entity_type_tmp."'
556 AND SLE.ENTITY_TYPE = ".$table_alias.".ENTITY_TYPE
557 AND SLE.ENTITY_ID = 0
558 AND SLE.ENTITY_MY = 'Y'
559 AND SLE.EVENT_ID = ".$table_alias.".EVENT_ID
560 )
561 )
562 AND
563 (
564 EXISTS(
565 SELECT ID
566 FROM b_sonet_log_events SLE
567 WHERE
568 SLE.USER_ID = ".$user_id."
569 AND SLE.ENTITY_TYPE = '".$entity_type_tmp."'
570 AND SLE.ENTITY_TYPE = ".$table_alias.".ENTITY_TYPE
571 AND SLE.ENTITY_ID = 0
572 AND SLE.ENTITY_MY = 'Y'
573 AND SLE.EVENT_ID = 'all'
574 ".$transportFilter."
575 ".$visibleFilter."
576 )
577 )
578 )
579 )
580 )
581 OR
582 " : "");
583 }
584 }
585
586 $strSQL .= "
587 (
588 EXISTS(
589 SELECT ID
590 FROM b_sonet_log_events SLE
591 WHERE
592 SLE.USER_ID = ".$user_id."
593 AND SLE.ENTITY_TYPE = ".$table_alias.".ENTITY_TYPE
594 AND SLE.ENTITY_ID = 0
595 AND SLE.ENTITY_MY = 'N'
596 AND SLE.EVENT_ID = ".$table_alias.".EVENT_ID
597 ".$transportFilter."
598 ".$visibleFilter."
599 )
600 OR
601 (
602 (
603 EXISTS(
604 SELECT ID
605 FROM b_sonet_log_events SLE
606 WHERE
607 SLE.USER_ID = ".$user_id."
608 AND SLE.ENTITY_TYPE = ".$table_alias.".ENTITY_TYPE
609 AND SLE.ENTITY_ID = 0
610 AND SLE.ENTITY_MY = 'N'
611 AND SLE.EVENT_ID = ".$table_alias.".EVENT_ID
612 AND ".($visibleFilter ? "SLE.VISIBLE = 'I'" : "SLE.TRANSPORT = 'I'")."
613 )
614 OR
615 NOT EXISTS(
616 SELECT ID
617 FROM b_sonet_log_events SLE
618 WHERE
619 SLE.USER_ID = ".$user_id."
620 AND SLE.ENTITY_TYPE = ".$table_alias.".ENTITY_TYPE
621 AND SLE.ENTITY_ID = 0
622 AND SLE.ENTITY_MY = 'N'
623 AND SLE.EVENT_ID = ".$table_alias.".EVENT_ID
624 )
625 )
626 AND
627 (
628 EXISTS(
629 SELECT ID
630 FROM b_sonet_log_events SLE
631 WHERE
632 SLE.USER_ID = ".$user_id."
633 AND SLE.ENTITY_TYPE = ".$table_alias.".ENTITY_TYPE
634 AND SLE.ENTITY_ID = 0
635 AND SLE.ENTITY_MY = 'N'
636 AND SLE.EVENT_ID = 'all'
637 ".$transportFilter."
638 ".$visibleFilter."
639 )
640 OR
641 EXISTS(
642 SELECT ID
643 FROM b_sonet_log_events SLE
644 WHERE
645 SLE.USER_ID = ".$user_id."
646 AND SLE.ENTITY_TYPE = ".$table_alias.".ENTITY_TYPE
647 AND SLE.ENTITY_ID = 0
648 AND SLE.ENTITY_MY = 'N'
649 AND SLE.EVENT_ID = 'all'
650 AND ".($visibleFilter ? "SLE.VISIBLE = 'I'" : "SLE.TRANSPORT = 'I'")."
651 )
652 OR
653 NOT EXISTS(
654 SELECT ID
655 FROM b_sonet_log_events SLE
656 WHERE
657 SLE.USER_ID = ".$user_id."
658 AND SLE.ENTITY_TYPE = ".$table_alias.".ENTITY_TYPE
659 AND SLE.ENTITY_ID = 0
660 AND SLE.ENTITY_MY = 'N'
661 AND SLE.EVENT_ID = 'all'
662 )
663 )
664 )
665 )
666 )
667 )
668 )
669 )";
670
671 return $strSQL;
672
673 }
674
675 public static function GetSQLForEvent($entity_type, $entity_id, $event_id, $user_id, $transport = false, $visible = true, $arOfEntities = array())
676 {
677 if (!in_array($entity_type, CSocNetAllowed::GetAllowedEntityTypes()))
678 {
679 return false;
680 }
681
682 if (intval($entity_id) <= 0)
683 return false;
684
685 $strSQL = "";
686
687 if (
688 is_array($arOfEntities)
689 && count($arOfEntities) > 0
690 )
691 $strOfEntities = "AND LE.USER_ID IN (".implode(",", $arOfEntities).")";
692 else
693 $strOfEntities = "";
694
695 if (is_array($transport) && count($transport) > 0)
696 $strTransport = "AND LE.TRANSPORT IN ('".implode("', '", $transport)."')";
697 elseif(!is_array($transport) && $transport <> '')
698 $strTransport = "AND LE.TRANSPORT = '".$transport."'";
699 else
700 $strTransport = "";
701
702 $strSQL .= "AND (
703 (
704 LE.ENTITY_TYPE = '".$entity_type."'
705 AND LE.ENTITY_ID = ".$entity_id."
706 AND LE.ENTITY_CB = 'N'
707 AND LE.EVENT_ID = '".$event_id."'
708 ".$strTransport."
709 )";
710
711 $arSocNetAllowedSubscribeEntityTypesDesc = CSocNetAllowed::GetAllowedEntityTypesDesc();
712
713 if (
714 array_key_exists("USE_CB_FILTER", $arSocNetAllowedSubscribeEntityTypesDesc[$entity_type])
715 && $arSocNetAllowedSubscribeEntityTypesDesc[$entity_type]["USE_CB_FILTER"] == "Y"
716 && intval($user_id) > 0
717 )
718 {
719 $strSQL .= "
720 OR
721 (
722 LE.ENTITY_TYPE = '".SONET_SUBSCRIBE_ENTITY_USER."'
723 AND LE.ENTITY_ID = ".$user_id."
724 AND LE.ENTITY_CB = 'Y'
725 AND
726 (
727 LE.EVENT_ID = '".$event_id."'
728 OR LE.EVENT_ID = 'all'
729 )
730 ".$strTransport."
731 )";
732 }
733
734 $strSQL .= "
735 OR
736 (
737 LE.ENTITY_TYPE = '".$entity_type."'
738 AND LE.ENTITY_ID = ".$entity_id."
739 AND LE.ENTITY_CB = 'N'
740 AND LE.EVENT_ID = 'all'
741 ".$strTransport."
742 )
743 OR
744 (
745 LE.ENTITY_TYPE = '".$entity_type."'
746 AND LE.ENTITY_ID = 0
747 AND LE.ENTITY_MY = 'Y'
748 AND
749 (
750 LE.EVENT_ID = '".$event_id."'
751 OR LE.EVENT_ID = 'all'
752 )
753 ".$strOfEntities."
754 ".$strTransport."
755 )
756 OR
757 (
758 LE.ENTITY_TYPE = '".$entity_type."'
759 AND LE.ENTITY_ID = 0
760 AND LE.ENTITY_MY = 'N'
761 AND
762 (
763 LE.EVENT_ID = '".$event_id."'
764 OR LE.EVENT_ID = 'all'
765 )
766 ".$strTransport."
767 )
768 )";
769
770 return $strSQL;
771 }
772}
$type
Определения options.php:106
$arResult
Определения generate_coupon.php:16
static DeleteByUserAndEntity($userID, $entityType, $entityID)
Определения log_events.php:175
static Delete($ID)
Определения log_events.php:142
static AutoSubscribe($userID, $entityType, $entityID)
Определения log_events.php:231
static GetSQL($user_id, $arMyEntities, $transport, $visible, $table_alias="L")
Определения log_events.php:282
static GetByID($ID)
Определения log_events.php:208
static CheckFields($ACTION, &$arFields, $ID=0)
Определения log_events.php:10
static GetSQLForEvent($entity_type, $entity_id, $event_id, $user_id, $transport=false, $visible=true, $arOfEntities=array())
Определения log_events.php:675
static DeleteNoDemand($userID)
Определения log_events.php:161
static GetByID($ID)
Определения log.php:228
static Add($arFields)
Определения log_events.php:10
static GetList($arOrder=Array("ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array(), $arParams=array())
Определения log_events.php:74
static FindLogCommentEventByID($event_id)
Определения log_tools.php:95
$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
$bFound
Определения get_search.php:40
if($ajaxMode) $ID
Определения get_user.php:27
global $DB
Определения cron_frame.php:29
$ACTION
Определения csv_new_setup.php:27
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
is_set($a, $k=false)
Определения tools.php:2133
GetMessage($name, $aReplace=null)
Определения tools.php:3397
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
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(!CSocNetUser::IsFriendsAllowed()||!CBXFeatures::IsFeatureEnabled("Friends")) $arEntityTypeTmp
Определения include.php:187
const SONET_SUBSCRIBE_ENTITY_USER
Определения include.php:121
const SONET_SUBSCRIBE_ENTITY_GROUP
Определения include.php:120
const DisableSonetLogVisibleSubscr
Определения include.php:50
global $arSocNetAllowedEntityTypes
Определения include.php:123
if( $_SERVER $arSocNetFeaturesSettings['REQUEST_METHOD']=="GET" &&($RestoreDefaults ?? null)<> '' && $SONET_RIGHT=="W" &&check_bitrix_sessid())
Определения options.php:35
$GLOBALS['_____370096793']
Определения update_client.php:1
$dbResult
Определения updtr957.php:3
$dbRes
Определения yandex_detail.php:168