CBitrixCloudCDN :: SetActive: Bitrix method

      
<?php 
//  CBitrixCloudCDN :: SetActive()
//  /dist/bitrix/modules/bitrixcloud/classes/general/cdn.php:48

    
public static function SetActive($bActive$force false)
    {
        
/* @global CMain $APPLICATION */
        
global $APPLICATION;
        if (
$bActive)
        {
            if (!
self::IsActive() || $force)
            {
                try
                {
                    
$o CBitrixCloudCDNConfig::getInstance()->loadRemoteXML(true);
                    
$o->saveToOptions();
                    if (!
$o->isActive())
                    {
                        if (
                            
$o->getQuota()->getTrafficSize() > $o->getQuota()->getAllowedSize()
                        )
                        {
                            
$ex = new CApplicationException(GetMessage("BCL_CDN_ERROR_QUOTA_LIMIT"));
                            
$APPLICATION->ThrowException($ex);
                            return 
false;
                        }
                        elseif (
                        
$o->getQuota()->isExpired()
                        )
                        {
                            
$ex = new CApplicationException(GetMessage("BCL_CDN_ERROR_QUOTA_EXPIRED"));
                            
$APPLICATION->ThrowException($ex);
                            return 
false;
                        }
                    }
                    
RegisterModuleDependences("main""OnEndBufferContent""bitrixcloud""CBitrixCloudCDN""OnEndBufferContent");
                    
self::$domain_changed false;
                }
                catch(
CBitrixCloudException $e)
                {
                    
$ex = new CApplicationException($e->getMessage()."\n".$e->getDebugInfo());
                    
$APPLICATION->ThrowException($ex);
                    return 
false;
                }
            }
            elseif (
self::$domain_changed)
            {
                try
                {
                    
$o CBitrixCloudCDNConfig::getInstance()->loadRemoteXML(true);
                    
$o->saveToOptions();
                    
self::$domain_changed false;
                }
                catch(
CBitrixCloudException $e)
                {
                    
$ex = new CApplicationException($e->getMessage()."\n".$e->getDebugInfo());
                    
$APPLICATION->ThrowException($ex);
                    return 
false;
                }
            }
        }
        else
        {
            if (
self::IsActive() || $force)
            {
                try
                {
                    
self::stop();
                    
UnRegisterModuleDependences("main""OnEndBufferContent""bitrixcloud""CBitrixCloudCDN""OnEndBufferContent");
                }
                catch(
CBitrixCloudException $e)
                {
                    
UnRegisterModuleDependences("main""OnEndBufferContent""bitrixcloud""CBitrixCloudCDN""OnEndBufferContent");
                    
$ex = new CApplicationException($e->getMessage()."\n".$e->getDebugInfo());
                    
$APPLICATION->ThrowException($ex);
                    return 
false;
                }
            }
        }
        return 
true;
    }