CBlogPost::UpdateLog: Bitrix method

      
<?php 
//  CBlogPost :: UpdateLog()
//  /dist/bitrix/modules/blog/general/blog_post.php:909

    
public static function UpdateLog($postID$arPost$arBlog$arParams)
    {
        static 
$blogPostEventIdList null;

        if (!
CModule::IncludeModule('socialnetwork'))
        {
            return;
        }

        
$parserBlog = new blogTextParser(false$arParams["PATH_TO_SMILE"]);

        
preg_match("#^(.*?)<cut[\s]*(/>|>).*?$#is"$arPost["DETAIL_TEXT"], $arMatches);
        if (
count($arMatches) <= 0)
        {
            
preg_match("#^(.*?)\[cut[\s]*(/\]|\]).*?$#is"$arPost["DETAIL_TEXT"], $arMatches);
        }

        
$cut_suffix = (count($arMatches) > "#CUT#" "");

        
$arImages = Array();
        
$res CBlogImage::GetList(array("ID"=>"ASC"),array("POST_ID"=>$postID"BLOG_ID"=>$arBlog["ID"], "IS_COMMENT" => "N"));
        while (
$arImage $res->Fetch())
        {
            
$arImages[$arImage['ID']] = $arImage['FILE_ID'];
        }

        if(
$arPost["DETAIL_TEXT_TYPE"] == "html" && $arParams["allowHTML"] == "Y" && $arBlog["ALLOW_HTML"] == "Y")
        {
            
$arAllow = array("HTML" => "Y""ANCHOR" => "Y""IMG" => "Y""SMILES" => "N""NL2BR" => "N""VIDEO" => "Y""QUOTE" => "Y""CODE" => "Y");
            if(
$arParams["allowVideo"] != "Y")
            {
                
$arAllow["VIDEO"] = "N";
            }
            
$text4message $parserBlog->convert($arPost["DETAIL_TEXT"], true$arImages$arAllow);
        }
        else
        {
            
$arAllow = array("HTML" => "N""ANCHOR" => "N""BIU" => "N""IMG" => "N""QUOTE" => "N""CODE" => "N""FONT" => "N""TABLE" => "N""LIST" => "N""SMILES" => "N""NL2BR" => "N""VIDEO" => "N");
            
$text4message $parserBlog->convert($arPost["DETAIL_TEXT"], true$arImages$arAllow, array("isSonetLog"=>true));
        }

        
$text4message .= $cut_suffix;

        
$arSoFields = array(
            
"TITLE_TEMPLATE" => "#USER_NAME# ".GetMessage("BLG_SONET_TITLE"),
            
"TITLE" => $arPost["TITLE"],
            
"MESSAGE" => $text4message,
            
"TEXT_MESSAGE" => $text4message,
            
"ENABLE_COMMENTS" => (array_key_exists("ENABLE_COMMENTS"$arPost) && $arPost["ENABLE_COMMENTS"] == "N" "N" "Y"),
            
"EVENT_ID" => (
                isset(
$arPost["UF_BLOG_POST_IMPRTNT"])
                && 
intval($arPost["UF_BLOG_POST_IMPRTNT"]) > 0
                    
? \Bitrix\Blog\Integration\Socialnetwork\Log::EVENT_ID_POST_IMPORTANT
                    
: \Bitrix\Blog\Integration\Socialnetwork\Log::EVENT_ID_POST
            
)
        );

        if (
$blogPostEventIdList === null)
        {
            
$blogPostLivefeedProvider = new \Bitrix\Socialnetwork\Livefeed\BlogPost;
            
$blogPostEventIdList $blogPostLivefeedProvider->getEventId();
        }

        
$dbRes CSocNetLog::GetList(
            array(
"ID" => "DESC"),
            array(
                
"EVENT_ID" => $blogPostEventIdList,
                
"SOURCE_ID" => $postID
            
),
            
false,
            
false,
            array(
"ID""ENTITY_TYPE""ENTITY_ID""EVENT_ID""USER_ID")
        );
        if (
$arLog $dbRes->Fetch())
        {
            
CSocNetLog::Update($arLog["ID"], $arSoFields);
            
$socnetPerms CBlogPost::GetSocNetPermsCode($postID);

            
$profileBlogPost false;
            foreach(
$socnetPerms as $perm)
            {
                if (
preg_match('/^UP(\d+)$/'$perm$matches))
                {
                    
$profileBlogPost true;
                    break;
                }
            }

            if(
                !
$profileBlogPost
                
&& !in_array("U".$arPost["AUTHOR_ID"], $socnetPerms)
            )
            {
                
$socnetPerms[] = "U".$arPost["AUTHOR_ID"];
                if (
CModule::IncludeModule("extranet"))
                {
                    
CSocNetLog::Update($arLog["ID"], array(
                        
"SITE_ID" => CExtranet::GetSitesByLogDestinations($socnetPerms$arPost["AUTHOR_ID"])
                    ));
                }
                
$socnetPerms[] = "SA"// socnet admin
            
}

            \
CSocNetLogRights::deleteByLogID($arLog["ID"]);
            \
CSocNetLogRights::add($arLog["ID"], $socnetPerms);

            if (
Loader::includeModule('crm'))
            {
                
CCrmLiveFeedComponent::processCrmBlogPostRights($arLog["ID"], $arLog$arPost'edit');
            }
        }
    }