- Модуль: webdav
- Путь к файлу: ~/bitrix/modules/webdav/classes/webdavstorage.php
- Класс: CWebDavStorageCore
- Вызов: CWebDavStorageCore::moveDirectory
public function moveDirectory($name, $targetDirectoryId, $newParentDirectoryId)
{
$this->init();
$key = $this->getStorageId();
if(!$newParentDirectoryId)
{
//in root
$newParentDirectoryId = $key['IBLOCK_SECTION_ID'];
}
$pathArray = $this->getPathArrayForSection($newParentDirectoryId);
$pathArray[] = $name;
$newPath = '/' . implode('/', $pathArray);
$options = array(
'section_id' => $targetDirectoryId,
'dest_url' => $newPath,
'overwrite' => false,
);
$response = $this->getWebDav()->move($options);
//todo bad hack. Operation move with symlink folders equals drop and create. This is not atomic operation.
//and we send response error, but this is fake error. Really we added new folders and move to trash.
$webdav = $this->getWebDav();
if($webdav::$lastActionMoveWithSymlink)
{
throw new CWebDavSymlinkMoveFakeErrorException;
}
$oError = $this->getLastException();
if(!$oError && intval($response) == 403)
{
throw new CWebDavAccessDeniedException;
}
elseif(intval($response) == 400) //FOLDER_IS_EXISTS (destination equals source)
{
return $this->getDirectory(null, array('id' => $targetDirectoryId), true);
}
elseif(!$oError && intval($response) >= 300)
{
return false;
}
elseif($oError)
{
return false;
}
$this->clearCache();
$directory = $this->getDirectory(null, array('id' => $targetDirectoryId), true);
//todo getPathArrayForSection() static cached. And we set path manual.
$directory['path'] = $newPath;
return $directory;
}