- Модуль: webdav
- Путь к файлу: ~/bitrix/modules/webdav/classes/file.php
- Класс: CWebDavFile
- Вызов: CWebDavFile::MKCOL
function MKCOL($options)
{
$io = self::GetIo();
$this->IsDir($options);
$result = '201 Created';
if ($this->arParams["is_file"])
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("WD_FILE_ERROR11"), "FOLDER_CAN_NOT_REPLACE_FILE");
$result = '405 Method not allowed';
}
elseif ($_SERVER['REQUEST_METHOD'] == "MKCOL" && !empty($_SERVER['CONTENT_LENGTH']))
{
$result = '415 Unsupported media type';
}
else
{
if ($this->arParams["not_found"])
{
$path = $io->CombinePath($this->arParams["parent_id"], $this->arParams["base_name"]);
}
else
{
$path = $this->arParams['item_id'];
}
$res = explode("/", $path);
$res = array_filter(!empty($res) && is_array($res) ? $res : array($path));
$path = $io->CombinePath($this->real_path_full, $path);
$name = trim(array_pop($res));
$parent = $io->CombinePath($this->real_path_full, implode("/", $res));
if (! $io->DirectoryExists($parent))
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("WD_FILE_ERROR9"), "PARENT_FOLDER_IS_NOT_FOUNDED");
$result = '409 Conflict';
}
elseif ($io->FileExists($parent))
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("WD_FILE_ERROR10"), "FOLDER_CAN_NOT_BE_CREATED_IN_THE_FILE");
$result = '403 Forbidden';
}
else
{
$stat = $io->CreateDirectory($io->CombinePath($parent, $name));
if (!$stat)
{
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("WD_FILE_ERROR12"));
$result = '403 Forbidden';
}
}
}
return $result;
}