/** * @param FieldType $fieldType Document field object. * @param mixed $value Field value. * @param string $toTypeClass Type class manager name. * @return null|mixed */ public static function convertTo(FieldType $fieldType, $value, $toTypeClass) { if (isset($value['VALUE'])) { $value = $value['VALUE']; } if (isset($value['TEXT'])) { $value = $value['TEXT']; } return parent::convertTo($fieldType, $value, $toTypeClass); }
public static function extractValue(FieldType $fieldType, array $field, array $request) { if (!Loader::includeModule('disk')) { return null; } $value = parent::extractValue($fieldType, $field, $request); if (isset($value['VALUE'])) { $value = $value['VALUE']; } if (!$value) { return null; } // Attach file disk $userFieldManager = \Bitrix\Disk\Driver::getInstance()->getUserFieldManager(); list($connectorClass, $moduleId) = $userFieldManager->getConnectorDataByEntityType('iblock_workflow'); list($type, $realId) = \Bitrix\Disk\Uf\FileUserType::detectType($value); if ($type != \Bitrix\Disk\Uf\FileUserType::TYPE_NEW_OBJECT) { return null; } $errorCollection = new \Bitrix\Disk\Internals\Error\ErrorCollection(); $fileModel = \Bitrix\Disk\File::loadById($realId, array('STORAGE')); if (!$fileModel) { return null; } $securityContext = $fileModel->getStorage()->getCurrentUserSecurityContext(); if (!$fileModel->canRead($securityContext)) { return null; } $documentType = $fieldType->getDocumentType(); $iblockId = intval(substr($documentType[2], strlen("iblock_"))); $canUpdate = $fileModel->canUpdate($securityContext); global $USER; $attachedModel = \Bitrix\Disk\AttachedObject::add(array('MODULE_ID' => $moduleId, 'OBJECT_ID' => $fileModel->getId(), 'ENTITY_ID' => $iblockId, 'ENTITY_TYPE' => $connectorClass, 'IS_EDITABLE' => (int) $canUpdate, 'ALLOW_EDIT' => (int) ($canUpdate && (int) \Bitrix\Main\Application::getInstance()->getContext()->getRequest()->getPost('DISK_FILE_' . $iblockId . '_DISK_ATTACHED_OBJECT_ALLOW_EDIT')), 'CREATED_BY' => $USER->getId()), $errorCollection); if (!$attachedModel || $errorCollection->hasErrors()) { return null; } return $attachedModel->getId(); }
/** * @param FieldType $fieldType * @param $value * @return string */ protected static function formatValuePrintable(FieldType $fieldType, $value) { $value = static::fixUserPrefix($value); return parent::formatValuePrintable($fieldType, $value); }
public static function extractValue(FieldType $fieldType, array $field, array $request) { $value = parent::extractValue($fieldType, $field, $request); if (is_array($value) && isset($value['VALUE'])) { $value = $value['VALUE']; } if (!$value) { return null; } $property = static::getUserType($fieldType); $iblockId = self::getIblockId($fieldType); if (array_key_exists('AttachFilesWorkflow', $property)) { return call_user_func_array($property['AttachFilesWorkflow'], array($iblockId, $value)); } return null; }
/** * @param FieldType $fieldType Document field object. * @param array $field Form field information. * @param mixed $value Field value. * @param bool $allowSelection Allow selection flag. * @param int $renderMode Control render mode. * @return string */ public static function renderControlMultiple(FieldType $fieldType, array $field, $value, $allowSelection, $renderMode) { static::initControlHelpers(); return parent::renderControlMultiple($fieldType, $field, $value, $allowSelection, $renderMode); }