protected function processActionShowFile() { $fileName = $this->file->getName(); $fileData = $this->file->getFile(); if (!$fileData) { $this->end(); } $isImage = TypeFile::isImage($fileData["ORIGINAL_NAME"]); $cacheTime = $isImage ? 86400 : 0; $width = $this->request->getQuery('width'); $height = $this->request->getQuery('height'); if ($isImage && ($width > 0 || $height > 0)) { $signature = $this->request->getQuery('signature'); if (!$signature) { $this->sendJsonInvalidSignResponse('Empty signature'); } if (!ParameterSigner::validateImageSignature($signature, $this->file->getId(), $width, $height)) { $this->sendJsonInvalidSignResponse('Invalid signature'); } /** @noinspection PhpDynamicAsStaticMethodCallInspection */ $tmpFile = \CFile::resizeImageGet($fileData, array("width" => $width, "height" => $height), $this->request->getQuery('exact') == "Y" ? BX_RESIZE_IMAGE_EXACT : BX_RESIZE_IMAGE_PROPORTIONAL, true, false, true); $fileData["FILE_SIZE"] = $tmpFile["size"]; $fileData["SRC"] = $tmpFile["src"]; } \CFile::viewByUser($fileData, array('force_download' => false, 'cache_time' => $cacheTime, 'attachment_name' => $fileName)); }
public static function add(array $data) { if (!isset($data['TYPE_FILE'])) { $data['TYPE_FILE'] = TypeFile::getByFilename($data['NAME']); } $data['TYPE'] = static::TYPE_FILE; return parent::add($data); }
public function __construct($type) { parent::__construct(); $type = trim(strtolower($type), '.'); if (!$this->issetType($type)) { throw new SystemException("Could not find type '{$type}' in BlankFile"); } $typeData = $this->getType($type); $this->name = $typeData['newFileName'] . $typeData['ext']; $this->mimeType = TypeFile::getMimeTypeByFilename($this->name); $this->src = $typeData['src']; $this->size = IO\File::isFileExists($typeData['src']) ? filesize($typeData['src']) : 0; }
public static function getIconClassByObject(BaseObject $object, $appendSharedClass = false) { $class = ''; if ($object instanceof Folder) { $class = 'bx-disk-folder-icon'; } elseif ($object instanceof File) { $class = 'bx-disk-file-icon'; $ext = strtolower($object->getExtension()); if (isset(self::$possibleIconClasses[$ext])) { $class .= ' ' . self::$possibleIconClasses[$ext]; } elseif (TypeFile::isImage($object)) { $class .= ' ' . self::$possibleIconClasses['img']; } elseif (TypeFile::isVideo($object)) { $class .= ' ' . self::$possibleIconClasses['vid']; } } if ($object->isLink()) { $class .= ' icon-shared shared icon-shared_2'; } elseif ($appendSharedClass) { $class .= ' icon-shared shared icon-shared_1 icon-shared_2'; } return $class; }
/** * Uploads new file to folder. * @param array $fileArray Structure like $_FILES. * @param array $data Contains additional fields (CREATED_BY, NAME, etc). * @param array $rights Rights (@see \Bitrix\Disk\RightsManager). * @param bool $generateUniqueName Generates unique name for object in directory. * @throws \Bitrix\Main\ArgumentException * @return File|null */ public function uploadFile(array $fileArray, array $data, array $rights = array(), $generateUniqueName = false) { $this->errorCollection->clear(); $this->checkRequiredInputParams($data, array('NAME', 'CREATED_BY')); if (!isset($fileArray['MODULE_ID'])) { $fileArray['MODULE_ID'] = Driver::INTERNAL_MODULE_ID; } if (empty($fileArray['type'])) { $fileArray['type'] = ''; } $fileArray['type'] = TypeFile::normalizeMimeType($fileArray['type'], $data['NAME']); /** @noinspection PhpDynamicAsStaticMethodCallInspection */ $fileId = CFile::saveFile($fileArray, Driver::INTERNAL_MODULE_ID, true, true); if (!$fileId) { $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FOLDER_MODEL_ERROR_COULD_NOT_SAVE_FILE'), self::ERROR_COULD_NOT_SAVE_FILE))); return null; } /** @noinspection PhpDynamicAsStaticMethodCallInspection */ $fileArray = CFile::getFileArray($fileId); $data['NAME'] = Ui\Text::correctFilename($data['NAME']); $fileModel = $this->addFile(array('NAME' => $data['NAME'], 'FILE_ID' => $fileId, 'CONTENT_PROVIDER' => isset($data['CONTENT_PROVIDER']) ? $data['CONTENT_PROVIDER'] : null, 'SIZE' => !isset($data['SIZE']) ? $fileArray['FILE_SIZE'] : $data['SIZE'], 'CREATED_BY' => $data['CREATED_BY']), $rights, $generateUniqueName); if (!$fileModel) { CFile::delete($fileId); return null; } return $fileModel; }
" type="text"> </div> </div> </td> </tr> </table> <a class="bx-disk-btn bx-disk-btn-big bx-disk-btn-green" href="<?php echo $arResult['FILE']['DOWNLOAD_URL']; ?> "><?php echo Loc::getMessage('DISK_FILE_VIEW_FILE_DOWNLOAD'); ?> </a> <?php if (!empty($arResult['CAN_UPDATE']) && \Bitrix\Disk\TypeFile::isDocument($arResult['FILE']['NAME'])) { ?> <a id="bx-disk-file-edit-btn" class="bx-disk-btn bx-disk-btn-big bx-disk-btn-lightgray" href=""><?php echo Loc::getMessage('DISK_FILE_VIEW_FILE_EDIT'); ?> </a><?php } ?> <?php if (!empty($arResult['CAN_UPDATE'])) { ?> <a id="bx-disk-file-upload-btn" class="bx-disk-btn bx-disk-btn-big bx-disk-btn-lightgray" href="javascript:void(0);"><?php echo Loc::getMessage('DISK_FILE_VIEW_FILE_UPLOAD_VERSION'); ?> </a><?php }
public static function GetPublicPath($type, \Bitrix\Disk\File $fileModel) { if (!in_array($type, array(self::PATH_TYPE_DOWNLOAD, self::PATH_TYPE_SHOW, self::PATH_TYPE_PREVIEW))) { return ''; } if ($fileModel->getGlobalContentVersion() <= 1) { return ''; } $isShow = in_array($type, array(self::PATH_TYPE_SHOW, self::PATH_TYPE_PREVIEW)) && \Bitrix\Disk\TypeFile::isImage($fileModel->getName()); $isPreview = $isShow && in_array($type, array(self::PATH_TYPE_PREVIEW)); if ($type == self::PATH_TYPE_PREVIEW && !$isPreview) { return ''; } $url = array('default' => '/bitrix/components/bitrix/im.messenger/' . ($isShow ? 'show.file.php?' : 'download.file.php?')); $url['desktop'] = '/desktop_app/' . ($isShow ? 'show.file.php?' : 'download.file.php?'); if (IsModuleInstalled('mobile')) { $url['mobile'] = '/mobile/ajax.php?mobile_action=im_files&fileType=' . ($isShow ? 'show&' : 'download&'); } foreach ($url as $key => $value) { $url[$key] = $value . 'fileId=' . $fileModel->getId() . ($isPreview ? '&preview=Y' : '') . ($isShow || $key == 'mobile' ? '&fileName=' . urlencode($fileModel->getName()) : ''); } return $url; }
private function getGridData($gridId, $showDeleted = false) { $grid = array('ID' => $gridId); $gridOptions = new CGridOptions($grid['ID']); $gridSort = $gridOptions->getSorting(array('sort' => array('NAME' => 'ASC'), 'vars' => array('by' => 'by', 'order' => 'order'))); $filter = array(); $grid['SORT'] = $gridSort['sort']; $grid['SORT_VARS'] = $gridSort['vars']; $grid['MODE'] = $this->getViewMode(); $possibleColumnForSorting = array('UPDATE_TIME' => array('ALIAS' => 'UPDATE_TIME', 'LABEL' => Loc::getMessage('DISK_FOLDER_LIST_SORT_BY_UPDATE_TIME')), 'NAME' => array('ALIAS' => 'NAME', 'LABEL' => Loc::getMessage('DISK_FOLDER_LIST_SORT_BY_NAME')), 'FORMATTED_SIZE' => array('ALIAS' => 'SIZE', 'LABEL' => Loc::getMessage('DISK_FOLDER_LIST_SORT_BY_FORMATTED_SIZE'))); $byColumn = key($grid['SORT']); if (!isset($possibleColumnForSorting[$byColumn]) || strtolower($grid['SORT'][$byColumn]) !== 'desc' && strtolower($grid['SORT'][$byColumn]) !== 'asc') { $grid['SORT'] = array(); } $order = $grid['SORT']; $byColumn = key($order); $sortingColumns = array('TYPE' => array(SORT_NUMERIC, SORT_ASC), $possibleColumnForSorting[$byColumn]['ALIAS'] => strtolower($order[$byColumn]) === 'asc' ? SORT_ASC : SORT_DESC); if ($byColumn !== 'NAME') { $sortingColumns[$possibleColumnForSorting['NAME']['ALIAS']] = SORT_ASC; } $securityContext = $this->storage->getCurrentUserSecurityContext(); $proxyType = $this->storage->getProxyType(); $isStorageCurrentUser = $proxyType instanceof ProxyType\User && $proxyType->getTitleForCurrentUser() != $proxyType->getTitle(); $parameters = array('with' => array('CREATE_USER'), 'filter' => array('PARENT_ID' => $this->folder->getRealObjectId(), 'DELETED_TYPE' => ObjectTable::DELETED_TYPE_NONE)); $parameters = Driver::getInstance()->getRightsManager()->addRightsCheck($securityContext, $parameters, array('ID', 'CREATED_BY')); $needPagination = $this->needPagination(); $pageNumber = (int) $this->request->getQuery('pageNumber'); if ($pageNumber <= 0) { $pageNumber = 1; } if ($needPagination) { $parameters['order'] = array(); foreach ($sortingColumns as $columnName => $columnData) { if (is_array($columnData)) { $parameters['order'][$columnName] = in_array(SORT_DESC, $columnData, true) ? 'DESC' : 'ASC'; } else { $parameters['order'][$columnName] = SORT_DESC === $columnData ? 'DESC' : 'ASC'; } } unset($columnName, $columnData); $parameters['limit'] = self::COUNT_ON_PAGE + 1; // +1 because we want to know about existence next page $parameters['offset'] = self::COUNT_ON_PAGE * ($pageNumber - 1); } $this->folder->preloadOperationsForChildren($securityContext); $sharedObjectIds = $this->getUserShareObjectIds(); $isDesktopDiskInstall = \Bitrix\Disk\Desktop::isDesktopDiskInstall(); $nowTime = time() + CTimeZone::getOffset(); $fullFormatWithoutSec = preg_replace('/:s$/', '', CAllDatabase::dateFormatToPHP(CSite::GetDateFormat("FULL"))); $urlManager = Driver::getInstance()->getUrlManager(); $rows = array(); $storageTitle = $proxyType->getTitle(); $isEnabledShowExtendedRights = $this->storage->isEnabledShowExtendedRights(); $result = $this->folder->getList($parameters); $countObjectsOnPage = 0; $needShowNextPagePagination = false; while ($row = $result->fetch()) { $countObjectsOnPage++; if ($needPagination && $countObjectsOnPage > self::COUNT_ON_PAGE) { $needShowNextPagePagination = true; break; } $object = BaseObject::buildFromArray($row); /** @var File|Folder $object */ $name = $object->getName(); $objectId = $object->getId(); $exportData = array('TYPE' => $object->getType(), 'NAME' => $name, 'ID' => $objectId); $relativePath = trim($this->arParams['RELATIVE_PATH'], '/'); $detailPageFile = CComponentEngine::makePathFromTemplate($this->arParams['PATH_TO_FILE_VIEW'], array('FILE_ID' => $objectId, 'FILE_PATH' => ltrim($relativePath . '/' . $name, '/'))); $listingPage = rtrim(CComponentEngine::makePathFromTemplate($this->arParams['PATH_TO_FOLDER_LIST'], array('PATH' => $relativePath)), '/'); $isFolder = $object instanceof Folder; $actions = $tileActions = $columns = array(); if ($object->canRead($securityContext)) { $exportData['OPEN_URL'] = $urlManager->encodeUrn($isFolder ? $listingPage . '/' . $name . '/' : $detailPageFile); $actions[] = array("PSEUDO_NAME" => "open", "DEFAULT" => true, "ICONCLASS" => "show", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_OPEN'), "ONCLICK" => "jsUtils.Redirect(arguments, '" . $exportData['OPEN_URL'] . "')"); if (!$object->canChangeRights($securityContext) && !$object->canShare($securityContext)) { $actions[] = array("PSEUDO_NAME" => "share", "ICONCLASS" => "share", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_SHOW_SHARING_DETAIL_2'), "ONCLICK" => "BX.Disk.showSharingDetailWithoutEdit({\n\t\t\t\t\t\t\t\tajaxUrl: '/bitrix/components/bitrix/disk.folder.list/ajax.php',\n\t\t\t\t\t\t\t\tobject: {\n\t\t\t\t\t\t\t\t\tid: {$objectId},\n\t\t\t\t\t\t\t\t\tname: '{$name}',\n\t\t\t\t\t\t\t\t\tisFolder: " . ($isFolder ? 'true' : 'false') . "\n\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t})"); } elseif ($object->canChangeRights($securityContext)) { $actions[] = array("PSEUDO_NAME" => "share", "ICONCLASS" => "share", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_SHOW_SHARING_DETAIL_2'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].showSharingDetailWithChangeRights({\n\t\t\t\t\t\t\t\tajaxUrl: '/bitrix/components/bitrix/disk.folder.list/ajax.php',\n\t\t\t\t\t\t\t\tobject: {\n\t\t\t\t\t\t\t\t\tid: {$objectId},\n\t\t\t\t\t\t\t\t\tname: '{$name}',\n\t\t\t\t\t\t\t\t\tisFolder: " . ($isFolder ? 'true' : 'false') . "\n\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t})"); } elseif ($object->canShare($securityContext)) { $actions[] = array("PSEUDO_NAME" => "share", "ICONCLASS" => "share", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_SHOW_SHARING_DETAIL_2'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].showSharingDetailWithSharing({\n\t\t\t\t\t\t\t\tajaxUrl: '/bitrix/components/bitrix/disk.folder.list/ajax.php',\n\t\t\t\t\t\t\t\tobject: {\n\t\t\t\t\t\t\t\t\tid: {$objectId},\n\t\t\t\t\t\t\t\t\tname: '{$name}',\n\t\t\t\t\t\t\t\t\tisFolder: " . ($isFolder ? 'true' : 'false') . "\n\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t})"); } if ($isEnabledShowExtendedRights && !$object->isLink() && $object->canChangeRights($securityContext)) { $actions[] = array("PSEUDO_NAME" => "rights", "ICONCLASS" => "rights", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_RIGHTS_SETTINGS'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].showRightsOnObjectDetail({\n\t\t\t\t\t\t\t\tobject: {\n\t\t\t\t\t\t\t\t\tid: {$objectId},\n\t\t\t\t\t\t\t\t\tname: '{$name}',\n\t\t\t\t\t\t\t\t\tisFolder: " . ($isFolder ? 'true' : 'false') . "\n\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t})"); } if (!$isFolder) { $actions[] = array("PSEUDO_NAME" => "download", "ICONCLASS" => "download", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_DOWNLOAD'), "ONCLICK" => "jsUtils.Redirect(arguments, '" . $urlManager->getUrlForDownloadFile($object) . "')"); } $actions[] = array("PSEUDO_NAME" => "copy", "ICONCLASS" => "copy", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_COPY'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].openCopyModalWindow({\n\t\t\t\t\t\tid: {$this->storage->getRootObjectId()},\n\t\t\t\t\t\tname: '" . CUtil::JSEscape($storageTitle) . "'\n\t\t\t\t\t}, {\n\t\t\t\t\t\tid: {$objectId},\n\t\t\t\t\t\tname: '" . CUtil::JSEscape($name) . "'\n\t\t\t\t\t});"); if ($object->canDelete($securityContext)) { $actions[] = array("PSEUDO_NAME" => "move", "ICONCLASS" => "move", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_MOVE'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].openMoveModalWindow({\n\t\t\t\t\t\t\tid: {$this->storage->getRootObjectId()},\n\t\t\t\t\t\t\tname: '" . CUtil::JSEscape($storageTitle) . "'\n\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\tid: {$objectId},\n\t\t\t\t\t\t\tname: '" . CUtil::JSEscape($name) . "'\n\t\t\t\t\t\t});"); } if (!$isStorageCurrentUser && (!isset($sharedObjectIds[$object->getRealObjectId()]) || $sharedObjectIds[$object->getRealObjectId()]['TO_ENTITY'] != Sharing::CODE_USER . $this->getUser()->getId())) { $actions[] = array("PSEUDO_NAME" => "connect", "ICONCLASS" => "connect", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_CONNECT'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].connectObjectToDisk({\n\t\t\t\t\t\t\tobject: {\n\t\t\t\t\t\t\t\tid: {$objectId},\n\t\t\t\t\t\t\t\tname: '" . CUtil::JSEscape($name) . "',\n\t\t\t\t\t\t\t\tisFolder: " . ($isFolder ? 'true' : 'false') . "\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});"); } if (!$isFolder) { $actions[] = array("ICONCLASS" => "show", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_GET_EXT_LINK'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].getExternalLink({$objectId});"); $downloadLink = $urlManager->getUrlForShowFile($object, array(), true); $actions[] = array("ICONCLASS" => "show", 'PSEUDO_NAME' => 'internal_link', 'PSEUDO_VALUE' => $downloadLink, "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_COPY_INTERNAL_LINK'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].getInternalLink('{$downloadLink}');"); $actions[] = array("ICONCLASS" => "history", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_SHOW_HISTORY'), "ONCLICK" => "jsUtils.Redirect(arguments, '" . $exportData['OPEN_URL'] . "#tab-history')"); } } if ($object->canRename($securityContext)) { $actions[] = array("TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_RENAME'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].renameInline({$objectId})"); } if ((!empty($sharedObjectIds[$objectId]) || $object->isLink()) && $object->canRead($securityContext)) { $tileActions['SHARE_INFO'] = array("ICONCLASS" => "show", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_DETAIL_SHARE_INFO'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].showShareInfoSmallView({\n\t\t\t\t\t\tobject: {\n\t\t\t\t\t\t\tid: {$objectId},\n\t\t\t\t\t\t\tname: '{$name}',\n\t\t\t\t\t\t\tisFolder: " . ($isFolder ? 'true' : 'false') . "\n\t\t\t\t\t\t }\n\t\t\t\t\t})"); } $columnsBizProc = array('BIZPROC' => ''); $bizprocIcon = array('BIZPROC' => ''); if ($this->arParams['STATUS_BIZPROC'] && !$isFolder) { list($actions, $columnsBizProc, $bizprocIcon) = $this->getBizProcData($object, $securityContext, $actions, $columnsBizProc, $bizprocIcon, $exportData); } if ($object->canDelete($securityContext)) { if ($object->isLink()) { $actions[] = array("PSEUDO_NAME" => "detach", "ICONCLASS" => "detach", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_DETACH_BUTTON'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].openConfirmDetach({\n\t\t\t\t\t\t\t\tobject: {\n\t\t\t\t\t\t\t\t\tid: {$objectId},\n\t\t\t\t\t\t\t\t\tname: '{$name}',\n\t\t\t\t\t\t\t\t\tisFolder: " . ($isFolder ? 'true' : 'false') . "\n\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t})"); } elseif ($object->getCode() !== Folder::CODE_FOR_UPLOADED_FILES) { $actions[] = array("PSEUDO_NAME" => "delete", "ICONCLASS" => "delete", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_MARK_DELETED'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].openConfirmDelete({\n\t\t\t\t\t\t\t\tobject: {\n\t\t\t\t\t\t\t\t\tid: {$objectId},\n\t\t\t\t\t\t\t\t\tname: '{$name}',\n\t\t\t\t\t\t\t\t\tisFolder: " . ($isFolder ? 'true' : 'false') . "\n\t\t\t\t\t\t\t\t },\n\t\t\t\t\t\t\t\tcanDelete: {$object->canDelete($securityContext)}\n\t\t\t\t\t\t\t})"); } } $iconClass = Ui\Icon::getIconClassByObject($object, !empty($sharedObjectIds[$objectId])); $dataAttributesForViewer = ''; if ($isFolder) { $dataAttributesForViewer = Ui\Viewer::getAttributesByObject($object); if ($grid['MODE'] === 'tile') { $exportData['VIEWER_ATTRS'] = $dataAttributesForViewer; $dataAttributesForViewer = ''; } $nameSpecialChars = htmlspecialcharsbx($name); $columnName = "\n\t\t\t\t\t<table class=\"bx-disk-object-name\"><tr>\n\t\t\t\t\t\t\t<td style=\"width: 45px;\"><div data-object-id=\"{$objectId}\" class=\"draggable bx-file-icon-container-small {$iconClass}\"></div></td>\n\t\t\t\t\t\t\t<td><a class=\"bx-disk-folder-title\" id=\"disk_obj_{$objectId}\" href=\"{$exportData['OPEN_URL']}\" {$dataAttributesForViewer}>{$nameSpecialChars}</a></td>\n\t\t\t\t\t</tr></table>\n\t\t\t\t"; } else { $externalId = ''; if ($isDesktopDiskInstall && $isStorageCurrentUser) { $externalId = "st{$this->storage->getId()}|{$this->storage->getRootObjectId()}|f{$objectId}"; } $dataAttributesForViewer = Ui\Viewer::getAttributesByObject($object, array('canUpdate' => $object->canUpdate($securityContext), 'relativePath' => $relativePath . '/' . $name, 'externalId' => $externalId)); if ($grid['MODE'] === 'tile') { $exportData['VIEWER_ATTRS'] = $dataAttributesForViewer; $dataAttributesForViewer = ''; } $nameSpecialChars = htmlspecialcharsbx($name); $columnName = "\n\t\t\t\t\t<table class=\"bx-disk-object-name\"><tr>\n\t\t\t\t\t\t<td style=\"width: 45px;\"><div data-object-id=\"{$objectId}\" class=\"draggable bx-file-icon-container-small {$iconClass}\"></div></td>\n\t\t\t\t\t\t<td><a class=\"bx-disk-folder-title\" id=\"disk_obj_{$objectId}\" href=\"{$exportData['OPEN_URL']}\" {$dataAttributesForViewer}>{$nameSpecialChars}</a></td>\n\t\t\t\t\t\t<td>{$bizprocIcon['BIZPROC']}</td>\n\t\t\t\t\t</tr></table>\n\t\t\t\t"; } $createdByLink = \CComponentEngine::makePathFromTemplate($this->arParams['PATH_TO_USER'], array("user_id" => $object->getCreatedBy())); $timestampCreate = $object->getCreateTime()->toUserTime()->getTimestamp(); $timestampUpdate = $object->getUpdateTime()->toUserTime()->getTimestamp(); $columns = array('CREATE_TIME' => $nowTime - $timestampCreate > 158400 ? formatDate($fullFormatWithoutSec, $timestampCreate, $nowTime) : formatDate('x', $timestampCreate, $nowTime), 'UPDATE_TIME' => $nowTime - $timestampCreate > 158400 ? formatDate($fullFormatWithoutSec, $timestampUpdate, $nowTime) : formatDate('x', $timestampUpdate, $nowTime), 'NAME' => $columnName, 'FORMATTED_SIZE' => $isFolder ? '' : CFile::formatSize($object->getSize()), 'CREATE_USER' => "\n\t\t\t\t\t<div class=\"bx-disk-user-link\"><a target='_blank' href=\"{$createdByLink}\" id=\"\">" . htmlspecialcharsbx($object->getCreateUser()->getFormattedName()) . "</a></div>\n\t\t\t\t"); if ($this->arParams['STATUS_BIZPROC']) { $columns['BIZPROC'] = $columnsBizProc["BIZPROC"]; } $exportData['ICON_CLASS'] = $iconClass; if ($grid['MODE'] === 'tile') { $exportData['IS_IMAGE'] = $isFolder ? false : \Bitrix\Disk\TypeFile::isImage($object); if ($exportData['IS_IMAGE']) { $exportData['SRC_IMAGE'] = $urlManager->getUrlForShowFile($object, array('exact' => 'Y', 'width' => 64, 'height' => 64)); } $exportData['UPDATE_TIME'] = $columns['UPDATE_TIME']; } $exportData['IS_SHARED'] = !empty($sharedObjectIds[$objectId]); $exportData['IS_LINK'] = $object->isLink(); $tildaExportData = array(); foreach ($exportData as $exportName => $exportValue) { $tildaExportData['~' . $exportName] = $exportValue; } unset($exportRow); $rows[] = array('data' => array_merge($exportData, $tildaExportData), 'columns' => $columns, 'actions' => $actions, 'tileActions' => $tileActions, 'TYPE' => $exportData['TYPE'], 'NAME' => $exportData['NAME'], 'UPDATE_TIME' => $object->getUpdateTime()->getTimestamp(), 'SIZE' => $isFolder ? 0 : $object->getSize()); } unset($object); if (!$needPagination) { Collection::sortByColumn($rows, $sortingColumns); } $grid['HEADERS'] = array(array('id' => 'ID', 'name' => 'ID', 'sort' => isset($possibleColumnForSorting['ID']) ? 'ID' : false, 'default' => false), array('id' => 'NAME', 'name' => Loc::getMessage('DISK_FOLDER_LIST_COLUMN_NAME'), 'sort' => isset($possibleColumnForSorting['NAME']) ? 'NAME' : false, 'default' => true, 'editable' => array('size' => 45)), array('id' => 'CREATE_TIME', 'name' => Loc::getMessage('DISK_FOLDER_LIST_COLUMN_CREATE_TIME'), 'sort' => isset($possibleColumnForSorting['CREATE_TIME']) ? 'CREATE_TIME' : false, 'default' => false), array('id' => 'UPDATE_TIME', 'name' => Loc::getMessage('DISK_FOLDER_LIST_COLUMN_UPDATE_TIME'), 'sort' => isset($possibleColumnForSorting['UPDATE_TIME']) ? 'UPDATE_TIME' : false, 'default' => true), array('id' => 'CREATE_USER', 'name' => Loc::getMessage('DISK_FOLDER_LIST_COLUMN_CREATE_USER'), 'sort' => isset($possibleColumnForSorting['CREATE_USER']) ? 'CREATE_USER' : false, 'default' => false), array('id' => 'FORMATTED_SIZE', 'name' => Loc::getMessage('DISK_FOLDER_LIST_COLUMN_FORMATTED_SIZE'), 'sort' => isset($possibleColumnForSorting['FORMATTED_SIZE']) ? 'FORMATTED_SIZE' : false, 'default' => true)); if ($this->arParams['STATUS_BIZPROC']) { $grid['HEADERS'][] = array('id' => 'BIZPROC', 'name' => Loc::getMessage('DISK_FOLDER_LIST_COLUMN_BIZPROC'), 'default' => false); } $grid['DATA_FOR_PAGINATION'] = array('ENABLED' => $needPagination); if ($needPagination) { $grid['DATA_FOR_PAGINATION']['SHOW_NEXT_PAGE'] = $needShowNextPagePagination; $grid['DATA_FOR_PAGINATION']['CURRENT_PAGE'] = $pageNumber; } $grid['COLUMN_FOR_SORTING'] = $possibleColumnForSorting; $grid['ROWS'] = $rows; $grid['ROWS_COUNT'] = count($rows); $grid['FOOTER'] = array(); if (isModuleInstalled('bitrix24')) { list($freeSpace, $diskSize) = $this->getDiskSpace(); $freeSpace = CFile::formatSize($freeSpace); $diskSize = CFile::formatSize($diskSize); $grid['FOOTER'] = array(array('custom_html' => ' <td class="tar" style="width: 100%;">' . Loc::getMessage('DISK_FOLDER_LIST_B24_LABEL_DISK_SPACE', array('#FREE_SPACE#' => '<span>' . $freeSpace, '#DISK_SIZE#' => $diskSize . '</span>')) . '</span></td> '), array('custom_html' => ' <td class="tar"><a class="bx-disk-mp-link-addhdd" href="' . Loc::getMessage('DISK_FOLDER_LIST_B24_URL_DISK_SPACE') . '" target="_blank">+ <span>' . Loc::getMessage('DISK_FOLDER_LIST_B24_APPEND_DISK_SPACE') . '</span></a></td> ')); } return $grid; }
public static function getMap() { return array('ID' => array('data_type' => 'integer', 'primary' => true, 'autocomplete' => true), 'NAME' => array('data_type' => 'string', 'validation' => array(__CLASS__, 'validateName'), 'title' => Loc::getMessage('DISK_OBJECT_ENTITY_NAME_FIELD')), 'TYPE' => array('data_type' => 'enum', 'values' => static::getListOfTypeValues()), 'CODE' => array('data_type' => 'string', 'validation' => array(__CLASS__, 'validateCode')), 'XML_ID' => array('data_type' => 'string', 'validation' => array(__CLASS__, 'validateXmlId')), 'STORAGE_ID' => array('data_type' => 'integer', 'required' => true), 'STORAGE' => array('data_type' => '\\Bitrix\\Disk\\Internals\\StorageTable', 'reference' => array('=this.STORAGE_ID' => 'ref.ID'), 'join_type' => 'INNER'), 'REAL_OBJECT_ID' => array('data_type' => 'integer'), 'REAL_OBJECT' => array('data_type' => '\\Bitrix\\Disk\\Internals\\ObjectTable', 'reference' => array('=this.REAL_OBJECT_ID' => 'ref.ID'), 'join_type' => 'INNER'), 'PARENT_ID' => array('data_type' => 'integer'), 'CONTENT_PROVIDER' => array('data_type' => 'string', 'validation' => array(__CLASS__, 'validateContentProvider')), 'CREATE_TIME' => array('data_type' => 'datetime', 'required' => true, 'default_value' => new DateTime()), 'UPDATE_TIME' => array('data_type' => 'datetime', 'default_value' => new DateTime()), 'DELETE_TIME' => array('data_type' => 'datetime'), 'CREATED_BY' => array('data_type' => 'integer'), 'CREATE_USER' => array('data_type' => 'Bitrix\\Main\\UserTable', 'reference' => array('=this.CREATED_BY' => 'ref.ID')), 'UPDATED_BY' => array('data_type' => 'integer'), 'UPDATE_USER' => array('data_type' => 'Bitrix\\Main\\UserTable', 'reference' => array('=this.UPDATED_BY' => 'ref.ID')), 'DELETED_BY' => array('data_type' => 'integer'), 'DELETE_USER' => array('data_type' => 'Bitrix\\Main\\UserTable', 'reference' => array('=this.DELETED_BY' => 'ref.ID')), 'GLOBAL_CONTENT_VERSION' => array('data_type' => 'integer'), 'FILE_ID' => array('data_type' => 'integer'), 'SIZE' => array('data_type' => 'integer'), 'EXTERNAL_HASH' => array('data_type' => 'string', 'validation' => array(__CLASS__, 'validateExternalHash')), 'DELETED_TYPE' => array('data_type' => 'enum', 'values' => static::getListOfDeletedTypes(), 'default_value' => self::DELETED_TYPE_NONE), 'TYPE_FILE' => array('data_type' => 'enum', 'values' => TypeFile::getListOfValues()), 'PATH_PARENT' => array('data_type' => '\\Bitrix\\Disk\\Internals\\ObjectPathTable', 'reference' => array('=this.ID' => 'ref.PARENT_ID'), 'join_type' => 'INNER'), 'PATH_CHILD' => array('data_type' => '\\Bitrix\\Disk\\Internals\\ObjectPathTable', 'reference' => array('=this.ID' => 'ref.OBJECT_ID'), 'join_type' => 'INNER')); }
private function getFileContent(File $file) { static $maxFileSize = null; if (!isset($maxFileSize)) { $maxFileSize = Option::get("search", "max_file_size", 0) * 1024; } $searchData = ''; $searchData .= strip_tags($file->getName()) . "\r\n"; $searchData .= strip_tags($file->getCreateUser()->getFormattedName()) . "\r\n"; if ($maxFileSize > 0 && $file->getSize() > $maxFileSize) { return $searchData; } $searchDataFile = array(); $fileArray = null; //improve work with s3 if (!ModuleManager::isModuleInstalled('bitrix24') || TypeFile::isDocument($file)) { $fileArray = CFile::makeFileArray($file->getFileId()); } if ($fileArray && $fileArray['tmp_name']) { $fileAbsPath = \CBXVirtualIo::getInstance()->getLogicalName($fileArray['tmp_name']); foreach (GetModuleEvents('search', 'OnSearchGetFileContent', true) as $event) { if ($searchDataFile = executeModuleEventEx($event, array($fileAbsPath, getFileExtension($fileArray['name'])))) { break; } } return is_array($searchDataFile) ? $searchData . "\r\n" . $searchDataFile['CONTENT'] : $searchData; } return $searchData; }
/** * Uploads new version to file. * @see \Bitrix\Disk\File::addVersion(). * @param array $fileArray Structure like $_FILES. * @param int $createdBy Id of user. * @return Version|null */ public function uploadVersion(array $fileArray, $createdBy) { $this->errorCollection->clear(); if (!isset($fileArray['MODULE_ID'])) { $fileArray['MODULE_ID'] = Driver::INTERNAL_MODULE_ID; } if (empty($fileArray['type'])) { $fileArray['type'] = ''; } $fileArray['type'] = TypeFile::normalizeMimeType($fileArray['type'], $this->name); /** @noinspection PhpDynamicAsStaticMethodCallInspection */ $fileId = CFile::saveFile($fileArray, Driver::INTERNAL_MODULE_ID, true, true); if (!$fileId) { $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FILE_MODEL_ERROR_COULD_NOT_SAVE_FILE'), self::ERROR_COULD_NOT_SAVE_FILE))); return null; } /** @noinspection PhpDynamicAsStaticMethodCallInspection */ $fileArray = CFile::getFileArray($fileId); $version = $this->addVersion($fileArray, $createdBy); if (!$version) { CFile::delete($fileId); } return $version; }
/** * @internal * @param $fileName * @param $mimeType * @return string */ protected function recoverExtensionInName($fileName, $mimeType) { $specificMimeTypes = array('application/vnd.google-apps.document' => 'docx', 'application/vnd.google-apps.spreadsheet' => 'xlsx', 'application/vnd.google-apps.presentation' => 'pptx'); if (isset($specificMimeTypes[$mimeType])) { $originalExtension = $specificMimeTypes[$mimeType]; } else { $originalExtension = TypeFile::getExtensionByMimeType($mimeType); } $newExtension = strtolower(trim(getFileExtension($fileName), '.')); if ($originalExtension !== $newExtension && $originalExtension !== null) { return getFileNameWithoutExtension($fileName) . '.' . $originalExtension; } return $fileName; }
protected function migrateVersion() { if (!$this->runWorkWithBizproc) { return; } if ($this->isStepFinished(__METHOD__)) { return; } $uploadDir = COption::getOptionString("main", "upload_dir", "upload"); $isCloud = CModule::IncludeModule("clouds"); $useGZipCompressionOption = \Bitrix\Main\Config\Option::get("bizproc", "use_gzip_compression", ""); $isBitrix24 = IsModuleInstalled('bitrix24'); $bucket = null; if ($isBitrix24 && $isCloud) { $bucket = new CCloudStorageBucket(1); $bucket->init(); } if ($useGZipCompressionOption === "Y") { $this->useGZipCompression = true; } elseif ($useGZipCompressionOption === "N") { $this->useGZipCompression = false; } else { $this->useGZipCompression = function_exists("gzcompress") && ($GLOBALS["DB"]->type != "ORACLE" || !defined('BX_UTF')); } $sqlHelper = $this->connection->getSqlHelper(); $lastId = $this->getStorageId(); $versionQuery = $this->connection->query("\n\t\t\tSELECT\n\t\t\t\tobj.*,\n\t\t\t\th.ID VERSION_ID,\n\t\t\t\th.NAME VERSION_NAME,\n\t\t\t\th.DOCUMENT VERSION_DOC,\n\t\t\t\th.USER_ID VERSION_USER_ID,\n\t\t\t\th.MODIFIED VERSION_MODIFIED\n\t\t\tFROM b_disk_object obj\n\t\t\t\tINNER JOIN b_bp_history h ON h.DOCUMENT_ID = obj.WEBDAV_ELEMENT_ID AND h.MODULE_ID = 'webdav'\n\n\t\t\tWHERE obj.TYPE = 3 AND h.ID > {$lastId} ORDER BY h.ID\n\t\t"); while ($version = $versionQuery->fetch()) { $this->abortIfNeeded(); if (strlen($version['VERSION_DOC']) > 0) { if ($this->useGZipCompression) { $version['VERSION_DOC'] = gzuncompress($version['VERSION_DOC']); } $version['VERSION_DOC'] = unserialize($version['VERSION_DOC']); if (!is_array($version['VERSION_DOC'])) { $version['VERSION_DOC'] = array(); } } else { $version['VERSION_DOC'] = array(); } if (empty($version['VERSION_DOC']) || empty($version['VERSION_DOC']['PROPERTIES']['WEBDAV_VERSION']['VALUE']) || empty($version['VERSION_DOC']['PROPERTIES']['FILE']['VALUE'])) { $this->storeStorageId($version['VERSION_ID']); continue; } $version['VERSION_NAME'] = $sqlHelper->forSql($version['VERSION_NAME']); $version['VERSION_MODIFIED'] = $sqlHelper->getCharToDateFunction($version['VERSION_MODIFIED']->format("Y-m-d H:i:s")); $version['UPDATE_TIME'] = $sqlHelper->getCharToDateFunction($version['UPDATE_TIME']->format("Y-m-d H:i:s")); $fullPath = $version['VERSION_DOC']['PROPERTIES']['FILE']['VALUE']; $handlerId = ''; $filename = bx_basename($fullPath); if (substr($fullPath, 0, 4) == "http") { if (!$isCloud) { $this->storeStorageId($version['VERSION_ID']); continue; } if (!$isBitrix24) { $bucket = CCloudStorage::findBucketByFile($fullPath); if (!$bucket) { $this->storeStorageId($version['VERSION_ID']); continue; } } $handlerId = $bucket->ID; $subDir = trim(substr(getDirPath($fullPath), strlen($bucket->getFileSRC('/'))), '/'); $contentType = \Bitrix\Disk\TypeFile::getMimeTypeByFilename($filename); } else { $subDir = trim(substr(getDirPath($fullPath), strlen('/' . $uploadDir)), '/'); $contentType = CFile::getContentType($_SERVER["DOCUMENT_ROOT"] . $fullPath); $contentType = \Bitrix\Disk\TypeFile::normalizeMimeType($contentType, $filename); } $webdavSize = $version['VERSION_DOC']['PROPERTIES']['WEBDAV_SIZE']['VALUE']; if (empty($webdavSize)) { $webdavSize = 0; } $fileId = CFile::doInsert(array('HEIGHT' => 0, 'WIDTH' => 0, 'FILE_SIZE' => $webdavSize, 'CONTENT_TYPE' => $contentType, 'SUBDIR' => $subDir, 'FILE_NAME' => $filename, 'MODULE_ID' => Driver::INTERNAL_MODULE_ID, 'ORIGINAL_NAME' => $filename, 'DESCRIPTION' => '', 'HANDLER_ID' => $handlerId, 'EXTERNAL_ID' => md5(mt_rand()))); if (!$fileId) { $this->storeStorageId($version['VERSION_ID']); continue; } $this->connection->queryExecute("\n\t\t\t\tINSERT INTO b_disk_version (OBJECT_ID, FILE_ID, " . $this->sqlHelper->quote('SIZE') . ", NAME, CREATE_TIME, CREATED_BY, MISC_DATA, OBJECT_CREATE_TIME, OBJECT_CREATED_BY, OBJECT_UPDATE_TIME, OBJECT_UPDATED_BY, GLOBAL_CONTENT_VERSION, BP_VERSION_ID)\n\t\t\t\tVALUES ({$version['ID']}, {$fileId}, {$webdavSize}, '{$version['VERSION_NAME']}', {$version['VERSION_MODIFIED']}, {$version['VERSION_USER_ID']}, null, {$version['VERSION_MODIFIED']}, {$version['CREATED_BY']}, {$version['UPDATE_TIME']}, {$version['UPDATED_BY']}, {$version['VERSION_DOC']['PROPERTIES']['WEBDAV_VERSION']['VALUE']}, {$version['VERSION_ID']})\n\t\t\t"); $this->storeStorageId($version['VERSION_ID']); } $this->abortIfNeeded(); $this->storeStorageId(0); $this->setStepFinished(__METHOD__); }
protected function recoverExtensionInName(&$fileName, $mimeType) { $originalExtension = TypeFile::getExtensionByMimeType($mimeType); $newExtension = strtolower(trim(getFileExtension($fileName), '.')); if ($originalExtension != $newExtension) { $fileName = getFileNameWithoutExtension($fileName) . '.' . $originalExtension; return true; } return false; }
/** * Gets data attributes by attached object to viewer. * @param AttachedObject $attachedObject Target attached object. * @param array $additionalParams Additional parameters 'relativePath', 'externalId', 'canUpdate', 'canFakeUpdate', 'showStorage', 'version'. * @return string */ public static function getAttributesByAttachedObject(AttachedObject $attachedObject, array $additionalParams = array()) { $urlManager = Driver::getInstance()->getUrlManager(); $version = $object = null; if ($attachedObject->isSpecificVersion()) { $version = $attachedObject->getVersion(); if (!$version) { return ''; } $name = $version->getName(); $extension = $version->getExtension(); $size = $version->getSize(); $updateTime = $version->getCreateTime(); } else { $object = $attachedObject->getObject(); if (!$object) { return ''; } $name = $object->getName(); $extension = $object->getExtension(); $size = $object->getSize(); $updateTime = $object->getUpdateTime(); } if (DocumentHandler::isEditable($extension)) { $dataAttributesForViewer = 'data-bx-viewer="iframe" ' . 'data-bx-title="' . htmlspecialcharsbx($name) . '" ' . 'data-bx-src="' . $urlManager->getUrlToShowAttachedFileByService($attachedObject->getId(), 'gvdrive') . '" ' . 'data-bx-isFromUserLib="" ' . 'data-bx-askConvert="' . (DocumentHandler::isNeedConvertExtension($extension) ? '1' : '') . '" ' . 'data-bx-download="' . $urlManager->getUrlUfController('download', array('attachedId' => $attachedObject->getId())) . '" ' . 'data-bx-size="' . htmlspecialcharsbx(CFile::formatSize($size)) . '" '; } elseif (Viewer::isViewable($extension)) { $dataAttributesForViewer = 'data-bx-viewer="iframe" ' . 'data-bx-title="' . htmlspecialcharsbx($name) . '" ' . 'data-bx-src="' . $urlManager->getUrlToShowAttachedFileByService($attachedObject->getId(), 'gvdrive') . '" ' . 'data-bx-isFromUserLib="" ' . 'data-bx-askConvert="0" ' . 'data-bx-download="' . $urlManager->getUrlUfController('download', array('attachedId' => $attachedObject->getId())) . '" ' . 'data-bx-size="' . htmlspecialcharsbx(CFile::formatSize($size)) . '" ' . 'data-bx-dateModify="' . htmlspecialcharsbx($updateTime) . '" '; } elseif (TypeFile::isImage($name)) { $dataAttributesForViewer = 'data-bx-viewer="image" ' . 'data-bx-title="' . htmlspecialcharsbx($name) . '" ' . 'data-bx-src="' . $urlManager->getUrlUfController('download', array('attachedId' => $attachedObject->getId())) . '" ' . 'data-bx-isFromUserLib="" ' . 'data-bx-download="' . $urlManager->getUrlUfController('download', array('attachedId' => $attachedObject->getId())) . '" '; } else { $user = $version ? $version->getCreateUser() : $object->getCreateUser(); $formattedName = $user ? $user->getFormattedName() : ''; $dataAttributesForViewer = 'data-bx-viewer="unknown" ' . 'data-bx-src="' . $urlManager->getUrlUfController('download', array('attachedId' => $attachedObject->getId())) . '" ' . 'data-bx-isFromUserLib="" ' . 'data-bx-download="' . $urlManager->getUrlUfController('download', array('attachedId' => $attachedObject->getId())) . '" ' . 'data-bx-title="' . htmlspecialcharsbx($name) . '" ' . 'data-bx-owner="' . htmlspecialcharsbx($formattedName) . '" ' . 'data-bx-dateModify="' . htmlspecialcharsbx($updateTime) . '" ' . 'data-bx-size="' . htmlspecialcharsbx(CFile::formatSize($size)) . '" '; } $dataAttributesForViewer .= " data-bx-history=\"\"" . " data-bx-historyPage=\"\""; if ($object) { $dataAttributesForViewer .= " bx-attach-file-id=\"{$object->getId()}\""; } if (!empty($additionalParams['relativePath'])) { $dataAttributesForViewer .= ' data-bx-relativePath="' . htmlspecialcharsbx($additionalParams['relativePath'] . '/' . $name) . '" '; } if (!empty($additionalParams['externalId'])) { $dataAttributesForViewer .= ' data-bx-externalId="' . htmlspecialcharsbx($additionalParams['externalId']) . '" '; } if (!empty($additionalParams['canUpdate'])) { $dataAttributesForViewer .= ' data-bx-edit="' . $urlManager->getUrlToStartEditUfFileByService($attachedObject->getId(), 'gdrive') . '" '; } if (!empty($additionalParams['canFakeUpdate'])) { $dataAttributesForViewer .= ' data-bx-fakeEdit="' . $urlManager->getUrlToStartEditUfFileByService($attachedObject->getId(), 'gdrive') . '" '; } if (!empty($additionalParams['showStorage']) && $object) { $dataAttributesForViewer .= ' data-bx-storage="' . htmlspecialcharsbx($object->getParent()->getName()) . '" '; } if (!empty($additionalParams['version'])) { $dataAttributesForViewer .= ' data-bx-version="' . htmlspecialcharsbx($additionalParams['version']) . '" '; } return $dataAttributesForViewer; }
/** * Gets a file's metadata by ID. * * @param FileData $fileData * @return array|null Describes file (id, title, size) */ public function getFileMetadata(FileData $fileData) { if (!$this->checkRequiredInputParams($fileData->toArray(), array('id'))) { return null; } $http = new HttpClient(array('socketTimeout' => 10, 'streamTimeout' => 30, 'version' => HttpClient::HTTP_1_1)); $http->setHeader('Content-Type', 'application/json; charset=UTF-8'); $http->setHeader('Authorization', "Bearer {$this->getAccessToken()}"); if ($http->get(self::API_URL_V2 . "/files/{$fileData->getId()}") === false) { $errorString = implode('; ', array_keys($http->getError())); $this->errorCollection->add(array(new Error($errorString, self::ERROR_HTTP_GET_METADATA))); return null; } if (!$this->checkHttpResponse($http)) { return null; } $metaData = Json::decode($http->getResult()); if ($metaData === null) { $this->errorCollection->add(array(new Error('Could not decode response as json', self::ERROR_BAD_JSON))); return null; } return array('id' => $metaData['id'], 'name' => $metaData['name'], 'size' => $metaData['size'], 'mimeType' => TypeFile::getMimeTypeByFilename($metaData['name']), 'etag' => $metaData['sha1']); }
protected function processActionDownloadFile() { $this->checkRequiredGetParams(array('attachedId')); if ($this->errorCollection->hasErrors()) { $this->sendJsonErrorResponse(); } $fileModel = null; list($type, $realValue) = FileUserType::detectType($this->request->getQuery('attachedId')); if ($type == FileUserType::TYPE_NEW_OBJECT) { /** @var File $fileModel */ $fileModel = File::loadById((int) $realValue, array('STORAGE')); if (!$fileModel) { $this->errorCollection->add(array(new Error("Could not find file"))); $this->sendJsonErrorResponse(); } if (!$fileModel->canRead($fileModel->getStorage()->getCurrentUserSecurityContext())) { $this->errorCollection->add(array(new Error("Bad permission. Could not read this file"))); $this->sendJsonErrorResponse(); } $fileName = $fileModel->getName(); $fileData = $fileModel->getFile(); if (!$fileData) { $this->end(); } $cacheTime = 0; $width = $this->request->getQuery('width'); $height = $this->request->getQuery('height'); if (TypeFile::isImage($fileData["ORIGINAL_NAME"]) && ($width > 0 || $height > 0)) { $signature = $this->request->getQuery('signature'); if (!$signature) { $this->sendJsonInvalidSignResponse('Empty signature'); } if (!ParameterSigner::validateImageSignature($signature, $fileModel->getId(), $width, $height)) { $this->sendJsonInvalidSignResponse('Invalid signature'); } /** @noinspection PhpDynamicAsStaticMethodCallInspection */ $tmpFile = \CFile::resizeImageGet($fileData, array("width" => $width, "height" => $height), $this->request->getQuery('exact') == "Y" ? BX_RESIZE_IMAGE_EXACT : BX_RESIZE_IMAGE_PROPORTIONAL, true, false, true); $fileData["FILE_SIZE"] = $tmpFile["size"]; $fileData["SRC"] = $tmpFile["src"]; $cacheTime = 86400; } \CFile::viewByUser($fileData, array("force_download" => false, "cache_time" => $cacheTime, 'attachment_name' => $fileName)); } else { $this->errorCollection->add(array(new Error('Could not find attached object'))); $this->sendJsonErrorResponse(); } }
private function loadFilesData() { if (empty($this->arParams['PARAMS']['arUserField'])) { return array(); } $userId = $this->getUser()->getId(); $values = $this->arParams['PARAMS']['arUserField']['VALUE']; if (!is_array($this->arParams['PARAMS']['arUserField']['VALUE'])) { $values = array($values); } $files = array(); $driver = \Bitrix\Disk\Driver::getInstance(); $urlManager = $driver->getUrlManager(); $userFieldManager = $driver->getUserFieldManager(); $userFieldManager->loadBatchAttachedObject($values); foreach ($values as $id) { $attachedModel = null; list($type, $realValue) = FileUserType::detectType($id); if ($realValue <= 0) { continue; } elseif ($type == FileUserType::TYPE_NEW_OBJECT) { /** @var File $fileModel */ $fileModel = File::loadById($realValue); if (!$fileModel || !$fileModel->canRead($fileModel->getStorage()->getCurrentUserSecurityContext())) { continue; } } else { /** @var \Bitrix\Disk\AttachedObject $attachedModel */ $attachedModel = $userFieldManager->getAttachedObjectById($realValue); if (!$attachedModel) { continue; } if (!$this->editMode) { $attachedModel->setOperableEntity(array('ENTITY_ID' => $this->arParams['PARAMS']['arUserField']['ENTITY_ID'], 'ENTITY_VALUE_ID' => $this->arParams['PARAMS']['arUserField']['ENTITY_VALUE_ID'])); } /** @var File $fileModel */ $fileModel = $attachedModel->getFile(); } $name = $fileModel->getName(); $data = array('ID' => $id, 'NAME' => $name, 'CONVERT_EXTENSION' => DocumentHandler::isNeedConvertExtension($fileModel->getExtension()), 'EDITABLE' => DocumentHandler::isEditable($fileModel->getExtension()), 'CAN_UPDATE' => $attachedModel ? $attachedModel->canUpdate($userId) : $fileModel->canUpdate($fileModel->getStorage()->getCurrentUserSecurityContext()), 'FROM_EXTERNAL_SYSTEM' => $fileModel->getContentProvider() && $fileModel->getCreatedBy() == $userId, 'EXTENSION' => $fileModel->getExtension(), 'SIZE' => \CFile::formatSize($fileModel->getSize()), 'XML_ID' => $fileModel->getXmlId(), 'FILE_ID' => $fileModel->getId(), 'VIEW_URL' => $urlManager->getUrlToShowAttachedFileByService($id, 'gvdrive'), 'EDIT_URL' => $urlManager->getUrlToStartEditUfFileByService($id, 'gdrive'), 'DOWNLOAD_URL' => $urlManager->getUrlUfController('download', array('attachedId' => $id)), 'COPY_TO_ME_URL' => $urlManager->getUrlUfController('copyToMe', array('attachedId' => $id)), 'DELETE_URL' => ""); if (\Bitrix\Disk\TypeFile::isImage($fileModel)) { $this->arParams['PARAMS']['THUMB_SIZE'] = $this->arParams['PARAMS']['THUMB_SIZE'] > 0 ? $this->arParams['PARAMS']['THUMB_SIZE'] : 100; $data["PREVIEW_URL"] = $attachedModel === null ? $urlManager->getUrlForShowFile($fileModel) : $urlManager->getUrlUfController('show', array('attachedId' => $id)); $data["IMAGE"] = $fileModel->getFile(); } if ($this->editMode) { $data['STORAGE'] = $fileModel->getStorage()->getProxyType()->getTitleForCurrentUser() . ' / ' . $fileModel->getParent()->getName(); } else { $data['ATTRIBUTES_FOR_VIEWER'] = Ui\Viewer::getAttributesByAttachedObject($attachedModel, array('canUpdate' => $data['CAN_UPDATE'], 'canFakeUpdate' => true, 'showStorage' => false, 'externalId' => false, 'relativePath' => false)); } $files[] = $data; } unset($id); return $files; }
public function getFileListByUser($user, array $filter = array()) { $items = array(); $urlManager = Driver::getInstance()->getUrlManager(); foreach ($this->getFileModelListByUser($user, $filter) as $file) { $id = FileUserType::NEW_FILE_PREFIX . $file->getId(); $items[$id] = array('id' => $id, 'name' => $file->getName(), 'type' => 'file', 'size' => \CFile::formatSize($file->getSize()), 'sizeInt' => $file->getSize(), 'modifyBy' => $file->getUpdateUser()->getFormattedName(), 'modifyDate' => $file->getUpdateTime()->format('d.m.Y'), 'modifyDateInt' => $file->getUpdateTime()->getTimestamp(), 'ext' => $file->getExtension()); if (TypeFile::isImage($file)) { $items[$id]['previewUrl'] = $urlManager->getUrlForShowFile($file); } } unset($file); return $items; }
protected function getDownloadUrl(FileData $fileData, $fileMetaData = array()) { if (!$this->checkRequiredInputParams($fileData->toArray(), array('id'))) { return null; } if (!$fileMetaData) { $fileMetaData = $this->getFileMetadataInternal($fileData); } if (!$fileMetaData) { return null; } if (!empty($fileMetaData['downloadUrl'])) { return self::API_URL_V2 . "/files/{$fileData->getId()}?alt=media"; } if (empty($fileMetaData['exportLinks'])) { return null; } $links = $fileMetaData['exportLinks']; $mimeType = TypeFile::getMimeTypeByFilename($fileMetaData['title']); if ($mimeType && isset($links[$mimeType])) { return $links[$mimeType]; } if (isset($links['application/vnd.openxmlformats-officedocument.wordprocessingml.document'])) { return $links['application/vnd.openxmlformats-officedocument.wordprocessingml.document']; } if (isset($links['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])) { return $links['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']; } if (isset($links['image/png'])) { return $links['image/png']; } if (isset($links['application/vnd.openxmlformats-officedocument.presentationml.presentation'])) { return $links['application/vnd.openxmlformats-officedocument.presentationml.presentation']; } return null; }
protected function processActionDownload($showFile = false, $runResize = false) { if ($this->externalLink->hasPassword() && !$this->checkPassword()) { $this->showAccessDenied(); return false; } $file = $this->externalLink->getFile(); if (!$file) { $this->includeComponentTemplate('error'); return false; } if (!$this->externalLink->isAutomatic() && !$this->checkDownloadToken($file, $this->request->getQuery('token'))) { $this->includeComponentTemplate('error'); return false; } $this->externalLink->incrementDownloadCount(); if ($this->externalLink->isSpecificVersion()) { $version = $file->getVersion($this->externalLink->getVersionId()); if (!$version) { $this->includeComponentTemplate('error'); return false; } $fileData = $version->getFile(); } else { $fileData = $file->getFile(); } if (!$fileData) { $this->includeComponentTemplate('error'); return false; } if ($runResize && TypeFile::isImage($fileData['ORIGINAL_NAME'])) { /** @noinspection PhpDynamicAsStaticMethodCallInspection */ $tmpFile = \CFile::resizeImageGet($fileData, array("width" => 255, "height" => 255), BX_RESIZE_IMAGE_EXACT, true, false, true); $fileData["FILE_SIZE"] = $tmpFile["size"]; $fileData["SRC"] = $tmpFile["src"]; } CFile::viewByUser($fileData, array('force_download' => !$showFile, 'attachment_name' => $file->getName())); }
protected function processActionCommit() { $this->checkRequiredPostParams(array('editSessionId')); if ($this->errorCollection->hasErrors()) { $this->sendJsonErrorResponse(); } $this->checkUpdatePermissions(); $currentSession = $this->getEditSessionByCurrentUser((int) $this->request->getPost('editSessionId')); if (!$currentSession) { $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_DOC_CONTROLLER_ERROR_COULD_NOT_FIND_EDIT_SESSION'), self::ERROR_COULD_NOT_FIND_EDIT_SESSION))); $this->sendJsonErrorResponse(); } $tmpFile = \CTempFile::getFileName(uniqid('_wd')); checkDirPath($tmpFile); $fileData = new FileData(); $fileData->setId($currentSession->getServiceFileId()); $fileData->setSrc($tmpFile); $newNameFileAfterConvert = null; if ($this->documentHandler->isNeedConvertExtension($this->file->getExtension())) { $newNameFileAfterConvert = getFileNameWithoutExtension($this->file->getName()) . '.' . $this->documentHandler->getConvertExtension($this->file->getExtension()); $fileData->setMimeType(TypeFile::getMimeTypeByFilename($newNameFileAfterConvert)); } else { $fileData->setMimeType(TypeFile::getMimeTypeByFilename($this->file->getName())); } $fileData = $this->documentHandler->downloadFile($fileData); if (!$fileData) { if ($this->documentHandler->isRequiredAuthorization()) { $this->sendNeedAuth(); } $this->errorCollection->add($this->documentHandler->getErrors()); $this->sendJsonErrorResponse(); } $this->deleteEditSession($currentSession); $oldName = $this->file->getName(); //rename in cloud service $renameInCloud = $fileData->getName() && $fileData->getName() != $this->file->getName(); if ($newNameFileAfterConvert || $renameInCloud) { if ($newNameFileAfterConvert && $renameInCloud) { $newNameFileAfterConvert = getFileNameWithoutExtension($fileData->getName()) . '.' . getFileExtension($newNameFileAfterConvert); } $this->file->rename($newNameFileAfterConvert); } $fileArray = \CFile::makeFileArray($tmpFile); $fileArray['name'] = $this->file->getName(); $fileArray['type'] = $fileData->getMimeType(); $fileArray['MODULE_ID'] = Driver::INTERNAL_MODULE_ID; /** @noinspection PhpDynamicAsStaticMethodCallInspection */ $fileId = \CFile::saveFile($fileArray, Driver::INTERNAL_MODULE_ID); if (!$fileId) { \CFile::delete($fileId); $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_DOC_CONTROLLER_ERROR_COULD_NOT_SAVE_FILE'), self::ERROR_COULD_NOT_SAVE_FILE))); $this->sendJsonErrorResponse(); } $versionModel = $this->file->addVersion(array('ID' => $fileId, 'FILE_SIZE' => $fileArray['size']), $this->getUser()->getId(), true); if (!$versionModel) { \CFile::delete($fileId); $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_DOC_CONTROLLER_ERROR_COULD_NOT_ADD_VERSION'), self::ERROR_COULD_NOT_ADD_VERSION))); $this->errorCollection->add($this->file->getErrors()); $this->sendJsonErrorResponse(); } if ($this->isLastEditSessionForFile()) { $this->deleteFile($currentSession, $fileData); } $this->sendJsonSuccessResponse(array('objectId' => $this->file->getId(), 'newName' => $this->file->getName(), 'oldName' => $oldName)); }
public static function createDocument($parentDocumentId, $fields) { /** @var File $file */ $file = File::loadById($parentDocumentId, array('STORAGE')); if (!$file) { return false; } $targetObject = $file->getParent(); if (!$targetObject) { return false; } $uploadFile = $targetObject->addBlankFile(array('NAME' => $fields['NAME'], 'CREATED_BY' => SystemUser::SYSTEM_USER_ID, 'MIME_TYPE' => TypeFile::getMimeTypeByFilename($fields['NAME'])), array(), true); if ($uploadFile) { $ufFields = array(); foreach ($fields as $codeField => $valueField) { $search = 'UF_'; $res = strpos($codeField, $search); if ($res === 0) { $ufFields[$codeField] = $valueField; } } if (!empty($ufFields)) { global $USER_FIELD_MANAGER; $storageId = $uploadFile->getStorageId(); $USER_FIELD_MANAGER->update('DISK_FILE_' . $storageId, $uploadFile->getId(), $ufFields); } return $uploadFile->getId(); } else { return false; } }
public static function getUFForPostForm($arParams) { $arFileData = array(); $arUF = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields($arParams["ENTITY_TYPE"], $arParams["ENTITY_ID"], LANGUAGE_ID); $ufCode = $arParams["UF_CODE"]; if (!empty($arUF[$ufCode]) && !empty($arUF[$ufCode]["VALUE"])) { if ($arParams["IS_DISK_OR_WEBDAV_INSTALLED"]) { if (\Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false) && CModule::IncludeModule('disk')) { $userFieldManager = \Bitrix\Disk\Driver::getInstance()->getUserFieldManager(); $urlManager = \Bitrix\Disk\Driver::getInstance()->getUrlManager(); $userFieldManager->loadBatchAttachedObject($arUF[$ufCode]["VALUE"]); foreach ($arUF[$ufCode]["VALUE"] as $attachedId) { $attachedObject = $userFieldManager->getAttachedObjectById($attachedId); if ($attachedObject) { $file = $attachedObject->getObject(); $fileName = $file->getName(); $fileUrl = $urlManager->getUrlUfController('download', array('attachedId' => $attachedId)); $fileUrl = str_replace("/bitrix/tools/disk/uf.php", SITE_DIR . "mobile/ajax.php", $fileUrl); $fileUrl = $fileUrl . (strpos($fileUrl, "?") === false ? "?" : "&") . "mobile_action=disk_uf_view&filename=" . $fileName; if (\Bitrix\Disk\TypeFile::isImage($file) && ($realFile = $file->getFile())) { $previewImageUrl = $urlManager->getUrlUfController('show', array('attachedId' => $attachedId, 'width' => 144, 'height' => 144, 'exact' => 'Y', 'signature' => \Bitrix\Disk\Security\ParameterSigner::getImageSignature($attachedId, 144, 144))); } else { $previewImageUrl = false; } $icon = CMobileHelper::mobileDiskGetIconByFilename($fileName); $iconUrl = CComponentEngine::makePathFromTemplate('/bitrix/components/bitrix/mobile.disk.file.detail/images/' . $icon); $fileFata = array('type' => $file->getExtension(), 'ufCode' => $ufCode, 'id' => $attachedId, 'extension' => $file->getExtension(), 'name' => $fileName, 'url' => $fileUrl, 'iconUrl' => $iconUrl); if ($previewImageUrl) { $fileFata['previewImageUrl'] = CHTTP::URN2URI($previewImageUrl); } $arFileData[] = $fileFata; } } } else { $data = CWebDavIblock::getRootSectionDataForUser($GLOBALS["USER"]->GetID()); if (is_array($data)) { $ibe = new CIBlockElement(); $dbWDFile = $ibe->GetList(array(), array('ID' => $arUF[$ufCode]["VALUE"], 'IBLOCK_ID' => $data["IBLOCK_ID"]), false, false, array('ID', 'IBLOCK_ID', 'PROPERTY_FILE')); while ($arWDFile = $dbWDFile->Fetch()) { if ($arFile = CFile::GetFileArray($arWDFile["PROPERTY_FILE_VALUE"])) { if (CFile::IsImage($arFile["FILE_NAME"], $arFile["CONTENT_TYPE"])) { $imageResized = CFile::ResizeImageGet($arFile["ID"], array("width" => 144, "height" => 144), BX_RESIZE_IMAGE_EXACT, false, true); $previewImageUrl = $imageResized["src"]; } else { $previewImageUrl = false; } $fileExtension = GetFileExtension($arFile["FILE_NAME"]); $fileData = array('type' => $fileExtension, 'ufCode' => $ufCode, 'id' => $arWDFile["ID"], 'extension' => $fileExtension, 'name' => $arFile["FILE_NAME"], 'url' => $arFile["SRC"]); if ($previewImageUrl) { $fileData['previewImageUrl'] = CHTTP::URN2URI($previewImageUrl); } $arFileData[] = $fileData; } } } } } else { $dbRes = CFile::GetList(array(), array("@ID" => implode(",", $arUF[$ufCode]["VALUE"]))); while ($arFile = $dbRes->GetNext()) { if (CFile::IsImage($arFile["FILE_NAME"], $arFile["CONTENT_TYPE"])) { $imageResized = CFile::ResizeImageGet($arFile["ID"], array("width" => 144, "height" => 144), BX_RESIZE_IMAGE_EXACT, false, true); $previewImageUrl = $imageResized["src"]; } else { $previewImageUrl = false; } $fileExtension = GetFileExtension($arFile["FILE_NAME"]); $fileData = array('type' => $fileExtension, 'ufCode' => $ufCode, 'id' => $arFile["ID"], 'extension' => $fileExtension, 'name' => $arFile["FILE_NAME"], 'downloadUrl' => $arFile["SRC"]); if ($previewImageUrl) { $fileData['previewImageUrl'] = CHTTP::URN2URI($previewImageUrl); } $arFileData[] = $fileData; } } } return $arFileData; }
protected function processActionDefault() { $gridId = 'file_version_list'; $securityContext = $this->storage->getCurrentUserSecurityContext(); $urlManager = Driver::getInstance()->getUrlManager(); $this->getApplication()->setTitle($this->storage->getProxyType()->getTitleForCurrentUser()); $breadcrumbs = $this->getBreadcrumbs(); $externalLinkData = array(); $externalLink = $this->getExternalLink(); if ($externalLink) { $externalLinkData = array('LINK' => Driver::getInstance()->getUrlManager()->getShortUrlExternalLink(array('hash' => $externalLink->getHash(), 'action' => 'default'), true)); } $createdByLink = \CComponentEngine::makePathFromTemplate($this->arParams['PATH_TO_USER'], array("user_id" => $this->file->getCreatedBy())); $canUpdate = $this->file->canUpdate($securityContext); $viewFile = CComponentEngine::makePathFromTemplate($this->arParams['PATH_TO_FILE_VIEW'], array('FILE_ID' => $this->file->getId(), 'FILE_PATH' => $this->arParams['RELATIVE_PATH'])); $this->arResult = array('VERSION_GRID' => array(), 'STORAGE' => $this->storage, 'USE_IN_ENTITIES' => false, 'ENTITIES' => array(), 'SHOW_USER_FIELDS' => false, 'USER_FIELDS' => array(), 'TOOLBAR' => array('BUTTONS' => array(array('TEXT' => Loc::getMessage('DISK_FILE_VIEW_GO_BACK_TEXT'), 'TITLE' => Loc::getMessage('DISK_FILE_VIEW_GO_BACK_TITLE'), 'LINK' => end($breadcrumbs), 'ICON' => 'back'), array('TEXT' => Loc::getMessage('DISK_FILE_VIEW_COPY_LINK_TEXT'), 'TITLE' => Loc::getMessage('DISK_FILE_VIEW_COPY_LINK_TITLE'), 'LINK' => "javascript:BX.Disk['FileViewClass_{$this->getComponentId()}'].getInternalLink();", 'ICON' => 'copy-link'))), 'EXTERNAL_LINK' => $externalLinkData, 'FILE' => array('ID' => $this->file->getId(), 'IS_IMAGE' => TypeFile::isImage($this->file->getName()), 'CREATE_USER' => array('LINK' => $createdByLink, 'NAME' => $this->file->getCreateUser()->getFormattedName(), 'AVA' => $this->file->getCreateUser()->getAvatarSrc(21, 21)), 'VIEWER_ATTRIBUTES' => Ui\Viewer::getAttributesByObject($this->file, array('canUpdate' => $canUpdate)), 'UPDATE_TIME' => $this->file->getUpdateTime(), 'ICON_CLASS' => Icon::getIconClassByObject($this->file), 'NAME' => $this->file->getName(), 'SIZE' => $this->file->getSize(), 'IS_LINK' => $this->file->isLink(), 'FOLDER_LIST_WEBDAV' => rtrim(end($breadcrumbs), '/') . '/' . $this->file->getName(), 'DOWNLOAD_URL' => $urlManager->getUrlForDownloadFile($this->file), 'SHOW_PREVIEW_URL' => \Bitrix\Disk\Driver::getInstance()->getUrlManager()->getUrlForShowFile($this->file, array('exact' => 'Y', 'width' => 255, 'height' => 255)), 'SHOW_FILE_URL' => \Bitrix\Disk\Driver::getInstance()->getUrlManager()->getUrlForShowFile($this->file)), 'CAN_UPDATE' => $canUpdate, 'CAN_DELETE' => $this->file->canDelete($securityContext), 'PATH_TO_FILE_VIEW' => $viewFile); $attachedObjects = $this->file->getAttachedObjects(); if ($attachedObjects) { $userId = $this->getUser()->getId(); $this->arResult['USE_IN_ENTITIES'] = true; Uf\Connector::setPathToUser($this->arParams['PATH_TO_USER']); Uf\Connector::setPathToGroup($this->arParams['PATH_TO_GROUP']); foreach ($attachedObjects as $attachedObject) { $connector = $attachedObject->getConnector(); if (!$connector->canRead($userId)) { continue; } $dataToShow = $connector->getDataToShow(); if ($dataToShow) { $this->arResult['ENTITIES'][] = $dataToShow; } } unset($attachedObject); } $userFieldsObject = \Bitrix\Disk\Driver::getInstance()->getUserFieldManager()->getFieldsForObject($this->file); foreach ($userFieldsObject as $field) { if ($field['VALUE'] !== false) { $this->arResult['SHOW_USER_FIELDS'] = true; $this->arResult['USER_FIELDS'] = $userFieldsObject; break; } } unset($field); $this->arParams['STATUS_BIZPROC'] = $this->storage->isEnabledBizProc() && Loader::includeModule("bizproc"); if ($this->arParams['STATUS_BIZPROC']) { $documentData = array('DISK' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($this->storage->getId()), 'DOCUMENT_ID' => \Bitrix\Disk\BizProcDocument::getDocumentComplexId($this->file->getId())), 'WEBDAV' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocumentCompatible::generateDocumentComplexType($this->storage->getId()), 'DOCUMENT_ID' => \Bitrix\Disk\BizProcDocumentCompatible::getDocumentComplexId($this->file->getId()))); $webdavFileId = $this->file->getXmlId(); if (!empty($webdavFileId)) { if (Loader::includeModule("iblock")) { if ($this->storage->getProxyType() instanceof ProxyType\Group) { $iblock = CIBlockElement::getList(array(), array("ID" => $webdavFileId, 'SHOW_NEW' => 'Y'), false, false, array('ID', 'IBLOCK_ID'))->fetch(); $entity = 'CIBlockDocumentWebdavSocnet'; } else { $iblock = CIBlockElement::getList(array(), array("ID" => $webdavFileId, 'SHOW_NEW' => 'Y'), false, false, array('ID', 'IBLOCK_ID'))->fetch(); $entity = 'CIBlockDocumentWebdav'; } if (!empty($iblock)) { $documentData['OLD_FILE'] = array('DOCUMENT_TYPE' => array('webdav', $entity, "iblock_" . $iblock['IBLOCK_ID']), 'DOCUMENT_ID' => array('webdav', $entity, $iblock['ID'])); } } } $this->getAutoloadTemplateBizProc($documentData); if ($this->request->isPost() && intval($this->request->getPost('bizproc_index')) > 0) { $this->showBizProc($documentData); } } $this->includeComponentTemplate(); }