CBlogPost :: GetBlogUserCommentPerms: Bitrix method

      
<?php 
//  CBlogPost :: GetBlogUserCommentPerms()
//  /dist/bitrix/modules/blog/general/blog_post.php:121

    
public static function GetBlogUserCommentPerms($ID$userID)
    {
        global 
$APPLICATION;
        
$ID IntVal($ID);
        
$userID IntVal($userID);

        
$arAvailPerms array_keys($GLOBALS["AR_BLOG_PERMS"]);

        
$blogModulePermissions $APPLICATION->GetGroupRight("blog");
        if (
$blogModulePermissions >= "W")
            return 
$arAvailPerms[count($arAvailPerms) - 1];

        if(
IntVal($ID) > 0)
        {
            if (!(
$arPost CBlogPost::GetByID($ID)))
            {
                return 
$arAvailPerms[0];
            }
            else
            {
                
$arBlog CBlog::GetByID($arPost["BLOG_ID"]);
                if (
$arBlog["ENABLE_COMMENTS"] != "Y")
                {
                    return 
$arAvailPerms[0];
                }

                if (
CBlog::IsBlogOwner($arPost["BLOG_ID"], $userID))
                {
                    return 
$arAvailPerms[count($arAvailPerms) - 1];
                }
                
                
$arUserGroups CBlogUser::GetUserGroups($userID$arPost["BLOG_ID"], "Y"BLOG_BY_USER_ID);
                
$permGroups CBlogUser::GetUserPerms($arUserGroups$arPost["BLOG_ID"], $IDBLOG_PERMS_COMMENTBLOG_BY_USER_ID);
                
//                if for user unset option "WRITE TO BLOG", they can only read (even if all user can write), or smaller rights, if group have smaller
                
$arBlogUser CBlogUser::GetByID($userIDBLOG_BY_USER_ID);
                if (
$arBlogUser && $arBlogUser["ALLOW_POST"] != "Y")
                {
                    if(
$permGroups && in_array(BLOG_PERMS_READ$arAvailPerms))
                        return 
min(BLOG_PERMS_READ$permGroups);
                    else
                        return 
$arAvailPerms[0];
                }

                if (
$permGroups)
                    return 
$permGroups;
            }
        }
        else
        {
            return 
$arAvailPerms[0];
        }

//        if(IntVal($userID) > 0)
//        {
//            $arBlogUser = CBlogUser::GetByID($userID, BLOG_BY_USER_ID);
//            if ($arBlogUser && $arBlogUser["ALLOW_POST"] != "Y")
//                return $arAvailPerms[0];
//        }

        
return $arAvailPerms[0];
    }