- Модуль: socialnetwork
- Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/group_features.php
- Класс: CAllSocNetFeatures
- Вызов: CAllSocNetFeatures::GetActiveFeatures
static function GetActiveFeatures($type, $id)
{
global $arSocNetAllowedEntityTypes, $APPLICATION;
$type = Trim($type);
if (($type == '') || !in_array($type, $arSocNetAllowedEntityTypes))
{
$APPLICATION->ThrowException(GetMessage("SONET_GF_ERROR_NO_ENTITY_TYPE"), "ERROR_EMPTY_TYPE");
return false;
}
$id = (int)$id;
if ($id <= 0)
{
$APPLICATION->ThrowException(GetMessage("SONET_GF_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
return false;
}
$arReturn = array();
if (array_key_exists("SONET_FEATURES_CACHE", $GLOBALS)
&& isset($GLOBALS["SONET_FEATURES_CACHE"][$type])
&& isset($GLOBALS["SONET_FEATURES_CACHE"][$type][$id])
&& is_array($GLOBALS["SONET_FEATURES_CACHE"][$type][$id]))
{
$arFeatures = $GLOBALS["SONET_FEATURES_CACHE"][$type][$id];
}
else
{
$arFeatures = self::getActiveFeaturesList($type, $id);
if (!array_key_exists("SONET_FEATURES_CACHE", $GLOBALS) || !is_array($GLOBALS["SONET_FEATURES_CACHE"]))
{
$GLOBALS["SONET_FEATURES_CACHE"] = array();
}
if (!array_key_exists($type, $GLOBALS["SONET_FEATURES_CACHE"]) || !is_array($GLOBALS["SONET_FEATURES_CACHE"][$type]))
{
$GLOBALS["SONET_FEATURES_CACHE"][$type] = array();
}
$GLOBALS["SONET_FEATURES_CACHE"][$type][$id] = $arFeatures;
}
$arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
foreach ($arSocNetFeaturesSettings as $feature => $arr)
{
if (
!array_key_exists("allowed", $arSocNetFeaturesSettings[$feature])
|| !is_array($arSocNetFeaturesSettings[$feature]["allowed"])
|| !in_array($type, $arSocNetFeaturesSettings[$feature]["allowed"])
)
{
continue;
}
if (
array_key_exists($feature, $arFeatures)
&& ($arFeatures[$feature]["ACTIVE"] === "N")
)
{
continue;
}
$arReturn[] = $feature;
}
return $arReturn;
}