Exemplo n.º 1
0
 public static function createSavedFolder($iblockId, $sectionId, $userId)
 {
     $savedMetaData = CWebDavIblock::getSavedMetaData();
     return self::createFolder($savedMetaData['alias'], null, $iblockId, $sectionId, $userId);
 }
Exemplo n.º 2
0
                if ($ob->CheckWebRights('', array('action' => 'read', 'arElement' => $wdElement), false)) {
                    $storage = new CWebDavStorageCore();
                    $storage->setStorageId(array('IBLOCK_ID' => $data['IBLOCK_ID'], 'IBLOCK_SECTION_ID' => $data['SECTION_ID']));
                    $filename = $storage->regenerateNameIfNonUnique($wdElement['element_name'], $savedFolderId);
                    $tmpFile = new CWebDavStubTmpFile();
                    if ($_REQUEST['v']) {
                        list($arFileH, $optionsH, $fullpath, $filenameH) = $ob->getHistoryFileData($wdElement['element_array']['ID'], (int) $_REQUEST['v'], $p);
                        $tmpFile->path = $fullpath;
                    } else {
                        $copyTmpFile = CFile::MakeFileArray($wdElement['element_array']['PROPERTY_FILE_VALUE']);
                        $tmpFile->path = $copyTmpFile['tmp_name'];
                    }
                    $response = array();
                    try {
                        $fileData = $storage->addFile($filename, $savedFolderId, $tmpFile);
                        $savedName = CWebDavIblock::getSavedMetaData();
                        $pathToUserLib = str_replace(array('#USER_ID#', '#user_id#'), array($USER->GetID(), $USER->GetID()), CWebDavIblock::LibOptions('lib_paths', true, $data['IBLOCK_ID']));
                        $pathToUserLib = strstr($pathToUserLib, 'files/element', true) . 'files/lib';
                        $pathToUserLib = $pathToUserLib . '/' . $savedName['alias'] . '?result=doc' . $fileData['extra']['id'];
                        $response = array('status' => 'success', 'newId' => $fileData['extra']['id'], 'viewUrl' => $pathToUserLib);
                    } catch (Exception $e) {
                        $response['status'] = 'error';
                        $fileData = array();
                    }
                    CWebDavTools::sendJsonResponse($response);
                }
            }
        }
    }
} elseif (!empty($_REQUEST['downloadHistory']) && !empty($_REQUEST['id'])) {
    $APPLICATION->RestartBuffer();