CBPHelper :: UsersArrayToStringInternal: Bitrix method

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

    
private static function UsersArrayToStringInternal($arUsers$arWorkflowTemplate$arAllowableUserGroups$appendId true)
    {
        if (
is_array($arUsers))
        {
            
$r = [];

            
$keys array_keys($arUsers);
            foreach (
$keys as $key)
            {
                
$r[$key] = self::UsersArrayToStringInternal($arUsers[$key], $arWorkflowTemplate$arAllowableUserGroups$appendId);
            }

            if (
count($r) == 2)
            {
                
$keys array_keys($r);
                if (
$keys[0] == && $keys[1] == && is_string($r[0]) && is_string($r[1]))
                {
                    if (
in_array($r[0], array("Document""Template""Variable""User"))
                        || 
preg_match('#^A\d+_\d+_\d+_\d+$#i'$r[0])
                        || 
is_array($arWorkflowTemplate) && CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate$r[0]) != null
                        
)
                    {
                        return 
"{=".$r[0].":".$r[1]."}";
                    }
                }
            }

            return 
implode(", "$r);
        }
        else
        {
            if (
array_key_exists(strtolower($arUsers), $arAllowableUserGroups))
            {
                return 
$arAllowableUserGroups[strtolower($arUsers)];
            }

            if (
CBPActivity::isExpression($arUsers))
            {
                return 
$arUsers;
            }

            
$userId 0;
            if (
substr($arUsers0strlen("user_")) == "user_")
            {
                
$userId intval(substr($arUsersstrlen("user_")));
            }

            if (
$userId 0)
            {
                
$db CUser::GetList(
                    (
$by "LAST_NAME"),
                    (
$order "asc"),
                    array(
"ID_EQUAL_EXACT" => $userId),
                    array(
                        
"NAV_PARAMS" => false,
                    )
                );

                if (
$ar $db->Fetch())
                {
                    
$str CUser::FormatName(COption::GetOptionString("bizproc""name_template"CSite::GetNameFormat(false), SITE_ID), $artruefalse);
                    if (
$appendId)
                    {
                        
$str $str." [".$ar["ID"]."]";
                    }
                    return 
str_replace(","" "$str);
                }
            }
            else if (
strpos($arUsers'group_') === 0)
            {
                
$str self::getExtendedGroupName($arUsers$appendId);
                return 
str_replace(array(','';'), array(' '' '), $str);
            }

            return 
str_replace(","" "$arUsers);
        }
    }