public function processActionLoadUsersForDetailUserShare(array $params) { $this->params = $params; $attachSectionData = $this->getSectionDataByAttachObject($params['attachObject']); $isLinkSection = false; if ($attachSectionData) { $exists = FolderInviteTable::getRow(array('filter' => array('INVITE_USER_ID' => $params['attachToUserId'], 'IBLOCK_ID' => $attachSectionData['IBLOCK_ID'], 'SECTION_ID' => $attachSectionData['SECTION_ID']), 'select' => array('ID'))); if ($exists) { $isLinkSection = true; } } $userListType = $this->params['userListType']; if ($userListType == 'can_edit') { return array_merge(array('IS_LINK_SECTION' => $isLinkSection), $this->getListConnectedUsersCanEdited($attachSectionData)); } elseif ($userListType == 'cannot_edit') { return array_merge(array('IS_LINK_SECTION' => $isLinkSection), $this->getListConnectedUsersCannotEdited($attachSectionData)); } elseif ($userListType == 'disconnect') { return array_merge(array('IS_LINK_SECTION' => $isLinkSection), $this->getListDisconnected($attachSectionData)); } }
/** * Simple logic. * @param array $sectionData * @return array */ private function getOwnerBySection(array $sectionData) { //shared docs if ($sectionData['IBLOCK_TYPE'] == 'shared_files' && !empty($sectionData['SECTION_ID']) && !empty($sectionData['CREATED_BY'])) { $user = \Bitrix\Main\UserTable::getById($sectionData['CREATED_BY'])->fetch(); return empty($user) ? array() : $this->reformatUserRow($user); } $row = \Bitrix\Webdav\FolderInviteTable::getList(array('select' => array('*', 'USER'), 'limit' => 1, 'filter' => array('=IBLOCK_ID' => $sectionData['IBLOCK_ID'], '=SECTION_ID' => $sectionData['SECTION_ID'])))->fetch(); return empty($row) ? array() : $this->reformatInviteRow($row); }
function GetSectionsTree($options = array()) { static $dataType = 'SectionsTree'; if (empty($options['prependPath'])) { $options['prependPath'] = ''; } $dataCache = $options; $dataCache['IBLOCK_ID'] = $this->IBLOCK_ID; $dataCache['ROOT_SECTION_ID'] = empty($this->arRootSection['ID']) ? 0 : $this->arRootSection['ID']; $id = md5(serialize($dataCache)); $sections = $this->_dataCache($dataType . $id); if ($sections === false) { $arElement = $this->GetObject($options, false, true); if ($arElement["not_found"]) { $sections = array(); } else { $arFilter = array("IBLOCK_ID" => $this->IBLOCK_ID); if (isset($options['not_check_permissions'])) { $arFilter['CHECK_PERMISSIONS'] = 'N'; } $bRootFounded = empty($this->arRootSection) ? true : false; if ($arElement["item_id"] > 0 && !empty($arElement["dir_array"])) { $arFilter["LEFT_MARGIN"] = intVal($arElement["dir_array"]["LEFT_MARGIN"]) + 1; $arFilter["RIGHT_MARGIN"] = intVal($arElement["dir_array"]["RIGHT_MARGIN"]) - 1; } elseif (!empty($this->arRootSection)) { $arFilter["LEFT_MARGIN"] = intVal($this->arRootSection["LEFT_MARGIN"]) + 1; $arFilter["RIGHT_MARGIN"] = intVal($this->arRootSection["RIGHT_MARGIN"]) - 1; } if (!empty($arElement["is_dir"]) && $arElement["item_id"]) { list($contextType, $contextEntityId) = $this->getContextData(); $sectionData = $this->getSectionDataForLinkAnalyze($arElement["item_id"], $arElement); $iblockId = $sectionData['IBLOCK_ID']; if (CWebDavSymlinkHelper::isLink($contextType, $contextEntityId, $sectionData)) { $arFilter['IBLOCK_ID'] = $iblockId; $symlinkSectionData = CWebDavSymlinkHelper::getLinkData($contextType, $contextEntityId, $sectionData); if (!empty($symlinkSectionData[self::UF_LINK_SECTION_ID]) && $symlinkSectionData['ID'] == $arElement["item_id"]) { $margins = CIBlockSection::GetList(array(), array('ID' => $symlinkSectionData[self::UF_LINK_SECTION_ID], 'IBLOCK_ID' => $symlinkSectionData[self::UF_LINK_IBLOCK_ID], 'CHECK_PERMISSIONS' => 'N'), false, array('LEFT_MARGIN', 'RIGHT_MARGIN', 'IBLOCK_ID'))->fetch(); if ($margins) { $arFilter["LEFT_MARGIN"] = intVal($margins["LEFT_MARGIN"]) + 1; $arFilter["RIGHT_MARGIN"] = intVal($margins["RIGHT_MARGIN"]) - 1; } } } } $arResult = array(); $db_res = CIBlockSection::GetTreeList($arFilter, array('ID', 'CREATED_BY', 'MODIFIED_BY', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'NAME', 'LEFT_MARGIN', 'RIGHT_MARGIN', 'DEPTH_LEVEL', 'SOCNET_GROUP_ID', 'IBLOCK_CODE', 'TIMESTAMP_X')); // TODO: add e_rights check $trashID = $this->GetMetaID('TRASH'); if ($db_res && ($res = $db_res->Fetch())) { $deep = -1; $arPath = array(); $arExclude = array(); do { if ($this->MetaNames($res)) { $res["DEPTH_LEVEL"] = intVal($res["DEPTH_LEVEL"]); if (isset($arExclude[(int) $res["IBLOCK_SECTION_ID"]]) || $this->MetaSectionHide($res, !empty($options['NON_DROPPED_SECTION']))) { $arExclude[(int) $res["ID"]] = true; } else { if ($res["DEPTH_LEVEL"] > $deep) { $deep = $res["DEPTH_LEVEL"]; array_push($arPath, strtolower(htmlspecialcharsbx($res["NAME"]))); } elseif ($res["DEPTH_LEVEL"] == $deep) { array_pop($arPath); array_push($arPath, strtolower(htmlspecialcharsbx($res["NAME"]))); } else { while ($res["DEPTH_LEVEL"] < $deep) { array_pop($arPath); $deep--; } array_pop($arPath); array_push($arPath, strtolower(htmlspecialcharsbx($res["NAME"]))); } $res["PATH"] = $options['prependPath'] . implode("/", $arPath); $arResult[$res["ID"]] = $res; } } else { $arExclude[(int) $res["ID"]] = true; } } while ($res = $db_res->Fetch()); } $sections = $arResult; } $this->_dataCache($dataType . $id, $sections); } if (!empty($options['setERights'])) { $sectionIds = array(); foreach ($sections as $section) { $sectionIds[] = $section['ID']; } unset($section); $sectionRights = $this->GetPermissions('SECTION', $sectionIds); foreach ($sections as &$section) { if (isset($sectionRights[$section['ID']])) { $section['E_RIGHTS'] = $sectionRights[$section['ID']]; } } unset($section); } global $USER; if (!empty($options['SET_IS_SHARED']) && $USER->getId()) { $querySelfSharedSections = \Bitrix\Webdav\FolderInviteTable::getList(array('filter' => array('USER_ID' => $USER->getId(), '!=INVITE_USER_ID' => $USER->getId()), 'select' => array('SECTION_ID', 'IBLOCK_ID'))); while ($folderInvite = $querySelfSharedSections->fetch()) { $selfSharedSections[$folderInvite['SECTION_ID']] = $folderInvite; } unset($folderInvite); foreach ($sections as &$section) { if (isset($selfSharedSections[$section['ID']])) { $section['IS_SHARED'] = true; } } unset($section); } return $sections; }
private function getDataSymlinkSections() { global $USER; $invitesQuery = \Bitrix\Webdav\FolderInviteTable::getList(array('filter' => array('INVITE_USER_ID' => $USER->getId(), 'IS_APPROVED' => true, 'IS_DELETED' => false))); $symlinkSections = array(); while ($invite = $invitesQuery->fetch()) { $symlinkSections[$invite['LINK_SECTION_ID']] = $invite; } return $symlinkSections; }
public static function onBeforeConfirmNotify($module, $tag, $value, $arNotify) { global $USER; $userId = $USER->getId(); if ($module == 'webdav' && $userId) { $tagData = explode('|', $tag); $folderInviteId = intval($tagData[2]); if ($tagData[0] == "WEBDAV" && $tagData[1] == "INVITE" && $folderInviteId > 0 && $userId == $tagData[3]) { if (\Bitrix\Main\Loader::includeModule('im')) { CIMNotify::DeleteByTag(\Bitrix\Webdav\FolderInviteTable::getNotifyTag(array('ID' => $folderInviteId, 'INVITE_USER_ID' => $userId))); } //decline if ($value === 'N') { \Bitrix\Webdav\FolderInviteTable::delete($folderInviteId); return false; } $targetSectionData = CWebDavIblock::getRootSectionDataForUser($userId); if (!$targetSectionData) { return false; } $folderInviteData = \Bitrix\Webdav\FolderInviteTable::getRowById($folderInviteId); if (!$folderInviteData) { return false; } $sectionToShare = CIBlockSection::getList(array(), array('ID' => $folderInviteData['SECTION_ID'], 'IBLOCK_ID' => $folderInviteData['IBLOCK_ID'], 'CHECK_PERMISSIONS' => 'N'), false, array('NAME', 'SOCNET_GROUP_ID'))->fetch(); if (empty($sectionToShare['NAME']) || empty($sectionToShare['SOCNET_GROUP_ID'])) { return false; } if (\Bitrix\Main\Loader::includeModule('socialnetwork')) { $group = CSocNetGroup::GetList(array(), array('ID' => $sectionToShare['SOCNET_GROUP_ID']), false, false, array('NAME'))->fetch(); } if (empty($group)) { return false; } $groupId = $sectionToShare['SOCNET_GROUP_ID']; $dispatcher = new \Bitrix\Webdav\InviteDispatcher(); $attachObjectType = CWebDavSymlinkHelper::ENTITY_TYPE_GROUP; $attachObjectId = (int) $groupId; $inviteComponentParams = array('attachObject' => array('id' => $attachObjectId, 'type' => $attachObjectType), 'attachToUserId' => $folderInviteData['INVITE_USER_ID'], 'inviteFromUserId' => $folderInviteData['USER_ID'], 'canEdit' => $folderInviteData['CAN_EDIT']); $response = $dispatcher->processActionConnect($inviteComponentParams); if ($response['status'] == $dispatcher::STATUS_SUCCESS) { \Bitrix\Webdav\FolderInviteTable::update($folderInviteId, array('IS_APPROVED' => true, 'LINK_SECTION_ID' => $response['sectionId'])); } return $response['status'] == $dispatcher::STATUS_SUCCESS; } } }
} } $selfSharedSections = $sectionsIds = $dataNavResults = array(); while ($res = $arResult["NAV_RESULT"]->Fetch()) { $dataNavResults[] = $res; if ($res["TYPE"] == "S") { $sectionsIds[] = $res['ID']; } } if ($sectionsIds) { //todo optimize! $filter = array('SECTION_ID' => $sectionsIds); if ($currentIblockCode && $currentIblockCode == 'shared_files') { $filter['USER_ID'] = $USER->getId(); } $querySelfSharedSections = \Bitrix\Webdav\FolderInviteTable::getList(array('filter' => $filter, 'select' => array('ID', 'SECTION_ID', 'IBLOCK_ID'))); while ($folderInvite = $querySelfSharedSections->fetch()) { $selfSharedSections[$folderInvite['SECTION_ID']] = $folderInvite; } unset($folderInvite); } foreach ($dataNavResults as $res) { if (isset($res["~NAME"]) && $res["~NAME"] === $ob->meta_names['TRASH']['name']) { continue; } if ($res["TYPE"] == "S") { if (!empty($res[CWebDavIblock::UF_LINK_SECTION_ID])) { $res['LINK'] = array('SECTION_ID' => $res[CWebDavIblock::UF_LINK_SECTION_ID], 'IBLOCK_ID' => $res[CWebDavIblock::UF_LINK_IBLOCK_ID], 'CAN_FORWARD' => $res[CWebDavIblock::UF_LINK_CAN_FORWARD]); } if ($res["TYPE"] == "S" && isset($selfSharedSections[$res['ID']])) { $res['SHARED_SECTION'] = array('SECTION_ID' => $selfSharedSections['SECTION_ID'], 'IBLOCK_ID' => $selfSharedSections['IBLOCK_ID'], 'USER_ID' => $selfSharedSections['USER_ID']);
public static function onDelete(Event $event) { $row = static::getRowById($event->getParameter('id')); if (!$row) { return; } global $USER; //todo unshare. Fork invite. Hack //not fork if owner by invite unshare user. if (!$row['IS_DELETED'] && $row['INVITE_USER_ID'] != $row['USER_ID'] && $row['USER_ID'] != $USER->getId()) { $scalarFields = array(); foreach (static::getEntity()->getFields() as $fieldName => $field) { if ($field instanceof Entity\ScalarField) { $scalarFields[$fieldName] = true; } } unset($field); $forkRow = array_intersect_key($row, $scalarFields); unset($forkRow['ID']); $forkRow['CAN_FORWARD'] = (bool) $forkRow['CAN_FORWARD']; $forkRow['CAN_EDIT'] = (bool) $forkRow['CAN_EDIT']; $forkRow['IS_DELETED'] = true; $forkRow['IS_APPROVED'] = false; \Bitrix\Webdav\FolderInviteTable::add($forkRow); } \CWebDavSymlinkHelper::sendNotifyUnshare($row); self::deleteSymlinkSections($row); }
public static function markDeleteBatch($deleteInviteOnSection = true) { if (empty(static::$dataDeletingMark)) { return false; } /** @var CWebDavDiskDispatcher $component */ $component = new static(); /** @var CWebDavAbstractStorage $storage */ $storage = $component->getStorageObject(); global $USER; $userId = $USER->getId(); $keeper = array(); $sectionIds = array(); foreach (static::$dataDeletingMark as $key => $data) { list($userIds, $sectionOwnersElement) = $data['ownerData']; foreach ($sectionOwnersElement as $ownerSection) { if (empty($ownerSection['IBLOCK_ID']) || empty($ownerSection['SECTION_ID'])) { continue; } $storage->setStorageId(array('IBLOCK_ID' => $ownerSection['IBLOCK_ID'], 'IBLOCK_SECTION_ID' => $ownerSection['SECTION_ID'])); $uniqueId = $storage->generateId(array('FILE' => !$data['isSection'], 'ID' => $data['ID'])); $keeper[] = array('IBLOCK_ID' => $ownerSection['IBLOCK_ID'], 'SECTION_ID' => $ownerSection['SECTION_ID'], 'ELEMENT_ID' => $uniqueId, 'USER_ID' => $userId, 'IS_DIR' => (int) $data['isSection']); if ($data['isSection'] && !isset($sectionIds[$data['ID']])) { $sectionIds[$data['ID']] = $data['ID']; } } unset($ownerSection); unset(static::$dataDeletingMark[$key]); } unset($data); if ($deleteInviteOnSection && $sectionIds) { \Bitrix\Webdav\FolderInviteTable::deleteByFilter(array('=SECTION_ID' => $sectionIds)); } CWebDavLogDeletedElement::addBatch($keeper); }
$arResult["URL"]["ELEMENT"]["BP_VIEW"] = CComponentEngine::MakePathFromTemplate($arParams["WEBDAV_BIZPROC_VIEW_URL"], array("ELEMENT_ID" => $arParams["ELEMENT_ID"])); $arResult["URL"]["HELP"] = CComponentEngine::MakePathFromTemplate($arParams["HELP_URL"], array()); $arResult["URL"]["CONNECTOR"] = CComponentEngine::MakePathFromTemplate($arParams["CONNECTOR_URL"], array()); $arResult["URL"]["SUBSCRIBE"] = CComponentEngine::MakePathFromTemplate($arParams["SECTIONS_URL"], array("PATH" => $path, "SECTION_ID" => $arParams["SECTION_ID"])); $arResult["URL"]["UNSUBSCRIBE"] = WDAddPageParams($arResult["URL"]["SUBSCRIBE"], array("subscribe_forum" => "N", "sessid" => bitrix_sessid())); $arResult["URL"]["SUBSCRIBE"] = WDAddPageParams($arResult["URL"]["SUBSCRIBE"], array("subscribe_forum" => "Y", "sessid" => bitrix_sessid())); /*************** For Custom components *****************************/ $arParams["USE_BIZPROC"] = $ob->workflow == "bizproc" ? "Y" : "N"; $arParams["USE_WORKFLOW"] = $ob->workflow == "workflow" ? "Y" : "N"; $arResult["URL"]["CHAIN"] = array(array("URL" => CComponentEngine::MakePathFromTemplate($arParams["SECTIONS_URL"], array("PATH" => "", "SECTION_ID" => 0)), "TITLE" => empty($arParams["STR_TITLE"]) ? GetMessage("WD_TITLE") : $arParams["STR_TITLE"])); $arResult['BP_PARAM_REQUIRED'] = 'N'; if ($ob->Type == 'iblock') { $arResult['BP_PARAM_REQUIRED'] = $ob->BPParameterRequired() ? 'Y' : 'N'; } /******************************************************************** /Data ********************************************************************/ $arResult['GROUP_DISK'] = array(); if ($ob->attributes['group_id'] && $ob->e_rights && $ob->GetPermission('SECTION', $ob->arParams['item_id'], 'section_edit') && CWebDavTools::isIntranetUser($USER->getId())) { $rootSectionDataForGroup = CWebDavIblock::getRootSectionDataForGroup($ob->attributes['group_id']); $arResult['GROUP_DISK']['CONNECTED'] = !\Bitrix\Webdav\FolderInviteTable::getRow(array('filter' => array('=INVITE_USER_ID' => $USER->getId(), '=USER_ID' => $USER->getId(), '=IS_APPROVED' => true, '=IBLOCK_ID' => $rootSectionDataForGroup['IBLOCK_ID'], '=SECTION_ID' => $rootSectionDataForGroup['SECTION_ID']))); $arResult['GROUP_DISK']['CONNECT_URL'] = $APPLICATION->GetCurUri(http_build_query(array('toWDController' => 1, 'wdaction' => 'connect', 'group' => $ob->attributes['group_id']))); $arResult['GROUP_DISK']['DISCONNECT_URL'] = $APPLICATION->GetCurUri(http_build_query(array('toWDController' => 1, 'wdaction' => 'disconnect', 'group' => $ob->attributes['group_id']))); $arResult['GROUP_DISK']['DETAIL_URL'] = $APPLICATION->GetCurUri(http_build_query(array('toWDController' => 1, 'wdaction' => 'detail_group_connect', 'group' => $ob->attributes['group_id']))); } $this->IncludeComponentTemplate(); if (!$ob->e_rights && $ob->CheckRight($arParams["PERMISSION"], "section_read") < "R") { ShowError(GetMessage("WD_ACCESS_DENIED")); return 0; } return array("PERMISSION" => $arParams["PERMISSION"]);