1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
event_user_view.php
См. документацию.
1<?php
2
4
6{
7 public static function SetUser($entityID, $feature = false, $permX = false, $bSetFeatures = false)
8 {
9 global $APPLICATION, $DB;
10
11 $CacheRelatedUsers = array();
12
13 $entityID = intval($entityID);
14 if ($entityID <= 0)
15 {
16 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
17 return false;
18 }
19
20 $event_id = array();
21 $arSocNetLogEvents = CSocNetAllowed::GetAllowedLogEvents();
22
23 foreach ($arSocNetLogEvents as $event_tmp_id => $arLogEventTmp)
24 {
25 if (
26 !array_key_exists("ENTITIES", $arLogEventTmp)
27 || !array_key_exists(SONET_ENTITY_USER, $arLogEventTmp["ENTITIES"])
28 )
29 continue;
30
31 if (
32 array_key_exists("NO_SET", $arLogEventTmp)
33 && $arLogEventTmp["NO_SET"]
34 )
35 continue;
36
37 if (
38 array_key_exists("OPERATION", $arLogEventTmp["ENTITIES"][SONET_ENTITY_USER])
39 && $arLogEventTmp["ENTITIES"][SONET_ENTITY_USER]["OPERATION"] == ''
40 )
41 continue;
42
43 $event_id[$arLogEventTmp["ENTITIES"][SONET_ENTITY_USER]["OPERATION"]] = $event_tmp_id;
44
45 if (
46 array_key_exists("COMMENT_EVENT", $arLogEventTmp)
47 && is_array($arLogEventTmp["COMMENT_EVENT"])
48 && array_key_exists("OPERATION", $arLogEventTmp["COMMENT_EVENT"])
49 && array_key_exists("EVENT_ID", $arLogEventTmp["COMMENT_EVENT"])
50 && $arLogEventTmp["COMMENT_EVENT"]["OPERATION"] <> ''
51 && $arLogEventTmp["COMMENT_EVENT"]["EVENT_ID"] <> ''
52 && $arLogEventTmp["ENTITIES"][SONET_ENTITY_USER]["OPERATION"] != $arLogEventTmp["COMMENT_EVENT"]["OPERATION"]
53 )
54 $event_id[$arLogEventTmp["COMMENT_EVENT"]["OPERATION"]] = $arLogEventTmp["COMMENT_EVENT"]["EVENT_ID"];
55 }
56
57 if ($feature && !array_key_exists($feature, $event_id))
58 return true;
59
60 if ($feature && !is_array($feature))
61 $event_id = array($feature => $event_id[$feature]);
62
63 foreach ($event_id as $op => $event)
64 {
66 {
67 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_ERROR_DELETE"), "ERROR_DELETE");
68 return false;
69 }
70
71 $ar_event_tmp = array($event);
72
74 if ($arCommentEvent)
75 {
76 $event_comment = $arCommentEvent["EVENT_ID"];
77 if (!in_array($event_comment, $event_id))
78 $ar_event_tmp[] = $event_comment;
79 }
80
81 foreach($ar_event_tmp as $event_tmp)
82 {
83 if ($feature && $permX)
84 $perm = $permX;
85 else
87
88 if (
89 array_key_exists(SONET_ENTITY_USER, $CacheRelatedUsers)
90 && array_key_exists($entityID, $CacheRelatedUsers[SONET_ENTITY_USER])
91 && array_key_exists($perm, $CacheRelatedUsers[SONET_ENTITY_USER][$entityID])
92 )
93 $arRelatedUsers = $CacheRelatedUsers[SONET_ENTITY_USER][$entityID][$perm];
94 else
95 {
96 $arRelatedUsers = array();
97
98 switch($perm)
99 {
101 $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $entityID);
103 while ($arFriends = $dbFriends->Fetch())
104 {
105 $friendID = (($entityID == $arFriends["FIRST_USER_ID"]) ? $arFriends["SECOND_USER_ID"] : $arFriends["FIRST_USER_ID"]);
106 $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $friendID);
107 }
108 break;
110 $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $entityID);
112 while ($arFriends = $dbFriends->Fetch())
113 {
114 $friendID = (($entityID == $arFriends["FIRST_USER_ID"]) ? $arFriends["SECOND_USER_ID"] : $arFriends["FIRST_USER_ID"]);
115 $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $friendID);
116
118 while ($arFriends2 = $dbFriends2->Fetch())
119 {
120 $friendID2 = (($friendID == $arFriends2["FIRST_USER_ID"]) ? $arFriends2["SECOND_USER_ID"] : $arFriends2["FIRST_USER_ID"]);
121 if ($friendID2 != $entityID)
122 $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $friendID2, "user_im_id" => $friendID);
123 }
124 }
125 break;
127 $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $entityID);
128 break;
130 $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => 0);
131 break;
133 $arRelatedUsers = false;
134 break;
135 }
136 }
137 if (!empty($arRelatedUsers))
138 $arRelatedUsers = array_unique($arRelatedUsers);
139
140 $CacheRelatedUsers[SONET_ENTITY_USER][$entityID][$perm] = $arRelatedUsers;
141
142 if($arRelatedUsers && is_array($arRelatedUsers))
143 {
144 foreach($arRelatedUsers as $arRelatedUserID)
145 {
147 "ENTITY_TYPE" => SONET_ENTITY_USER,
148 "ENTITY_ID" => $arRelatedUserID["entity_id"],
149 "EVENT_ID" => $event_tmp,
150 "USER_ID" => $arRelatedUserID["user_id"],
151 "USER_ANONYMOUS" => "N"
152 );
153
154 if (array_key_exists("user_im_id", $arRelatedUserID))
155 $arFields["USER_IM_ID"] = $arRelatedUserID["user_im_id"];
156
158 {
159 $errorMessage = "";
160 if ($e = $APPLICATION->GetException())
161 $errorMessage = $e->GetString();
162 if ($errorMessage == '')
163 $errorMessage = GetMessage("SONET_EUV_ERROR_SET");
164
165 $APPLICATION->ThrowException($errorMessage, "ERROR_SET");
166 return false;
167 }
168 }
169 }
170 elseif($arRelatedUsers === false)
171 {
173 "ENTITY_TYPE" => SONET_ENTITY_USER,
174 "ENTITY_ID" => $entityID,
175 "EVENT_ID" => $event_tmp,
176 "USER_ID" => 0,
177 "USER_ANONYMOUS" => "Y"
178 );
180 {
181 $errorMessage = "";
182 if ($e = $APPLICATION->GetException())
183 $errorMessage = $e->GetString();
184 if ($errorMessage == '')
185 $errorMessage = GetMessage("SONET_EUV_ERROR_SET");
186
187 $APPLICATION->ThrowException($errorMessage, "ERROR_SET");
188 return false;
189 }
190 }
191 }
192 }
193
194 if ($bSetFeatures)
195 {
196 $arActiveFeatures = array_keys(CSocNetFeatures::GetActiveFeaturesNames(SONET_ENTITY_USER, $entityID));
197 foreach ($arActiveFeatures as $feature)
198 {
200 }
201 }
202
203 return true;
204 }
205
206 public static function SetGroup($entityID, $bSetFeatures = false)
207 {
208 global $APPLICATION, $DB;
209
210 $entityID = intval($entityID);
211 if ($entityID <= 0)
212 {
213 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
214 return false;
215 }
216
217 $arGroup = CSocNetGroup::GetByID($entityID);
218 if (!$arGroup)
219 {
220 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_NO_ENTITY"), "SONET_EUV_NO_ENTITY");
221 return false;
222 }
223
224 $arLogEvent = array();
225 $arSocNetLogEvents = CSocNetAllowed::GetAllowedLogEvents();
226
227 foreach ($arSocNetLogEvents as $event_tmp_id => $arLogEventTmp)
228 {
229 if (
230 !array_key_exists("ENTITIES", $arLogEventTmp)
231 || !array_key_exists(SONET_SUBSCRIBE_ENTITY_GROUP, $arLogEventTmp["ENTITIES"])
232 )
233 continue;
234
235 if (
236 array_key_exists("NO_SET", $arLogEventTmp)
237 && $arLogEventTmp["NO_SET"]
238 )
239 continue;
240
241 $arLogEvent[] = $event_tmp_id;
242
243 if (
244 array_key_exists("COMMENT_EVENT", $arLogEventTmp)
245 && is_array($arLogEventTmp["COMMENT_EVENT"])
246 && array_key_exists("EVENT_ID", $arLogEventTmp["COMMENT_EVENT"])
247 && $arLogEventTmp["COMMENT_EVENT"]["EVENT_ID"] <> ''
248 )
249 $arLogEvent[] = $arLogEventTmp["COMMENT_EVENT"]["EVENT_ID"];
250 }
251 $arLogEvent = array_unique($arLogEvent);
252
253 foreach ($arLogEvent as $event_tmp_id)
254 {
255 if (!CSocNetEventUserView::Delete(SONET_ENTITY_GROUP, $entityID, $event_tmp_id))
256 {
257 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_ERROR_DELETE"), "ERROR_DELETE");
258 return false;
259 }
260 }
261
262 $dbResult = CSocNetUserToGroup::GetList(
263 array(),
264 array(
265 "GROUP_ID" => $entityID,
266 "<=ROLE" => SONET_ROLES_USER,
267 "USER_ACTIVE" => "Y"
268 ),
269 false,
270 false,
271 array("USER_ID")
272 );
273 while ($arResult = $dbResult->Fetch())
274 {
275 foreach ($arLogEvent as $event_tmp_id)
276 {
278 "ENTITY_TYPE" => SONET_ENTITY_GROUP,
279 "ENTITY_ID" => $entityID,
280 "EVENT_ID" => $event_tmp_id,
281 "USER_ID" => $arResult["USER_ID"],
282 "USER_ANONYMOUS" => "N"
283 );
285 {
286 $errorMessage = "";
287 if ($e = $APPLICATION->GetException())
288 $errorMessage = $e->GetString();
289 if ($errorMessage == '')
290 $errorMessage = GetMessage("SONET_EUV_ERROR_SET");
291
292 $APPLICATION->ThrowException($errorMessage, "ERROR_SET");
293 return false;
294 }
295 }
296 }
297
298 if ($bSetFeatures)
299 {
300 $arActiveFeatures = array_keys(CSocNetFeatures::GetActiveFeaturesNames(SONET_ENTITY_GROUP, $entityID));
301 foreach ($arActiveFeatures as $feature)
302 {
304 }
305 }
306
307 return true;
308 }
309
310 public static function SetFeature($entityType, $entityID, $feature, $op = false, $permX = false, $bCheckEmpty = false)
311 {
313
314 $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
315 $arSocNetAllowedSubscribeEntityTypesDesc = CSocNetAllowed::GetAllowedEntityTypesDesc();
316
317 $CacheRelatedUsers = array();
318
319 $entityType = trim($entityType);
320 if (!in_array($entityType, $arSocNetAllowedEntityTypes))
321 {
322 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_INCORRECT_ENTITY_TYPE"), "ERROR_INCORRECT_ENTITY_TYPE");
323 return false;
324 }
325
326 $entityID = intval($entityID);
327 if ($entityID <= 0)
328 {
329 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
330 return false;
331 }
332
333 if (!$bCheckEmpty || !CSocNetEventUserView::IsEntityEmpty($entityType, $entityID))
334 {
335 $event_id = array();
336 if (!$op || !$permX)
337 {
338 if (
339 array_key_exists($feature, $arSocNetFeaturesSettings)
340 && array_key_exists("subscribe_events", $arSocNetFeaturesSettings[$feature])
341 )
342 {
343 foreach ($arSocNetFeaturesSettings[$feature]["subscribe_events"] as $event_id_tmp => $arEventIDTmp)
344 {
345 if (
346 array_key_exists("NO_SET", $arEventIDTmp)
347 && $arEventIDTmp["NO_SET"]
348 )
349 continue;
350
351 if (
352 !array_key_exists("ENTITIES", $arEventIDTmp)
353 || !array_key_exists($entityType, $arEventIDTmp["ENTITIES"])
354 )
355 continue;
356
357 $event_id[$arEventIDTmp["OPERATION"]][] = $event_id_tmp;
358
359 if (
360 array_key_exists("COMMENT_EVENT", $arEventIDTmp)
361 && is_array($arEventIDTmp["COMMENT_EVENT"])
362 && array_key_exists("OPERATION", $arEventIDTmp["COMMENT_EVENT"])
363 && $arEventIDTmp["COMMENT_EVENT"]["OPERATION"] <> ''
364 )
365 $event_id[$arEventIDTmp["OPERATION"]][] = $arEventIDTmp["COMMENT_EVENT"]["EVENT_ID"];
366 }
367 if (is_array($event_id[$arEventIDTmp["OPERATION"]]))
368 $event_id[$arEventIDTmp["OPERATION"]] = array_unique($event_id[$arEventIDTmp["OPERATION"]]);
369 }
370 }
371 else
372 {
373 $arOpTmp = array();
374 if (
375 array_key_exists($feature, $arSocNetFeaturesSettings)
376 && array_key_exists("subscribe_events", $arSocNetFeaturesSettings[$feature])
377 )
378 {
379 foreach ($arSocNetFeaturesSettings[$feature]["subscribe_events"] as $event_id_tmp => $arEventIDTmp)
380 {
381 if (
382 array_key_exists("NO_SET", $arEventIDTmp)
383 && $arEventIDTmp["NO_SET"]
384 )
385 continue;
386
387 if (
388 !array_key_exists("ENTITIES", $arEventIDTmp)
389 || !array_key_exists($entityType, $arEventIDTmp["ENTITIES"])
390 )
391 continue;
392
393 if (
394 !array_key_exists("OPERATION", $arEventIDTmp)
395 || $arEventIDTmp["OPERATION"] == ''
396 )
397 continue;
398
399 $arOpTmp[] = $arEventIDTmp["OPERATION"];
400
401 if (
402 array_key_exists("COMMENT_EVENT", $arEventIDTmp)
403 && is_array($arEventIDTmp["COMMENT_EVENT"])
404 && array_key_exists("OPERATION", $arEventIDTmp["COMMENT_EVENT"])
405 && $arEventIDTmp["COMMENT_EVENT"]["OPERATION"] <> ''
406 )
407 $arOpTmp[] = $arEventIDTmp["COMMENT_EVENT"]["OPERATION"];
408 }
409 }
410 if (is_array($arOpTmp))
411 $arOpTmp = array_unique($arOpTmp);
412
413 if (in_array($op, $arOpTmp))
414 {
415 foreach ($arSocNetFeaturesSettings[$feature]["subscribe_events"] as $event_id_tmp => $arEventIDTmp)
416 {
417 if ($arEventIDTmp["OPERATION"] == $op)
418 $event_id[$op][] = $event_id_tmp;
419
420 if (
421 array_key_exists("COMMENT_EVENT", $arEventIDTmp)
422 && is_array($arEventIDTmp["COMMENT_EVENT"])
423 && array_key_exists("OPERATION", $arEventIDTmp["COMMENT_EVENT"])
424 && $arEventIDTmp["COMMENT_EVENT"]["OPERATION"] == $op
425 )
426 $event_id[$op][] = $arEventIDTmp["COMMENT_EVENT"]["EVENT_ID"];
427 }
428 if (is_array($event_id[$op]))
429 $event_id[$op] = array_unique($event_id[$op]);
430 }
431 else
432 return true;
433 }
434
435 if
436 (
437 intval($entityID) > 0
438 && array_key_exists($entityType, $arSocNetAllowedSubscribeEntityTypesDesc)
439 && array_key_exists("CLASS_DESC_GET", $arSocNetAllowedSubscribeEntityTypesDesc[$entityType])
440 && array_key_exists("METHOD_DESC_GET", $arSocNetAllowedSubscribeEntityTypesDesc[$entityType])
441 )
442 $arEntityTmp = call_user_func(
443 array(
444 $arSocNetAllowedSubscribeEntityTypesDesc[$entityType]["CLASS_DESC_GET"],
445 $arSocNetAllowedSubscribeEntityTypesDesc[$entityType]["METHOD_DESC_GET"]
446 ),
447 $entityID
448 );
449
450 foreach ($event_id as $op => $arEvent)
451 {
452 $arRelatedUsers = array();
453
454 if (is_array($arEvent))
455 {
456 foreach($arEvent as $event)
457 {
458 if (!CSocNetEventUserView::Delete($entityType, $entityID, $feature, $event))
459 {
460 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_ERROR_DELETE"), "ERROR_DELETE");
461 return false;
462 }
463
464 if (!$feature || !$permX)
465 $perm = CSocNetFeaturesPerms::GetOperationPerm($entityType, $entityID, $feature, $op);
466 else
467 $perm = $permX;
468
469 if (
470 $entityType == SONET_SUBSCRIBE_ENTITY_GROUP
471 && $arEntityTmp
472 && $arEntityTmp["VISIBLE"] == "N"
474 )
476 elseif ($entityType == SONET_SUBSCRIBE_ENTITY_USER)
477 {
478 $perm_profile = CSocNetUserPerms::GetOperationPerms($entityID, "viewprofile");
479 if ($perm < $perm_profile)
480 $perm = $perm_profile;
481 }
482
483 if (
484 array_key_exists($entityType, $CacheRelatedUsers)
485 && array_key_exists($entityID, $CacheRelatedUsers[$entityType])
486 && array_key_exists($perm, $CacheRelatedUsers[$entityType][$entityID])
487 )
488 $arRelatedUsers = $CacheRelatedUsers[$entityType][$entityID][$perm];
489 else
490 {
491 if ($entityType == SONET_SUBSCRIBE_ENTITY_USER)
492 {
493 switch($perm)
494 {
496 $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $entityID);
498 while ($arFriends = $dbFriends->Fetch())
499 {
500 $friendID = (($entityID == $arFriends["FIRST_USER_ID"]) ? $arFriends["SECOND_USER_ID"] : $arFriends["FIRST_USER_ID"]);
501 $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $friendID);
502 }
503 break;
505 $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $entityID);
507 while ($arFriends = $dbFriends->Fetch())
508 {
509 $friendID = (($entityID == $arFriends["FIRST_USER_ID"]) ? $arFriends["SECOND_USER_ID"] : $arFriends["FIRST_USER_ID"]);
510 $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $friendID);
511
513 while ($arFriends2 = $dbFriends2->Fetch())
514 {
515 $friendID2 = (($friendID == $arFriends2["FIRST_USER_ID"]) ? $arFriends2["SECOND_USER_ID"] : $arFriends2["FIRST_USER_ID"]);
516 if ($friendID2 != $entityID)
517 $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $friendID2, "user_im_id" => $friendID);
518 }
519 }
520 break;
522 $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $entityID);
523 break;
525 $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => 0);
526 break;
528 $arRelatedUsers = false;
529 break;
530 }
531 if (!empty($arRelatedUsers))
532 $arRelatedUsers = array_unique($arRelatedUsers);
533
534 $CacheRelatedUsers[SONET_ENTITY_USER][$entityID][$perm] = $arRelatedUsers;
535 }
536 elseif ($entityType == SONET_SUBSCRIBE_ENTITY_GROUP)
537 {
538 switch($perm)
539 {
540 case SONET_ROLES_USER:
541 $dbResult = CSocNetUserToGroup::GetList(
542 array(),
543 array(
544 "GROUP_ID" => $entityID,
545 "<=ROLE" => SONET_ROLES_USER,
546 "USER_ACTIVE" => "Y"
547 ),
548 false,
549 false,
550 array("USER_ID")
551 );
552 while ($arResult = $dbResult->Fetch())
553 $arRelatedUsers[] = $arResult["USER_ID"];
554 break;
556 $dbResult = CSocNetUserToGroup::GetList(
557 array(),
558 array(
559 "GROUP_ID" => $entityID,
560 "<=ROLE" => SONET_ROLES_MODERATOR,
561 "USER_ACTIVE" => "Y"
562 ),
563 false,
564 false,
565 array("USER_ID")
566 );
567 while ($arResult = $dbResult->Fetch())
568 $arRelatedUsers[] = $arResult["USER_ID"];
569 break;
571 $dbResult = CSocNetUserToGroup::GetList(
572 array(),
573 array(
574 "GROUP_ID" => $entityID,
575 "<=ROLE" => SONET_ROLES_OWNER,
576 "USER_ACTIVE" => "Y"
577 ),
578 false,
579 false,
580 array("USER_ID")
581 );
582 while ($arResult = $dbResult->Fetch())
583 $arRelatedUsers[] = $arResult["USER_ID"];
584 break;
586 $arRelatedUsers[] = 0;
587 break;
588 case SONET_ROLES_ALL:
589 $arRelatedUsers = false;
590 break;
591 }
592
593 if ($arRelatedUsers && is_array($arRelatedUsers) && in_array(0, $arRelatedUsers))
594 $arRelatedUsers = array(0);
595 elseif ($arRelatedUsers && is_array($arRelatedUsers))
596 $arRelatedUsers = array_unique($arRelatedUsers);
597
598 $CacheRelatedUsers[SONET_ENTITY_GROUP][$entityID][$perm] = $arRelatedUsers;
599 }
600 }
601
602 if($arRelatedUsers && is_array($arRelatedUsers))
603 {
604 foreach($arRelatedUsers as $relatedUserID)
605 {
606 if (is_array($relatedUserID))
607 {
609 "ENTITY_TYPE" => $entityType,
610 "ENTITY_ID" => $relatedUserID["entity_id"],
611 "EVENT_ID" => $event,
612 "USER_ID" => $relatedUserID["user_id"],
613 "USER_ANONYMOUS" => "N"
614 );
615
616 if (array_key_exists("user_im_id", $relatedUserID))
617 $arFields["USER_IM_ID"] = $relatedUserID["user_im_id"];
618
620 {
621 $errorMessage = "";
622 if ($e = $APPLICATION->GetException())
623 $errorMessage = $e->GetString();
624 if ($errorMessage == '')
625 $errorMessage = GetMessage("SONET_EUV_ERROR_SET");
626
627 $APPLICATION->ThrowException($errorMessage, "ERROR_SET");
628 return false;
629 }
630 }
631 else
632 {
634 "ENTITY_TYPE" => $entityType,
635 "ENTITY_ID" => $entityID,
636 "EVENT_ID" => $event,
637 "USER_ID" => $relatedUserID,
638 "USER_ANONYMOUS" => "N"
639 );
641 {
642 $errorMessage = "";
643 if ($e = $APPLICATION->GetException())
644 $errorMessage = $e->GetString();
645 if ($errorMessage == '')
646 $errorMessage = GetMessage("SONET_EUV_ERROR_SET");
647
648 $APPLICATION->ThrowException($errorMessage, "ERROR_SET");
649 return false;
650 }
651 }
652 }
653 }
654 else
655 {
657 "ENTITY_TYPE" => $entityType,
658 "ENTITY_ID" => $entityID,
659 "EVENT_ID" => $event,
660 "USER_ID" => 0,
661 "USER_ANONYMOUS" => "Y"
662 );
664 {
665 $errorMessage = "";
666 if ($e = $APPLICATION->GetException())
667 $errorMessage = $e->GetString();
668 if ($errorMessage == '')
669 $errorMessage = GetMessage("SONET_EUV_ERROR_SET");
670
671 $APPLICATION->ThrowException($errorMessage, "ERROR_SET");
672 return false;
673 }
674 }
675 }
676 }
677 }
678 }
679 elseif($entityType == SONET_ENTITY_GROUP)
680 CSocNetEventUserView::SetGroup($entityID, true);
681 elseif($entityType == SONET_ENTITY_USER)
682 CSocNetEventUserView::SetUser($entityID, false, false, true);
683
684 return true;
685 }
686
687 public static function Entity2UserAdd($entityType, $entityID, $userID, $role)
688 {
690
691 $CacheRelatedUsers = array();
692
693 $entityType = trim($entityType);
694 if (!in_array($entityType, $arSocNetAllowedEntityTypes))
695 {
696 $APPLICATION->ThrowException(GetMessage("SONET_EUV_INCORRECT_ENTITY_TYPE"), "ERROR_INCORRECT_ENTITY_TYPE");
697 return false;
698 }
699
700 $entityID = intval($entityID);
701 if ($entityID <= 0)
702 {
703 $APPLICATION->ThrowException(GetMessage("SONET_EUV_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
704 return false;
705 }
706
707 $userID = intval($userID);
708 if ($userID <= 0)
709 {
710 $APPLICATION->ThrowException(GetMessage("SONET_EUV_EMPTY_USER_ID"), "ERROR_EMPTY_USER_ID");
711 return false;
712 }
713
714 if (is_array($role))
715 {
716 if (count($role) <= 0)
717 {
718 $APPLICATION->ThrowException(GetMessage("SONET_EUV_EMPTY_ROLE"), "ERROR_EMPTY_ROLE");
719 return false;
720 }
721 }
722 else
723 {
724 $role = trim($role);
725 if ($role == '')
726 {
727 $APPLICATION->ThrowException(GetMessage("SONET_EUV_EMPTY_ROLE"), "ERROR_EMPTY_ROLE");
728 return false;
729 }
730 $role = array($role);
731 }
732
733 if (!CSocNetEventUserView::IsEntityEmpty($entityType, $entityID))
734 {
735 $arEvents = array();
736 $arSocNetLogEvents = CSocNetAllowed::GetAllowedLogEvents();
737
738 foreach ($arSocNetLogEvents as $event_tmp_id => $arLogEventTmp)
739 {
740 if (
741 !array_key_exists("ENTITIES", $arLogEventTmp)
742 || !array_key_exists($entityType, $arLogEventTmp["ENTITIES"])
743 )
744 continue;
745
746 if (
747 array_key_exists("NO_SET", $arLogEventTmp)
748 && $arLogEventTmp["NO_SET"]
749 )
750 continue;
751
752 $arEvents[] = $event_tmp_id;
753
754 if (
755 array_key_exists("COMMENT_EVENT", $arLogEventTmp)
756 && is_array($arLogEventTmp["COMMENT_EVENT"])
757 && array_key_exists("EVENT_ID", $arLogEventTmp["COMMENT_EVENT"])
758 && $arLogEventTmp["COMMENT_EVENT"]["EVENT_ID"] <> ''
759 )
760 $arEvents[] = $arLogEventTmp["COMMENT_EVENT"]["EVENT_ID"];
761 }
762
763 $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedEntityTypes();
764 foreach ($arSocNetFeaturesSettings as $feature => $arFeature)
765 {
766 if (!array_key_exists("subscribe_events", $arFeature))
767 {
768 continue;
769 }
770
771 foreach ($arFeature["subscribe_events"] as $event_id_tmp => $arEventIDTmp)
772 {
773 if (
774 array_key_exists("NO_SET", $arEventIDTmp)
775 && $arEventIDTmp["NO_SET"]
776 )
777 continue;
778
779 if (
780 !array_key_exists("OPERATION", $arEventIDTmp)
781 || $arEventIDTmp["OPERATION"] == ''
782 )
783 continue;
784
785 $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm($entityType, $entityID, $feature, $arEventIDTmp["OPERATION"]);
786 if (in_array($featureOperationPerms, $role))
787 $arEvents[] = $event_id_tmp;
788
789 if (
790 array_key_exists("COMMENT_EVENT", $arEventIDTmp)
791 && is_array($arEventIDTmp["COMMENT_EVENT"])
792 && array_key_exists("EVENT_ID", $arEventIDTmp["COMMENT_EVENT"])
793 && array_key_exists("OPERATION", $arEventIDTmp["COMMENT_EVENT"])
794 && $arEventIDTmp["COMMENT_EVENT"]["EVENT_ID"] <> ''
795 && $arEventIDTmp["COMMENT_EVENT"]["OPERATION"] <> ''
796 && ($arEventIDTmp["COMMENT_EVENT"]["EVENT_ID"] != $event_id_tmp)
797 )
798 {
799 $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm($entityType, $entityID, $feature, $arEventIDTmp["COMMENT_EVENT"]["OPERATION"]);
800 if (in_array($featureOperationPerms, $role))
801 $arEvents[] = $arEventIDTmp["COMMENT_EVENT"]["EVENT_ID"];
802 }
803 }
804 }
805 $arEvents = array_unique($arEvents);
806
807 foreach($arEvents as $event)
808 {
809 $arFieldsEUV = array(
810 "ENTITY_TYPE" => SONET_ENTITY_GROUP,
811 "ENTITY_ID" => $entityID,
812 "EVENT_ID" => $event,
813 "USER_ID" => $userID,
814 "USER_ANONYMOUS" => "N"
815 );
816 CSocNetEventUserView::Add($arFieldsEUV);
817 }
818 }
819 elseif($entityType == SONET_ENTITY_GROUP)
820 CSocNetEventUserView::SetGroup($entityID, true);
821 elseif($entityType == SONET_ENTITY_USER)
822 CSocNetEventUserView::SetUser($entityID, false, false, true);
823 }
824
825 public static function CheckFields($ACTION, &$arFields)
826 {
827 global $DB;
828
829 $arSocNetAllowedSubscribeEntityTypes = CSocNetAllowed::GetAllowedEntityTypes();
830
831 if (!array_key_exists("ENTITY_TYPE", $arFields))
832 {
833 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_EMPTY_ENTITY_TYPE"), "ERROR_EMPTY_ENTITY_TYPE");
834 return false;
835 }
836
837 if (!in_array($arFields["ENTITY_TYPE"], CSocNetAllowed::GetAllowedEntityTypes()))
838 {
839 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_INCORRECT_ENTITY_TYPE"), "ERROR_INCORRECT_ENTITY_TYPE");
840 return false;
841 }
842
843 if (!array_key_exists("ENTITY_ID", $arFields))
844 {
845 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
846 return false;
847 }
848
849 // check primary key
850 if ($ACTION == "ADD")
851 {
853 Array("ENTITY_ID" => "DESC"),
854 Array(
855 "ENTITY_TYPE" => $arFields["ENTITY_TYPE"],
856 "ENTITY_ID" => intval($arFields["ENTITY_ID"]),
857 "EVENT_ID" => (array_key_exists("EVENT_ID", $arFields) ? $arFields["EVENT_ID"] : ""),
858 "USER_ID" => (array_key_exists("USER_ID", $arFields) ? intval($arFields["USER_ID"]) : 0),
859 "USER_IM_ID" => (array_key_exists("USER_IM_ID", $arFields) ? intval($arFields["USER_IM_ID"]) : 0)
860 )
861 );
862
863 if ($arRes = $dbResult->Fetch())
864 {
865 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_RECORD_EXISTS"), "ERROR_RECORD_EXISTS");
866 return false;
867 }
868 }
869
870 return True;
871 }
872
873 public static function Delete($entityType, $entityID, $feature = false, $event = false)
874 {
875 global $DB;
876
877 $arSocNetAllowedSubscribeEntityTypes = CSocNetAllowed::GetAllowedEntityTypes();
878 $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
879 $arSocNetLogEvents = CSocNetAllowed::GetAllowedLogEvents();
880
881 $entityType = trim($entityType);
882
883 if (!in_array($entityType, CSocNetAllowed::GetAllowedEntityTypes()))
884 {
885 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_INCORRECT_ENTITY_TYPE"), "ERROR_INCORRECT_ENTITY_TYPE");
886 return false;
887 }
888
889 $entityID = intval($entityID);
890 if ($entityID <= 0)
891 {
892 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
893 return false;
894 }
895
896 $strWhere = " WHERE ENTITY_TYPE = '".$entityType."' AND ENTITY_ID = ".$entityID;
897 if ($feature)
898 {
899 if ($event)
900 $strWhere .= " AND EVENT_ID = '".$event."'";
901 else
902 {
903 $event_id = array();
904
905 if (
906 (
907 array_key_exists($feature, $arSocNetLogEvents)
908 && array_key_exists("ENTITIES", $arSocNetLogEvents[$feature])
909 && array_key_exists($entityType, $arSocNetLogEvents[$feature]["ENTITIES"])
910 )
911 ||
912 (
913 array_key_exists($feature, $arSocNetFeaturesSettings)
914 && array_key_exists("subscribe_events", $arSocNetFeaturesSettings[$feature])
915 && count($arSocNetFeaturesSettings[$feature]["subscribe_events"]) > 0
916 )
917 )
918 {
919 if (array_key_exists($feature, $arSocNetLogEvents))
920 {
921 $event_id[] = $feature;
922
923 if (
924 array_key_exists("COMMENT_EVENT", $arSocNetLogEvents[$feature])
925 && is_array($arSocNetLogEvents[$feature]["COMMENT_EVENT"])
926 && array_key_exists("EVENT_ID", $arSocNetLogEvents[$feature]["COMMENT_EVENT"])
927 && $arSocNetLogEvents[$feature]["COMMENT_EVENT"]["EVENT_ID"] <> ''
928 )
929 $event_id[] = $arSocNetLogEvents[$feature]["COMMENT_EVENT"]["EVENT_ID"];
930 }
931
932 if (
933 array_key_exists($feature, $arSocNetFeaturesSettings)
934 && array_key_exists("subscribe_events", $arSocNetFeaturesSettings[$feature])
935 && count($arSocNetFeaturesSettings[$feature]["subscribe_events"]) > 0
936 )
937 {
938 foreach ($arSocNetFeaturesSettings[$feature]["subscribe_events"] as $event_id_tmp => $arEventIDTmp)
939 {
940 if (
941 array_key_exists("NO_SET", $arEventIDTmp)
942 && $arEventIDTmp["NO_SET"]
943 )
944 {
945 continue;
946 }
947
948 $event_id[] = $event_id_tmp;
949
950 if (
951 array_key_exists("COMMENT_EVENT", $arEventIDTmp)
952 && is_array($arEventIDTmp["COMMENT_EVENT"])
953 && array_key_exists("EVENT_ID", $arEventIDTmp["COMMENT_EVENT"])
954 && $arEventIDTmp["COMMENT_EVENT"]["EVENT_ID"] <> ''
955 )
956 $event_id[] = $arEventIDTmp["COMMENT_EVENT"]["EVENT_ID"];
957 }
958 }
959 $event_id = array_unique($event_id);
960
961 $strWhere .= " AND (";
962 $i = 0;
963 foreach ($event_id as $ev)
964 {
965 if ($i > 0)
966 $strWhere .= " OR ";
967 $strWhere .= "EVENT_ID = '".$ev."'";
968 $i++;
969 }
970 $strWhere .= ")";
971 }
972 }
973 }
974 $bSuccess = $DB->Query("DELETE FROM b_sonet_event_user_view".$strWhere, true);
975
976 return $bSuccess;
977 }
978
979 public static function IsEntityEmpty($entityType, $entityID)
980 {
982
983 $entityType = trim($entityType);
984 if (!in_array($entityType, $arSocNetAllowedEntityTypes))
985 {
986 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_INCORRECT_ENTITY_TYPE"), "ERROR_INCORRECT_ENTITY_TYPE");
987 return false;
988 }
989
990 $entityID = intval($entityID);
991 if ($entityID <= 0)
992 {
993 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
994 return false;
995 }
996
997 $iCnt = CSocNetEventUserView::GetList(array(), array("ENTITY_TYPE" => $entityType, "ENTITY_ID" => $entityID), array());
998 if (intval($iCnt) > 0)
999 return false;
1000 else
1001 return true;
1002 }
1003
1004 public static function CheckPermissions($table, $user_id)
1005 {
1006 if ($user_id === false)
1007 $strUser = " AND EUV.USER_ANONYMOUS = 'Y' AND EUV.USER_ID = 0";
1008 else
1009 $strUser = " AND EUV.USER_ID IN (".intval($user_id).", 0)";
1010
1011 return "INNER JOIN b_sonet_event_user_view EUV USE INDEX (IX_SONET_EVENT_USER_VIEW_2) ON
1012 EUV.ENTITY_TYPE = ".$table.".ENTITY_TYPE
1013 AND (
1014 EUV.ENTITY_ID = ".$table.".ENTITY_ID
1015 OR EUV.ENTITY_ID = 0
1016 )
1017 AND EUV.EVENT_ID = ".$table.".EVENT_ID ".$strUser;
1018 }
1019
1020 public static function CheckPermissionsByEvent($entity_type, $entity_id, $event_id, $user_id)
1021 {
1022 global $DB;
1023
1024 $user_id = intval($user_id);
1025 if ($user_id <= 0)
1026 $user_id = $GLOBALS["USER"]->GetID();
1027 if ($user_id <= 0)
1028 return false;
1029
1030 $entity_id = intval($entity_id);
1031 if ($entity_id <= 0)
1032 return false;
1033
1034 $entity_type = trim($entity_type);
1035 if ($entity_type == '')
1036 return false;
1037
1038 $event_id = trim($event_id);
1039 if ($event_id == '')
1040 return false;
1041
1042 $strSQL = "SELECT USER_ID FROM b_sonet_event_user_view WHERE
1043 ENTITY_TYPE = '".$DB->ForSQL($entity_type)."'
1044 AND ENTITY_ID IN (0, ".$entity_id.")
1045 AND EVENT_ID = '".$DB->ForSQL($event_id)."'
1046 AND USER_ID IN (0, ".$user_id.")";
1047
1048 $dbRes = $GLOBALS["DB"]->Query($strSQL);
1049 if ($arRes = $dbRes->Fetch())
1050 return true;
1051 else
1052 return false;
1053
1054 }
1055}
global $APPLICATION
Определения include.php:80
$arResult
Определения generate_coupon.php:16
static SetFeature($entityType, $entityID, $feature, $op=false, $permX=false, $bCheckEmpty=false)
Определения event_user_view.php:310
static CheckPermissionsByEvent($entity_type, $entity_id, $event_id, $user_id)
Определения event_user_view.php:1020
static SetUser($entityID, $feature=false, $permX=false, $bSetFeatures=false)
Определения event_user_view.php:7
static SetGroup($entityID, $bSetFeatures=false)
Определения event_user_view.php:206
static CheckPermissions($table, $user_id)
Определения event_user_view.php:1004
static IsEntityEmpty($entityType, $entityID)
Определения event_user_view.php:979
static CheckFields($ACTION, &$arFields)
Определения event_user_view.php:825
static Delete($entityType, $entityID, $feature=false, $event=false)
Определения event_user_view.php:873
static Entity2UserAdd($entityType, $entityID, $userID, $role)
Определения event_user_view.php:687
static GetOperationPerms($userID, $operation)
Определения user_perms.php:155
static GetRelatedUsers($userID, $relation, $arNavStartParams=false, $bActiveOnly="N")
Определения user_relations.php:215
static GetList($arOrder=Array("ENTITY_ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения event_user_view.php:33
static Add($arFields)
Определения event_user_view.php:10
static FindLogCommentEventByLogEventID($log_event_id)
Определения log_tools.php:142
$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
$perm
Определения options.php:169
while($arParentIBlockProperty=$dbParentIBlockProperty->Fetch()) $errorMessage
global $DB
Определения cron_frame.php:29
$ACTION
Определения csv_new_setup.php:27
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$event
Определения prolog_after.php:141
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$i
Определения factura.php:643
</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
const SONET_ROLES_USER
Определения include.php:31
const SONET_SUBSCRIBE_ENTITY_USER
Определения include.php:121
const SONET_ENTITY_GROUP
Определения include.php:117
const SONET_SUBSCRIBE_ENTITY_GROUP
Определения include.php:120
const SONET_ROLES_AUTHORIZED
Определения include.php:36
const SONET_ENTITY_USER
Определения include.php:118
const SONET_ROLES_MODERATOR
Определения include.php:30
const SONET_ROLES_OWNER
Определения include.php:29
const SONET_RELATIONS_FRIEND
Определения include.php:24
const SONET_RELATIONS_TYPE_FRIENDS
Определения include.php:41
const SONET_ROLES_ALL
Определения include.php:35
const SONET_RELATIONS_TYPE_FRIENDS2
Определения include.php:40
const SONET_RELATIONS_TYPE_ALL
Определения include.php:38
const SONET_RELATIONS_TYPE_AUTHORIZED
Определения include.php:39
const SONET_RELATIONS_TYPE_NONE
Определения include.php:42
global $arSocNetAllowedEntityTypes
Определения include.php:123
if( $_SERVER $arSocNetFeaturesSettings['REQUEST_METHOD']=="GET" &&($RestoreDefaults ?? null)<> '' && $SONET_RIGHT=="W" &&check_bitrix_sessid())
Определения options.php:35
$arRes
Определения options.php:104
$GLOBALS['_____370096793']
Определения update_client.php:1
$dbResult
Определения updtr957.php:3
$dbRes
Определения yandex_detail.php:168