CAdvContract :: Delete: Bitrix method

      
<?php 
//  CAdvContract :: Delete()
//  /dist/bitrix/modules/advertising/classes/general/advertising.php:1050

    
public static function Delete($CONTRACT_ID$CHECK_RIGHTS="Y")
    {
        
$err_mess = (CAdvContract_all::err_mess())."<br>Function: Delete<br>Line: ";
        global 
$DB$strError;
        
$CONTRACT_ID intval($CONTRACT_ID);
        if (
$CONTRACT_ID<=1)
            return 
false;
        
$isAdmin = ($CHECK_RIGHTS=="N"true CAdvContract::IsAdmin());
        if (
$isAdmin)
        {
            
$strSql "SELECT ID FROM b_adv_banner WHERE CONTRACT_ID = $CONTRACT_ID";
            
$rs $DB->Query($strSqlfalse$err_mess.__LINE__);
            while (
$ar $rs->Fetch()) CAdvBanner::Delete($ar["ID"], "N");

            
CAdvContract::DeletePageLink($CONTRACT_ID);
            
CAdvContract::DeleteSiteLink($CONTRACT_ID);
            
CAdvContract::DeleteTypeLink($CONTRACT_ID);
            
CAdvContract::DeleteUserLink($CONTRACT_ID);
            
CAdvContract::DeleteWeekdayLink($CONTRACT_ID);

            
$strSql "DELETE FROM b_adv_contract WHERE ID = $CONTRACT_ID";
            
$DB->Query($strSqlfalse$err_mess.__LINE__);
            return 
true;
        }
        else
        {
            
$strError .= GetMessage("AD_ERROR_NOT_ENOUGH_PERMISSIONS_CONTRACT")."<br>";
            return 
false;
        }
    }