CBlog::Delete: Bitrix method

      
<?php 
//  CBlog :: Delete()
//  /dist/bitrix/modules/blog/general/blog.php:265

    
public static function Delete($ID)
    {
        global 
$DB;

        
$ID IntVal($ID);
        
$bSuccess True;

        foreach(
GetModuleEvents("blog""OnBeforeBlogDelete"true) as $arEvent)
        {
            if (
ExecuteModuleEventEx($arEvent, Array($ID))===false)
                return 
false;
        }

        foreach(
GetModuleEvents("blog""OnBlogDelete"true) as $arEvent)
        {
            
ExecuteModuleEventEx($arEvent, Array($ID));
        }

        
$arBlog CBlog::GetByID($ID);

        
$DB->StartTransaction();

        if (
$bSuccess)
            
$bSuccess $DB->Query("DELETE FROM b_blog_user2blog WHERE BLOG_ID = ".$ID.""true);
        if (
$bSuccess)
            
$bSuccess $DB->Query("DELETE FROM b_blog_user_group_perms WHERE BLOG_ID = ".$ID.""true);
        if (
$bSuccess)
            
$bSuccess $DB->Query("DELETE FROM b_blog_user2user_group WHERE BLOG_ID = ".$ID.""true);
        if (
$bSuccess)
            
$bSuccess $DB->Query("DELETE FROM b_blog_user_group WHERE BLOG_ID = ".$ID.""true);
        if (
$bSuccess)
            
$bSuccess $DB->Query("DELETE FROM b_blog_trackback WHERE BLOG_ID = ".$ID.""true);
        if (
$bSuccess)
            
$bSuccess $DB->Query("DELETE FROM b_blog_comment WHERE BLOG_ID = ".$ID.""true);
        if (
$bSuccess)
            
$bSuccess $DB->Query("DELETE FROM b_blog_post WHERE BLOG_ID = ".$ID.""true);
        if (
$bSuccess)
            
$bSuccess $DB->Query("DELETE FROM b_blog_category WHERE BLOG_ID = ".$ID.""true);

        if (
$bSuccess)
        {
            unset(
$GLOBALS["BLOG"]["BLOG_CACHE_".$ID]);
            unset(
$GLOBALS["BLOG"]["BLOG4OWNER_CACHE_".$arBlog["OWNER_ID"]]);
        }

        if (
$bSuccess)
            
$bSuccess $DB->Query("DELETE FROM b_blog WHERE ID = ".$ID.""true);

        if (
$bSuccess)
            
$DB->Commit();
        else
            
$DB->Rollback();

        if (
$bSuccess)
        {
            if (
CModule::IncludeModule("search"))
            {
                
CSearch::DeleteIndex("blog"false"COMMENT"$ID."|%");
                
CSearch::DeleteIndex("blog"false"POST"$ID);
                
CSearch::DeleteIndex("blog""B".$ID);
            }
        }
        
        if (
$bSuccess)
        {
            
$res CBlogImage::GetList(array(), array("BLOG_ID"=>$ID));
            while(
$aImg $res->Fetch())
                
CBlogImage::Delete($aImg['ID']);
        }
        if (
$bSuccess)
            
$GLOBALS["USER_FIELD_MANAGER"]->Delete("BLOG_BLOG"$ID);
        
        
CBlog::DeleteSocnetRead($ID);

        return 
$bSuccess;
    }