• Модуль: webdav
  • Путь к файлу: ~/bitrix/modules/webdav/classes/iblock.php
  • Класс: CWebDavIblock
  • Вызов: CWebDavIblock::MKCOL
function MKCOL($options)
{
	$this->IsDir($options, true);

	if ($this->check_creator || !$this->CheckWebRights("", array('action' => 'mkcol', 'arElement' => $this->arParams), false))
	{
		return $this->ThrowAccessDenied(__LINE__);
	}
	elseif ($_SERVER['REQUEST_METHOD'] == "MKCOL" && !empty($_SERVER["CONTENT_LENGTH"]))
	{
		return "415 Unsupported media type";
	}
	if ($this->arParams["is_dir"] == true)
	{
		return $this->ThrowError( "405 Method not allowed", "FOLDER_IS_EXISTS", str_replace("#FOLDER#", $this->arParams["basename"], GetMessage("WD_FILE_ERROR5")), __LINE__);
	}
	elseif ($this->arParams["is_file"] === true)
	{
		return $this->ThrowError( "405 Method not allowed", "FILE_ALREADY_EXISTS", str_replace("#FILE#", $this->arParams["basename"], GetMessage("WD_FILE_ERROR8")), __LINE__);
	}
	elseif ($this->arParams["parent_id"] === false)
		return $this->ThrowError("409 Conflict" , "NO_PARENT_FOLDER", __LINE__);

	$iblockId = $this->IBLOCK_ID;
	if($this->arParams["parent_id"])
	{
		list($contextType, $contextEntityId) = $this->getContextData();
		$sectionData = $this->getSectionDataForLinkAnalyze($this->arParams["parent_id"]);
		$iblockId = $sectionData['IBLOCK_ID'];
		if(CWebDavSymlinkHelper::isLink($contextType, $contextEntityId, $sectionData))
		{
			$parentSectionData = CWebDavSymlinkHelper::getLinkData($contextType, $contextEntityId, $sectionData);
			if($parentSectionData)
			{
				$iblockId = $parentSectionData[self::UF_LINK_IBLOCK_ID];
			}
		}
	}


	$se = new CIBlockSection();
	$b = $se->Add(array(
		"IBLOCK_SECTION_ID" => $this->arParams["parent_id"],
		"NAME" => $this->CorrectName($this->arParams["basename"]),
		"IBLOCK_ID" => $iblockId,
		"ACTIVE" => "Y"));
	if (!$b)
	{
		return "403 Forbidden";
	}
	else
	{
		$this->arParams["changed_element_id"] = $b;
		$this->_onEvent('Add', $b, 'FOLDER');

		CWebDavDiskDispatcher::sendEventToOwners(null, array(
			'IBLOCK_ID' => (int)$iblockId,
			'ID' => (int)$b,
		), 'mkcol');
	}
	$this->ClearCache("section");
	return "201 Created";
}