CBlogUser :: Delete: Bitrix method

      
<?php 
//  CBlogUser :: Delete()
//  /dist/bitrix/modules/blog/general/blog_user.php:105

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

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

        
$arUser CBlogUser::GetByID($IDBLOG_BY_USER_ID);
        if (
$arUser)
        {

            
$dbResult CBlog::GetList(array(), array("OWNER_ID" => $arUser["USER_ID"]), falsefalse, array("ID"));
            if (
$dbResult->Fetch())
            {
                
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GU_ERROR_OWNER"), "ERROR_OWNER");
                
$bSuccess False;
            }

            if (
$bSuccess)
            {
                
$dbResult CBlogPost::GetList(array(), array("AUTHOR_ID" => $arUser["USER_ID"]), falsefalse, array("ID"));
                if (
$arResult $dbResult->Fetch())
                {
                    if(!
CBlogPost::Delete($arResult["ID"]))
                    {
                        
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GU_ERROR_AUTHOR"), "ERROR_AUTHOR");
                        
$bSuccess False;
                    }
                }
            }

            if (
$bSuccess)
            {
                
$dbGloUser CUser::GetByID($arUser["USER_ID"]);
                
$arGloUser $dbGloUser->Fetch();

                
$DB->Query(
                    
"UPDATE b_blog_comment SET ".
                    
"    AUTHOR_NAME = '".$DB->ForSql(CBlogUser::GetUserName($arUser["ALIAS"], $arGloUser["NAME"], $arGloUser["LAST_NAME"], $arGloUser["LOGIN"], $arGloUser["SECOND_NAME"]))."', ".
                    
"    AUTHOR_ID = null ".
                    
"WHERE AUTHOR_ID = ".$arUser["USER_ID"]."",
                    
true
                
);

                
$DB->Query("DELETE FROM b_blog_user2user_group WHERE USER_ID = ".$arUser["USER_ID"].""true);
            }

            if (
$bSuccess)
            {
                
$strSql =
                    
"SELECT F.ID ".
                    
"FROM b_blog_user FU, b_file F ".
                    
"WHERE FU.ID = ".$arUser["ID"]." ".
                    
"    AND FU.AVATAR = F.ID ";
                
$z $DB->Query($strSqlfalse"FILE: ".__FILE__." LINE:".__LINE__);
                while (
$zr $z->Fetch())
                    
CFile::Delete($zr["ID"]);


                if (
CModule::IncludeModule("search"))
                {
                    
CSearch::Index("blog""U".$arUser["ID"],
                        array(
                            
"TITLE" => "",
                            
"BODY" => ""
                        
)
                    );
                }


                unset(
$GLOBALS["BLOG_USER"]["BLOG_USER_CACHE_".$arUser["ID"]]);
                unset(
$GLOBALS["BLOG_USER"]["BLOG_USER1_CACHE_".$arUser["USER_ID"]]);
                unset(
$GLOBALS["BLOG_USER"]["BLOG_USER2GROUP_CACHE_".$arUser["ID"]]);
                unset(
$GLOBALS["BLOG_USER"]["BLOG_USER2GROUP1_CACHE_".$arUser["USER_ID"]]);

                return 
$DB->Query("DELETE FROM b_blog_user WHERE ID = ".$arUser["ID"].""true);
            }
            if(!
$bSuccess)
                return 
false;
        }

        return 
True;
    }