Пример #1
0
 public static function PrepareStorageElementInfo(&$arFields)
 {
     $storageTypeID = isset($arFields['STORAGE_TYPE_ID']) ? (int) $arFields['STORAGE_TYPE_ID'] : StorageType::Undefined;
     if (!StorageType::IsDefined($storageTypeID)) {
         $storageTypeID = self::GetDefaultStorageTypeID();
     }
     $storageElementIDs = isset($arFields['STORAGE_ELEMENT_IDS']) && is_array($arFields['STORAGE_ELEMENT_IDS']) ? $arFields['STORAGE_ELEMENT_IDS'] : array();
     if ($storageTypeID === StorageType::File) {
         $arFields['FILES'] = array();
         foreach ($storageElementIDs as $fileID) {
             $arData = CFile::GetFileArray($fileID);
             if (is_array($arData)) {
                 $arFields['FILES'][] = array('fileID' => $arData['ID'], 'fileName' => $arData['FILE_NAME'], 'fileURL' => CCrmUrlUtil::UrnEncode($arData['SRC']), 'fileSize' => $arData['FILE_SIZE']);
             }
         }
     } elseif ($storageTypeID === StorageType::WebDav) {
         $infos = array();
         foreach ($storageElementIDs as $elementID) {
             $infos[] = \CCrmWebDavHelper::GetElementInfo($elementID, $storageTypeID);
         }
         $arFields['WEBDAV_ELEMENTS'] =& $infos;
         unset($infos);
     } elseif ($storageTypeID === StorageType::Disk) {
         $infos = array();
         foreach ($storageElementIDs as $elementID) {
             $infos[] = Bitrix\Crm\Integration\DiskManager::getFileInfo($elementID, false, array('OWNER_TYPE_ID' => CCrmOwnerType::Activity, 'OWNER_ID' => $arFields['ID']));
         }
         $arFields['DISK_FILES'] =& $infos;
         unset($infos);
     }
 }