CAdvBanner :: Delete: Bitrix method

      
<?php 
//  CAdvBanner :: Delete()
//  /dist/bitrix/modules/advertising/classes/general/advertising.php:1402

    
public static function Delete($BANNER_ID$CHECK_RIGHTS="Y")
    {
        
$err_mess = (CAdvBanner_all::err_mess())."<br>Function: Delete<br>Line: ";
        global 
$DB$strError;
        
$BANNER_ID intval($BANNER_ID);
        if (
$BANNER_ID<=0)
            return 
false;

        
$strSql "SELECT CONTRACT_ID, IMAGE_ID, TYPE_SID FROM b_adv_banner WHERE ID = '$BANNER_ID'";
        
$rsBanner $DB->Query($strSqlfalse$err_mess.__LINE__);
        if (
$arBanner $rsBanner->Fetch())
        {
            
$ok false;
            if (
$CHECK_RIGHTS=="Y")
            {
                
$arrPERM CAdvContract::GetUserPermissions($arBanner["CONTRACT_ID"]);
                
$arrPERM $arrPERM[$arBanner["CONTRACT_ID"]];
                if (
in_array("ADD"$arrPERM))
                    
$ok true;
            }
            else
            {
                
$ok true;
            }

            if (
$ok)
            {
                if (
defined('BX_COMP_MANAGED_CACHE'))
                {
                    
$taggedCache Application::getInstance()->getTaggedCache();
                    
$taggedCache->clearByTag('advertising_banner_type_'.$arBanner['TYPE_SID']);
                }

                
CFile::Delete($arBanner["IMAGE_ID"]);
                
CAdvBanner::DeleteCountryLink($BANNER_ID);
                
CAdvBanner::DeleteSiteLink($BANNER_ID);
                
CAdvBanner::DeleteStatAdvLink($BANNER_ID);
                
CAdvBanner::DeletePageLink($BANNER_ID);
                
CAdvBanner::DeleteWeekdayLink($BANNER_ID);
                
CAdvBanner::DeleteGroupLink($BANNER_ID);

                
$strSql "DELETE FROM b_adv_banner_2_day WHERE BANNER_ID = $BANNER_ID";
                
$DB->Query($strSqlfalse$err_mess.__LINE__);

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