139 if ($value !==
null && !is_array($value))
141 if (self::isRawValue($value))
154 $valueString = \CBPHelper::usersArrayToString($value,
null, $fieldType->
getDocumentType());
156 if ($allowSelection && !$isPublic)
158 return static::renderControlSelector($field, $valueString,
'combine',
'', $fieldType);
163 \CUtil::InitJSCore([
'bp_user_selector']);
164 $name = static::generateControlName($field);
165 $controlId = static::generateControlId($field);
170 'valueInputName' => $name,
171 'value' => $valueString,
172 'items' => $value ? static::getSelectedItems($value, $settings) : [],
179 $config += $settings;
182 $groups = \CBPRuntime::GetRuntime()
183 ->GetService(
'DocumentService')
188 $config[
'groups'] = [];
189 foreach ($groups as $id => $groupName)
191 if (!$groupName || mb_strpos($id,
'group_') === 0)
196 $config[
'groups'][] = [
197 'id' => preg_match(
'/^[0-9]+$/', $id) ?
'G'.$id : $id,
203 $controlIdJs = \CUtil::JSEscape($controlId);
204 $controlIdHtml = htmlspecialcharsbx($controlId);
205 $configHtml = htmlspecialcharsbx(Main\Web\Json::encode($config));
206 $className = htmlspecialcharsbx(static::generateControlClassName($fieldType, $field));
208 $property[
'Type'] = static::getType();
209 $propertyHtml = htmlspecialcharsbx(Main\Web\Json::encode($property));
214 var c = document.getElementById(
'{$controlIdJs}');
217 BX.Bizproc.FieldType.initControl(c.parentNode, JSON.parse(c.dataset.property));
221 <div
id=
"{$controlIdHtml}" data-role=
"user-selector" data-
property=
"{$propertyHtml}" data-config=
"{$configHtml}" class=
"{$className}"></div>
225 $renderResult = parent::renderControl($fieldType, $field, $valueString, $allowSelection, $renderMode);
226 $renderResult .= static::renderControlSelector($field,
null,
false,
'', $fieldType);
228 return $renderResult;
241 return static::renderControl($fieldType, $field, $value, $allowSelection, $renderMode);
254 return static::renderControl($fieldType, $field, $value, $allowSelection, $renderMode);
265 $value = parent::extractValue($fieldType, $field, $request);
268 if (is_string($value) && $value !==
'')
309 $useExtraction = $fieldType->
getSettings()[
'ExternalExtract'] ??
false;
313 $useExtraction =
true;
316 if ($useExtraction && $value)
320 return \CBPHelper::ExtractUsers($value, $docId,
true);
323 return parent::externalizeValue($fieldType, $context, $value);
328 $useExtraction = $fieldType->
getSettings()[
'ExternalExtract'] ??
false;
332 $useExtraction =
true;
335 if ($useExtraction && $value)
338 return \CBPHelper::ExtractUsers($value, $docId);
341 return parent::externalizeValueMultiple($fieldType, $context, $value);
402 $value = static::toSingleValue($fieldType, $value);
404 $value = trim($value);
406 $isUser = (mb_strpos($value,
'user_') !==
false);
412 $isGroup = (mb_strpos($value,
'group_') !==
false);
418 $isNumber = preg_match(
'#^[0-9]+$#', $value);
424 $isDocumentGroup = Automation\Helper::isDocumentUserGroup($value, $fieldType->
getDocumentType());
425 if ($isDocumentGroup)
445 $value = \CBPHelper::flatten($fieldType->
getValue());
446 $value = array_values(array_filter($value, fn($v) => strpos($v,
'user_') !==
false));
448 $property[
'Settings'] = [
'entityList' => static::getSelectedItems($value)];
449 $property[
'Type'] = static::getType();
452 return parent::convertPropertyToView($fieldType, $viewMode, $property);