- Модуль: webdav
- Путь к файлу: ~/bitrix/modules/webdav/classes/iblock.php
- Класс: CWebDavIblock
- Вызов: CWebDavIblock::DELETE
function DELETE($options)
{
$options["~path"] = $this->_udecode($options["path"]);
WDUnpackCookie();
if (isset($options['path']))
{
$arPath = explode('/', $options['path']); // ms excel tries to create and delete ~$FileName.xls
$basename = array_pop($arPath);
$basename = $this->CorrectName($this->_udecode($basename));
array_push($arPath, $basename);
$options['path'] = implode('/', $arPath);
}
if (!empty($options["~path"]) && $_SESSION["WEBDAV_DATA"]["PUT_MAC_OS"] == $options["~path"])
{
$this->IsDir($options);
$_SESSION["WEBDAV_DATA"]["PUT_MAC_OS"] = "";
WDPackCookie();
if (intval($this->arParams["element_id"]) > 0)
{
$this->_ib_elm_delete($this->arParams["element_id"]);
return "204 No Content";
}
return "404 Not Found";
}
else
{
$this->IsDir($options);
//symlink logic
list($contextType, $contextEntityId) = $this->getContextData();
//we can't forward delete symlink. Only delete symlink section.
$sectionData = $this->getSectionDataForLinkAnalyze($this->arParams['is_dir']? $this->arParams['dir_array']['ID'] : $this->arParams['element_array']['IBLOCK_SECTION_ID'], array(), false);
if(CWebDavSymlinkHelper::isLink($contextType, $contextEntityId, $sectionData))
{
//we don't enable symlink mode, because we move to real trash
$parentSectionData = CWebDavSymlinkHelper::getLinkData($contextType, $contextEntityId, $sectionData);
if($parentSectionData)
{
$linkWebdav = new self($parentSectionData[self::UF_LINK_IBLOCK_ID], $this->base_url . $this->_path, array(
'ROOT_SECTION_ID' => $parentSectionData[self::UF_LINK_ROOT_SECTION_ID],
));
return $linkWebdav->DELETE($options);
}
else
{
return "404 Not Found";
}
}
if(!$this->CheckWebRights("DELETE", array('action' => 'delete', 'arElement' => $this->arParams), false))
return $this->ThrowAccessDenied(__LINE__);
$resLock = array();
$lockedBy = $lockedDate = null;
$resLock["LOCK_STATUS"] = CIBlockElement::WF_GetLockStatus($this->arParams["item_id"], $lockedBy, $lockedDate);
if ($resLock['LOCK_STATUS'] == 'red' && !$GLOBALS['USER']->CanDoOperation('webdav_change_settings'))
return $this->ThrowAccessDenied(__LINE__);
//delete symlink. Not move to trash
if(!empty($this->arParams['dir_array'][self::UF_LINK_SECTION_ID]))
{
$options['force'] = true;
}
if (!isset($options['force']) && ($this->arParams["is_dir"] === true || intval($this->arParams["element_id"]) > 0))
{
if ($trashID = $this->GetMetaID("TRASH"))
{
$item_id = $this->arParams['item_id'];
$arSectionsChain = array();
$bRootFounded = (empty($this->arRootSection) ? true : false);
foreach (CWebDavSymlinkHelper::getNavChain($this->IBLOCK_ID, $this->arParams['parent_id']) as $res)
{
if (!$bRootFounded && $res["ID"] == $this->arRootSection["ID"])
{
$bRootFounded = true;
continue;
}
if (!$bRootFounded)
continue;
$arSectionsChain[] = $res["ID"];
}
if ($item_id == $trashID && $this->arParams["is_dir"]) // empty trash
{
if($this->CheckWebRights("DESTROY", array('action' => 'destroy', 'arElement' => $this->arParams), false))
{
if(isset($this->attributes['user_id']) && ($this->attributes['user_id'] == $GLOBALS['USER']->GetID()))
{
//now we clean own bin so simple, so fast
$this->runCleaningTrash($trashID);
}
else
{
//old cleaning. So-so
$this->_delete_section($options["section_id"]);
}
$this->GetMetaID('TRASH'); // create
return "204 No Content";
}
else
{
return $this->ThrowAccessDenied(__LINE__);
}
}
elseif ( (!in_array($trashID, $arSectionsChain)) &&
(mb_strpos($this->arParams['file_name'], "_$") !== 0) // ms office special files
) // move to trash
{
return $this->_move_to_trash($options);
}
}
else
{
return "404 Not Found";
}
}
$this->IsDir($options);
if(!$this->CheckWebRights("DESTROY", array('action' => 'destroy', 'arElement' => $this->arParams), false))
return $this->ThrowAccessDenied(__LINE__);
if ($this->arParams["is_dir"] === true)
{
if ($this->check_creator)
return $this->ThrowAccessDenied(__LINE__);
if($this->_delete_section($options["section_id"]) === true && !empty($this->arParams['dir_array'][self::UF_LINK_SECTION_ID]) && $this->attributes['user_id'])
{
if(!empty($this->attributes['user_id']))
{
CWebDavDiskDispatcher::sendChangeStatus($this->attributes['user_id'], 'delete_symlink');
}
BitrixWebdavFolderInviteTable::deleteByFilter(array(
'=INVITE_USER_ID' => $this->attributes['user_id'],
'=IS_APPROVED' => true,
'=IBLOCK_ID' => $this->arParams['dir_array'][self::UF_LINK_IBLOCK_ID],
'=SECTION_ID' => $this->arParams['dir_array'][self::UF_LINK_SECTION_ID],
));
}
}
elseif (intval($this->arParams["element_id"]) > 0)
{
CWebDavDiskDispatcher::addElementForDeletingMark($this->arParams['element_array'], null, false);
$el = new CIBlockElement();
$this->_onEvent('Delete', $this->arParams["element_id"]);
if($this->_ib_elm_delete($this->arParams["element_id"]))
{
CWebDavDiskDispatcher::markDeleteBatch();
CWebDavDiskDispatcher::sendEventToOwners($this->arParams['element_array'], null, 'force_delete_element');
}
else
{
CWebDavDiskDispatcher::clearDeleteBatch();
}
}
else
{
return "404 Not Found";
}
if ($_SESSION["WEBDAV_DATA"]["PUT_EMPTY"] == $options["~path"])
{
$_SESSION["WEBDAV_DATA"]["PUT_EMPTY"] = "";
}
}
return "204 No Content";
}