advertising :: InstallDB: Bitrix method

      
<?php 
//  advertising :: InstallDB()
//  /dist/bitrix/modules/advertising/install/index.php:74

    
function InstallDB()
    {
        global 
$APPLICATION$DB$errors;

        if (!
$DB->Query("SELECT 'x' FROM b_adv_banner"true)) $EMPTY "Y"; else $EMPTY "N";

        if (
$EMPTY=="Y")
        {
            
$errors $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/advertising/install/db/".strtolower($DB->type)."/install.sql");

            if (!empty(
$errors))
            {
                
$APPLICATION->ThrowException(implode(""$errors));
                return 
false;
            }
        }

        
RegisterModule("advertising");

        
RegisterModuleDependences("main""OnBeforeProlog""advertising");
        
RegisterModuleDependences("main""OnEndBufferContent""advertising""CAdvBanner""FixShowAll");
        
RegisterModuleDependences("main""OnBeforeRestartBuffer""advertising""CAdvBanner""BeforeRestartBuffer");

        
RegisterModuleDependences('conversion''OnGetCounterTypes' 'advertising''\Bitrix\Advertising\Internals\ConversionHandlers''onGetCounterTypes');
        
RegisterModuleDependences('conversion''OnGetRateTypes' 'advertising''\Bitrix\Advertising\Internals\ConversionHandlers''onGetRateTypes');
        
RegisterModuleDependences('advertising''onBannerClick''advertising''\Bitrix\Advertising\Internals\ConversionHandlers''onBannerClick');

        
CAgent::AddAgent("CAdvContract::SendInfo();","advertising""N"7200);
        
CAgent::AddAgent("CAdvBanner::CleanUpDynamics();","advertising""N"86400);

        if (
$EMPTY=="Y")
        {
            
CModule::IncludeModule('advertising');

            
$arSites = array();
            
$rs CSite::GetList($b="sort"$o="asc");
            while(
$ar $rs->Fetch())
            {
                
$arSites[] = $ar['ID'];
            }

            
$ac = new CAdvContract();
            
$arFields = array(
                
'ACTIVE' => 'Y',
                
'NAME' => 'Default',
                
'SORT' => 10000,
                
'DESCRIPTION' => 'all site without any restrictions',
                
'EMAIL_COUNT' => 1,
                
'arrTYPE' => array('ALL'),
                
'arrWEEKDAY' => array(
                    
'MONDAY'    => array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23),
                    
'SATURDAY'    => array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23),
                    
'SUNDAY'    => array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23),
                    
'THURSDAY'    => array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23),
                    
'TUESDAY'    => array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23),
                    
'WEDNESDAY'    => array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23),
                    
'FRIDAY'    => array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23),
                ),
                
'arrSITE' => $arSites,
            );
            
$ac->Set($arFields0'N');
        }

        return 
true;
    }