- Модуль: webdav
- Путь к файлу: ~/bitrix/modules/webdav/classes/webdavstorage.php
- Класс: CWebDavStorageCore
- Вызов: CWebDavStorageCore::addFile
public function addFile($name, $targetDirectoryId, CWebDavTmpFile $tmpFile)
{
$key = $this->getStorageId();
if(!$targetDirectoryId)
{
//in root
$targetDirectoryId = $key['IBLOCK_SECTION_ID'];
}
$name = $this->init()->getWebDav()->correctName($name);
if(!$this->checkRights('create', array('targetDirectoryId' => $targetDirectoryId)))
{
throw new CWebDavAccessDeniedException;
}
$options = array(
'new' => true,
'dropped' => true,
'arDocumentStates' => array(),
'arUserGroups' => $this->getWebDav()->USER['GROUPS'],
'TMP_FILE' => $tmpFile->getAbsolutePath(),
'WIDTH' => $tmpFile->width,
'HEIGHT' => $tmpFile->height,
'FILE_NAME' => $name,
'IBLOCK_ID' => $key['IBLOCK_ID'],
'IBLOCK_SECTION_ID' => $targetDirectoryId,
'WF_STATUS_ID' => 1,
);
$options['arUserGroups'][] = 'Author';
$this->getDb()->startTransaction();
if (!$this->getWebDav()->put_commit($options))
{
$this->getDb()->rollback();
$tmpFile->delete();
return false;
}
$this->getDb()->commit();
$tmpFile->delete();
if(!empty($options['ELEMENT_ID']))
{
$this->clearCache();
$file = $this->getFile(null, array('id' => $options['ELEMENT_ID']), true);
if($file)
{
return $file;
}
}
throw new WebDavStorageBreakDownException('bd addFile');
}