public function processActionShare(array $params) { $this->params = $params; $attachSectionData = $this->getSectionDataByAttachObject($params['attachObject']); \CWebDavSymlinkHelper::setPathPattern('user', $params['pathToUser']); \CWebDavSymlinkHelper::setPathPattern('group', $params['pathToGroup']); $result = array(); foreach ($params['attachToUserIds'] as $userIdToShare) { if ($userIdToShare == $params['inviteFromUserId']) { //to owner we don't create really symlink. Already there section. $result[] = array('userId' => $attachSectionData['SECTION_ID']); continue; } $targetSectionData = $this->getSectionDataByUserId($userIdToShare); $targetSectionData['IBLOCK_SECTION_ID'] = $targetSectionData['SECTION_ID']; $linkData = array('ID' => $attachSectionData['SECTION_ID'], 'IBLOCK_ID' => $attachSectionData['IBLOCK_ID'], 'NAME' => $this->generateNameForSymLinkSection($targetSectionData, $params['attachObject']), 'CREATED_BY' => $params['inviteFromUserId'], 'INVITE_USER_ID' => $userIdToShare, 'CAN_EDIT' => $params['canEdit'], 'CAN_FORWARD' => 0); $symlinkSectionId = \CWebDavSymlinkHelper::createSymLinkSection($targetSectionData, $linkData, $params['attachObject']['type']); if ($symlinkSectionId) { $result[] = array('userId' => $symlinkSectionId); } } if ($result) { \CWebDavDiskDispatcher::sendChangeStatus($params['inviteFromUserId'], 'share_section'); global $DB; //update timestamp_x for incremental snapshot from disk. $section = new \CIBlockSection(); $section->update($attachSectionData['SECTION_ID'], array('~TIMESTAMP_X' => $DB->getNowFunction()), false, false); return $this->sendJsonResponse(array('status' => self::STATUS_SUCCESS, 'sections' => $result)); } return $this->sendJsonResponse(array('status' => self::STATUS_ERROR)); }
/** * User by user * array( * 'IBLOCK_ID' => 16, * 'IBLOCK_SECTION_ID' => 162, * ); * array( * 'NAME' => 'link on folder', * 'IBLOCK_ID' => 15, * 'ID' => 3574, * 'CREATED_BY' => 1, * 'CAN_FORWARD' => 1, * 'INVITE_USER_ID' => 480, * ); * * @param array $sectionTargetData * @param array $sectionLinkData * @param string $typeLibrary - user, group, shared * @return bool|int */ public static function createSymLinkSection(array $sectionTargetData, array $sectionLinkData, $typeLibrary = self::ENTITY_TYPE_USER) { if (empty($sectionLinkData['IBLOCK_ID']) || empty($sectionLinkData['ID']) || empty($sectionLinkData['NAME']) || empty($sectionLinkData['CREATED_BY'])) { return false; } if (empty($sectionTargetData['IBLOCK_ID']) || empty($sectionTargetData['IBLOCK_SECTION_ID'])) { return false; } $typeLibrary = strtolower($typeLibrary); if ($typeLibrary != self::ENTITY_TYPE_USER && $typeLibrary != self::ENTITY_TYPE_GROUP && $typeLibrary != self::ENTITY_TYPE_SHARED) { return false; } if (!CWebDavTools::isIntranetUser($sectionLinkData['INVITE_USER_ID'])) { return false; } $sectionTargetData = array_intersect_key($sectionTargetData, array('IBLOCK_ID' => true, 'IBLOCK_SECTION_ID' => true)); $additionalData = array(CWebDavIblock::UF_LINK_IBLOCK_ID => $sectionLinkData['IBLOCK_ID'], CWebDavIblock::UF_LINK_SECTION_ID => $sectionLinkData['ID'], CWebDavIblock::UF_LINK_ROOT_SECTION_ID => self::getRootSectionId($sectionLinkData['IBLOCK_ID'], $sectionLinkData['ID'], $typeLibrary), CWebDavIblock::UF_LINK_CAN_FORWARD => $sectionLinkData['CAN_FORWARD'], 'CREATED_BY' => $sectionLinkData['CREATED_BY'], 'MODIFIED_BY' => $sectionLinkData['CREATED_BY'], 'NAME' => $sectionLinkData['NAME']); $exists = \Bitrix\Webdav\FolderInviteTable::getRow(array('filter' => array('INVITE_USER_ID' => $sectionLinkData['INVITE_USER_ID'], 'IBLOCK_ID' => $sectionLinkData['IBLOCK_ID'], 'SECTION_ID' => $sectionLinkData['ID']), 'select' => array('ID', 'LINK_SECTION_ID', 'IS_DELETED', 'IS_APPROVED'))); //rewrite old self-deleted by user invite if ($exists && !$exists['IS_DELETED'] && $exists['IS_APPROVED']) { return $exists['LINK_SECTION_ID']; } $section = new CIBlockSection(); $sectionId = $section->add(array_merge($sectionTargetData, $additionalData)); if ($typeLibrary == self::ENTITY_TYPE_GROUP) { $inviteUserId = $sectionLinkData['CREATED_BY']; \Bitrix\Webdav\FolderInviteTable::addIfNonExists(array('INVITE_USER_ID' => $sectionLinkData['CREATED_BY'], 'USER_ID' => $sectionLinkData['CREATED_BY'], 'IBLOCK_ID' => $sectionLinkData['IBLOCK_ID'], 'SECTION_ID' => $sectionLinkData['ID'], 'LINK_SECTION_ID' => $sectionId, 'IS_APPROVED' => true, 'IS_DELETED' => false, 'CAN_FORWARD' => false)); } elseif ($typeLibrary == self::ENTITY_TYPE_USER) { if ($sectionId) { $inviteUserId = $sectionLinkData['INVITE_USER_ID']; \Bitrix\Webdav\FolderInviteTable::addIfNonExists(array('INVITE_USER_ID' => $sectionLinkData['INVITE_USER_ID'], 'USER_ID' => $sectionLinkData['CREATED_BY'], 'IBLOCK_ID' => $sectionLinkData['IBLOCK_ID'], 'SECTION_ID' => $sectionLinkData['ID'], 'LINK_SECTION_ID' => $sectionId, 'IS_APPROVED' => true, 'IS_DELETED' => false, 'CAN_FORWARD' => false, 'CAN_EDIT' => $sectionLinkData['CAN_EDIT'])); $rightsLetter = $sectionLinkData['CAN_EDIT'] ? 'W' : 'R'; CWebDavIblock::appendRightsOnSections(array($sectionLinkData), array($rightsLetter => 'U' . $sectionLinkData['INVITE_USER_ID'])); } } if ($sectionId && $inviteUserId) { CWebDavDiskDispatcher::sendChangeStatus($inviteUserId, 'symlink'); } return $sectionId; }
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"]) { 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) && strpos($this->arParams['file_name'], "_\$") !== 0) { 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'); } \Bitrix\Webdav\FolderInviteTable::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"; }
private static function removeNotifyToUser(array $folderInvite) { if (\Bitrix\Main\Loader::includeModule('im')) { \CIMNotify::deleteByTag(self::getNotifyTag($folderInvite)); } \CWebDavDiskDispatcher::sendChangeStatus($folderInvite['INVITE_USER_ID'], 'delete_symlink'); }