10if (Loader::requireModule(
'bizproc'))
12 class UserTypePropertyEmployee
extends UserTypeProperty
19 public static function getType()
21 if (!static::isCompatibleMode())
22 return FieldType::USER;
23 return FieldType::STRING;
26 public static function convertTo(FieldType $fieldType, $value,
$toTypeClass)
29 $value = $value[
'VALUE'];
31 $value = (string) $value;
32 return BaseType\User::convertTo($fieldType, $value,
$toTypeClass);
41 public static function convertFrom(FieldType $fieldType, $value,
$fromTypeClass)
47 $type = $fromTypeClass::getType();
50 case FieldType::DOUBLE:
52 $value =
'user_'.(int)$value;
54 case FieldType::INTERNALSELECT:
55 case FieldType::SELECT:
56 case FieldType::STRING:
63 elseif (static::isCompatibleMode())
65 $value = \CBPHelper::stripUserPrefix($value);
79 public static function getConversionMap()
81 $userMap = BaseType\User::getConversionMap();
87 FieldType::INTERNALSELECT,
106 $value = static::fixUserPrefix($value);
111 $selectorValue = \CBPActivity::isExpression($value) ? $value :
null;
128 $value = static::fixUserPrefix($value);
134 if (!
is_array($value) ||
is_array($value) && \CBPHelper::isAssociativeArray($value))
135 $value =
array($value);
137 foreach ($value
as $v)
139 if (\CBPActivity::isExpression(
$v))
156 $value = (
int) parent::extractValue($fieldType, $field, $request);
160 if ($value !==
null && !static::isCompatibleMode())
162 $value =
"user_".$value;
168 public static function extractValueMultiple(FieldType $fieldType,
array $field,
array $request)
170 $values = parent::extractValueMultiple($fieldType, $field, $request);
179 protected static function formatValuePrintable(FieldType $fieldType, $value)
181 $value = static::fixUserPrefix($value);
182 $userType = static::getUserType($fieldType);
184 $value = $value[
'VALUE'];
186 if (!
empty($userType[
'GetPublicViewHTML']))
189 $userType[
'GetPublicViewHTML'],
192 'LINK_IBLOCK_ID' => $fieldType->getOptions(),
198 'MODE' =>
'SIMPLE_TEXT',
204 return parent::formatValuePrintable($fieldType, $value);
207 public static function toSingleValue(FieldType $fieldType, $value)
211 $value = \CBPHelper::MakeArrayFlat($value);
212 $value = current($value);
216 return parent::toSingleValue($fieldType, $value);
221 if (!static::isCompatibleMode())
224 $value[
'VALUE'] = \CBPHelper::stripUserPrefix($value[
'VALUE']);
226 $value = \CBPHelper::stripUserPrefix($value);
234 if (static::$isCompatible ===
null)
236 static::$isCompatible = Config\Option::get(
'bizproc',
'employee_compatible_mode',
'N') ==
'Y';
238 return static::$isCompatible;
extractValue(array $fieldProperties, $value)