protected function getWebDavSettings() { if ($this->webdavSettings !== null) { return $this->webdavSettings; } if (!CModule::IncludeModule('webdav')) { throw new RestException('Could not load webdav module.'); } $opt = COption::getOptionString('webdav', 'user_files', null); if ($opt == null) { throw new RestException('Could not find webdav settings.'); } $user = CCrmSecurityHelper::GetCurrentUser(); $opt = unserialize($opt); $iblockID = intval($opt[CSite::GetDefSite()]['id']); $userSectionID = CWebDavIblock::getRootSectionIdForUser($iblockID, $user->GetID()); if (!is_numeric($userSectionID) || $userSectionID <= 0) { throw new RestException('Could not find webdav section for user ' . $user->GetLastName() . '.'); } return $this->webdavSettings = array('IBLOCK_ID' => $iblockID, 'IBLOCK_SECTION_ID' => intval($userSectionID)); }
public static function getRootSectionDataForUser($userId) { $userLib = CWebDavIblock::LibOptions('user_files', false, SITE_ID); if ($userLib && isset($userLib['id']) && ($iblockId = intval($userLib['id']))) { $userSectionId = CWebDavIblock::getRootSectionIdForUser($iblockId, $userId); if ($userSectionId) { return array('IBLOCK_ID' => $iblockId, 'SECTION_ID' => $userSectionId); } } return array(); }
/** * @return array * @throws Exception */ protected function getUserStorageId() { if ($this->enableDiskModule) { $storage = \Bitrix\Disk\Driver::getInstance()->getStorageByUserId($this->getUser()->getId()); if (!$storage) { $storage = \Bitrix\Disk\Driver::getInstance()->addUserStorage($this->getUser()->getId()); } if ($storage) { return array('IBLOCK_ID' => $storage->getId(), 'IBLOCK_SECTION_ID' => $storage->getRootObjectId()); } } $userFilesOptions = COption::getOptionString('webdav', 'user_files', null); if ($userFilesOptions == null) { throw new Exception('Where are options "user_files"?'); } $userFilesOptions = unserialize($userFilesOptions); $iblockId = $userFilesOptions[CSite::getDefSite()]['id']; $userSectionId = CWebDavIblock::getRootSectionIdForUser($iblockId, $this->getUser()->getId()); if (!$userSectionId) { throw new Exception('Wrong section for user ' . $this->getUser()->getLastName()); } return array('IBLOCK_ID' => $iblockId, 'IBLOCK_SECTION_ID' => $userSectionId); }