1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
group_features.php
См. документацию.
1<?php
2
4
5$GLOBALS["SONET_FEATURES_CACHE"] = array();
6
8use Bitrix\Socialnetwork\Integration;
9
11{
12 /***************************************/
13 /******** DATA MODIFICATION **********/
14 /***************************************/
15 public static function CheckFields($ACTION, &$arFields, $ID = 0)
16 {
18
19 if ($ACTION !== "ADD" && (int)$ID <= 0)
20 {
21 $APPLICATION->ThrowException("System error 870164", "ERROR");
22 return false;
23 }
24
25 if ((is_set($arFields, "ENTITY_TYPE") || $ACTION === "ADD") && $arFields["ENTITY_TYPE"] == '')
26 {
27 $APPLICATION->ThrowException(GetMessage("SONET_GF_EMPTY_ENTITY_TYPE"), "EMPTY_ENTITY_TYPE");
28 return false;
29 }
30
31 if (is_set($arFields, "ENTITY_TYPE"))
32 {
33 if (!in_array($arFields["ENTITY_TYPE"], $arSocNetAllowedEntityTypes))
34 {
35 $APPLICATION->ThrowException(GetMessage("SONET_GF_ERROR_NO_ENTITY_TYPE"), "ERROR_NO_ENTITY_TYPE");
36 return false;
37 }
38 }
39
40 if ((is_set($arFields, "ENTITY_ID") || $ACTION === "ADD") && (int)$arFields["ENTITY_ID"] <= 0)
41 {
42 $APPLICATION->ThrowException(GetMessage("SONET_GF_EMPTY_ENTITY_ID"), "EMPTY_ENTITY_ID");
43 return false;
44 }
45
46 if (is_set($arFields, "ENTITY_ID"))
47 {
48 $type = "";
49 if (is_set($arFields, "ENTITY_TYPE"))
50 {
51 $type = $arFields["ENTITY_TYPE"];
52 }
53 elseif ($ACTION !== 'ADD')
54 {
56 if ($arRe)
57 $type = $arRe["ENTITY_TYPE"];
58 }
59 if ($type == '')
60 {
61 $APPLICATION->ThrowException(GetMessage("SONET_GF_ERROR_CALC_ENTITY_TYPE"), "ERROR_CALC_ENTITY_TYPE");
62 return false;
63 }
64
66 {
67 $arResult = CSocNetGroup::GetByID($arFields["ENTITY_ID"]);
68 if ($arResult == false)
69 {
70 $APPLICATION->ThrowException(GetMessage("SONET_GF_ERROR_NO_ENTITY_ID"), "ERROR_NO_ENTITY_ID");
71 return false;
72 }
73 }
75 {
76 $dbResult = CUser::GetByID($arFields["ENTITY_ID"]);
77 if (!$dbResult->Fetch())
78 {
79 $APPLICATION->ThrowException(GetMessage("SONET_GF_ERROR_NO_ENTITY_ID"), "ERROR_NO_ENTITY_ID");
80 return false;
81 }
82 }
83 else
84 {
85 $APPLICATION->ThrowException(GetMessage("SONET_GF_ERROR_CALC_ENTITY_TYPE"), "ERROR_CALC_ENTITY_TYPE");
86 return false;
87 }
88 }
89
90 if ((is_set($arFields, "FEATURE") || $ACTION === "ADD") && $arFields["FEATURE"] == '')
91 {
92 $APPLICATION->ThrowException(GetMessage("SONET_GF_EMPTY_FEATURE_ID"), "EMPTY_FEATURE");
93 return false;
94 }
95
96 if (is_set($arFields, "FEATURE"))
97 {
98 $arFields["FEATURE"] = mb_strtolower($arFields["FEATURE"]);
99 $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
100
101 if (!array_key_exists($arFields["FEATURE"], $arSocNetFeaturesSettings))
102 {
103 $parameters = $arFields['parameters'] ?? [];
104 if (!($parameters['isCollab'] ?? false) && $arFields["FEATURE"] === 'chat')
105 {
106 $APPLICATION->ThrowException(GetMessage("SONET_GF_ERROR_NO_FEATURE_ID"), "ERROR_NO_FEATURE");
107 return false;
108 }
109 }
110 }
111
112 if (is_set($arFields, "DATE_CREATE") && (!$DB->IsDate($arFields["DATE_CREATE"], false, LANG, "FULL")))
113 {
114 $APPLICATION->ThrowException(GetMessage("SONET_GB_EMPTY_DATE_CREATE"), "EMPTY_DATE_CREATE");
115 return false;
116 }
117
118 if (is_set($arFields, "DATE_UPDATE") && (!$DB->IsDate($arFields["DATE_UPDATE"], false, LANG, "FULL")))
119 {
120 $APPLICATION->ThrowException(GetMessage("SONET_GB_EMPTY_DATE_UPDATE"), "EMPTY_DATE_UPDATE");
121 return false;
122 }
123
124 if (
125 (is_set($arFields, "ACTIVE") || $ACTION === "ADD")
126 && !in_array($arFields["ACTIVE"], array("Y", "N"))
127 )
128 {
129 $arFields["ACTIVE"] = "Y";
130 }
131
132 return True;
133 }
134
135 public static function Delete($ID)
136 {
137 global $DB, $CACHE_MANAGER;
138
139 if (!CSocNetGroup::__ValidateID($ID))
140 return false;
141
142 $ID = intval($ID);
143 $bSuccess = True;
144
145 $db_events = GetModuleEvents("socialnetwork", "OnBeforeSocNetFeatures");
146 while ($arEvent = $db_events->Fetch())
147 if (ExecuteModuleEventEx($arEvent, array($ID))===false)
148 return false;
149
150 $events = GetModuleEvents("socialnetwork", "OnSocNetFeatures");
151 while ($arEvent = $events->Fetch())
152 ExecuteModuleEventEx($arEvent, array($ID));
153
154 $DB->StartTransaction();
155
156 if ($bSuccess)
157 $bSuccess = $DB->Query("DELETE FROM b_sonet_features2perms WHERE FEATURE_ID = ".$ID."", true);
158 if ($bSuccess)
159 $bSuccess = $DB->Query("DELETE FROM b_sonet_features WHERE ID = ".$ID."", true);
160
161 if ($bSuccess)
162 {
163 $DB->Commit();
164 if (defined("BX_COMP_MANAGED_CACHE"))
165 {
166 $CACHE_MANAGER->ClearByTag('sonet_features');
167 $CACHE_MANAGER->ClearByTag("sonet_feature_".$ID);
168 }
169
170 FeatureTable::cleanCache();
171 }
172 else
173 {
174 $DB->Rollback();
175 }
176
177 return $bSuccess;
178 }
179
180 public static function DeleteNoDemand($userID)
181 {
182 global $DB, $CACHE_MANAGER;
183
184 if (!CSocNetGroup::__ValidateID($userID))
185 return false;
186
187 $userID = intval($userID);
188
189 $dbResult = CSocNetFeatures::GetList(array(), array("ENTITY_TYPE" => "U", "ENTITY_ID" => $userID), false, false, array("ID"));
190 while ($arResult = $dbResult->Fetch())
191 {
192 $DB->Query("DELETE FROM b_sonet_features2perms WHERE FEATURE_ID = ".$arResult["ID"]."", true);
193 if (defined("BX_COMP_MANAGED_CACHE"))
194 {
195 $CACHE_MANAGER->ClearByTag("sonet_feature_".$arResult["ID"]);
196 }
197 }
198
199 $DB->Query("DELETE FROM b_sonet_features WHERE ENTITY_TYPE = 'U' AND ENTITY_ID = ".$userID."", true);
200
201 return true;
202 }
203
204 public static function Update($ID, $arFields)
205 {
206 global $DB, $CACHE_MANAGER;
207
208 if (!CSocNetGroup::__ValidateID($ID))
209 return false;
210
211 $ID = intval($ID);
212
214
216 return false;
217
218 $db_events = GetModuleEvents("socialnetwork", "OnBeforeSocNetFeaturesUpdate");
219 while ($arEvent = $db_events->Fetch())
220 if (ExecuteModuleEventEx($arEvent, array($ID, &$arFields))===false)
221 return false;
222
223 $strUpdate = $DB->PrepareUpdate("b_sonet_features", $arFields);
225
226 if ($strUpdate <> '')
227 {
228 $strSql =
229 "UPDATE b_sonet_features SET ".
230 " ".$strUpdate." ".
231 "WHERE ID = ".$ID." ";
232 $DB->Query($strSql);
233
234 if (array_key_exists("ENTITY_TYPE", $arFields) && array_key_exists("ENTITY_ID", $arFields))
235 {
236 unset($GLOBALS["SONET_FEATURES_CACHE"][$arFields["ENTITY_TYPE"]][$arFields["ENTITY_ID"]]);
237 }
238
239 $events = GetModuleEvents("socialnetwork", "OnSocNetFeaturesUpdate");
240 while ($arEvent = $events->Fetch())
242
243 if (defined("BX_COMP_MANAGED_CACHE"))
244 {
245 $CACHE_MANAGER->ClearByTag('sonet_features');
246 $CACHE_MANAGER->ClearByTag("sonet_feature_".$ID);
247 }
248
249 FeatureTable::cleanCache();
250 }
251 else
252 {
253 $ID = false;
254 }
255
256 return $ID;
257 }
258
259 public static function SetFeature($type, $id, $feature, $active, $featureName = false, array $parameters = [])
260 {
262
263 $type = Trim($type);
264 if (($type == '') || !in_array($type, $arSocNetAllowedEntityTypes))
265 {
266 $APPLICATION->ThrowException(GetMessage("SONET_GF_ERROR_NO_ENTITY_TYPE"), "ERROR_EMPTY_TYPE");
267 return false;
268 }
269
270 $id = intval($id);
271 if ($id <= 0)
272 {
273 $APPLICATION->ThrowException(GetMessage("SONET_GF_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
274 return false;
275 }
276
277 $feature = mb_strtolower(Trim($feature));
278 if ($feature == '')
279 {
280 $APPLICATION->ThrowException(GetMessage("SONET_GF_EMPTY_FEATURE_ID"), "ERROR_EMPTY_FEATURE_ID");
281 return false;
282 }
283
284 $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
285 if (
286 !array_key_exists($feature, $arSocNetFeaturesSettings)
287 || !in_array($type, $arSocNetFeaturesSettings[$feature]["allowed"])
288 )
289 {
290 if (!($parameters['isCollab'] ?? false) && $feature === 'chat')
291 {
292 $APPLICATION->ThrowException(GetMessage("SONET_GF_ERROR_NO_FEATURE_ID"), "ERROR_NO_FEATURE_ID");
293 return false;
294 }
295 }
296
297 $active = ($active ? "Y" : "N");
298
299 $dbResult = CSocNetFeatures::GetList(
300 array(),
301 array(
302 "ENTITY_TYPE" => $type,
303 "ENTITY_ID" => $id,
304 "FEATURE" => $feature
305 ),
306 false,
307 false,
308 array("ID", "ACTIVE")
309 );
310
311 if ($arResult = $dbResult->Fetch())
312 {
314 $arResult["ID"],
315 array(
316 "FEATURE_NAME" => $featureName,
317 "ACTIVE" => $active,
318 "=DATE_UPDATE" => CDatabase::CurrentTimeFunction()
319 )
320 );
321 if ($r)
322 {
323 $CACHE_MANAGER->clearByTag("sonet_feature_all_".$type."_".$feature);
324 }
325 }
326 else
327 {
328 $r = CSocNetFeatures::Add(array(
329 "ENTITY_TYPE" => $type,
330 "ENTITY_ID" => $id,
331 "FEATURE" => $feature,
332 "FEATURE_NAME" => $featureName,
333 "ACTIVE" => $active,
334 "=DATE_UPDATE" => CDatabase::CurrentTimeFunction(),
335 "=DATE_CREATE" => CDatabase::CurrentTimeFunction(),
336 'parameters' => $parameters,
337 ));
338 }
339
340 if ($feature === 'chat')
341 {
343 'group_id' => $id,
344 'skipAvailabilityCheck' => true
345 ));
346
347 if (
348 $active === 'Y'
349 && (
350 empty($chatData[$id])
351 || (int)$chatData[$id] <= 0
352 )
353 )
354 {
356 'group_id' => $id
357 ));
358 }
359 elseif (
360 $active === 'N'
361 && !empty($chatData[$id])
362 && (int)$chatData[$id] > 0
363 )
364 {
366 'group_id' => $id
367 ));
368 }
369 }
370
371 if (!$r)
372 {
373 $errorMessage = "";
374 if ($e = $APPLICATION->GetException())
375 $errorMessage = $e->GetString();
376 if ($errorMessage == '')
377 $errorMessage = GetMessage("SONET_GF_ERROR_SET").".";
378
379 $APPLICATION->ThrowException($errorMessage, "ERROR_SET_RECORD");
380 return false;
381 }
382
383 return $r;
384 }
385
386 /***************************************/
387 /********** DATA SELECTION ***********/
388 /***************************************/
389 public static function GetByID($ID)
390 {
391 if (!CSocNetGroup::__ValidateID($ID))
392 {
393 return false;
394 }
395
396 $ID = (int)$ID;
397
398 $dbResult = CSocNetFeatures::GetList(Array(), Array("ID" => $ID));
399 if ($arResult = $dbResult->GetNext())
400 {
401 return $arResult;
402 }
403
404 return False;
405 }
406
407 /***************************************/
408 /********** COMMON METHODS ***********/
409 /***************************************/
410 public static function IsActiveFeature($type, $id, $feature)
411 {
413
414 $arReturn = [];
415
416 $type = trim($type);
417 if (
418 $type == ''
420 )
421 {
422 $APPLICATION->ThrowException(GetMessage("SONET_GF_ERROR_NO_ENTITY_TYPE"), "ERROR_EMPTY_TYPE");
423 return false;
424 }
425
426 $feature = mb_strtolower(trim($feature));
427 if ($feature == '')
428 {
429 $APPLICATION->ThrowException(GetMessage("SONET_GF_EMPTY_FEATURE_ID"), "ERROR_EMPTY_FEATURE_ID");
430 return false;
431 }
432
433 $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
434 if (
435 !isset($arSocNetFeaturesSettings[$feature]['allowed'])
436 || !in_array($type, $arSocNetFeaturesSettings[$feature]['allowed'], true)
437 )
438 {
439 $APPLICATION->ThrowException(GetMessage("SONET_GF_ERROR_NO_FEATURE_ID"), "ERROR_NO_FEATURE_ID");
440 return false;
441 }
442
443 $arFeatures = [];
444
445 if (is_array($id))
446 {
447 $arGroupToGet = array();
448 foreach($id as $group_id)
449 {
450 if ($group_id <= 0)
451 {
452 $arReturn[$group_id] = false;
453 }
454 elseif (
455 isset($GLOBALS['SONET_FEATURES_CACHE'][$type][$group_id])
456 && is_array($GLOBALS['SONET_FEATURES_CACHE'][$type][$group_id])
457 )
458 {
459 $arFeatures[$group_id] = $GLOBALS["SONET_FEATURES_CACHE"][$type][$group_id];
460
461 if (!array_key_exists($feature, $arFeatures[$group_id]))
462 {
463 $arReturn[$group_id] = true;
464 continue;
465 }
466
467 $arReturn[$group_id] = ($arFeatures[$group_id][$feature]['ACTIVE'] === "Y");
468 }
469 else
470 {
471 $arGroupToGet[] = $group_id;
472 }
473 }
474
475 if (!empty($arGroupToGet))
476 {
477 $res = CSocNetFeatures::getList(
478 [],
479 [
480 '@ENTITY_ID' => $arGroupToGet,
481 'ENTITY_TYPE' => $type,
482 ],
483 false,
484 false,
485 [ 'ENTITY_ID', 'FEATURE', 'ACTIVE', 'FEATURE_NAME' ]
486 );
487 while ($featureFields = $res->getNext(true, false))
488 {
489 $arFeatures[$featureFields['ENTITY_ID']][$featureFields['FEATURE']] = [
490 'ACTIVE' => $featureFields['ACTIVE'],
491 'FEATURE_NAME' => $featureFields['FEATURE_NAME'],
492 ];
493 }
494
495 foreach ($arGroupToGet as $group_id)
496 {
497 if (
498 !isset($GLOBALS['SONET_FEATURES_CACHE'])
499 || !is_array($GLOBALS['SONET_FEATURES_CACHE'])
500 )
501 {
502 $GLOBALS['SONET_FEATURES_CACHE'] = [];
503 }
504
505 if (
506 !isset($GLOBALS['SONET_FEATURES_CACHE'][$type])
507 || !is_array($GLOBALS['SONET_FEATURES_CACHE'][$type])
508 )
509 {
510 $GLOBALS['SONET_FEATURES_CACHE'][$type] = [];
511 }
512
513 if (!isset($arFeatures[$group_id]))
514 {
515 $arFeatures[$group_id] = Array();
516 }
517
518 $GLOBALS["SONET_FEATURES_CACHE"][$type][$group_id] = $arFeatures[$group_id];
519
520 if (!array_key_exists($feature, $arFeatures[$group_id]))
521 {
522 $arReturn[$group_id] = true;
523 continue;
524 }
525
526 $arReturn[$group_id] = ($arFeatures[$group_id][$feature]["ACTIVE"] === "Y");
527 }
528 }
529
530 return $arReturn;
531 }
532
533 // not array
534 $id = (int)$id;
535 if ($id <= 0)
536 {
537 $APPLICATION->ThrowException(GetMessage("SONET_GF_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
538 return false;
539 }
540
541 if (
542 isset($GLOBALS['SONET_FEATURES_CACHE'][$type][$id])
543 && is_array($GLOBALS['SONET_FEATURES_CACHE'][$type][$id])
544 )
545 {
546 $arFeatures = $GLOBALS["SONET_FEATURES_CACHE"][$type][$id];
547 }
548 else
549 {
550 $res = CSocNetFeatures::getList(
551 [],
552 [
553 'ENTITY_ID' => $id,
554 'ENTITY_TYPE' => $type,
555 ],
556 false,
557 false,
558 [ 'FEATURE', 'ACTIVE', 'FEATURE_NAME' ]
559 );
560 while ($featureFields = $res->getNext())
561 {
562 $arFeatures[$featureFields['FEATURE']] = [
563 'ACTIVE' => $featureFields['ACTIVE'],
564 'FEATURE_NAME' => $featureFields['FEATURE_NAME'],
565 ];
566 }
567
568 if (
569 !isset($GLOBALS['SONET_FEATURES_CACHE'])
570 || !is_array($GLOBALS['SONET_FEATURES_CACHE'])
571 )
572 {
573 $GLOBALS['SONET_FEATURES_CACHE'] = [];
574 }
575
576 if (
577 !isset($GLOBALS['SONET_FEATURES_CACHE'][$type])
578 || !is_array($GLOBALS['SONET_FEATURES_CACHE'][$type])
579 )
580 {
581 $GLOBALS["SONET_FEATURES_CACHE"][$type] = [];
582 }
583
584 $GLOBALS['SONET_FEATURES_CACHE'][$type][$id] = $arFeatures;
585 }
586
587 if (!array_key_exists($feature, $arFeatures))
588 {
589 return true;
590 }
591
592 return ($arFeatures[$feature]['ACTIVE'] === 'Y');
593 }
594
595 private static function getActiveFeaturesList($type, $id)
596 {
597 global $CACHE_MANAGER;
598
599 $arFeatures = array();
600
601 $cache = new CPHPCache;
602 $cache_time = 31536000;
603 $cache_id = $type."_".$id;
604 $cache_path = "/sonet/features/".$type."/".intval($id / 1000)."/".$id."/";
605
606 if ($cache->InitCache($cache_time, $cache_id, $cache_path))
607 {
608 $arCacheVars = $cache->GetVars();
609 $arFeatures = $arCacheVars["FEATURES"];
610 }
611 else
612 {
613 $cache->StartDataCache($cache_time, $cache_id, $cache_path);
614 if (defined("BX_COMP_MANAGED_CACHE"))
615 {
616 $CACHE_MANAGER->StartTagCache($cache_path);
617 $CACHE_MANAGER->RegisterTag("sonet_features_".$type."_".$id);
618 }
619
621 [],
622 [
623 "ENTITY_ID" => $id,
624 "ENTITY_TYPE" => $type,
625 ]
626 );
627 while ($arResult = $dbResult->GetNext())
628 {
629 $arFeatures[$arResult["FEATURE"]] = [
630 "ACTIVE" => $arResult["ACTIVE"],
631 "FEATURE_NAME" => $arResult["FEATURE_NAME"],
632 "~FEATURE_NAME" => $arResult["~FEATURE_NAME"],
633 ];
634 if (defined("BX_COMP_MANAGED_CACHE"))
635 {
636 $CACHE_MANAGER->RegisterTag("sonet_feature_".$arResult["ID"]);
637 }
638 }
639
640 $arCacheData = Array(
641 "FEATURES" => $arFeatures
642 );
643 if(defined("BX_COMP_MANAGED_CACHE"))
644 {
645 $CACHE_MANAGER->EndTagCache();
646 }
647 $cache->EndDataCache($arCacheData);
648 }
649
650 return $arFeatures;
651 }
652
653 public static function GetActiveFeatures($type, $id)
654 {
656
657 $type = Trim($type);
658 if (($type == '') || !in_array($type, $arSocNetAllowedEntityTypes))
659 {
660 $APPLICATION->ThrowException(GetMessage("SONET_GF_ERROR_NO_ENTITY_TYPE"), "ERROR_EMPTY_TYPE");
661 return false;
662 }
663
664 $id = (int)$id;
665 if ($id <= 0)
666 {
667 $APPLICATION->ThrowException(GetMessage("SONET_GF_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
668 return false;
669 }
670
671 $arReturn = array();
672
673 if (array_key_exists("SONET_FEATURES_CACHE", $GLOBALS)
674 && isset($GLOBALS["SONET_FEATURES_CACHE"][$type])
675 && isset($GLOBALS["SONET_FEATURES_CACHE"][$type][$id])
676 && is_array($GLOBALS["SONET_FEATURES_CACHE"][$type][$id]))
677 {
678 $arFeatures = $GLOBALS["SONET_FEATURES_CACHE"][$type][$id];
679 }
680 else
681 {
682 $arFeatures = self::getActiveFeaturesList($type, $id);
683
684 if (!array_key_exists("SONET_FEATURES_CACHE", $GLOBALS) || !is_array($GLOBALS["SONET_FEATURES_CACHE"]))
685 {
686 $GLOBALS["SONET_FEATURES_CACHE"] = array();
687 }
688 if (!array_key_exists($type, $GLOBALS["SONET_FEATURES_CACHE"]) || !is_array($GLOBALS["SONET_FEATURES_CACHE"][$type]))
689 {
690 $GLOBALS["SONET_FEATURES_CACHE"][$type] = array();
691 }
692
693 $GLOBALS["SONET_FEATURES_CACHE"][$type][$id] = $arFeatures;
694 }
695
696 $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
697 foreach ($arSocNetFeaturesSettings as $feature => $arr)
698 {
699 if (
700 !array_key_exists("allowed", $arSocNetFeaturesSettings[$feature])
701 || !is_array($arSocNetFeaturesSettings[$feature]["allowed"])
702 || !in_array($type, $arSocNetFeaturesSettings[$feature]["allowed"])
703 )
704 {
705 continue;
706 }
707
708 if (
709 array_key_exists($feature, $arFeatures)
710 && ($arFeatures[$feature]["ACTIVE"] === "N")
711 )
712 {
713 continue;
714 }
715
716 $arReturn[] = $feature;
717 }
718
719 return $arReturn;
720 }
721
722 public static function getActiveFeaturesNames($type, $id)
723 {
725
726 $type = Trim($type);
727 if (($type == '') || !in_array($type, $arSocNetAllowedEntityTypes))
728 {
729 $APPLICATION->ThrowException(GetMessage("SONET_GF_ERROR_NO_ENTITY_TYPE"), "ERROR_EMPTY_TYPE");
730 return false;
731 }
732
733 $id = intval($id);
734 if ($id <= 0)
735 {
736 $APPLICATION->ThrowException(GetMessage("SONET_GF_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
737 return false;
738 }
739
740 $arReturn = array();
741
742 if (array_key_exists("SONET_FEATURES_CACHE", $GLOBALS)
743 && isset($GLOBALS["SONET_FEATURES_CACHE"][$type])
744 && isset($GLOBALS["SONET_FEATURES_CACHE"][$type][$id])
745 && is_array($GLOBALS["SONET_FEATURES_CACHE"][$type][$id]))
746 {
747 $arFeatures = $GLOBALS["SONET_FEATURES_CACHE"][$type][$id];
748 }
749 else
750 {
751 $arFeatures = self::getActiveFeaturesList($type, $id);
752
753 if (!array_key_exists("SONET_FEATURES_CACHE", $GLOBALS) || !is_array($GLOBALS["SONET_FEATURES_CACHE"]))
754 {
755 $GLOBALS["SONET_FEATURES_CACHE"] = array();
756 }
757
758 if (!array_key_exists($type, $GLOBALS["SONET_FEATURES_CACHE"]) || !is_array($GLOBALS["SONET_FEATURES_CACHE"][$type]))
759 {
760 $GLOBALS["SONET_FEATURES_CACHE"][$type] = array();
761 }
762
763 $GLOBALS["SONET_FEATURES_CACHE"][$type][$id] = $arFeatures;
764 }
765
766 $arSocNetFeaturesSettings = CSocNetAllowed::getAllowedFeatures();
767 foreach ($arSocNetFeaturesSettings as $feature => $arr)
768 {
769 if (
770 !array_key_exists("allowed", $arSocNetFeaturesSettings[$feature])
771 || !in_array($type, $arSocNetFeaturesSettings[$feature]["allowed"])
772 )
773 {
774 continue;
775 }
776
777 if (
778 array_key_exists($feature, $arFeatures)
779 && ($arFeatures[$feature]["ACTIVE"] === "N")
780 )
781 {
782 continue;
783 }
784
785 $arReturn[$feature] = $arFeatures[$feature]["FEATURE_NAME"] ?? null;
786 }
787
788 return $arReturn;
789 }
790
791 public static function getFeaturesNames(string $entityType, int $entityId): array
792 {
793 $featuresNames = [];
794
795 $activeFeaturesList = self::getActiveFeaturesList($entityType, $entityId);
796
797 $allowedFeatures = CSocNetAllowed::getAllowedFeatures();
798 foreach ($allowedFeatures as $featureId => $feature)
799 {
800 if (
801 !array_key_exists('allowed', $allowedFeatures[$featureId])
802 || !in_array($entityType, $allowedFeatures[$featureId]['allowed'])
803 )
804 {
805 continue;
806 }
807
808 if (
809 array_key_exists($featureId, $activeFeaturesList)
810 && ($activeFeaturesList[$featureId]['ACTIVE'] === 'N')
811 )
812 {
813 continue;
814 }
815
816 $featuresNames[$featureId] = $activeFeaturesList[$featureId]['~FEATURE_NAME'] ?? null;
817 }
818
819 return $featuresNames;
820 }
821}
$type
Определения options.php:106
global $APPLICATION
Определения include.php:80
$arResult
Определения generate_coupon.php:16
static processEqualityFieldsToUpdate($fields1, &$update)
Определения util.php:239
static getEqualityFields(&$fields)
Определения util.php:207
static Delete($ID)
Определения group_features.php:135
static getActiveFeaturesNames($type, $id)
Определения group_features.php:722
static GetByID($ID)
Определения group_features.php:389
static CheckFields($ACTION, &$arFields, $ID=0)
Определения group_features.php:15
static getFeaturesNames(string $entityType, int $entityId)
Определения group_features.php:791
static SetFeature($type, $id, $feature, $active, $featureName=false, array $parameters=[])
Определения group_features.php:259
static IsActiveFeature($type, $id, $feature)
Определения group_features.php:410
static Update($ID, $arFields)
Определения group_features.php:204
static DeleteNoDemand($userID)
Определения group_features.php:180
static GetActiveFeatures($type, $id)
Определения group_features.php:653
static GetList($arOrder=Array("ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения group_features.php:76
global $CACHE_MANAGER
Определения clear_component_cache.php:7
$arFields
Определения dblapprove.php:5
$arr
Определения file_new.php:624
</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
$GLOBALS["SONET_FEATURES_CACHE"]
Определения group_features.php:5
if($ajaxMode) $ID
Определения get_user.php:27
while($arParentIBlockProperty=$dbParentIBlockProperty->Fetch()) $errorMessage
global $DB
Определения cron_frame.php:29
$ACTION
Определения csv_new_setup.php:27
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения tools.php:5214
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
Определения tools.php:5177
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
is_set($a, $k=false)
Определения tools.php:2133
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$entityId
Определения payment.php:4
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
const SONET_ENTITY_GROUP
Определения include.php:117
const SONET_ENTITY_USER
Определения include.php:118
global $arSocNetAllowedEntityTypes
Определения include.php:123
if( $_SERVER $arSocNetFeaturesSettings['REQUEST_METHOD']=="GET" &&($RestoreDefaults ?? null)<> '' && $SONET_RIGHT=="W" &&check_bitrix_sessid())
Определения options.php:35
$arFeatures
Определения options.php:54
$GLOBALS['_____370096793']
Определения update_client.php:1
$dbResult
Определения updtr957.php:3