CBPHelper::SearchUserByName: Bitrix method

      
<?php 
//  CBPHelper :: SearchUserByName()
//  /dist/bitrix/modules/bizproc/classes/general/helper.php:229

    
private static function SearchUserByName($user)
    {
        
$user trim($user);
        if (
strlen($user) <= 0)
        {
            return [];
        }

        
$userId 0;
        if (
$user."|" == intval($user)."|")
        {
            
$userId intval($user);
        }

        if (
$userId <= 0)
        {
            
$arMatches = [];
            if (
preg_match('#\[(\d+)\]#i'$user$arMatches))
            {
                
$userId intval($arMatches[1]);
            }
        }

        
$arResult = [];

        
$dbUsers false;
        if (
$userId 0)
        {
            
$arFilter = array("ID_EQUAL_EXACT" => $userId);

            
$dbUsers CUser::GetList(
                (
$by "LAST_NAME"),
                (
$order "asc"),
                
$arFilter,
                [
'NAV_PARAMS' => false]
            );
        }
        else
        {
            
$userLogin "";
            
$arMatches = [];
            if (
preg_match('#\((.+?)\)#i'$user$arMatches))
            {
                
$userLogin $arMatches[1];
                
$user trim(str_replace("(".$userLogin.")"""$user));
            }

            
$userEmail "";
            
$arMatches = [];
            if (
preg_match("#<(.+?)>#i"$user$arMatches))
            {
                if (
check_email($arMatches[1]))
                {
                    
$userEmail $arMatches[1];
                    
$user trim(Str_Replace("<".$userEmail.">"""$user));
                }
            }

            
$arUser = [];
            
$arUserTmp explode(" "$user);
            foreach (
$arUserTmp as $s)
            {
                
$s trim($s);
                if (
strlen($s) > 0)
                {
                    
$arUser[] = $s;
                }
            }
            if (
strlen($userLogin) > 0)
            {
                
$arUser[] = $userLogin;
            }

            
$dbUsers CUser::SearchUserByName($arUser$userEmailtrue);
        }

        if (
$dbUsers)
        {
            while (
$arUsers $dbUsers->GetNext())
            {
                
$arResult[] = $arUsers["ID"];
            }
        }

        return 
$arResult;
    }