diff options
author | Sergey Linnik <sergey.linnik@onlyoffice.com> | 2022-06-14 18:06:23 +0300 |
---|---|---|
committer | Sergey Linnik <sergey.linnik@onlyoffice.com> | 2022-06-14 18:06:23 +0300 |
commit | 47e0d8451539c1e43435c73520f066cdfed1c12d (patch) | |
tree | b8ce3c2f8ba8182a9ec5f31dd289d1ec018fa8b0 | |
parent | 1edf7a43b2a4bbd0d299104a249cad6f91d4ccdf (diff) | |
parent | 12cb1ee170dc82aaf8afcc1267892135b84b7ae2 (diff) |
Merge branch 'feature/extra-permissions_' into feature/nc-23
44 files changed, 1740 insertions, 47 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index d9c60a7..8870a39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## ## Added +- advanced access rights - macro launch setting - opening file location from viewer - Catalan translation diff --git a/appinfo/application.php b/appinfo/application.php index c5c1ec8..fbbc7f6 100644 --- a/appinfo/application.php +++ b/appinfo/application.php @@ -44,6 +44,7 @@ use OCA\Onlyoffice\AppConfig; use OCA\Onlyoffice\Controller\CallbackController; use OCA\Onlyoffice\Controller\EditorController; use OCA\Onlyoffice\Controller\EditorApiController; +use OCA\Onlyoffice\Controller\SharingApiController; use OCA\Onlyoffice\Controller\SettingsController; use OCA\Onlyoffice\Controller\TemplateController; use OCA\Onlyoffice\Listeners\FilesListener; @@ -158,6 +159,19 @@ class Application extends App implements IBootstrap { ); }); + $context->registerService("SharingApiController", function (ContainerInterface $c) { + return new SharingApiController( + $c->get("AppName"), + $c->get("Request"), + $c->get("RootStorage"), + $c->get("Logger"), + $c->get("UserSession"), + $c->get("UserManager"), + $c->get("IManager"), + $this->appConfig + ); + }); + $context->registerService("EditorApiController", function (ContainerInterface $c) { return new EditorApiController( $c->get("AppName"), diff --git a/appinfo/routes.php b/appinfo/routes.php index b714c3d..e2ab78e 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -48,6 +48,8 @@ return [ "ocs" => [ ["name" => "federation#key", "url" => "/api/v1/key", "verb" => "POST"], ["name" => "federation#keylock", "url" => "/api/v1/keylock", "verb" => "POST"], - ["name" => "editorapi#config", "url" => "/api/v1/config/{fileId}", "verb" => "GET"] + ["name" => "editorapi#config", "url" => "/api/v1/config/{fileId}", "verb" => "GET"], + ["name" => "sharingapi#get_shares", "url" => "/api/v1/shares/{fileId}", "verb" => "GET"], + ["name" => "sharingapi#set_shares", "url" => "/api/v1/shares", "verb" => "PUT"] ] ];
\ No newline at end of file diff --git a/controller/callbackcontroller.php b/controller/callbackcontroller.php index 9bc8099..a2fd341 100644 --- a/controller/callbackcontroller.php +++ b/controller/callbackcontroller.php @@ -466,11 +466,6 @@ class CallbackController extends Controller { $user = $this->userManager->get($userId); if (!empty($user)) { \OC_User::setUserId($userId); - \OC_Util::setupFS($userId); - - if ($userId === $hashData->userId) { - $filePath = $hashData->filePath; - } } else { if (empty($shareToken)) { $this->logger->error("Track without token: $fileId status $status", ["app" => $this->appName]); @@ -480,6 +475,29 @@ class CallbackController extends Controller { $this->logger->debug("Track $fileId by token for $userId", ["app" => $this->appName]); } + // owner of file from the callback link + $ownerId = $hashData->ownerId; + $owner = $this->userManager->get($ownerId); + + if (!empty($owner)) { + $userId = $ownerId; + } else { + $callbackUserId = $hashData->userId; + $callbackUser = $this->userManager->get($callbackUserId); + + if (!empty($callbackUser)) { + // author of the callback link + $userId = $callbackUserId; + + // path for author of the callback link + $filePath = $hashData->filePath; + } + } + + if (!empty($userId)) { + \OC_Util::setupFS($userId); + } + list ($file, $error) = empty($shareToken) ? $this->getFile($userId, $fileId, $filePath) : $this->getFileByToken($fileId, $shareToken); if (isset($error)) { @@ -487,13 +505,6 @@ class CallbackController extends Controller { return $error; } - if (empty($user)) { - $owner = $file->getFileInfo()->getOwner(); - if ($owner !== null) { - \OC_Util::setupFS($owner->getUID()); - } - } - $url = $this->config->ReplaceDocumentServerUrlToInternal($url); $prevVersion = $file->getFileInfo()->getMtime(); diff --git a/controller/editorapicontroller.php b/controller/editorapicontroller.php index 5a2a58e..ba5f333 100644 --- a/controller/editorapicontroller.php +++ b/controller/editorapicontroller.php @@ -47,6 +47,7 @@ use OCA\Onlyoffice\Crypt; use OCA\Onlyoffice\DocumentService; use OCA\Onlyoffice\FileUtility; use OCA\Onlyoffice\TemplateManager; +use OCA\Onlyoffice\ExtraPermissions; /** * Controller with the main functions @@ -131,6 +132,13 @@ class EditorApiController extends OCSController { private $tagManager; /** + * Extra permissions + * + * @var ExtraPermissions + */ + private $extraPermissions; + + /** * Mobile regex from https://github.com/ONLYOFFICE/CommunityServer/blob/v9.1.1/web/studio/ASC.Web.Studio/web.appsettings.config#L35 */ const USER_AGENT_MOBILE = "/android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i"; @@ -184,6 +192,11 @@ class EditorApiController extends OCSController { } } + if ($this->config->GetAdvanced() + && \OC::$server->getAppManager()->isInstalled("files_sharing")) { + $this->extraPermissions = new ExtraPermissions($AppName, $logger, $shareManager, $config); + } + $this->fileUtility = new FileUtility($AppName, $trans, $logger, $config, $shareManager, $session); } @@ -305,6 +318,48 @@ class EditorApiController extends OCSController { $params["document"]["permissions"]["modifyFilter"] = $permissions_modifyFilter; } + $restrictedEditing = false; + $fileStorage = $file->getStorage(); + if (empty($shareToken) && $fileStorage->instanceOfStorage("\OCA\Files_Sharing\SharedStorage")) { + $shareId = $fileStorage->getShareId(); + + $extraPermissions = null; + if ($this->extraPermissions !== null) { + $extraPermissions = $this->extraPermissions->getExtra($shareId); + } + + if (!empty($extraPermissions)) { + if (isset($format["review"]) && $format["review"]) { + $reviewPermission = ($extraPermissions["permissions"] & ExtraPermissions::Review) === ExtraPermissions::Review; + if ($reviewPermission) { + $restrictedEditing = true; + $params["document"]["permissions"]["review"] = true; + } + } + + if (isset($format["comment"]) && $format["comment"]) { + $commentPermission = ($extraPermissions["permissions"] & ExtraPermissions::Comment) === ExtraPermissions::Comment; + if ($commentPermission) { + $restrictedEditing = true; + $params["document"]["permissions"]["comment"] = true; + } + } + + if (isset($format["fillForms"]) && $format["fillForms"]) { + $fillFormsPermission = ($extraPermissions["permissions"] & ExtraPermissions::FillForms) === ExtraPermissions::FillForms; + if ($fillFormsPermission) { + $restrictedEditing = true; + $params["document"]["permissions"]["fillForms"] = true; + } + } + + if (isset($format["modifyFilter"]) && $format["modifyFilter"]) { + $modifyFilter = ($extraPermissions["permissions"] & ExtraPermissions::ModifyFilter) === ExtraPermissions::ModifyFilter; + $params["document"]["permissions"]["modifyFilter"] = $modifyFilter; + } + } + } + $isTempLock = false; if ($version < 1 && \OC::$server->getAppManager()->isInstalled("files_lock")) { @@ -335,8 +390,14 @@ class EditorApiController extends OCSController { && !$isTempLock && (empty($shareToken) || ($share->getPermissions() & Constants::PERMISSION_UPDATE) === Constants::PERMISSION_UPDATE); $params["document"]["permissions"]["edit"] = $editable; - if ($editable && ($canEdit || $canFillForms)) { - $hashCallback = $this->crypt->GetHash(["userId" => $userId, "fileId" => $file->getId(), "filePath" => $filePath, "shareToken" => $shareToken, "action" => "track"]); + if (($editable || $restrictedEditing) && ($canEdit || $canFillForms)) { + $ownerId = null; + $owner = $file->getOwner(); + if (!empty($owner)) { + $ownerId = $owner->getUID(); + } + + $hashCallback = $this->crypt->GetHash(["userId" => $userId, "ownerId" => $ownerId, "fileId" => $file->getId(), "filePath" => $filePath, "shareToken" => $shareToken, "action" => "track"]); $callback = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.track", ["doc" => $hashCallback]); if (!empty($this->config->GetStorageUrl())) { diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php index 5a97fc3..d7918e6 100644 --- a/controller/settingscontroller.php +++ b/controller/settingscontroller.php @@ -116,6 +116,7 @@ class SettingsController extends Controller { "formats" => $this->config->FormatsSetting(), "sameTab" => $this->config->GetSameTab(), "preview" => $this->config->GetPreview(), + "advanced" => $this->config->GetAdvanced(), "versionHistory" => $this->config->GetVersionHistory(), "limitGroups" => $this->config->GetLimitGroups(), "chat" => $this->config->GetCustomizationChat(), @@ -194,6 +195,7 @@ class SettingsController extends Controller { * @param array $editFormats - editable formats array * @param bool $sameTab - open in the same tab * @param bool $preview - generate preview files + * @param bool $advanced - use advanced tab * @param bool $versionHistory - keep version history * @param array $limitGroups - list of groups * @param bool $chat - display chat @@ -210,6 +212,7 @@ class SettingsController extends Controller { $editFormats, $sameTab, $preview, + $advanced, $versionHistory, $limitGroups, $chat, @@ -226,6 +229,7 @@ class SettingsController extends Controller { $this->config->SetEditableFormats($editFormats); $this->config->SetSameTab($sameTab); $this->config->SetPreview($preview); + $this->config->SetAdvanced($advanced); $this->config->SetVersionHistory($versionHistory); $this->config->SetLimitGroups($limitGroups); $this->config->SetCustomizationChat($chat); diff --git a/controller/sharingapicontroller.php b/controller/sharingapicontroller.php new file mode 100644 index 0000000..12ab326 --- /dev/null +++ b/controller/sharingapicontroller.php @@ -0,0 +1,228 @@ +<?php +/** + * + * (c) Copyright Ascensio System SIA 2022 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +namespace OCA\Onlyoffice\Controller; + +use OCP\AppFramework\Http; +use OCP\AppFramework\Http\DataResponse; +use OCP\AppFramework\OCSController; +use OCP\IL10N; +use OCP\ILogger; +use OCP\IRequest; +use OCP\ISession; +use OCP\Constants; +use OCP\Share\IManager; +use OCP\Files\IRootFolder; +use OCP\IUserManager; +use OCP\IUserSession; +use OCP\Files\File; +use OCP\Share\IShare; +use OCP\Share\Exceptions\ShareNotFound; + + +use OCA\Onlyoffice\AppConfig; +use OCA\Onlyoffice\DocumentService; +use OCA\Onlyoffice\FileUtility; +use OCA\Onlyoffice\KeyManager; +use OCA\Onlyoffice\ExtraPermissions; + +/** + * OCS handler + */ +class SharingApiController extends OCSController { + + /** + * Current user session + * + * @var IUserSession + */ + private $userSession; + + /** + * User manager + * + * @var IUserManager + */ + private $userManager; + + /** + * Root folder + * + * @var IRootFolder + */ + private $root; + + /** + * Logger + * + * @var ILogger + */ + private $logger; + + /** + * Application configuration + * + * @var AppConfig + */ + private $config; + + /** + * Share manager + * + * @var IManager + */ + private $shareManager; + + /** + * Extra permissions + * + * @var ExtraPermissions + */ + private $extraPermissions; + + /** + * @param string $AppName - application name + * @param IRequest $request - request object + * @param IRootFolder $root - root folder + * @param ILogger $logger - logger + * @param IUserSession $userSession - current user session + * @param IUserManager $userManager - user manager + * @param IManager $shareManager - Share manager + * @param AppConfig $config - application configuration + */ + public function __construct($AppName, + IRequest $request, + IRootFolder $root, + ILogger $logger, + IUserSession $userSession, + IUserManager $userManager, + IManager $shareManager, + AppConfig $appConfig + ) { + parent::__construct($AppName, $request); + + $this->root = $root; + $this->logger = $logger; + $this->userSession = $userSession; + $this->userManager = $userManager; + $this->shareManager = $shareManager; + $this->appConfig = $appConfig; + + if ($this->appConfig->GetAdvanced() + && \OC::$server->getAppManager()->isInstalled("files_sharing")) { + $this->extraPermissions = new ExtraPermissions($AppName, $logger, $shareManager, $appConfig); + } + } + + /** + * Get shares for file + * + * @param integer $fileId - file identifier + * + * @return DataResponse + * + * @NoAdminRequired + * @NoCSRFRequired + */ + public function getShares($fileId) { + if ($this->extraPermissions === null) { + $this->logger->debug("extraPermissions isn't init", ["app" => $this->appName]); + return new DataResponse([], Http::STATUS_BAD_REQUEST); + } + + $user = $this->userSession->getUser(); + $userId = $user->getUID(); + + $sourceFile = $this->getFile($fileId, $userId); + $fileStorage = $sourceFile->getStorage(); + if ($fileStorage->instanceOfStorage("\OCA\Files_Sharing\SharedStorage")) { + return new DataResponse([]); + } + + $sharesUser = $this->shareManager->getSharesBy($userId, IShare::TYPE_USER, $sourceFile); + $sharesGroup = $this->shareManager->getSharesBy($userId, IShare::TYPE_GROUP, $sourceFile); + $shares = array_merge($sharesUser, $sharesGroup); + $extras = $this->extraPermissions->getExtras($shares, $sourceFile); + + return new DataResponse($extras); + } + + /** + * Set shares for file + * + * @param integer $extraId - extra permission identifier + * @param integer $shareId - share identifier + * @param integer $fileId - file identifier + * @param integer $permissions - permissions value + * + * @return DataResponse + * + * @NoAdminRequired + * @NoCSRFRequired + */ + public function setShares($extraId, $shareId, $fileId, $permissions) { + if ($this->extraPermissions === null) { + $this->logger->debug("extraPermissions isn't init", ["app" => $this->appName]); + return new DataResponse([], Http::STATUS_BAD_REQUEST); + } + + $user = $this->userSession->getUser(); + $userId = $user->getUID(); + + $sourceFile = $this->getFile($fileId, $userId); + $fileStorage = $sourceFile->getStorage(); + if ($fileStorage->instanceOfStorage("\OCA\Files_Sharing\SharedStorage")) { + return new DataResponse([], Http::STATUS_BAD_REQUEST); + } + + if (!$this->extraPermissions->setExtra($shareId, $permissions, $extraId)) { + $this->logger->error("setShares: couldn't set extra permissions for: " . $shareId, ["app" => $this->appName]); + return new DataResponse([], Http::STATUS_BAD_REQUEST); + } + + $extra = $this->extraPermissions->getExtra($shareId); + + return new DataResponse($extra); + } + + /** + * Get source file + * + * @param integer $fileId - file identifier + * @param string $userId - user identifier + * + * @return File + */ + private function getFile($fileId, $userId) { + try { + $folder = $this->root->getUserFolder($userId); + $files = $folder->getById($fileId); + } catch (\Exception $e) { + $this->logger->logException($e, ["message" => "getFile: $fileId", "app" => $this->appName]); + return null; + } + + if (empty($files)) { + $this->logger->error("getFile: file not found: " . $fileId, ["app" => $this->appName]); + return null; + } + + return $files[0]; + } +} diff --git a/css/share.css b/css/share.css new file mode 100644 index 0000000..b7818b8 --- /dev/null +++ b/css/share.css @@ -0,0 +1,48 @@ +/** + * + * (c) Copyright Ascensio System SIA 2022 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +.icon-onlyoffice-sharing { + background-image: url("../img/app-dark.svg"); +} +.onlyoffice-share-item { + display: flex; + list-style-type: none; +} +.onlyoffice-share-item img { + width: 32px; + height: 32px; +} +.onlyoffice-share-popup { + margin-right: 14px; + margin-top: 44px; +} +.onlyoffice-share-item span { + margin-left: 10px; + margin-top: 5px; +} +#onlyoffice-share-menu { + margin-left: auto; +} +.onlyoffice-share-action { + line-height: 44px; +} +.onlyoffice-share-label { + padding-right: 14px !important; + padding-left: 14px !important; + opacity: .7; +}
\ No newline at end of file @@ -469,6 +469,14 @@ } }; + OCA.Onlyoffice.TabView = { + attach(fileList) { + if (OCA.Onlyoffice.SharingTabView) { + fileList.registerTabView(new OCA.Onlyoffice.SharingTabView()) + } + } + } + var getFileExtension = function (fileName) { var extension = fileName.substr(fileName.lastIndexOf(".") + 1).toLowerCase(); return extension; @@ -558,6 +566,8 @@ } else { OC.Plugins.register("OCA.Files.NewFileMenu", OCA.Onlyoffice.NewFileMenu); + OC.Plugins.register("OCA.Files.FileList", OCA.Onlyoffice.TabView); + OCA.Onlyoffice.registerAction(); OCA.Onlyoffice.bindVersionClick(); diff --git a/js/settings.js b/js/settings.js index 96db8a3..87adadc 100644 --- a/js/settings.js +++ b/js/settings.js @@ -191,6 +191,7 @@ var sameTab = $("#onlyofficeSameTab").is(":checked"); var preview = $("#onlyofficePreview").is(":checked"); + var advanced = $("#onlyofficeAdvanced").is(":checked"); var versionHistory = $("#onlyofficeVersionHistory").is(":checked"); var limitGroupsString = $("#onlyofficeGroups").prop("checked") ? $("#onlyofficeLimitGroups").val() : ""; @@ -213,6 +214,7 @@ editFormats: editFormats, sameTab: sameTab, preview: preview, + advanced: advanced, versionHistory: versionHistory, limitGroups: limitGroups, chat: chat, diff --git a/js/share.js b/js/share.js new file mode 100644 index 0000000..e1f6ab7 --- /dev/null +++ b/js/share.js @@ -0,0 +1,418 @@ +/** + * + * (c) Copyright Ascensio System SIA 2022 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + (function ($, OC) { + + OCA.Onlyoffice = _.extend({ + AppName: "onlyoffice", + }, OCA.Onlyoffice); + + OCA.Onlyoffice.Permissions = { + None: 0, + Review: 1, + Comment: 2, + FillForms: 4, + ModifyFilter: 8 + }; + + var tabcontext = null; + + OCA.Onlyoffice.SharingTabView = OCA.Files.DetailTabView.extend({ + id: "onlyofficeSharingTabView", + className: "tab onlyofficeSharingTabView", + + customEvents: null, + fileInfo: null, + templateItem: null, + permissionsMenu: null, + colectionLoading: null, + collection: null, + format: null, + + events: { + "click #onlyoffice-share-action": "_onClickPermissionMenu", + "change .onlyoffice-share-action input": "_onClickSetPermissions" + }, + + initialize() { + OCA.Files.DetailTabView.prototype.initialize.apply(this, arguments); + tabcontext = this; + + this.colectionLoading = false; + }, + + getLabel() { + return t(OCA.Onlyoffice.AppName, "Advanced") + }, + + getIcon() { + return "icon-onlyoffice-sharing" + }, + + render() { + var self = this; + + if (this.customEvents === null) { + this.customEvents = this._customEvents(); + this.customEvents.on(); + } + + this._getTemplate(() => { + this.collection.forEach(extra => { + var itemNode = self.templateItem.clone(); + var descNode = itemNode.find("span"); + var avatar = itemNode.find("img"); + + var avatarSrc = "/index.php/avatar/" + extra.shareWith + "/32?v=0"; + var label = extra.shareWithName; + if (extra.type == OC.Share.SHARE_TYPE_GROUP) { + avatarSrc = "/index.php/avatar/guest/" + extra.shareWith + "/32?v=0"; + label = extra.shareWith + " (" + t(OCA.Onlyoffice.AppName, "group") + ")"; + } + + avatar[0].src = avatarSrc; + descNode[0].innerText = label; + + itemNode[0].id = extra.share_id; + + self._getContainer().append(itemNode); + }); + }); + }, + + setFileInfo(fileInfo) { + if(fileInfo) { + this.fileInfo = fileInfo; + + if (this.colectionLoading) { + return; + } + + this._getContainer().children().remove(); + + this.colectionLoading = true; + OCA.Onlyoffice.GetShares(this.fileInfo.id, (shares) => { + this.collection = shares; + + this.colectionLoading = false; + this.render(); + }); + } + }, + + canDisplay: function (fileInfo) { + var canDisplay = false; + + if (!fileInfo.isDirectory()) { + var ext = fileInfo.name.split(".").pop(); + var format = OCA.Onlyoffice.setting.formats[ext]; + if (format && (format["review"] + || format["comment"] + || format["fillForms"] + || format["modifyFilter"])) { + canDisplay = true; + tabcontext.format = format; + + if ($("#sharing").hasClass("active") + && tabcontext.fileInfo + && tabcontext.fileInfo.id == fileInfo.id) { + this.update(fileInfo); + } + } + }; + + return canDisplay; + }, + + _getContainer: function () { + return this.$el.find(".onlyoffice-share-container"); + }, + + _getTemplate: function (callback) { + if (this.templateItem) { + callback(); + return; + } + + var self = this; + $.get(OC.filePath(OCA.Onlyoffice.AppName, "templates", "share.html"), + function (tmpl) { + self.templateItem = $(tmpl); + + $("<ul>", {class: "onlyoffice-share-container"}).appendTo(self.$el) + $("<div>").html(t(OCA.Onlyoffice.AppName, "Provide advanced document permissions using ONLYOFFICE Docs")).prependTo(self.$el); + + callback(); + }); + }, + + _onClickSetPermissions: function (e) { + var permissionValues = this.permissionsMenu.getValues(); + var shareId = this.permissionsMenu.getTargetId(); + var fileId = this.fileInfo.id; + var extra = this.collection.find(item => item.share_id == shareId); + + var permissions = OCA.Onlyoffice.Permissions.None; + if (permissionValues[OCA.Onlyoffice.Permissions.Review]) { + permissions |= OCA.Onlyoffice.Permissions.Review; + } + if (permissionValues[OCA.Onlyoffice.Permissions.Comment] + && (permissions & OCA.Onlyoffice.Permissions.Review) != OCA.Onlyoffice.Permissions.Review) { + permissions |= OCA.Onlyoffice.Permissions.Comment; + } + if (permissionValues[OCA.Onlyoffice.Permissions.FillForms] + && (permissions & OCA.Onlyoffice.Permissions.Review) != OCA.Onlyoffice.Permissions.Review) { + permissions |= OCA.Onlyoffice.Permissions.FillForms; + } + if (permissionValues[OCA.Onlyoffice.Permissions.ModifyFilter]) { + permissions |= OCA.Onlyoffice.Permissions.ModifyFilter; + } + + this.permissionsMenu.block(true); + OCA.Onlyoffice.SetShares(extra.id, shareId, fileId, permissions, (extra) => { + this.collection.forEach(item => { + if (item.share_id == extra.share_id) { + item.id = extra.id; + item.permissions = extra.permissions; + item.available = extra.available + } + }); + + var attributes = this._getPermissionAttributes(extra); + + this.permissionsMenu.refresh(attributes); + this.permissionsMenu.block(false); + }); + }, + + _onClickPermissionMenu: function (e) { + if (!this.permissionsMenu) { + this.permissionsMenu = this._permissionMenu(); + } + + var shareNode = $(e.target).closest(".onlyoffice-share-item")[0]; + var shareId = shareNode.id; + + + if (this.permissionsMenu.isOpen()) { + var previousId = this.permissionsMenu.getTargetId(); + this.permissionsMenu.close(); + + if (previousId == shareId) return; + } + + var extra = this.collection.find(item => item.share_id == shareId); + + var attributes = this._getPermissionAttributes(extra); + + this.permissionsMenu.open(extra.share_id, attributes, $(e.target).position()); + }, + + _getPermissionAttributes: function (extra) { + var attributes = []; + + if (this.format["review"] + && (OCA.Onlyoffice.Permissions.Review & extra["available"]) === OCA.Onlyoffice.Permissions.Review) { + var review = (OCA.Onlyoffice.Permissions.Review & extra["permissions"]) === OCA.Onlyoffice.Permissions.Review; + attributes.push({ + checked: review, + extra: OCA.Onlyoffice.Permissions.Review, + label: t(OCA.Onlyoffice.AppName, "Review") + }); + } + if (this.format["comment"] + && (OCA.Onlyoffice.Permissions.Comment & extra["available"]) === OCA.Onlyoffice.Permissions.Comment) { + var comment = (OCA.Onlyoffice.Permissions.Comment & extra["permissions"]) === OCA.Onlyoffice.Permissions.Comment; + attributes.push({ + checked: comment, + extra: OCA.Onlyoffice.Permissions.Comment, + label: t(OCA.Onlyoffice.AppName, "Comment") + }); + } + if (this.format["fillForms"] + && (OCA.Onlyoffice.Permissions.FillForms & extra["available"]) === OCA.Onlyoffice.Permissions.FillForms) { + var fillForms = (OCA.Onlyoffice.Permissions.FillForms & extra["permissions"]) === OCA.Onlyoffice.Permissions.FillForms; + attributes.push({ + checked: fillForms, + extra: OCA.Onlyoffice.Permissions.FillForms, + label: t(OCA.Onlyoffice.AppName, "Form filling") + }); + } + + if (this.format["modifyFilter"] + && (OCA.Onlyoffice.Permissions.ModifyFilter & extra["available"]) === OCA.Onlyoffice.Permissions.ModifyFilter) { + var modifyFilter = (OCA.Onlyoffice.Permissions.ModifyFilter & extra["permissions"]) === OCA.Onlyoffice.Permissions.ModifyFilter; + attributes.push({ + checked: modifyFilter, + extra: OCA.Onlyoffice.Permissions.ModifyFilter, + label: t(OCA.Onlyoffice.AppName, "Custom filter") + }); + } + + return attributes; + }, + + _customEvents: function () { + var init = false; + var self = this; + + return { + on: function () { + if (!init) { + $("#content").on("click", function (e) { + var target = $(e.target)[0]; + if (!self.permissionsMenu + || !self.permissionsMenu.isOpen() + || target.id == "onlyoffice-share-action" + || target.className == "onlyoffice-share-label" + || target.closest(".onlyoffice-share-action")) { + return; + } + + self.permissionsMenu.close(); + }); + + init = true; + } + } + } + }, + + _permissionMenu: function () { + var popup = $("<div>", { + class: "popovermenu onlyoffice-share-popup" + }).append($("<ul>"), { + id: -1 + }); + + var appendItem = function (checked, extra, name) { + var item = $("<li>").append($("<span>", { + class: "onlyoffice-share-action" + }).append($("<input>", { + id: "extra-" + extra, + type: "checkbox", + class: "checkbox action-checkbox__checkbox focusable", + checked: checked + })).append($("<label>", { + for: "extra-" + extra, + text: name, + class: "onlyoffice-share-label" + }))); + + popup.find("ul").append(item); + }; + + var removeItems = function () { + var items = popup.find("li"); + if (items) { + items.remove(); + } + } + + var setTargetId = function (id) { + popup.find("ul").attr("id", id); + }; + + this.$el.append(popup); + + return { + isOpen: function () { + return popup.is(":visible"); + }, + + open: function (id, attributes, position) { + removeItems(); + + if (position) { + popup.css({top: position.top}); + } + + attributes.forEach(attr => { + appendItem(attr.checked, attr.extra, attr.label); + }); + + setTargetId(id); + popup.show(); + }, + + close: function () { + removeItems(); + + setTargetId(-1); + popup.hide(); + }, + + refresh: function (attributes) { + removeItems(); + + attributes.forEach(attr => { + appendItem(attr.checked, attr.extra, attr.label); + }); + }, + + block: function (value) { + popup.find("input").prop("disabled", value); + }, + + getValues: function () { + var values = []; + + var items = popup.find("input"); + for (var i = 0; i < items.length; i++) { + var extra = items[i].id.split("extra-")[1]; + values[extra] = items[i].checked; + } + + return values; + }, + + getTargetId: function () { + return popup.find("ul").attr("id"); + }, + } + } + }); + + OCA.Onlyoffice.GetShares = function(fileId, callback) { + $.ajax({ + url: OC.linkToOCS("apps/" + OCA.Onlyoffice.AppName + "/api/v1/shares", 2) + fileId + "?format=json", + success: function onSuccess(response) { + callback(response.ocs.data); + } + }) + } + + OCA.Onlyoffice.SetShares = function(id, shareId, fileId, permissions, callback) { + var data = { + extraId: id, + shareId: shareId, + fileId: fileId, + permissions: permissions + } + + $.ajax({ + method: "PUT", + url: OC.linkToOCS("apps/" + OCA.Onlyoffice.AppName + "/api/v1", 2) + "shares?format=json", + data: data, + success: function onSuccess(response) { + callback(response.ocs.data); + } + }) + } + +})(jQuery, OC);
\ No newline at end of file @@ -115,6 +115,17 @@ OC.L10N.register( "Create new Form template": "Създайте нов шаблон на формуляр", "Create form": "Създайте формуляр", "Fill in form in ONLYOFFICE": "Попълнете формуляр в ONLYOFFICE", - "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Молим да актуализирате ONLYOFFICE Docs към версия 7.0, за да работи с онлайн формуляри за попълване" + "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Молим да актуализирате ONLYOFFICE Docs към версия 7.0, за да работи с онлайн формуляри за попълване", + "Security": "Сигурност", + "Anonymous": "Анонимен", + "Light": "Светла", + "Classic Light": "Класически светла", + "Dark": "Тъмна", + "Review": "Преглед", + "Comment": "Коментар", + "Form filling": "Попълване на формуляр", + "Custom filter": "Персонализиран филтър", + "group": "група", + "Advanced": "Допълнително" }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/bg.json b/l10n/bg.json index a385044..9f1bdd2 100644 --- a/l10n/bg.json +++ b/l10n/bg.json @@ -113,6 +113,17 @@ "Create new Form template": "Създайте нов шаблон на формуляр", "Create form": "Създайте формуляр", "Fill in form in ONLYOFFICE": "Попълнете формуляр в ONLYOFFICE", - "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Молим да актуализирате ONLYOFFICE Docs към версия 7.0, за да работи с онлайн формуляри за попълване" + "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Молим да актуализирате ONLYOFFICE Docs към версия 7.0, за да работи с онлайн формуляри за попълване", + "Security": "Сигурност", + "Anonymous": "Анонимен", + "Light": "Светла", + "Classic Light": "Класически светла", + "Dark": "Тъмна", + "Review": "Преглед", + "Comment": "Коментар", + "Form filling": "Попълване на формуляр", + "Custom filter": "Персонализиран филтър", + "group": "група", + "Advanced": "Допълнително" },"pluralForm": "nplurals=2; plural=(n != 1);" }
\ No newline at end of file @@ -62,7 +62,6 @@ OC.L10N.register( "This is a public test server, please do not use it for private sensitive data. The server will be available during a 30-day period.": "Aquest és un servidor de proves públic, si us plau no l'usis per a les teves dades confidencials. El servidor estarà disponible durant un període de 30 dies.", "The 30-day test period is over, you can no longer connect to demo ONLYOFFICE Docs server.": "El període de prova de 30 dies ha acabat, ja no pots connectar-te al servidor d'ONLYOFFICE Docs de demostració", "You are using public demo ONLYOFFICE Docs server. Please do not store private sensitive data.": "Estàs fent servir el servidor d'ONLYOFFICE Docs de demostració. Si us plau, no emmagatzemis les teves dades confidencials aquí.", - "Secure view settings": "Configuració de visualització segura", "Secure view enables you to secure documents by embedding a watermark": "La vista segura permet assegurar documents mitjançant la inserció d'una marca d'aigua en ells", "Enable watermarking": "Habilitar marques d'aigua", "Watermark text": "Text de marca d'aigua", @@ -116,6 +115,17 @@ OC.L10N.register( "Create new Form template": "Crear nova plantilla de formulari", "Create form": "Crear formulari", "Fill in form in ONLYOFFICE": "Omplir el formulari en ONLYOFFICE", - "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Si us plau, actualitzi ONLYOFFICE Docs a la versió 7.0 per a poder treballar amb formularis emplenables en línia" + "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Si us plau, actualitzi ONLYOFFICE Docs a la versió 7.0 per a poder treballar amb formularis emplenables en línia", + "Security": "Seguretat", + "Anonymous": "Anònim", + "Light": "Llum", + "Classic Light": "Llum clàssica", + "Dark": "Fosc", + "Review": "Visualització prèvia", + "Comment": "Comentari", + "Form filling": "Emplenament de formularis", + "Custom filter": "Filtre personalitzat", + "group": "agrupa", + "Advanced": "Avançat" }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/ca.json b/l10n/ca.json index 4192254..c825836 100644 --- a/l10n/ca.json +++ b/l10n/ca.json @@ -60,7 +60,6 @@ "This is a public test server, please do not use it for private sensitive data. The server will be available during a 30-day period.": "Aquest és un servidor de proves públic, si us plau no l'usis per a les teves dades confidencials. El servidor estarà disponible durant un període de 30 dies.", "The 30-day test period is over, you can no longer connect to demo ONLYOFFICE Docs server.": "El període de prova de 30 dies ha acabat, ja no pots connectar-te al servidor d'ONLYOFFICE Docs de demostració", "You are using public demo ONLYOFFICE Docs server. Please do not store private sensitive data.": "Estàs fent servir el servidor d'ONLYOFFICE Docs de demostració. Si us plau, no emmagatzemis les teves dades confidencials aquí.", - "Secure view settings": "Configuració de visualització segura", "Secure view enables you to secure documents by embedding a watermark": "La vista segura permet assegurar documents mitjançant la inserció d'una marca d'aigua en ells", "Enable watermarking": "Habilitar marques d'aigua", "Watermark text": "Text de marca d'aigua", @@ -115,5 +114,16 @@ "Create form": "Crear formulari", "Fill in form in ONLYOFFICE": "Omplir el formulari en ONLYOFFICE", "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Si us plau, actualitzi ONLYOFFICE Docs a la versió 7.0 per a poder treballar amb formularis emplenables en línia" + "Security": "Seguretat", + "Anonymous": "Anònim", + "Light": "Llum", + "Classic Light": "Llum clàssica", + "Dark": "Fosc", + "Review": "Visualització prèvia", + "Comment": "Comentari", + "Form filling": "Emplenament de formularis", + "Custom filter": "Filtre personalitzat", + "group": "agrupa", + "Advanced": "Avançat" },"pluralForm" :"nplurals=2; plural=(n != 1);" } @@ -115,6 +115,19 @@ OC.L10N.register( "Create new Form template": "Neue Formularvorlage erstellen", "Create form": "Formular erstellen", "Fill in form in ONLYOFFICE": "Formular in ONLYOFFICE ausfüllen", - "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Für Online-Arbeit mit Formularen ist Version 7.0 von ONLYOFFICE Docs erforderlich" + "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Für Online-Arbeit mit Formularen ist Version 7.0 von ONLYOFFICE Docs erforderlich", + "Security": "Sicherheit", + "Anonymous": "Anonym", + "Default editor theme": "Standardmäßiges Thema des Editors", + "Light": "Hell", + "Classic Light": "Klassisch Hell", + "Dark": "Dunkel", + "Review": "Review", + "Comment": "Kommentar", + "Form filling": "Ausfüllen von formularen", + "Custom filter": "Benutzerdefinierter filter", + "group": "gruppe", + "Advanced": "Erweitert", + "Provide advanced document permissions using ONLYOFFICE Docs": "Erweiterte Zugriffsrechte in ONLYOFFICE Docs vergeben" }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/de.json b/l10n/de.json index 7fdfa60..3e2bd4a 100644 --- a/l10n/de.json +++ b/l10n/de.json @@ -113,6 +113,19 @@ "Create new Form template": "Neue Formularvorlage erstellen", "Create form": "Formular erstellen", "Fill in form in ONLYOFFICE": "Formular in ONLYOFFICE ausfüllen", - "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Für Online-Arbeit mit Formularen ist Version 7.0 von ONLYOFFICE Docs erforderlich" + "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Für Online-Arbeit mit Formularen ist Version 7.0 von ONLYOFFICE Docs erforderlich", + "Security": "Sicherheit", + "Anonymous": "Anonym", + "Default editor theme": "Standardmäßiges Thema des Editors", + "Light": "Hell", + "Classic Light": "Klassisch Hell", + "Dark": "Dunkel", + "Review": "Review", + "Comment": "Kommentarе", + "Form filling": "Ausfüllen von formularen", + "Custom filter": "Benutzerdefinierter filter", + "group": "gruppe", + "Advanced": "Erweitert", + "Provide advanced document permissions using ONLYOFFICE Docs": "Erweiterte Zugriffsrechte in ONLYOFFICE Docs vergeben" },"pluralForm" :"nplurals=2; plural=(n != 1);" }
\ No newline at end of file diff --git a/l10n/de_DE.js b/l10n/de_DE.js index 740399b..d3199f6 100644 --- a/l10n/de_DE.js +++ b/l10n/de_DE.js @@ -115,6 +115,19 @@ OC.L10N.register( "Create new Form template": "Neue Formularvorlage erstellen", "Create form": "Formular erstellen", "Fill in form in ONLYOFFICE": "Formular in ONLYOFFICE ausfüllen", - "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Für Online-Arbeit mit Formularen ist Version 7.0 von ONLYOFFICE Docs erforderlich" + "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Für Online-Arbeit mit Formularen ist Version 7.0 von ONLYOFFICE Docs erforderlich", + "Security": "Sicherheit", + "Anonymous": "Anonym", + "Default editor theme": "Standardmäßiges Thema des Editors", + "Light": "Hell", + "Classic Light": "Klassisch Hell", + "Dark": "Dunkel", + "Review": "Review", + "Comment": "Kommentar", + "Form filling": "Ausfüllen von formularen", + "Custom filter": "Benutzerdefinierter filter", + "group": "gruppe", + "Advanced": "Erweitert", + "Provide advanced document permissions using ONLYOFFICE Docs": "Erweiterte Zugriffsrechte in ONLYOFFICE Docs vergeben" }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/de_DE.json b/l10n/de_DE.json index 5992357..c341b07 100644 --- a/l10n/de_DE.json +++ b/l10n/de_DE.json @@ -113,6 +113,19 @@ "Create new Form template": "Neue Formularvorlage erstellen", "Create form": "Formular erstellen", "Fill in form in ONLYOFFICE": "Formular in ONLYOFFICE ausfüllen", - "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Für Online-Arbeit mit Formularen ist Version 7.0 von ONLYOFFICE Docs erforderlich" + "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Für Online-Arbeit mit Formularen ist Version 7.0 von ONLYOFFICE Docs erforderlich", + "Security": "Sicherheit", + "Anonymous": "Anonym", + "Default editor theme": "Standardmäßiges Thema des Editors", + "Light": "Hell", + "Classic Light": "Klassisch Hell", + "Dark": "Dunkel", + "Review": "Review", + "Comment": "Kommentarе", + "Form filling": "Ausfüllen von formularen", + "Custom filter": "Benutzerdefinierter filter", + "group": "gruppe", + "Advanced": "Erweitert", + "Provide advanced document permissions using ONLYOFFICE Docs": "Erweiterte Zugriffsrechte in ONLYOFFICE Docs vergeben" },"pluralForm" :"nplurals=2; plural=(n != 1);" }
\ No newline at end of file @@ -115,6 +115,19 @@ OC.L10N.register( "Create new Form template": "Crear nueva plantilla de formulario", "Create form": "Crear formulario", "Fill in form in ONLYOFFICE": "Rellenar el formulario en ONLYOFFICE", - "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Por favor, actualice ONLYOFFICE Docs a la versión 7.0 para poder trabajar con formularios rellenables en línea" + "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Por favor, actualice ONLYOFFICE Docs a la versión 7.0 para poder trabajar con formularios rellenables en línea", + "Security": "Seguridad", + "Anonymous": "Anónimo", + "Default editor theme": "Tema del editor predeterminado", + "Light": "Claro", + "Classic Light": "Clásico claro", + "Dark": "Oscuro", + "Review": "Revista", + "Comment": "Comentarios", + "Form filling": "Relleno de formulario", + "Custom filter": "Filtro personalizado", + "group": "grupo", + "Advanced": "Avanzado", + "Provide advanced document permissions using ONLYOFFICE Docs": "Proporcione permisos avanzados para los documentos utilizando ONLYOFFICE Docs" }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/es.json b/l10n/es.json index b6fef4a..ac872ea 100644 --- a/l10n/es.json +++ b/l10n/es.json @@ -113,6 +113,19 @@ "Create new Form template": "Crear nueva plantilla de formulario", "Create form": "Crear formulario", "Fill in form in ONLYOFFICE": "Rellenar el formulario en ONLYOFFICE", - "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Por favor, actualice ONLYOFFICE Docs a la versión 7.0 para poder trabajar con formularios rellenables en línea" + "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Por favor, actualice ONLYOFFICE Docs a la versión 7.0 para poder trabajar con formularios rellenables en línea", + "Security": "Seguridad", + "Anonymous": "Anónimo", + "Default editor theme": "Tema del editor predeterminado", + "Light": "Claro", + "Classic Light": "Clásico claro", + "Dark": "Oscuro", + "Review": "Revista", + "Comment": "Comentarios", + "Form filling": "Relleno de formulario", + "Custom filter": "Filtro personalizado", + "group": "grupo", + "Advanced": "Avanzado", + "Provide advanced document permissions using ONLYOFFICE Docs": "Proporcione permisos avanzados para los documentos utilizando ONLYOFFICE Docs" },"pluralForm" :"nplurals=2; plural=(n != 1);" }
\ No newline at end of file @@ -115,6 +115,19 @@ OC.L10N.register( "Create new Form template": "Créer un nouveau modèle de formulaire", "Create form": "Créer un formulaire", "Fill in form in ONLYOFFICE": "Remplir le formulaire dans ONLYOFFICE", - "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Veuillez mettre à jour ONLYOFFICE Docs vers la version 7.0 pour travailler sur les formulaires à remplir en ligne" + "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Veuillez mettre à jour ONLYOFFICE Docs vers la version 7.0 pour travailler sur les formulaires à remplir en ligne", + "Security": "Sécurité", + "Anonymous": "Anonyme", + "Default editor theme": "Thème d'éditeur par défaut", + "Light": "Clair", + "Classic Light": "Classique clair", + "Dark": "Sombre", + "Review": "Révision", + "Comment": "Commentaire", + "Form filling": "Remplissage de formulaire", + "Custom filter": "Filtre personnalisé", + "group": "groupe", + "Advanced": "Avancé", + "Provide advanced document permissions using ONLYOFFICE Docs": "Fournir des autorisations avancées pour les documents en utilisant ONLYOFFICE Docs" }, "nplurals=2; plural=(n > 1);"); diff --git a/l10n/fr.json b/l10n/fr.json index 0ac6c12..7e7aa6e 100644 --- a/l10n/fr.json +++ b/l10n/fr.json @@ -114,5 +114,18 @@ "Create form": "Créer un formulaire", "Fill in form in ONLYOFFICE": "Remplir le formulaire dans ONLYOFFICE", "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Veuillez mettre à jour ONLYOFFICE Docs vers la version 7.0 pour travailler sur les formulaires à remplir en ligne" + "Security": "Sécurité", + "Anonymous": "Anonyme", + "Default editor theme": "Thème d'éditeur par défaut", + "Light": "Clair", + "Classic Light": "Classique clair", + "Dark": "Sombre", + "Review": "Révision", + "Comment": "Commentaire", + "Form filling": "Remplissage de formulaire", + "Custom filter": "Filtre personnalisé", + "group": "groupe", + "Advanced": "Avancé", + "Provide advanced document permissions using ONLYOFFICE Docs": "Fournir des autorisations avancées pour les documents en utilisant ONLYOFFICE Docs" },"pluralForm" :"nplurals=2; plural=(n > 1);" -} +}
\ No newline at end of file @@ -115,6 +115,19 @@ OC.L10N.register( "Create new Form template": "Creare un nuovo modello di modulo", "Create form": "Creare modulo", "Fill in form in ONLYOFFICE": "Compilare il modulo in ONLYOFFICE", - "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Si prega di aggiornare ONLYOFFICE Docs alla versione 7.0 per lavorare su moduli compilabili online" + "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Si prega di aggiornare ONLYOFFICE Docs alla versione 7.0 per lavorare su moduli compilabili online", + "Security": "Sicurezza", + "Anonymous": "Anonimo", + "Default editor theme": "Tema dell'editor predefinito", + "Light": "Chiaro", + "Classic Light": "Classico chiaro", + "Dark": "Scuro", + "Review": "Revisione", + "Comment": "Commento", + "Form filling": "Compilare un modulo", + "Custom filter": "Filtro personalizzato", + "group": "gruppo", + "Advanced": "Avanzate", + "Provide advanced document permissions using ONLYOFFICE Docs": "Fornisci autorizzazioni avanzate per i documenti utilizzando ONLYOFFICE Docs" }, "nplurals=2; plural=(n != 1);");
\ No newline at end of file diff --git a/l10n/it.json b/l10n/it.json index ba13688..df7d782 100644 --- a/l10n/it.json +++ b/l10n/it.json @@ -113,6 +113,19 @@ "Create new Form template": "Creare un nuovo modello di modulo", "Create form": "Creare modulo", "Fill in form in ONLYOFFICE": "Compilare il modulo in ONLYOFFICE", - "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Si prega di aggiornare ONLYOFFICE Docs alla versione 7.0 per lavorare su moduli compilabili online" + "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Si prega di aggiornare ONLYOFFICE Docs alla versione 7.0 per lavorare su moduli compilabili online", + "Security": "Sicurezza", + "Anonymous": "Anonimo", + "Default editor theme": "Tema dell'editor predefinito", + "Light": "Chiaro", + "Classic Light": "Classico chiaro", + "Dark": "Scuro", + "Review": "Revisione", + "Comment": "Commento", + "Form filling": "Compilare un modulo", + "Custom filter": "Filtro personalizzato", + "group": "gruppo", + "Advanced": "Avanzate", + "Provide advanced document permissions using ONLYOFFICE Docs": "Fornisci autorizzazioni avanzate per i documenti utilizzando ONLYOFFICE Docs" },"pluralForm" :"nplurals=2; plural=(n != 1);" }
\ No newline at end of file @@ -115,6 +115,19 @@ OC.L10N.register( "Create new Form template": "新しいフォームテンプレートの作成", "Create form": "フォームの作成", "Fill in form in ONLYOFFICE": "ONLYOFFICEでフォームを記入する", - "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "オンラインで入力可能なフォームを作成するには、ONLYOFFICE Docs 7.0版まで更新してください" + "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "オンラインで入力可能なフォームを作成するには、ONLYOFFICE Docs 7.0版まで更新してください", + "Security": "セキュリティ", + "Anonymous": "匿名", + "Default editor theme": "デフォルトのエディタテーマ", + "Light": "明るい", + "Classic Light": "明るい(クラシック)", + "Dark": "ダーク", + "Review": "レビュー", + "Comment": "コメント", + "Form filling": "フォーム入力", + "Custom filter": "ユーザー設定フィルター", + "group": "グループ", + "Advanced": "詳細", + "Provide advanced document permissions using ONLYOFFICE Docs": "ONLYOFFICE Docsを利用した高度なドキュメント権限の提供" }, "nplurals=1; plural=0;"); diff --git a/l10n/ja.json b/l10n/ja.json index f6a4140..21543c1 100644 --- a/l10n/ja.json +++ b/l10n/ja.json @@ -113,6 +113,19 @@ "Create new Form template": "新しいフォームテンプレートの作成", "Create form": "フォームの作成", "Fill in form in ONLYOFFICE": "ONLYOFFICEでフォームを記入する", - "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "オンラインで入力可能なフォームを作成するには、ONLYOFFICE Docs 7.0版まで更新してください" + "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "オンラインで入力可能なフォームを作成するには、ONLYOFFICE Docs 7.0版まで更新してください", + "Security": "セキュリティ", + "Anonymous": "匿名", + "Default editor theme": "デフォルトのエディタテーマ", + "Light": "明るい", + "Classic Light": "明るい(クラシック)", + "Dark": "ダーク", + "Review": "レビュー", + "Comment": "コメント", + "Form filling": "フォーム入力", + "Custom filter": "ユーザー設定フィルター", + "group": "グループ", + "Advanced": "詳細", + "Provide advanced document permissions using ONLYOFFICE Docs": "ONLYOFFICE Docsを利用した高度なドキュメント権限の提供" },"pluralForm" :"nplurals=1; plural=0;" }
\ No newline at end of file @@ -115,6 +115,17 @@ OC.L10N.register( "Create new Form template": "Utwórz nowy szablon formularza",
"Create form": "Utwórz formularz",
"Fill in form in ONLYOFFICE": "Wypełnić formularz w ONLYOFFICE",
- "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Zaktualizuj ONLYOFFICE Docs do wersji 7.0, aby działały w formularzach do wypełniania online"
+ "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Zaktualizuj ONLYOFFICE Docs do wersji 7.0, aby działały w formularzach do wypełniania online",
+ "Security": "Bezpieczeństwo",
+ "Anonymous": "Anonimowy",
+ "Light": "Jasny",
+ "Classic Light": "Klasyczny jasny",
+ "Dark": "Ciemny",
+ "Review": "Recenzja",
+ "Comment": "Komentarz",
+ "Form filling": "Wypełnianie formularza",
+ "Custom filter": "Niestandardowy filtr",
+ "group": "grupa",
+ "Advanced": "Zaawansowane"
},
"nplurals=4; plural=(n==1 ? 0 : (n%10>=2 && n%10<=4) && (n%100<12 || n%100>14) ? 1 : n!=1 && (n%10>=0 && n%10<=1) || (n%10>=5 && n%10<=9) || (n%100>=12 && n%100<=14) ? 2 : 3);");
\ No newline at end of file diff --git a/l10n/pl.json b/l10n/pl.json index 627c00b..2987f9f 100644 --- a/l10n/pl.json +++ b/l10n/pl.json @@ -113,6 +113,17 @@ "Create new Form template": "Utwórz nowy szablon formularza",
"Create form": "Utwórz formularz",
"Fill in form in ONLYOFFICE": "Wypełnić formularz w ONLYOFFICE",
- "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Zaktualizuj ONLYOFFICE Docs do wersji 7.0, aby działały w formularzach do wypełniania online"
+ "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Zaktualizuj ONLYOFFICE Docs do wersji 7.0, aby działały w formularzach do wypełniania online",
+ "Security": "Bezpieczeństwo",
+ "Anonymous": "Anonimowy",
+ "Light": "Jasny",
+ "Classic Light": "Klasyczny jasny",
+ "Dark": "Ciemny",
+ "Review": "Recenzja",
+ "Comment": "Komentarz",
+ "Form filling": "Wypełnianie formularza",
+ "Custom filter": "Niestandardowy filtr",
+ "group": "grupa",
+ "Advanced": "Zaawansowane"
},"pluralForm" :"nplurals=4; plural=(n==1 ? 0 : (n%10>=2 && n%10<=4) && (n%100<12 || n%100>14) ? 1 : n!=1 && (n%10>=0 && n%10<=1) || (n%10>=5 && n%10<=9) || (n%100>=12 && n%100<=14) ? 2 : 3);"
}
\ No newline at end of file diff --git a/l10n/pt_BR.js b/l10n/pt_BR.js index ca516c4..f77060e 100644 --- a/l10n/pt_BR.js +++ b/l10n/pt_BR.js @@ -115,6 +115,17 @@ OC.L10N.register( "Create new Form template": "Criar novo modelo de formulário", "Create form": "Criar formulário", "Fill in form in ONLYOFFICE": "Preencher formulário no ONLYOFFICE", - "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Atualize o ONLYOFFICE Docs para a versão 7.0 para trabalhar em formulários preenchíveis online" + "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Atualize o ONLYOFFICE Docs para a versão 7.0 para trabalhar em formulários preenchíveis online", + "Security": "Segurança", + "Anonymous": "Anônimo", + "Light": "Claro", + "Classic Light": "Clássico claro", + "Dark": "Escuro", + "Review": "Revisar", + "Comment": "Comente", + "Form filling": "Preenchimento de formularios", + "Custom filter": "Filtro personalizado", + "group": "grupo", + "Advanced": "Avançado" }, "nplurals=2; plural=(n > 1);"); diff --git a/l10n/pt_BR.json b/l10n/pt_BR.json index e24cbb2..267714e 100644 --- a/l10n/pt_BR.json +++ b/l10n/pt_BR.json @@ -114,5 +114,16 @@ "Create form": "Criar formulário", "Fill in form in ONLYOFFICE": "Preencher formulário no ONLYOFFICE", "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Atualize o ONLYOFFICE Docs para a versão 7.0 para trabalhar em formulários preenchíveis online" + "Security": "Segurança", + "Anonymous": "Anônimo", + "Light": "Claro", + "Classic Light": "Clássico claro", + "Dark": "Escuro", + "Review": "Revisar", + "Comment": "Comente", + "Form filling": "Preenchimento de formularios", + "Custom filter": "Filtro personalizado", + "group": "grupo", + "Advanced": "Avançado" },"pluralForm" :"nplurals=2; plural=(n > 1);" -} +}
\ No newline at end of file @@ -121,6 +121,13 @@ OC.L10N.register( "Default editor theme": "Тема редактора по умолчанию", "Light": "Светлая", "Classic Light": "Светлая классическая", - "Dark": "Темная" + "Dark": "Темная", + "Review": "Рецензирование", + "Comment": "Комментирование", + "Form filling": "Заполнение форм", + "Custom filter": "Пользовательский фильтр", + "group": "группа", + "Advanced": "Дополнительно", + "Provide advanced document permissions using ONLYOFFICE Docs": "Предоставление расширенных прав доступа к документам с помощью ONLYOFFICE Docs" }, "nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);"); diff --git a/l10n/ru.json b/l10n/ru.json index 737d849..e4bc0b5 100644 --- a/l10n/ru.json +++ b/l10n/ru.json @@ -119,6 +119,13 @@ "Default editor theme": "Тема редактора по умолчанию", "Light": "Светлая", "Classic Light": "Классическая светлая", - "Dark": "Темная" + "Dark": "Темная", + "Review": "Рецензирование", + "Comment": "Комментирование", + "Form filling": "Заполнение форм", + "Custom filter": "Пользовательский фильтр", + "group": "группа", + "Advanced": "Дополнительно", + "Provide advanced document permissions using ONLYOFFICE Docs": "Предоставление расширенных прав доступа к документам с помощью ONLYOFFICE Docs" },"pluralForm" :"nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);" }
\ No newline at end of file @@ -115,6 +115,17 @@ OC.L10N.register( "Create new Form template": "Skapa ny formulärmall", "Create form": "Skapa formulär", "Fill in form in ONLYOFFICE": "Fylla i formulär i ONLYOFFICE", - "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Uppdatera ONLYOFFICE Docs till version 7.0 för att arbeta med ifyllbart onlineformulär" + "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Uppdatera ONLYOFFICE Docs till version 7.0 för att arbeta med ifyllbart onlineformulär", + "Security": "Säkerhet", + "Anonymous": "Anonym", + "Light": "Ljus", + "Classic Light": "Klassiskt ljus", + "Dark": "Mörk", + "Review": "Granska", + "Comment": "Kommentar", + "Form filling": "Formulärfyllning", + "Custom filter": "Anpassat filter", + "group": "grupp", + "Advanced": "Avancerad" }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/sv.json b/l10n/sv.json index 0a5f150..ebce00d 100644 --- a/l10n/sv.json +++ b/l10n/sv.json @@ -107,12 +107,23 @@ "%1$s mentioned in the %2$s: \"%3$s\".": "%1$s har nämnt i %2$s: \"%3$s\".", "{notifier} mentioned in the {file}: \"%1$s\".": "{notifier} nämnde dig i {file}: \"%1$s\".", "Choose a format to convert {fileName}": "Välj det filformat som {fileName} ska konverteras till.", - "New form template": "Ny formulärmall", + "New form template": "Ny formulärmall", "Blank": "Töm", "From text document": "Formulärmall från textfil", "Create new Form template": "Skapa ny formulärmall", "Create form": "Skapa formulär", "Fill in form in ONLYOFFICE": "Fylla i formulär i ONLYOFFICE", - "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Uppdatera ONLYOFFICE Docs till version 7.0 för att arbeta med ifyllbart onlineformulär" + "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "Uppdatera ONLYOFFICE Docs till version 7.0 för att arbeta med ifyllbart onlineformulär", + "Security": "Säkerhet", + "Anonymous": "Anonym", + "Light": "Ljus", + "Classic Light": "Klassiskt ljus", + "Dark": "Mörk", + "Review": "Granska", + "Comment": "Kommentar", + "Form filling": "Formulärfyllning", + "Custom filter": "Anpassat filter", + "group": "grupp", + "Advanced": "Avancerad" },"pluralForm" :"nplurals=2; plural=(n != 1);" }
\ No newline at end of file diff --git a/l10n/zh_CN.js b/l10n/zh_CN.js index 2c7057f..46cdefd 100644 --- a/l10n/zh_CN.js +++ b/l10n/zh_CN.js @@ -115,6 +115,19 @@ OC.L10N.register( "Create new Form template": "创建新的表单模板", "Create form": "创建表单", "Fill in form in ONLYOFFICE": "在ONLYOFFICE上填写表单", - "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "请将ONLYOFFICE Docs更新到7.0版本,以便在线编辑可填写的表单" + "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "请将ONLYOFFICE Docs更新到7.0版本,以便在线编辑可填写的表单", + "Security": "安全", + "Anonymous": "匿名", + "Default editor theme": "编辑器默认的主题", + "Light": "光", + "Classic Light": "经典浅色", + "Dark": "黑暗的", + "Review": "审阅", + "Comment": "评论", + "Form filling": "表单填报", + "Custom filter": "自定义筛选器", + "group": "分组", + "Advanced": "进阶", + "Provide advanced document permissions using ONLYOFFICE Docs": "使用ONLYOFFICE Docs 提供高级文档权限" }, "nplurals=1; plural=0;"); diff --git a/l10n/zh_CN.json b/l10n/zh_CN.json index a4977ff..0c8dfbc 100644 --- a/l10n/zh_CN.json +++ b/l10n/zh_CN.json @@ -113,6 +113,19 @@ "Create new Form template": "创建新的表单模板", "Create form": "创建表单", "Fill in form in ONLYOFFICE": "在ONLYOFFICE上填写表单", - "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "请将ONLYOFFICE Docs更新到7.0版本,以便在线编辑可填写的表单" + "Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online": "请将ONLYOFFICE Docs更新到7.0版本,以便在线编辑可填写的表单", + "Security": "安全", + "Anonymous": "匿名", + "Default editor theme": "编辑器默认的主题", + "Light": "光", + "Classic Light": "经典浅色", + "Dark": "黑暗的", + "Review": "审阅", + "Comment": "评论", + "Form filling": "表单填报", + "Custom filter": "自定义筛选器", + "group": "分组", + "Advanced": "进阶", + "Provide advanced document permissions using ONLYOFFICE Docs": "使用ONLYOFFICE Docs 提供高级文档权限" },"pluralForm" :"nplurals=1; plural=0;" }
\ No newline at end of file diff --git a/lib/Migration/Version070400Date20220607111111.php b/lib/Migration/Version070400Date20220607111111.php new file mode 100644 index 0000000..1ca7636 --- /dev/null +++ b/lib/Migration/Version070400Date20220607111111.php @@ -0,0 +1,89 @@ +<?php + +declare(strict_types=1); + +namespace OCA\Onlyoffice\Migration; + +use Closure; +use OCP\DB\ISchemaWrapper; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +/** + * Auto-generated migration step: Please modify to your needs! + */ +class Version070400Date20220607111111 extends SimpleMigrationStep { + + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + */ + public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { + } + + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + if (!$schema->hasTable('onlyoffice_filekey')) { + $table = $schema->createTable('onlyoffice_filekey'); + $table->addColumn('id', 'integer', [ + 'autoincrement' => true, + 'notnull' => true, + ]); + $table->addColumn('file_id', 'bigint', [ + 'notnull' => false, + 'default' => '-1', + ]); + $table->addColumn('key', 'string', [ + 'notnull' => true, + 'length' => 128, + ]); + $table->addColumn('lock', 'integer', [ + 'notnull' => true, + 'default' => 0, + ]); + $table->addColumn('fs', 'integer', [ + 'notnull' => true, + 'default' => 0, + ]); + $table->setPrimaryKey(['id']); + $table->addUniqueIndex(['file_id'], 'file_id_index'); + } + + if (!$schema->hasTable('onlyoffice_permissions')) { + $table = $schema->createTable('onlyoffice_permissions'); + $table->addColumn('id', 'integer', [ + 'autoincrement' => true, + 'notnull' => true, + ]); + $table->addColumn('share_id', 'bigint', [ + 'notnull' => true, + 'default' => '-1', + ]); + $table->addColumn('permissions', 'integer', [ + 'notnull' => true, + 'default' => 0, + ]); + $table->setPrimaryKey(['id']); + $table->addUniqueIndex(['share_id'], 'share_id_index'); + } + + return $schema; + } + + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + */ + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { + } +} diff --git a/lib/appconfig.php b/lib/appconfig.php index 6897048..b3d0af4 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -117,6 +117,13 @@ class AppConfig { private $_preview = "preview"; /** + * The config key for the advanced + * + * @var string + */ + private $_advanced = "advanced"; + + /** * The config key for the keep versions history * * @var string @@ -659,6 +666,26 @@ class AppConfig { } /** + * Get advanced setting + * + * @return bool + */ + public function GetAdvanced() { + return $this->config->getAppValue($this->appName, $this->_advanced, "false") === "true"; + } + + /** + * Save advanced setting + * + * @param bool $value - advanced + */ + public function SetAdvanced($value) { + $this->logger->info("Set advanced: " . json_encode($value), ["app" => $this->appName]); + + $this->config->setAppValue($this->appName, $this->_advanced, json_encode($value)); + } + + /** * Get generate preview setting * * @return bool @@ -1160,8 +1187,8 @@ class AppConfig { "csv" => [ "mime" => "text/csv", "type" => "cell", "edit" => true, "editable" => true, "saveas" => ["ods", "pdf", "xlsx"] ], "doc" => [ "mime" => "application/msword", "type" => "word", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ], "docm" => [ "mime" => "application/vnd.ms-word.document.macroEnabled.12", "type" => "word", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ], - "docx" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "type" => "word", "edit" => true, "def" => true, "saveas" => ["odt", "pdf", "rtf", "txt", "docxf"] ], - "docxf" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf", "type" => "word", "edit" => true, "def" => true, "saveas" => ["odt", "pdf", "rtf", "txt"], "createForm" => true ], + "docx" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "type" => "word", "edit" => true, "def" => true, "review" => true, "comment" => true, "saveas" => ["odt", "pdf", "rtf", "txt", "docxf"] ], + "docxf" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf", "type" => "word", "edit" => true, "def" => true, "review" => true, "comment" => true, "saveas" => ["odt", "pdf", "rtf", "txt"], "createForm" => true ], "oform" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform", "type" => "word", "fillForms" => true, "def" => true ], "dot" => [ "type" => "word", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ], "dotx" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.template", "type" => "word", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ], @@ -1183,12 +1210,12 @@ class AppConfig { "ppsx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.slideshow", "type" => "slide", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ], "ppt" => [ "mime" => "application/vnd.ms-powerpoint", "type" => "slide", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ], "pptm" => [ "mime" => "application/vnd.ms-powerpoint.presentation.macroEnabled.12", "type" => "slide", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ], - "pptx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.presentation", "type" => "slide", "edit" => true, "def" => true, "saveas" => ["pdf", "odp"] ], + "pptx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.presentation", "type" => "slide", "edit" => true, "def" => true, "comment" => true, "saveas" => ["pdf", "odp"] ], "rtf" => [ "mime" => "text/rtf", "type" => "word", "conv" => true, "editable" => true, "saveas" => ["docx", "odt", "pdf", "txt"] ], "txt" => [ "mime" => "text/plain", "type" => "word", "edit" => true, "editable" => true, "saveas" => ["docx", "odt", "pdf", "rtf"] ], "xls" => [ "mime" => "application/vnd.ms-excel", "type" => "cell", "conv" => true, "saveas" => ["csv", "ods", "pdf", "xlsx"] ], "xlsm" => [ "mime" => "application/vnd.ms-excel.sheet.macroEnabled.12", "type" => "cell", "conv" => true, "saveas" => ["csv", "ods", "pdf", "xlsx"] ], - "xlsx" => [ "mime" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "type" => "cell", "edit" => true, "def" => true, "saveas" => ["csv", "ods", "pdf"] ], + "xlsx" => [ "mime" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "type" => "cell", "edit" => true, "def" => true, "comment" => true, "modifyFilter" => true, "saveas" => ["csv", "ods", "pdf"] ], "xlt" => [ "type" => "cell", "conv" => true, "saveas" => ["csv", "ods", "pdf", "xlsx"] ], "xltm" => [ "mime" => "application/vnd.ms-excel.template.macroEnabled.12", "type" => "cell", "conv" => true, "saveas" => ["csv", "ods", "pdf", "xlsx"] ], "xltx" => [ "mime" => "application/vnd.openxmlformats-officedocument.spreadsheetml.template", "type" => "cell", "conv" => true, "saveas" => ["csv", "ods", "pdf", "xlsx"] ] diff --git a/lib/extrapermissions.php b/lib/extrapermissions.php new file mode 100644 index 0000000..e98f37c --- /dev/null +++ b/lib/extrapermissions.php @@ -0,0 +1,426 @@ +<?php +/** + * + * (c) Copyright Ascensio System SIA 2022 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +namespace OCA\Onlyoffice; + +use OCP\Constants; +use OCP\ILogger; +use OCP\Files\File; +use OCP\Share\IShare; +use OCP\Share\IManager; +use OCP\Share\Exceptions\ShareNotFound; + +use OCA\Onlyoffice\AppConfig; + +/** + * Class expands base permissions + * + * @package OCA\Onlyoffice + */ +class ExtraPermissions { + + /** + * Application name + * + * @var string + */ + private $appName; + + /** + * Logger + * + * @var ILogger + */ + private $logger; + + /** + * Share manager + * + * @var IManager + */ + private $shareManager; + + /** + * Application configuration + * + * @var AppConfig + */ + private $config; + + /** + * Table name + */ + private const TableName_Key = "onlyoffice_permissions"; + + /** + * Extra permission values + * + * @var integer + */ + public const None = 0; + public const Review = 1; + public const Comment = 2; + public const FillForms = 4; + public const ModifyFilter = 8; + + /** + * @param string $AppName - application name + * @param ILogger $logger - logger + * @param AppConfig $config - application configuration + * @param IManager $shareManager - Share manager + */ + public function __construct($AppName, + ILogger $logger, + IManager $shareManager, + AppConfig $config) { + $this->appName = $AppName; + $this->logger = $logger; + $this->shareManager = $shareManager; + $this->config = $config; + } + + /** + * Get extra permissions by shareId + * + * @param integer $shareId - share identifier + * + * @return array + */ + public function getExtra($shareId) { + $share = $this->getShare($shareId); + if (empty($share)) { + return null; + } + + $shareId = $share->getId(); + $extra = self::get($shareId); + + $checkExtra = isset($extra["permissions"]) ? (int)$extra["permissions"] : self::None; + list($availableExtra, $defaultPermissions) = $this->validation($share, $checkExtra); + + if ($availableExtra === 0 + || ($availableExtra & $checkExtra) !== $checkExtra) { + if (!empty($extra)) { + self::delete($shareId); + } + + $this->logger->debug("Share " . $shareId . " does not support extra permissions", ["app" => $this->appName]); + return null; + } + + if (empty($extra)) { + $extra["id"] = -1; + $extra["share_id"] = $share->getId(); + $extra["permissions"] = $defaultPermissions; + } + + $extra["type"] = $share->getShareType(); + $extra["shareWith"] = $share->getSharedWith(); + $extra["shareWithName"] = $share->getSharedWithDisplayName(); + $extra["available"] = $availableExtra; + + return $extra; + } + + /** + * Get list extra permissions by shares + * + * @param array $shares - array of shares + * + * @return array + */ + public function getExtras($shares) { + $result = []; + + $shareIds = []; + foreach ($shares as $share) { + array_push($shareIds, $share->getId()); + } + + if (empty($shareIds)) { + return $result; + } + + $extras = self::getList($shareIds); + + $noActualList = []; + foreach ($shares as $share) { + + $currentExtra = []; + foreach ($extras as $extra) { + if ($extra["share_id"] === $share->getId()) { + $currentExtra = $extra; + } + } + + $checkExtra = isset($currentExtra["permissions"]) ? (int)$currentExtra["permissions"] : self::None; + list($availableExtra, $defaultPermissions) = $this->validation($share, $checkExtra); + + if ($availableExtra === 0 + || ($availableExtra & $checkExtra) !== $checkExtra) { + if (!empty($currentExtra)) { + array_push($noActualList, $share->getId()); + $currentExtra = []; + } + } + + if ($availableExtra > 0) { + if (empty($currentExtra)) { + $currentExtra["id"] = -1; + $currentExtra["share_id"] = $share->getId(); + $currentExtra["permissions"] = $defaultPermissions; + } + + $currentExtra["type"] = $share->getShareType(); + $currentExtra["shareWith"] = $share->getSharedWith(); + $currentExtra["shareWithName"] = $share->getSharedWithDisplayName(); + $currentExtra["available"] = $availableExtra; + + array_push($result, $currentExtra); + } + } + + if (!empty($noActualList)) { + self::deleteList($noActualList); + } + + return $result; + } + + /** + * Get extra permissions by share + * + * @param integer $shareId - share identifier + * @param integer $permissions - value extra permissions + * @param integer $extraId - extra permission identifier + * + * @return bool + */ + public function setExtra($shareId, $permissions, $extraId) { + $result = false; + + $share = $this->getShare($shareId); + if (empty($share)) { + return $result; + } + + list($availableExtra, $defaultPermissions) = $this->validation($share, $permissions); + if (($availableExtra & $permissions) !== $permissions) { + $this->logger->debug("Share " . $shareId . " does not available to extend permissions", ["app" => $this->appName]); + return $result; + } + + if ($extraId > 0) { + $result = self::update($share->getId(), $permissions); + } else { + $result = self::insert($share->getId(), $permissions); + } + + return $result; + } + + /** + * Delete extra permissions for share + * + * @param integer $shareId - file identifier + * + * @return bool + */ + public static function delete($shareId) { + $connection = \OC::$server->getDatabaseConnection(); + $delete = $connection->prepare(" + DELETE FROM `*PREFIX*" . self::TableName_Key . "` + WHERE `share_id` = ? + "); + return (bool)$delete->execute([$shareId]); + } + + /** + * Delete list extra permissions + * + * @param integer $shareIds - array of share identifiers + * + * @return bool + */ + public static function deleteList($shareIds) { + $connection = \OC::$server->getDatabaseConnection(); + + $condition = ""; + if (count($shareIds) > 1) { + for ($i = 1; $i < count($shareIds); $i++) { + $condition = $condition . " OR `share_id` = ?"; + } + } + + $delete = $connection->prepare(" + DELETE FROM `*PREFIX*" . self::TableName_Key . "` + WHERE `share_id` = ? + " . $condition); + return (bool)$delete->execute($shareIds); + } + + /** + * Get extra permissions for share + * + * @param integer $shareId - share identifier + * + * @return array + */ + private static function get($shareId) { + $connection = \OC::$server->getDatabaseConnection(); + $select = $connection->prepare(" + SELECT id, share_id, permissions + FROM `*PREFIX*" . self::TableName_Key . "` + WHERE `share_id` = ? + "); + $result = $select->execute([$shareId]); + + $values = $result ? $select->fetch() : []; + + return $values; + } + + /** + * Get list extra permissions + * + * @param array $shareIds - array of share identifiers + * + * @return array + */ + private static function getList($shareIds) { + $connection = \OC::$server->getDatabaseConnection(); + + $condition = ""; + if (count($shareIds) > 1) { + for ($i = 1; $i < count($shareIds); $i++) { + $condition = $condition . " OR `share_id` = ?"; + } + } + + $select = $connection->prepare(" + SELECT id, share_id, permissions + FROM `*PREFIX*" . self::TableName_Key . "` + WHERE `share_id` = ? + " . $condition); + + $result = $select->execute($shareIds); + + $values = $result ? $select->fetchAll() : []; + + return $values; + } + + /** + * Store extra permissions for share + * + * @param integer $shareId - share identifier + * @param integer $permissions - value permissions + * + * @return bool + */ + private static function insert($shareId, $permissions) { + $connection = \OC::$server->getDatabaseConnection(); + $insert = $connection->prepare(" + INSERT INTO `*PREFIX*" . self::TableName_Key . "` + (`share_id`, `permissions`) + VALUES (?, ?) + "); + return (bool)$insert->execute([$shareId, $permissions]); + } + + /** + * Update extra permissions for share + * + * @param integer $shareId - share identifier + * @param bool $permissions - value permissions + * + * @return bool + */ + private static function update($shareId, $permissions) { + $connection = \OC::$server->getDatabaseConnection(); + $update = $connection->prepare(" + UPDATE `*PREFIX*" . self::TableName_Key . "` + SET `permissions` = ? + WHERE `share_id` = ? + "); + return (bool)$update->execute([$permissions, $shareId]); + } + + /** + * Validation share on extend capability by extra permissions + * + * @param IShare $share - share + * @param int $checkExtra - checkable extra permissions + * + * @return array + */ + private function validation($share, $checkExtra) { + $availableExtra = self::None; + $defaultExtra = self::None; + + if (($share->getPermissions() & Constants::PERMISSION_SHARE) === Constants::PERMISSION_SHARE) { + return [$availableExtra, $defaultExtra]; + } + + $node = $share->getNode(); + $pathinfo = pathinfo($node->getName()); + $extension = $pathinfo["extension"]; + $format = $this->config->FormatsSetting()[$extension]; + + if (($share->getPermissions() & Constants::PERMISSION_UPDATE) === Constants::PERMISSION_UPDATE) { + if (isset($format["modifyFilter"]) && $format["modifyFilter"]) { + $availableExtra |= self::ModifyFilter; + $defaultExtra |= self::ModifyFilter; + } + } + if (($share->getPermissions() & Constants::PERMISSION_UPDATE) !== Constants::PERMISSION_UPDATE) { + if (isset($format["review"]) && $format["review"]) { + $availableExtra |= self::Review; + } + if (isset($format["comment"]) && $format["comment"] + && ($checkExtra & self::Review) !== self::Review) { + $availableExtra |= self::Comment; + } + if (isset($format["fillForms"]) && $format["fillForms"] + && ($checkExtra & self::Review) !== self::Review) { + $availableExtra |= self::FillForms; + } + } + + return [$availableExtra, $defaultExtra]; + } + + /** + * Get origin share + * + * @param integer $shareId - share identifier + * + * @return IShare + */ + private function getShare($shareId) { + try { + $share = $this->shareManager->getShareById("ocinternal:" . $shareId); + } catch (ShareNotFound $e) { + $this->logger->logException($e, ["message" => "getShare error", "app" => $this->appName]); + return null; + } + + return $share; + } +}
\ No newline at end of file diff --git a/lib/hooks.php b/lib/hooks.php index d063c83..6cf92c2 100644 --- a/lib/hooks.php +++ b/lib/hooks.php @@ -25,6 +25,7 @@ use OCP\Util; use OCA\Onlyoffice\FileVersions; use OCA\Onlyoffice\KeyManager; +use OCA\Onlyoffice\ExtraPermissions; /** * The class to handle the filesystem hooks @@ -55,6 +56,9 @@ class Hooks { // Listen file version restore Util::connectHook("\OCP\Versions", "rollback", Hooks::class, "fileVersionRestore"); + + // Listen share deletion + Util::connectHook("OCP\Share", "post_unshare", Hooks::class, "extraPermissionsDelete"); } /** @@ -194,4 +198,27 @@ class Hooks { \OC::$server->getLogger()->logException($e, ["message" => "Hook: fileVersionRestore " . json_encode($params), "app" => self::$appName]); } } + + /** + * Erase extra permissions of deleted share + * + * @param array $params - hook param + */ + public static function extraPermissionsDelete($params) { + $shares = $params["deletedShares"]; + if (empty($shares)) { + return; + } + + try { + $shareIds = []; + foreach ($shares as $share) { + array_push($shareIds, $share["id"]); + } + + ExtraPermissions::deleteList($shareIds); + } catch (\Exception $e) { + \OC::$server->getLogger()->logException($e, ["message" => "Hook: extraPermissionsDelete " . json_encode($params), "app" => self::$appName]); + } + } } diff --git a/lib/listeners/fileslistener.php b/lib/listeners/fileslistener.php index 042f4de..ccb07f0 100644 --- a/lib/listeners/fileslistener.php +++ b/lib/listeners/fileslistener.php @@ -63,6 +63,12 @@ class FilesListener implements IEventListener { Util::addScript("onlyoffice", "listener"); } + if ($this->appConfig->GetAdvanced() + && \OC::$server->getAppManager()->isInstalled("files_sharing")) { + Util::addScript("onlyoffice", "share"); + Util::addStyle("onlyoffice", "share"); + } + Util::addStyle("onlyoffice", "main"); Util::addStyle("onlyoffice", "template"); } diff --git a/templates/settings.php b/templates/settings.php index 75913f4..fd9d0d8 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -114,6 +114,12 @@ </p> <p> + <input type="checkbox" class="checkbox" id="onlyofficeAdvanced" + <?php if ($_["advanced"]) { ?>checked="checked"<?php } ?> /> + <label for="onlyofficeAdvanced"><?php p($l->t("Provide advanced document permissions using ONLYOFFICE Docs")) ?></label> + </p> + + <p> <input type="checkbox" class="checkbox" id="onlyofficeVersionHistory" <?php if ($_["versionHistory"]) { ?>checked="checked"<?php } ?> /> <label for="onlyofficeVersionHistory"><?php p($l->t("Keep metadata for each version once the document is edited (it will take up disk space)")) ?></label> diff --git a/templates/share.html b/templates/share.html new file mode 100644 index 0000000..cde8a27 --- /dev/null +++ b/templates/share.html @@ -0,0 +1,9 @@ +<li id="-1" class="onlyoffice-share-item"> + <div class="avatardiv popovermenu-wrapper"> + <img src="" /> + </div> + <span></span> + <div id="onlyoffice-share-menu"> + <button id="onlyoffice-share-action" class="icon-more"></button> + </div> +</li>
\ No newline at end of file |