CBPHelper::usersArrayToStringInternal

  1. Bitrix24 API (v. 23.675.0)
  2. bizproc
  3. CBPHelper
  4. usersArrayToStringInternal
  • Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/classes/general/helper.php
  • Класс: CBPHelper
  • Вызов: CBPHelper::usersArrayToStringInternal
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] == 0 && $keys[1] == 1 && is_string($r[0]) && is_string($r[1]))
			{
				if (in_array($r[0], array("Document", "Template", "Variable", "User"))
					|| preg_match('#^Ad+_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(mb_strtolower($arUsers), $arAllowableUserGroups))
		{
			return $arAllowableUserGroups[mb_strtolower($arUsers)];
		}

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

		$userId = 0;
		if (mb_substr($arUsers, 0, mb_strlen("user_")) == "user_")
		{
			$userId = intval(mb_substr($arUsers, mb_strlen("user_")));
		}

		if ($userId > 0)
		{
			$db = CUser::GetList(
				"LAST_NAME",
				"asc",
				["ID_EQUAL_EXACT" => $userId],
				[
					"NAV_PARAMS" => false,
					'FIELDS'=> [
						'ID',
						'LOGIN',
						'EMAIL',
						'NAME',
						'LAST_NAME',
						'SECOND_NAME'
					],
				]
			);

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

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

Добавить комментарий