• Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/lib/basetype/user.php
  • Класс: BitrixBizprocBaseTypeUser
  • Вызов: User::renderControl
static function renderControl(FieldType $fieldType, array $field, $value, $allowSelection, $renderMode)
{
	if ($value !== null && !is_array($value))
	{
		if (self::isRawValue($value))
		{
			$errors = [];
			$value = CBPHelper::UsersStringToArray($value, $fieldType->getDocumentType(), $errors);
		}
		else
		{
			$value = [$value];
		}
	}

	$isPublic = ($renderMode & FieldType::RENDER_MODE_PUBLIC);

	$valueString = CBPHelper::usersArrayToString($value, null, $fieldType->getDocumentType());

	if ($allowSelection && !$isPublic)
	{
		return static::renderControlSelector($field, $valueString, 'combine', '', $fieldType);
	}

	if ($isPublic)
	{
		CUtil::InitJSCore(['bp_user_selector']);
		$name = static::generateControlName($field);
		$controlId = static::generateControlId($field);

		$settings = $fieldType->getSettings();

		$config = [
			'valueInputName' => $name,
			'value' => $valueString,
			'items' => $value ? static::getSelectedItems($value, $settings) : [],
			'multiple' => $fieldType->isMultiple(),
			'required' => $fieldType->isRequired(),
		];

		if ($settings)
		{
			$config += $settings;
		}

		$groups = CBPRuntime::GetRuntime()
			->GetService('DocumentService')
			->GetAllowableUserGroups($fieldType->getDocumentType(), true);

		if ($groups)
		{
			$config['groups'] = [];
			foreach ($groups as $id => $groupName)
			{
				if (!$groupName || mb_strpos($id, 'group_') === 0)
				{
					continue;
				}

				$config['groups'][] = [
					'id' => preg_match('/^[0-9]+$/', $id) ? 'G'.$id : $id,
					'name' => $groupName
				];
			}
		}

		$controlIdJs = CUtil::JSEscape($controlId);
		$controlIdHtml = htmlspecialcharsbx($controlId);
		$configHtml = htmlspecialcharsbx(MainWebJson::encode($config));
		$className = htmlspecialcharsbx(static::generateControlClassName($fieldType, $field));
		$property = $fieldType->getProperty();
		$property['Type'] = static::getType();
		$propertyHtml = htmlspecialcharsbx(MainWebJson::encode($property));

		return <<
				BX.ready(function(){
					var c = document.getElementById('{$controlIdJs}');
					if (c)
					{
						BX.Bizproc.FieldType.initControl(c.parentNode, JSON.parse(c.dataset.property));
					}
				});
			
			
HTML; } $renderResult = parent::renderControl($fieldType, $field, $valueString, $allowSelection, $renderMode); $renderResult .= static::renderControlSelector($field, null, false, '', $fieldType); return $renderResult; }