CBlogUser :: GetUserGroups: Bitrix method

      
<?php 
//  CBlogUser :: GetUserGroups()
//  /dist/bitrix/modules/blog/general/blog_user.php:429

    
public static function GetUserGroups($ID$blogID$joinStatus ""$selectType BLOG_BY_BLOG_USER_ID$bUrl false)
    {
        global 
$DB;

        
$ID IntVal($ID);
        
$joinStatus = (($joinStatus == "Y" || $joinStatus == "N") ? $joinStatus "");
        
$selectType = (($selectType == BLOG_BY_USER_ID) ? BLOG_BY_USER_ID BLOG_BY_BLOG_USER_ID);
        if(
$bUrl)
            
$bUrl true;
        else
            
$bUrl false;
        
        if(!
$bUrl)
            
$blogID IntVal($blogID);
        else
            
$blogID preg_replace("/[^a-zA-Z0-9_-]/is"""Trim($blogID));

        
$varName = (($selectType == BLOG_BY_USER_ID) ? "BLOG_USER2GROUP1_CACHE_".$blogID."_".$joinStatus."_".$ID."_".$bUrl "BLOG_USER2GROUP_CACHE_".$blogID."_".$joinStatus."_".$ID."_".$bUrl);

        if (isset(
$GLOBALS["BLOG_USER"][$varName]) && is_array($GLOBALS["BLOG_USER"][$varName]))
        {
            return 
$GLOBALS["BLOG_USER"][$varName];
        }
        else
        {
            
$arGroups = array(1);
            if (isset(
$GLOBALS["USER"]) && is_object($GLOBALS["USER"]) && $GLOBALS["USER"]->IsAuthorized())
                
$arGroups[] = 2;

            if (
$ID && strlen($blogID) > 0)
            {
                if(
$selectType == BLOG_BY_BLOG_USER_ID)
                {
                    
$arBlogUser CBlogUser::GetByID($ID$selectType);
                    
$userID $arBlogUser["USER_ID"];
                }
                else
                    
$userID $ID;
                
                
$strSql =
                    
"SELECT UG.ID, UG.USER_ID, UG.BLOG_ID, UG.USER_GROUP_ID ".
                    
"FROM b_blog_user2user_group UG ";
                if(
$bUrl)
                    
$strSql .= " INNER JOIN b_blog B ON (UG.BLOG_ID = B.ID AND B.URL='".$DB->ForSql($blogID)."') ";
                
                
$strSql .= " WHERE UG.USER_ID = ".$userID." ";
                
                if(!
$bUrl)
                    
$strSql .= "    AND UG.BLOG_ID = ".$blogID." ";

                
$dbResult $DB->Query($strSqlFalse"File: ".__FILE__."<br>Line: ".__LINE__);

                while (
$arResult $dbResult->Fetch())
                    
$arGroups[] = IntVal($arResult["USER_GROUP_ID"]);
            }

            if(
$selectType == BLOG_BY_BLOG_USER_ID && !empty($arBlogUser))
                
$GLOBALS["BLOG_USER"]["BLOG_USER2GROUP_CACHE_".$blogID."_".$joinStatus."_".IntVal($arBlogUser["ID"])."_".$bUrl] = $arGroups;
            
$GLOBALS["BLOG_USER"]["BLOG_USER2GROUP1_CACHE_".$blogID."_".$joinStatus."_".IntVal($userID)."_".$bUrl] = $arGroups;
            return 
$arGroups;
        }

        return 
False;
    }