8use Bitrix\Socialnetwork\Integration;
21 $APPLICATION->ThrowException(
"System error 870164",
"ERROR");
57 $type = $arRe[
"ENTITY_TYPE"];
103 $parameters =
$arFields[
'parameters'] ?? [];
104 if (!($parameters[
'isCollab'] ??
false) &&
$arFields[
"FEATURE"] ===
'chat')
139 if (!CSocNetGroup::__ValidateID(
$ID))
145 $db_events =
GetModuleEvents(
"socialnetwork",
"OnBeforeSocNetFeatures");
146 while ($arEvent = $db_events->Fetch())
151 while ($arEvent = $events->Fetch())
154 $DB->StartTransaction();
157 $bSuccess =
$DB->Query(
"DELETE FROM b_sonet_features2perms WHERE FEATURE_ID = ".
$ID.
"",
true);
159 $bSuccess =
$DB->Query(
"DELETE FROM b_sonet_features WHERE ID = ".
$ID.
"",
true);
164 if (defined(
"BX_COMP_MANAGED_CACHE"))
170 FeatureTable::cleanCache();
184 if (!CSocNetGroup::__ValidateID($userID))
187 $userID = intval($userID);
189 $dbResult = CSocNetFeatures::GetList(
array(),
array(
"ENTITY_TYPE" =>
"U",
"ENTITY_ID" => $userID),
false,
false,
array(
"ID"));
192 $DB->Query(
"DELETE FROM b_sonet_features2perms WHERE FEATURE_ID = ".
$arResult[
"ID"].
"",
true);
193 if (defined(
"BX_COMP_MANAGED_CACHE"))
199 $DB->Query(
"DELETE FROM b_sonet_features WHERE ENTITY_TYPE = 'U' AND ENTITY_ID = ".$userID.
"",
true);
208 if (!CSocNetGroup::__ValidateID(
$ID))
218 $db_events =
GetModuleEvents(
"socialnetwork",
"OnBeforeSocNetFeaturesUpdate");
219 while ($arEvent = $db_events->Fetch())
223 $strUpdate =
$DB->PrepareUpdate(
"b_sonet_features",
$arFields);
226 if ($strUpdate <>
'')
229 "UPDATE b_sonet_features SET ".
231 "WHERE ID = ".$ID.
" ";
234 if (array_key_exists(
"ENTITY_TYPE",
$arFields) && array_key_exists(
"ENTITY_ID",
$arFields))
240 while ($arEvent = $events->Fetch())
243 if (defined(
"BX_COMP_MANAGED_CACHE"))
249 FeatureTable::cleanCache();
277 $feature = mb_strtolower(Trim($feature));
290 if (!($parameters[
'isCollab'] ??
false) && $feature ===
'chat')
297 $active = ($active ?
"Y" :
"N");
302 "ENTITY_TYPE" =>
$type,
304 "FEATURE" => $feature
308 array(
"ID",
"ACTIVE")
316 "FEATURE_NAME" => $featureName,
318 "=DATE_UPDATE" => CDatabase::CurrentTimeFunction()
328 $r = CSocNetFeatures::Add(
array(
329 "ENTITY_TYPE" =>
$type,
331 "FEATURE" => $feature,
332 "FEATURE_NAME" => $featureName,
334 "=DATE_UPDATE" => CDatabase::CurrentTimeFunction(),
335 "=DATE_CREATE" => CDatabase::CurrentTimeFunction(),
336 'parameters' => $parameters,
340 if ($feature ===
'chat')
344 'skipAvailabilityCheck' =>
true
350 empty($chatData[$id])
351 || (
int)$chatData[$id] <= 0
361 && !empty($chatData[$id])
362 && (
int)$chatData[$id] > 0
391 if (!CSocNetGroup::__ValidateID(
$ID))
398 $dbResult = CSocNetFeatures::GetList(Array(), Array(
"ID" =>
$ID));
426 $feature = mb_strtolower(trim($feature));
447 $arGroupToGet =
array();
448 foreach($id as $group_id)
452 $arReturn[$group_id] =
false;
456 && is_array(
$GLOBALS[
'SONET_FEATURES_CACHE'][
$type][$group_id])
461 if (!array_key_exists($feature,
$arFeatures[$group_id]))
463 $arReturn[$group_id] =
true;
467 $arReturn[$group_id] = (
$arFeatures[$group_id][$feature][
'ACTIVE'] ===
"Y");
471 $arGroupToGet[] = $group_id;
475 if (!empty($arGroupToGet))
477 $res = CSocNetFeatures::getList(
480 '@ENTITY_ID' => $arGroupToGet,
481 'ENTITY_TYPE' =>
$type,
485 [
'ENTITY_ID',
'FEATURE',
'ACTIVE',
'FEATURE_NAME' ]
487 while ($featureFields =
$res->getNext(
true,
false))
489 $arFeatures[$featureFields[
'ENTITY_ID']][$featureFields[
'FEATURE']] = [
490 'ACTIVE' => $featureFields[
'ACTIVE'],
491 'FEATURE_NAME' => $featureFields[
'FEATURE_NAME'],
495 foreach ($arGroupToGet as $group_id)
498 !isset(
$GLOBALS[
'SONET_FEATURES_CACHE'])
499 || !is_array(
$GLOBALS[
'SONET_FEATURES_CACHE'])
502 $GLOBALS[
'SONET_FEATURES_CACHE'] = [];
520 if (!array_key_exists($feature,
$arFeatures[$group_id]))
522 $arReturn[$group_id] =
true;
526 $arReturn[$group_id] = (
$arFeatures[$group_id][$feature][
"ACTIVE"] ===
"Y");
550 $res = CSocNetFeatures::getList(
554 'ENTITY_TYPE' =>
$type,
558 [
'FEATURE',
'ACTIVE',
'FEATURE_NAME' ]
560 while ($featureFields =
$res->getNext())
563 'ACTIVE' => $featureFields[
'ACTIVE'],
564 'FEATURE_NAME' => $featureFields[
'FEATURE_NAME'],
569 !isset(
$GLOBALS[
'SONET_FEATURES_CACHE'])
570 || !is_array(
$GLOBALS[
'SONET_FEATURES_CACHE'])
573 $GLOBALS[
'SONET_FEATURES_CACHE'] = [];
595 private static function getActiveFeaturesList(
$type, $id)
601 $cache =
new CPHPCache;
602 $cache_time = 31536000;
603 $cache_id =
$type.
"_".$id;
604 $cache_path =
"/sonet/features/".$type.
"/".intval($id / 1000).
"/".$id.
"/";
606 if ($cache->InitCache($cache_time, $cache_id, $cache_path))
608 $arCacheVars = $cache->GetVars();
613 $cache->StartDataCache($cache_time, $cache_id, $cache_path);
614 if (defined(
"BX_COMP_MANAGED_CACHE"))
624 "ENTITY_TYPE" =>
$type,
631 "FEATURE_NAME" =>
$arResult[
"FEATURE_NAME"],
632 "~FEATURE_NAME" =>
$arResult[
"~FEATURE_NAME"],
634 if (defined(
"BX_COMP_MANAGED_CACHE"))
640 $arCacheData = Array(
643 if(defined(
"BX_COMP_MANAGED_CACHE"))
647 $cache->EndDataCache($arCacheData);
673 if (array_key_exists(
"SONET_FEATURES_CACHE",
$GLOBALS)
684 if (!array_key_exists(
"SONET_FEATURES_CACHE",
$GLOBALS) || !is_array(
$GLOBALS[
"SONET_FEATURES_CACHE"]))
716 $arReturn[] = $feature;
742 if (array_key_exists(
"SONET_FEATURES_CACHE",
$GLOBALS)
753 if (!array_key_exists(
"SONET_FEATURES_CACHE",
$GLOBALS) || !is_array(
$GLOBALS[
"SONET_FEATURES_CACHE"]))
785 $arReturn[$feature] =
$arFeatures[$feature][
"FEATURE_NAME"] ??
null;
795 $activeFeaturesList = self::getActiveFeaturesList($entityType,
$entityId);
797 $allowedFeatures = CSocNetAllowed::getAllowedFeatures();
798 foreach ($allowedFeatures as $featureId => $feature)
801 !array_key_exists(
'allowed', $allowedFeatures[$featureId])
802 || !in_array($entityType, $allowedFeatures[$featureId][
'allowed'])
809 array_key_exists($featureId, $activeFeaturesList)
810 && ($activeFeaturesList[$featureId][
'ACTIVE'] ===
'N')
816 $featuresNames[$featureId] = $activeFeaturesList[$featureId][
'~FEATURE_NAME'] ??
null;
819 return $featuresNames;
static unlinkChat($params)
static createChat($params)
static getChatData($params)
static processEqualityFieldsToUpdate($fields1, &$update)
static getEqualityFields(&$fields)
static getActiveFeaturesNames($type, $id)
static CheckFields($ACTION, &$arFields, $ID=0)
static getFeaturesNames(string $entityType, int $entityId)
static SetFeature($type, $id, $feature, $active, $featureName=false, array $parameters=[])
static IsActiveFeature($type, $id, $feature)
static Update($ID, $arFields)
static DeleteNoDemand($userID)
static GetActiveFeatures($type, $id)
static GetList($arOrder=Array("ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
$GLOBALS["SONET_FEATURES_CACHE"]
while($arParentIBlockProperty=$dbParentIBlockProperty->Fetch()) $errorMessage
ExecuteModuleEventEx($arEvent, $arParams=[])
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
GetMessage($name, $aReplace=null)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
global $arSocNetAllowedEntityTypes
if( $_SERVER $arSocNetFeaturesSettings['REQUEST_METHOD']=="GET" &&($RestoreDefaults ?? null)<> '' && $SONET_RIGHT=="W" &&check_bitrix_sessid())
$GLOBALS['_____370096793']