- Модуль: webdav
- Путь к файлу: ~/bitrix/modules/webdav/classes/webdavstorage.php
- Класс: CWebDavStorageCore
- Вызов: CWebDavStorageCore::moveFile
public function moveFile($name, $targetElementId, $newParentDirectoryId)
{
$this->init();
$key = $this->getStorageId();
if(!$newParentDirectoryId)
{
//in root
$newParentDirectoryId = $key['IBLOCK_SECTION_ID'];
}
$name = $this->getWebDav()->correctName($name);
$pathArray = $this->getPathArrayForSection($newParentDirectoryId);
$pathArray[] = $name;
$newPath = '/' . implode('/', $pathArray);
$options = array(
'element_id' => $targetElementId,
'dest_url' => $newPath,
'overwrite' => false,
);
$response = $this->getWebDav()->move($options);
$oError = $this->getLastException();
if(intval($response) == 412) //FILE_OR_FOLDER_ALREADY_EXISTS
{
return false;
}
elseif(intval($response) == 400) //FOLDER_IS_EXISTS (destination equals source)
{
return $this->getFile(null, array('id' => $targetElementId), true);
}
elseif(intval($response) == 403)
{
throw new CWebDavAccessDeniedException;
}
elseif(!$oError && intval($response) >= 300)
{
return false;
}
elseif($oError)
{
return false;
}
$file = $this->getFile(null, array('id' => $targetElementId), true);
if($file)
{
return $file;
}
throw new WebDavStorageBreakDownException('bd moveFile');
}