public static function GetStorage() { if (!self::Enabled()) { return false; } $storageModel = false; if ($storageId = self::GetStorageId()) { $storageModel = \Bitrix\Disk\Storage::loadById($storageId); if (!$storageModel || $storageModel->getModuleId() != self::MODULE_ID) { $storageModel = false; } } if (!$storageModel) { $data['NAME'] = GetMessage('IM_DISK_STORAGE_TITLE'); $data['USE_INTERNAL_RIGHTS'] = 1; $data['MODULE_ID'] = self::MODULE_ID; $data['ENTITY_TYPE'] = IM\Disk\ProxyType\Im::className(); $data['ENTITY_ID'] = self::MODULE_ID; $driver = \Bitrix\Disk\Driver::getInstance(); $rightsManager = $driver->getRightsManager(); $fullAccessTaskId = $rightsManager->getTaskIdByName($rightsManager::TASK_FULL); $storageModel = $driver->addStorageIfNotExist($data, array(array('ACCESS_CODE' => 'AU', 'TASK_ID' => $fullAccessTaskId))); if ($storageModel) { self::SetStorageId($storageModel->getId()); } else { $storageModel = false; } } return $storageModel; }
private static function needProxyToDiskByDocType($documentType) { if (!(\Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false) && CModule::includeModule('disk'))) { return false; } if (empty($documentType)) { return false; } $storage = null; if (substr($documentType, 0, 7) == 'STORAGE') { $storageId = (int) substr($documentType, 8); if ($storageId) { $storage = \Bitrix\Disk\Storage::loadById($storageId); } if ($storage) { return $storage; } } list(, $iblockId, $typeLib, $entityId) = explode('_', $documentType); if ($typeLib == 'user') { $storage = \Bitrix\Disk\Driver::getInstance()->getStorageByUserId($entityId); } elseif ($typeLib == 'group') { $storage = \Bitrix\Disk\Driver::getInstance()->getStorageByGroupId($entityId); } else { return false; } return $storage; }
protected function parsePath($requestUri) { static $storages; if (empty($storages)) { $cache = new \CPHPCache(); if ($cache->initCache(30 * 24 * 3600, 'webdav_disk_common_storage', '/webdav/storage')) { $storages = $cache->getVars(); } else { $storages = \Bitrix\Disk\Storage::getModelList(array('filter' => array('=ENTITY_TYPE' => \Bitrix\Disk\ProxyType\Common::className()))); foreach ($storages as $key => $storage) { $storages[$key] = array('id' => $storage->getEntityId(), 'path' => $storage->getProxyType()->getStorageBaseUrl()); } $cache->startDataCache(); if (defined('BX_COMP_MANAGED_CACHE')) { $taggedCache = \Bitrix\Main\Application::getInstance()->getTaggedCache(); $taggedCache->startTagCache('/webdav/storage'); $taggedCache->registerTag('disk_common_storage'); $taggedCache->endTagCache(); } $cache->endDataCache($storages); } } $patterns = array(array('user', '/(?:company|contacts)/personal/user/(\\d+)/files/lib(.*)$'), array('user', '/(?:company|contacts)/personal/user/(\\d+)/disk/path(.*)$'), array('group', '/workgroups/group/(\\d+)/files(.*)$'), array('group', '/workgroups/group/(\\d+)/disk/path(.*)$')); foreach ($storages as $storage) { $storagePath = trim($storage['path'], '/'); $patterns[] = array('docs', sprintf('^/%s/path(.*)$', $storagePath), $storage['id']); $patterns[] = array('docs', sprintf('^/%s(.*)$', $storagePath), $storage['id']); } // @TODO: aggregator $patterns[] = array('docs', '^/docs/path(.*)$', 'shared_files_s1'); $patterns[] = array('docs', '^/docs(.*)$', 'shared_files_s1'); $type = null; $id = null; $path = null; foreach ($patterns as $pattern) { $matches = array(); if (preg_match('#' . $pattern[1] . '#i', $requestUri, $matches)) { $type = $pattern[0]; list($id, $path) = $type == 'docs' ? array($pattern[2], $matches[1]) : array($matches[1], $matches[2]); break; } } /** @var Storage $storage */ $storage = null; if ($type == 'user') { $storage = Driver::getInstance()->getStorageByUserId((int) $id); } elseif ($type == 'group') { $storage = Driver::getInstance()->getStorageByGroupId((int) $id); } elseif ($type == 'docs') { $storage = Driver::getInstance()->getStorageByCommonId($id); } else { return array(null, null); } $path = static::UrlDecode($path); return array($storage, $path); }
protected function initializeStorage() { if (isset($this->arParams['STORAGE'])) { $this->storage = $this->arParams['STORAGE']; return $this; } else { $this->storage = Storage::load(array('MODULE_ID' => $this->arParams['STORAGE_MODULE_ID'], 'ENTITY_TYPE' => $this->arParams['STORAGE_ENTITY_TYPE'], 'ENTITY_ID' => $this->arParams['STORAGE_ENTITY_ID'])); } return $this; }
private function formatFileToResponse(File $file) { if (empty($file) || !$file->getName()) { return array(); } $path = $this->getBreadcrumbs($file); if (!$path) { return array(); } $result = array('id' => $this->generateId(array('FILE' => true, 'ID' => $file->getId())), 'isDirectory' => false, 'isDeleted' => false, 'storageId' => $this->getStringStorageId(), 'path' => '/' . trim($path, '/'), 'name' => (string) $file->getName(), 'revision' => $file->getFileId(), 'version' => (string) $this->generateTimestamp($file->getUpdateTime()->getTimestamp()), 'extra' => array('id' => (string) $file->getId(), 'iblockId' => (string) $file->getStorageId(), 'sectionId' => (string) $file->getParentId(), 'rootSectionId' => (string) $this->storage->getRootObjectId(), 'name' => (string) $file->getName()), 'size' => (string) $file->getSize(), 'permission' => 'W', 'createdBy' => (string) $file->getCreatedBy(), 'modifiedBy' => (string) $file->getUpdatedBy()); if ($this->storage->getRootObjectId() != $file->getParentId()) { $result['parentId'] = $this->generateId(array('FILE' => false, 'ID' => $file->getParentId())); } return $result; }
protected function processActionGetListStorage() { $this->checkRequiredPostParams(array('proxyType')); if ($this->errorCollection->hasErrors()) { $this->sendJsonErrorResponse(); } $proxyTypePost = $this->request->getPost('proxyType'); $diskSecurityContext = $this->getSecurityContextByUser($this->getUser()); $siteId = null; $siteDir = null; if ($this->request->getPost('siteId')) { $siteId = $this->request->getPost('siteId'); } if ($this->request->getPost('siteDir')) { $siteDir = rtrim($this->request->getPost('siteDir'), '/'); } $result = array(); $filterReadableList = array(); $checkSiteId = false; if ($proxyTypePost == 'user') { $result['TITLE'] = Loc::getMessage('DISK_AGGREGATOR_USER_TITLE'); $filterReadableList = array('STORAGE.ENTITY_TYPE' => ProxyType\User::className()); } elseif ($proxyTypePost == 'group') { $checkSiteId = true; $result['TITLE'] = Loc::getMessage('DISK_AGGREGATOR_GROUP_TITLE'); $filterReadableList = array('STORAGE.ENTITY_TYPE' => ProxyType\Group::className()); } foreach (Storage::getReadableList($diskSecurityContext, array('filter' => $filterReadableList)) as $storage) { if ($checkSiteId) { $groupObject = CSocNetGroup::getList(array(), array('ID' => $storage->getEntityId()), false, false, array('SITE_ID')); $group = $groupObject->fetch(); if (!empty($group) && $group['SITE_ID'] != $siteId) { continue; } } $proxyType = $storage->getProxyType(); $result['DATA'][] = array("TITLE" => $proxyType->getEntityTitle(), "URL" => $siteDir . $proxyType->getBaseUrlFolderList(), "ICON" => $proxyType->getEntityImageSrc(64, 64)); } if (!empty($result['DATA'])) { Collection::sortByColumn($result['DATA'], array('TITLE' => SORT_ASC)); $this->sendJsonSuccessResponse(array('listStorage' => $result['DATA'], 'title' => $result['TITLE'])); } else { $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_AGGREGATOR_ERROR_COULD_NOT_FIND_DATA')))); $this->sendJsonErrorResponse(); } }
protected function processActionDefault() { $diskSecurityContext = $this->getSecurityContextByUser($this->getUser()); $this->arResult["COMMON_DISK"] = array(); $filterReadableList = array('STORAGE.ENTITY_TYPE' => ProxyType\Common::className()); foreach (Storage::getReadableList($diskSecurityContext, array('filter' => $filterReadableList)) as $storage) { $proxyType = $storage->getProxyType(); if ($storage->getSiteId() != SITE_ID) { continue; } $this->arResult["COMMON_DISK"][$storage->getEntityId()] = array("TITLE" => $proxyType->getEntityTitle(), "URL" => $proxyType->getBaseUrlFolderList(), "ICON" => $proxyType->getEntityImageSrc(64, 64)); } $userId = $this->getUser()->getId(); $storage = Driver::getInstance()->getStorageByUserId($userId); $proxyType = $storage->getProxyType(); $this->arResult["COMMON_DISK"][$storage->getEntityId()] = array("TITLE" => $proxyType->getTitleForCurrentUser(), "URL" => $proxyType->getBaseUrlFolderList(), "ICON" => $proxyType->getEntityImageSrc(64, 64)); $this->arResult["COMMON_DISK"]["GROUP"] = array("TITLE" => Loc::getMessage('DISK_AGGREGATOR_GROUP_TITLE'), "ID" => "bx-disk-aggregator-group-link"); $this->arResult["COMMON_DISK"]["USER"] = array("TITLE" => Loc::getMessage('DISK_AGGREGATOR_USER_TITLE'), "ID" => "bx-disk-aggregator-user-link"); $this->arResult["NETWORK_DRIVE_LINK"] = Driver::getInstance()->getUrlManager()->getHostUrl() . $this->getApplication()->GetCurPage(); $this->includeComponentTemplate(); }
/** * Return name of storage. * @return string */ public function getTitle() { return Loc::getMessage('DISK_PROXY_TYPE_BASE_TITLE', array('#NAME#' => $this->storage->getName())); }
public static function getDocumentTypeName($documentType) { $storageId = self::getStorageIdByType($documentType); if ($storageId) { $storage = Storage::getById($storageId); return '[' . $storage->getSiteId() . '] ' . $storage->getName(); } return $documentType; }
/** * Returns the list attributes which is connected with another models. * @return array */ public static function getMapReferenceAttributes() { $userClassName = User::className(); $fields = User::getFieldsForSelect(); return array('CREATE_USER' => array('class' => $userClassName, 'select' => $fields), 'UPDATE_USER' => array('class' => $userClassName, 'select' => $fields), 'DELETE_USER' => array('class' => $userClassName, 'select' => $fields), 'REAL_OBJECT' => BaseObject::className(), 'STORAGE' => Storage::className()); }
/** * Returns grid id. * @return string */ public function getGridId() { return 'folder_list_' . $this->storage->getId(); }
public static function getUsersFromUserGroup($group, $documentId) { if (substr($documentId, 0, 8) == "STORAGE_") { $storageId = self::getStorageIdByType($documentId); } else { if (is_array($documentId)) { $documentId = intval($documentId[2]); } /** @var File $file */ $file = File::loadById($documentId); if (!$file) { return array(); } $storageId = $file->getStorageId(); } if (strtolower($group) == "author") { $documentId = intval($documentId); if ($documentId <= 0) { return array(); } /** @var File $file */ $file = File::loadById($documentId); if (!$file) { return array(); } return array($file->getCreatedBy()); } if ($storageId) { $storage = Storage::loadById($storageId, array('ROOT_OBJECT')); if ($storage->getProxyType() instanceof ProxyType\Group) { $entityId = $storage->getEntityId(); $group = strtoupper($group); if (Loader::includeModule("socialnetwork")) { $listUserGroup = array(); if ($group == SONET_ROLES_OWNER) { $listGroup = \CSocNetGroup::getByID($entityId); if ($listGroup) { $listUserGroup[] = $listGroup["OWNER_ID"]; } } elseif ($group == SONET_ROLES_MODERATOR) { $dbRes = \CSocNetUserToGroup::getList(array(), array("GROUP_ID" => $entityId, "<=ROLE" => SONET_ROLES_MODERATOR, "USER_ACTIVE" => "Y"), false, false, array("USER_ID")); while ($res = $dbRes->fetch()) { $listUserGroup[] = $res["USER_ID"]; } } elseif ($group == SONET_ROLES_USER) { $dbRes = \CSocNetUserToGroup::getList(array(), array("GROUP_ID" => $entityId, "<=ROLE" => SONET_ROLES_USER, "USER_ACTIVE" => "Y"), false, false, array("USER_ID")); while ($res = $dbRes->fetch()) { $listUserGroup[] = $res["USER_ID"]; } } return $listUserGroup; } } } $group = intval($group); if ($group <= 0) { return array(); } $userIds = array(); $filter = array("ACTIVE" => "Y"); if ($group != 2) { $filter["GROUPS_ID"] = $group; } $query = \CUser::getList($b = "ID", $o = "ASC", $filter); while ($user = $query->fetch()) { $userIds[] = $user["ID"]; } return $userIds; }
protected static function createFolder(Storage $storage, $code) { $name = static::getName($code); if (!$name) { return null; } if ($storage->getProxyType() instanceof ProxyType\User) { $createdBy = $storage->getEntityId(); } else { $createdBy = SystemUser::SYSTEM_USER_ID; } if (static::shouldBeUnderUploadedFolder($code)) { $folderForUploadedFiles = $storage->getFolderForUploadedFiles(); if (!$folderForUploadedFiles) { return null; } return $folderForUploadedFiles->addSubFolder(array('NAME' => $name, 'CODE' => $code, 'CREATED_BY' => $createdBy), array(), true); } return $storage->addFolder(array('NAME' => $name, 'CODE' => $code, 'CREATED_BY' => $createdBy), array(), true); }
private function getStorageByType($type, $storageId) { $storage = null; if ($type === 'user') { return Driver::getInstance()->getStorageByUserId($this->getUser()->getId()); } elseif ($type === 'group') { $storage = Storage::loadById($storageId); if (!$storage->getProxyType() instanceof ProxyType\Group) { $this->errorCollection->add(array(new Error("Invalid storage type {$type}. Is not a group."))); return null; } } elseif ($type === 'common') { $storage = Storage::loadById($storageId); if (!$storage->getProxyType() instanceof ProxyType\Common) { $this->errorCollection->add(array(new Error("Invalid storage type {$type}. Is not a common storage."))); return null; } } return $storage; }
private function getPathToUserLib(User $userModel, Storage $storageModel) { if ($userModel->isExtranetUser()) { $extranetProxyType = new ProxyType\ExtranetUser($userModel->getId(), $storageModel); return $extranetProxyType->getBaseUrlFolderList(); } return $storageModel->getProxyType()->getBaseUrlFolderList(); }
/** * Checks read permissions by user for group. * Uses denormalized rights (b_disk_simple_right). * * Be careful^ this is internal method. * @param mixed $user User. * @param int $groupId Id of group. * @internal * @return bool */ public static function canRead($user, $groupId) { $entityType = static::className(); $groupStorage = Storage::buildFromArray(array('ENTITY_ID' => $groupId, 'ENTITY_TYPE' => $entityType)); $proxyType = new static($groupId, $groupStorage); $parameters = array('filter' => array('ENTITY_ID' => (int) $groupId, 'ENTITY_TYPE' => $entityType, 'MODULE_ID' => Driver::INTERNAL_MODULE_ID, 'USE_INTERNAL_RIGHTS' => 1)); $parameters = Driver::getInstance()->getRightsManager()->addRightsCheck($proxyType->getSecurityContextByUser($user), $parameters, array('ROOT_OBJECT_ID', 'USE_INTERNAL_RIGHTS')); return (bool) Storage::getList($parameters)->fetch(); }
} global $USER; if (!isset($USER) || !$USER->isAuthorized() || !$USER->getId()) { return; } $arDefaultUrlTemplates404 = array("trashcan_list" => "trashcan/#TRASH_PATH#", "trashcan_file_view" => "trash/file/#TRASH_FILE_PATH#", "folder_list" => "path/#PATH#", "file_view" => "file/#FILE_PATH#", "external_link_list" => "external", "disk_help" => "help", "disk_bizproc_workflow_admin" => "bp/", "disk_bizproc_workflow_edit" => "bp_edit/#ID#/", "disk_start_bizproc" => "bp_start/#ELEMENT_ID#/", "disk_task" => "bp_task/#ID#/", "disk_task_list" => "bp_task_list/"); $arDefaultVariableAliases404 = array(); $arDefaultVariableAliases = array(); $componentPage = ''; $arComponentVariables = array('FOLDER_ID', 'FILE_ID', 'PATH'); $arParams['NAME_TEMPLATE'] = empty($arParams['NAME_TEMPLATE']) ? CSite::GetNameFormat(false) : str_replace(array("#NOBR#", "#/NOBR#"), array("", ""), $arParams["NAME_TEMPLATE"]); if (empty($arParams['STORAGE'])) { if (empty($arParams['STORAGE_ID'])) { return; } $arParams['STORAGE'] = \Bitrix\Disk\Storage::loadById((int) $arParams['STORAGE_ID'], array('ROOT_OBJECT')); } if (empty($arParams['STORAGE'])) { //necessary return; } if ($arParams['SEF_MODE'] == 'Y') { $arVariables = array(); $engine = new CComponentEngine($this); $engine->addGreedyPart("#PATH#"); $engine->addGreedyPart("#FILE_PATH#"); $engine->addGreedyPart("#TRASH_PATH#"); $engine->addGreedyPart("#TRASH_FILE_PATH#"); $engine->setResolveCallback(array(\Bitrix\Disk\Driver::getInstance()->getUrlManager(), "resolvePathComponentEngine")); $arUrlTemplates = CComponentEngine::MakeComponentUrlTemplates($arDefaultUrlTemplates404, isset($arParams["SEF_URL_TEMPLATES"]) ? $arParams["SEF_URL_TEMPLATES"] : array()); $arVariableAliases = CComponentEngine::MakeComponentVariableAliases($arDefaultVariableAliases404, isset($arParams["VARIABLE_ALIASES"]) ? $arParams["VARIABLE_ALIASES"] : array());
private function checkUseInternalsRightsOnStorage(BaseObject $object, $rights) { $storageModel = Storage::loadById($object->getStorageId()); if (!empty($rights) && !$storageModel->isUseInternalRights()) { throw new SystemException('Attempt to set the rights, but not to use the internal rights.'); } }
private function resolvePath(Storage $storage, $path, $lookUpFromFolderId, $lastPart = FolderTable::TYPE_FOLDER) { Diag::getInstance()->collectDebugInfo('urlmanager'); $path = trim($path, '/'); $relativeItems = array(); if ($path == 'index.php' || !$path) { if ($lastPart == FolderTable::TYPE_FILE) { return null; } //by default we show root folder. return array('STORAGE' => $storage, 'OBJECT_ID' => $storage->getRootObjectId(), 'RELATIVE_PATH' => '/', 'RELATIVE_ITEMS' => array()); } $filter = array('TYPE' => FolderTable::TYPE_FOLDER, 'STORAGE_ID' => $storage->getId()); if ($lookUpFromFolderId !== null) { $filter['PARENT_ID'] = $lookUpFromFolderId; } $partsOfPath = explode('/', $path); if (end($partsOfPath) == 'index.php') { array_pop($partsOfPath); } foreach ($partsOfPath as $i => $pieceOfPath) { if ($i === count($partsOfPath) - 1) { if ($lastPart !== null) { $filter['TYPE'] = $lastPart; } else { unset($filter['TYPE']); } } $filter['=NAME'] = $pieceOfPath; $folder = ObjectTable::getList(array('filter' => $filter, 'select' => array('ID', 'NAME', 'REAL_OBJECT_ID', 'STORAGE_ID', 'PARENT_ID')))->fetch(); if (!$folder) { return null; } if ($folder['REAL_OBJECT_ID']) { $filter['PARENT_ID'] = $folder['REAL_OBJECT_ID']; unset($filter['STORAGE_ID']); } else { $filter['PARENT_ID'] = $folder['ID']; $filter['STORAGE_ID'] = $folder['STORAGE_ID']; } $lookUpFromFolderId = $folder['ID']; $relativeItems[] = array('ID' => $folder['ID'], 'NAME' => $pieceOfPath); } unset($pieceOfPath); Diag::getInstance()->logDebugInfo('urlmanager'); return array('STORAGE' => $storage, 'OBJECT_ID' => $lookUpFromFolderId, 'RELATIVE_PATH' => implode('/', $partsOfPath), 'RELATIVE_ITEMS' => $relativeItems); }
protected function processActionLoadItems() { $this->checkRequiredPostParams(array('FORM_TAB_TYPE', 'FORM_TAB_ID', 'FORM_PATH')); if ($this->errorCollection->hasErrors()) { $this->sendJsonErrorResponse(); } $dialogName = $this->request->getPost('FORM_NAME') ?: 'DiskFileDialog'; $typeStorage = strtolower($this->request->getPost('FORM_TAB_TYPE')); if (!in_array($typeStorage, array('user', 'common', 'group', 'cloud'), true)) { $this->errorCollection->add(array(new Error("Invalid storage type {$typeStorage}"))); $this->sendJsonErrorResponse(); } $storageId = (int) $this->request->getPost('FORM_TAB_ID'); $path = $this->request->getPost('FORM_PATH'); $storage = null; if ($typeStorage === 'user') { $storage = Driver::getInstance()->getStorageByUserId($this->getUser()->getId()); } elseif ($typeStorage === 'group') { $storage = Storage::loadById($storageId); if (!$storage->getProxyType() instanceof ProxyType\Group) { $this->errorCollection->add(array(new Error("Invalid storage type {$typeStorage}. Is not a group."))); $this->sendJsonErrorResponse(); } } elseif ($typeStorage === 'common') { $storage = Storage::loadById($storageId); if (!$storage->getProxyType() instanceof ProxyType\Common) { $this->errorCollection->add(array(new Error("Invalid storage type {$typeStorage}. Is not a common storage."))); $this->sendJsonErrorResponse(); } } elseif ($typeStorage === 'cloud') { $documentHandlersManager = Driver::getInstance()->getDocumentHandlersManager(); $documentHandler = $documentHandlersManager->getHandlerByCode($this->request->getQuery('service')); if (!$documentHandler) { $this->errorCollection->add($documentHandlersManager->getErrors()); $this->sendJsonErrorResponse(); } if (!$documentHandler->checkAccessibleTokenService()) { $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_UF_CONTROLLER_ERROR_COULD_NOT_WORK_WITH_TOKEN_SERVICE', array('#NAME#' => $documentHandler->getName())), self::ERROR_COULD_NOT_WORK_WITH_TOKEN_SERVICE))); $this->errorCollection->add($documentHandler->getErrors()); $this->sendJsonErrorResponse(); } if (!$documentHandler->queryAccessToken()->hasAccessToken() || $documentHandler->isRequiredAuthorization()) { $this->sendNeedAuth($documentHandler->getUrlForAuthorizeInTokenService('opener')); } $itemsCloud = $this->listItemsCloud($documentHandler, $path); if ($itemsCloud === null && $documentHandler->isRequiredAuthorization()) { $this->sendNeedAuth($documentHandler->getUrlForAuthorizeInTokenService('opener')); } $this->sendJsonSuccessResponse(array('FORM_NAME' => $dialogName, 'FORM_ITEMS' => $itemsCloud, 'FORM_ITEMS_DISABLED' => array(), 'FORM_PATH' => $path, 'FORM_IBLOCK_ID' => 0)); } if (!$storage) { $this->errorCollection->add(array(new Error('Could not find storage for current user'))); $this->sendJsonErrorResponse(); } $this->sendJsonSuccessResponse(array('FORM_NAME' => $dialogName, 'FORM_ITEMS' => $this->listItems($storage, $path), 'FORM_ITEMS_DISABLED' => array(), 'FORM_PATH' => $path, 'FORM_IBLOCK_ID' => 0)); }
protected function processActionSaveRightsOnStorage() { $this->checkRequiredPostParams(array('storageId')); if ($this->errorCollection->hasErrors()) { $this->sendJsonErrorResponse(); } $storage = Storage::loadById((int) $this->request->getPost('storageId'), array('ROOT_OBJECT')); if (!$storage) { $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FOLDER_LIST_ERROR_COULD_NOT_FIND_OBJECT'), self::ERROR_COULD_NOT_FIND_OBJECT))); $this->sendJsonErrorResponse(); } $rightsManager = Driver::getInstance()->getRightsManager(); $securityContext = $storage->getCurrentUserSecurityContext(); if (!$storage->canChangeRights($securityContext)) { $this->sendJsonAccessDeniedResponse(); } $showExtendedRights = (bool) $this->request->getPost('showExtendedRights'); if ($storage->isEnabledShowExtendedRights() != $showExtendedRights) { $showExtendedRights ? $storage->enableShowExtendedRights() : $storage->disableShowExtendedRights(); } if (!$this->request->getPost('isChangedRights')) { $this->sendJsonSuccessResponse(); } $storageNewRights = $this->request->getPost('storageNewRights'); if (!empty($storageNewRights) && is_array($storageNewRights)) { $newRights = array(); foreach ($storageNewRights as $accessCode => $right) { if (!empty($right['right']['id'])) { $newRights[] = array('ACCESS_CODE' => $accessCode, 'TASK_ID' => $right['right']['id']); } } unset($accessCode, $right); if (empty($newRights)) { $this->sendJsonErrorResponse(); } if ($rightsManager->set($storage->getRootObject(), $newRights)) { $this->sendJsonSuccessResponse(); } } $this->sendJsonErrorResponse(); }
private static function needProxyToDiskByDocType($documentType) { if (!(\Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false) && CModule::includeModule('disk'))) { return false; } if (empty($documentType)) { return false; } $storage = null; if (substr($documentType, 0, 7) == 'STORAGE') { $storageId = (int) substr($documentType, 8); if ($storageId) { $storage = \Bitrix\Disk\Storage::loadById($storageId); } if ($storage) { return $storage; } } list(, $iblockId) = explode('_', $documentType); if (!$iblockId) { return false; } $storage = \Bitrix\Disk\Storage::load(array('XML_ID' => $iblockId, 'MODULE_ID' => \Bitrix\Disk\Driver::INTERNAL_MODULE_ID, 'ENTITY_TYPE' => \Bitrix\Disk\ProxyType\Common::className())); if (!$storage) { return false; } return $storage; }
$componentPage = "index"; $arParams["RESOURCE_TYPE"] = $arParams["RESOURCE_TYPE"] == "FOLDER" ? "FOLDER" : "IBLOCK"; if ($arParams["RESOURCE_TYPE"] == "IBLOCK") { //$arParams["IBLOCK_TYPE"] $arParams["IBLOCK_ID"] = intVal($arParams["IBLOCK_ID"]); $arParams['CHECK_CREATOR'] = "N"; // only for socnet $arParams['SHOW_TAGS'] = $arParams['SHOW_TAGS'] == "Y" ? "Y" : "N"; if (\Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false) && CModule::includeModule('disk')) { $requestURL = $APPLICATION->GetCurPage(); $arParams["SEF_FOLDER"] = str_replace("\\", "/", $arParams["SEF_FOLDER"]); if ($arParams["SEF_FOLDER"] != "/") { $arParams["SEF_FOLDER"] = "/" . Trim($arParams["SEF_FOLDER"], "/ \t\n\r\v") . "/"; } $currentPageUrl = SubStr($requestURL, StrLen($arParams["SEF_FOLDER"])); $diskStorage = \Bitrix\Disk\Storage::load(array('MODULE_ID' => \Bitrix\Disk\Driver::INTERNAL_MODULE_ID, 'ENTITY_TYPE' => \Bitrix\Disk\ProxyType\Common::className(), 'XML_ID' => (int) $arParams['IBLOCK_ID']), array('ROOT_OBJECT')); if ($diskStorage) { //it means / if (!$currentPageUrl || $currentPageUrl == 'index.php') { if ($arParams["SEF_FOLDER"]) { $arParams["SEF_FOLDER"] = rtrim($arParams["SEF_FOLDER"], '/'); } LocalRedirect($arParams["SEF_FOLDER"] . '/path/'); } $arParams['STORAGE'] = $diskStorage; $componentPage = ''; $arVariablesD = array(); $engine = new CComponentEngine($this); $engine->addGreedyPart("#PATH#"); $engine->addGreedyPart("#FILE_PATH#"); $engine->addGreedyPart("#TRASH_PATH#");
/** * Collect all subscribers by object (@see Sharing) * Return associative array: storageId => userId. * * @param \Bitrix\Disk\BaseObject|BaseObject $object Target object. * @return array */ public function collectSubscribers(BaseObject $object) { $subscribers = array(); foreach ($object->getParents($this->getFakeSecurityContext()) as $parent) { if (!$parent instanceof Folder) { continue; } $subscribers = $this->appendSubscribersBySharings($parent, $subscribers); } unset($parent); $subscribers = $this->appendSubscribersBySharings($object, $subscribers); $storage = Storage::loadById($object->getStorageId()); if ($storage && $storage->getProxyType() instanceof ProxyType\User) { $subscribers[$storage->getId()] = $storage->getEntityId(); } return $subscribers; }
/** * @return array */ public static function getMapReferenceAttributes() { $storageClassName = Storage::className(); $objectClassName = BaseObject::className(); return array('PARENT' => static::className(), 'LINK_OBJECT' => $objectClassName, 'REAL_OBJECT' => $objectClassName, 'LINK_STORAGE' => $storageClassName, 'REAL_STORAGE' => $storageClassName, 'CREATE_USER' => array('class' => User::className(), 'select' => User::getFieldsForSelect())); }
/** * @param $id * @return Disk\Storage * @throws RestException */ private function getStorageById($id) { $storage = Disk\Storage::getById($id); if (!$storage) { throw new RestException("Could not find entity with id '{$id}'.", RestException::ERROR_NOT_FOUND); } return $storage; }