• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/log_follow.php
  • Класс: CSocNetLogFollow
  • Вызов: CSocNetLogFollow::GetDefaultValue
static function GetDefaultValue($user_id)
{
	if (intval($user_id) <= 0)
	{
		return false;
	}

	global $CACHE_MANAGER;

	$ttl = (defined("BX_COMP_MANAGED_CACHE") ? 2592000 : 600);

	$cache_id = 'sonet_follow_default_'.$user_id;
	$obCache = new CPHPCache;
	$cache_dir = '/sonet/log_follow/'.$user_id.'/';

	if($obCache->InitCache($ttl, $cache_id, $cache_dir))
	{
		$tmpVal = $obCache->GetVars();
		$default_follow = $tmpVal["VALUE"];
		unset($tmpVal);
	}
	else
	{
		$default_follow = false;
		
		if (is_object($obCache))
			$obCache->StartDataCache($ttl, $cache_id, $cache_dir);

		if (defined("BX_COMP_MANAGED_CACHE"))
		{
			$CACHE_MANAGER->StartTagCache($cache_dir);
			$CACHE_MANAGER->RegisterTag("SONET_LOG_FOLLOW_".$user_id);
		}

		$rsFollow = CSocNetLogFollow::GetList(
			array(
				"USER_ID" => $user_id,
				"CODE" => "**"
			),
			array("TYPE")
		);
		if ($arFollow = $rsFollow->Fetch())
		{
			$default_follow = $arFollow["TYPE"];
		}

		if (is_object($obCache))
		{
			$arCacheData = Array(
				"VALUE" => $default_follow
			);
			$obCache->EndDataCache($arCacheData);
			if (defined("BX_COMP_MANAGED_CACHE"))
			{
				$CACHE_MANAGER->EndTagCache();
			}
		}
	}
	unset($obCache);

	if (!$default_follow)
	{
		$default_follow = COption::GetOptionString("socialnetwork", "follow_default_type", "Y");
	}

	return $default_follow;
}