diff --git a/CHANGELOG.md b/CHANGELOG.md index ca05a151..5b7ad5b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## 2.1.3 +## Added +- restricting access for groups +- goback from editor to shared folder by link + +## Changed +- using notification methods + ## 2.1.1 ## Added - Swedish translation diff --git a/appinfo/application.php b/appinfo/application.php index 6a4b130f..6b4a0240 100644 --- a/appinfo/application.php +++ b/appinfo/application.php @@ -68,7 +68,9 @@ public function __construct(array $urlParams = []) { $eventDispatcher = \OC::$server->getEventDispatcher(); $eventDispatcher->addListener("OCA\Files::loadAdditionalScripts", function() { - if (!empty($this->appConfig->GetDocumentServerUrl()) && $this->appConfig->SettingsAreSuccessful()) { + if (!empty($this->appConfig->GetDocumentServerUrl()) + && $this->appConfig->SettingsAreSuccessful() + && $this->appConfig->isUserAllowedToUse()) { Util::addScript("onlyoffice", "desktop"); Util::addScript("onlyoffice", "main"); Util::addStyle("onlyoffice", "main"); diff --git a/appinfo/info.xml b/appinfo/info.xml index 5d3368e0..bc65bc10 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -7,7 +7,7 @@ ONLYOFFICE connector enables you to edit Office documents within ONLYOFFICE from the familiar web interface. This will create a new Open in ONLYOFFICE action within the document library for Office documents. This allows multiple users to collaborate in real time and to save back those changes to your file storage. agpl Ascensio System SIA - 2.1.1 + 2.1.3 Onlyoffice @@ -26,6 +26,6 @@ https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-owncloud/master/screenshots/new.png https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-owncloud/master/screenshots/open.png - + \ No newline at end of file diff --git a/controller/callbackcontroller.php b/controller/callbackcontroller.php index b20d2446..05f8e300 100644 --- a/controller/callbackcontroller.php +++ b/controller/callbackcontroller.php @@ -301,7 +301,9 @@ public function emptyfile($doc) { * @param string $doc - verification token with the file identifier * @param array $users - the list of the identifiers of the users * @param string $key - the edited document identifier + * @param integer $status - the edited status * @param string $url - the link to the edited document to be saved + * @param string $token - access token * * @return array * @@ -449,7 +451,7 @@ public function track($doc, $users, $key, $status, $url, $token) { /** * Getting file by identifier * - * @param integer $userId - user identifier + * @param string $userId - user identifier * @param integer $fileId - file identifier * * @return array diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index 2563e562..dcc85dd4 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -180,6 +180,10 @@ public function __construct($AppName, public function create($name, $dir) { $this->logger->debug("Create: " . $name, array("app" => $this->appName)); + if (!$this->config->isUserAllowedToUse()) { + return ["error" => $this->trans->t("Not permitted")]; + } + $userId = $this->userSession->getUser()->getUID(); $userFolder = $this->root->getUserFolder($userId); $folder = $userFolder->get($dir); @@ -228,6 +232,14 @@ public function create($name, $dir) { return $result; } + /** + * Get template path + * + * @param string $lang - language + * @param string $ext - file extension + * + * @return string + */ private function getTemplatePath($lang, $ext) { return dirname(__DIR__) . DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . $lang . DIRECTORY_SEPARATOR . "new" . $ext; } @@ -244,6 +256,10 @@ private function getTemplatePath($lang, $ext) { public function convert($fileId) { $this->logger->debug("Convert: " . $fileId, array("app" => $this->appName)); + if (!$this->config->isUserAllowedToUse()) { + return ["error" => $this->trans->t("Not permitted")]; + } + $userId = $this->userSession->getUser()->getUID(); list ($file, $error) = $this->getFile($userId, $fileId); @@ -342,11 +358,15 @@ public function index($fileId, $token = NULL) { return new RedirectResponse($redirectUrl); } + if (empty($token) && !$this->config->isUserAllowedToUse()) { + return $this->renderError($this->trans->t("Not permitted")); + } + $documentServerUrl = $this->config->GetDocumentServerUrl(); if (empty($documentServerUrl)) { $this->logger->error("documentServerUrl is empty", array("app" => $this->appName)); - return ["error" => $this->trans->t("ONLYOFFICE app is not configured. Please contact admin")]; + return $this->renderError($this->trans->t("ONLYOFFICE app is not configured. Please contact admin")); } $params = [ @@ -374,6 +394,7 @@ public function index($fileId, $token = NULL) { /** * Print public editor section * + * @param integer $fileId - file identifier * @param string $token - access token * * @return TemplateResponse @@ -391,6 +412,7 @@ public function PublicPage($fileId, $token) { * * @param integer $fileId - file identifier * @param string $token - access token + * @param bool $desktop - desktop label * * @return array * @@ -399,13 +421,17 @@ public function PublicPage($fileId, $token) { */ public function config($fileId, $token = NULL, $desktop = false) { + if (empty($token) && !$this->config->isUserAllowedToUse()) { + return ["error" => $this->trans->t("Not permitted")]; + } + $user = $this->userSession->getUser(); $userId = NULL; if (!empty($user)) { $userId = $user->getUID(); } - list ($file, $error) = empty($token) ? $this->getFile($userId, $fileId) : $this->getFileByToken($fileId, $token); + list ($file, $error, $share) = empty($token) ? $this->getFile($userId, $fileId) : $this->getFileByToken($fileId, $token); if (isset($error)) { $this->logger->error("Config: " . $fileId . " " . $error, array("app" => $this->appName)); @@ -443,7 +469,7 @@ public function config($fileId, $token = NULL, $desktop = false) { $canEdit = isset($format["edit"]) && $format["edit"]; $editable = $file->isUpdateable() - && (empty($token) || ($this->getShare($token)[0]->getPermissions() & Constants::PERMISSION_UPDATE) === Constants::PERMISSION_UPDATE); + && (empty($token) || ($share->getPermissions() & Constants::PERMISSION_UPDATE) === Constants::PERMISSION_UPDATE); if ($editable && $canEdit) { $ownerId = NULL; $owner = $file->getOwner(); @@ -468,21 +494,40 @@ public function config($fileId, $token = NULL, $desktop = false) { "id" => $userId, "name" => $user->getDisplayName() ]; + } + + $folderLink = NULL; + if (!empty($token)) { + $node = $share->getNode(); + if ($node instanceof Folder) { + $sharedFolder = $node; + $folderPath = $sharedFolder->getRelativePath($file->getParent()->getPath()); + if (!empty($folderPath)) { + $linkAttr = [ + "path" => $folderPath, + "scrollto" => $file->getName(), + "token" => $token + ]; + $folderLink = $this->urlGenerator->linkToRouteAbsolute("files_sharing.sharecontroller.showShare", $linkAttr); + } + } + } else if (!empty($userId)) { $userFolder = $this->root->getUserFolder($userId); $folderPath = $userFolder->getRelativePath($file->getParent()->getPath()); - $linkAttr = NULL; if (!empty($folderPath)) { $linkAttr = [ "dir" => $folderPath, "scrollto" => $file->getName() ]; $folderLink = $this->urlGenerator->linkToRouteAbsolute("files.view.index", $linkAttr); - - $params["editorConfig"]["customization"]["goback"] = [ - "url" => $folderLink - ]; } + } + + if ($folderLink !== NULL) { + $params["editorConfig"]["customization"]["goback"] = [ + "url" => $folderLink + ]; if (!$desktop) { if ($this->config->GetSameTab()) { @@ -506,7 +551,7 @@ public function config($fileId, $token = NULL, $desktop = false) { /** * Getting file by identifier * - * @param integer $userId - user identifier + * @param string $userId - user identifier * @param integer $fileId - file identifier * * @return array @@ -566,7 +611,7 @@ private function getFileByToken($fileId, $token) { $file = $node; } - return [$file, NULL]; + return [$file, NULL, $share]; } /** @@ -681,4 +726,21 @@ private function setCustomization($params) { return $params; } + + /** + * Print error page + * + * @param string $error - error message + * @param string $hint - error hint + * + * @return TemplateResponse + */ + private function renderError($error, $hint = "") { + return new TemplateResponse("", "error", array( + "errors" => array(array( + "error" => $error, + "hint" => $hint + )) + ), "error"); + } } \ No newline at end of file diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php index e0aabfc4..269e1f56 100644 --- a/controller/settingscontroller.php +++ b/controller/settingscontroller.php @@ -121,7 +121,8 @@ public function index() { "currentServer" => $this->urlGenerator->getAbsoluteURL("/"), "formats" => $this->config->FormatsSetting(), "sameTab" => $this->config->GetSameTab(), - "encryption" => $this->checkEncryptionModule() + "encryption" => $this->checkEncryptionModule(), + "limitGroups" => $this->config->GetLimitGroups() ]; return new TemplateResponse($this->appName, "settings", $data, "blank"); } @@ -133,7 +134,10 @@ public function index() { * @param string $documentserverInternal - document service address available from ownCloud * @param string $storageUrl - ownCloud address available from document server * @param string $secret - secret key for signature - * @param string $defFormats - formats array with default action + * @param array $defFormats - formats array with default action + * @param array $editFormats - editable formats array + * @param bool $sameTab - open in same tab + * @param array $limitGroups - list of groups * * @return array */ @@ -143,7 +147,8 @@ public function SaveSettings($documentserver, $secret, $defFormats, $editFormats, - $sameTab + $sameTab, + $limitGroups ) { $this->config->SetDocumentServerUrl($documentserver); $this->config->SetDocumentServerInternalUrl($documentserverInternal); @@ -161,6 +166,7 @@ public function SaveSettings($documentserver, $this->config->SetDefaultFormats($defFormats); $this->config->SetEditableFormats($editFormats); $this->config->SetSameTab($sameTab); + $this->config->SetLimitGroups($limitGroups); if ($this->checkEncryptionModule()) { $this->logger->info("SaveSettings when encryption is enabled", array("app" => $this->appName)); @@ -195,8 +201,6 @@ public function GetSettings() { /** * Checking document service location * - * @param string $documentServer - document service address - * * @return string */ private function checkDocServiceUrl() { @@ -280,6 +284,8 @@ private function checkDocServiceUrl() { /** * Checking encryption enabled + * + * @return bool */ private function checkEncryptionModule() { if (!App::isEnabled("encryption")) { diff --git a/css/editor.css b/css/editor.css index 436f7fe7..d8171672 100644 --- a/css/editor.css +++ b/css/editor.css @@ -30,9 +30,6 @@ position: absolute; vertical-align: top; } -#iframeEditor.error { - color: red; -} .AscDesktopEditor #header { display: none; @@ -40,4 +37,3 @@ .AscDesktopEditor #content-wrapper { padding-top: 0; } - diff --git a/js/editor.js b/js/editor.js index 8a01b1c3..51bd5f8d 100644 --- a/js/editor.js +++ b/js/editor.js @@ -34,7 +34,9 @@ OCA.Onlyoffice.InitEditor = function () { var displayError = function (error) { - $("#iframeEditor").text(error).addClass("error"); + OC.Notification.show(error, { + type: "error" + }); }; var fileId = $("#iframeEditor").data("id"); diff --git a/js/main.js b/js/main.js index 6f235c17..b663d0ee 100644 --- a/js/main.js +++ b/js/main.js @@ -55,20 +55,19 @@ if (winEditor) { winEditor.close(); } - var row = OC.Notification.show(response.error); - setTimeout(function () { - OC.Notification.hide(row); - }, 3000); + OC.Notification.show(response.error, { + type: "error", + timeout: 3 + }); return; } fileList.add(response, { animate: true }); OCA.Onlyoffice.OpenEditor(response.id, winEditor); - var row = OC.Notification.show(t(OCA.Onlyoffice.AppName, "File created")); - setTimeout(function () { - OC.Notification.hide(row); - }, 3000); + OC.Notification.show(t(OCA.Onlyoffice.AppName, "File created"), { + timeout: 3 + }); } ); }; @@ -107,10 +106,10 @@ }, function onSuccess(response) { if (response.error) { - var row = OC.Notification.show(response.error); - setTimeout(function () { - OC.Notification.hide(row); - }, 3000); + OC.Notification.show(response.error, { + type: "error", + timeout: 3 + }); return; } @@ -118,10 +117,9 @@ fileList.add(response, { animate: true }); } - var row = OC.Notification.show(t(OCA.Onlyoffice.AppName, "File created")); - setTimeout(function () { - OC.Notification.hide(row); - }, 3000); + OC.Notification.show(t(OCA.Onlyoffice.AppName, "File created"), { + timeout: 3 + }); }); }; diff --git a/js/settings.js b/js/settings.js index 4c51540d..33561dd2 100644 --- a/js/settings.js +++ b/js/settings.js @@ -50,6 +50,20 @@ advToogle(); }); + $("#onlyofficeGroups").prop("checked", $("#onlyofficeLimitGroups").val() != ""); + + var groupListToggle = function() { + if ($("#onlyofficeGroups").prop("checked")) { + OC.Settings.setupGroupsSelect($("#onlyofficeLimitGroups")); + } else { + $("#onlyofficeLimitGroups").select2("destroy"); + } + }; + + $("#onlyofficeGroups").click(groupListToggle); + groupListToggle(); + + $("#onlyofficeSave").click(function () { $(".section-onlyoffice").addClass("icon-loading"); var onlyofficeUrl = $("#onlyofficeUrl").val().trim(); @@ -74,6 +88,9 @@ var sameTab = $("#onlyofficeSameTab").is(":checked"); + var limitGroupsString = $("#onlyofficeGroups").prop("checked") ? $("#onlyofficeLimitGroups").val() : ""; + var limitGroups = limitGroupsString ? limitGroupsString.split("|") : []; + $.ajax({ method: "PUT", url: OC.generateUrl("apps/onlyoffice/ajax/settings"), @@ -84,7 +101,8 @@ secret: onlyofficeSecret, defFormats: defFormats, editFormats: editFormats, - sameTab: sameTab + sameTab: sameTab, + limitGroups: limitGroups }, success: function onSuccess(response) { $(".section-onlyoffice").removeClass("icon-loading"); @@ -98,10 +116,10 @@ response.error ? (t(OCA.Onlyoffice.AppName, "Error when trying to connect") + " (" + response.error + ")") : t(OCA.Onlyoffice.AppName, "Settings have been successfully updated"); - var row = OC.Notification.show(message); - setTimeout(function () { - OC.Notification.hide(row); - }, 3000); + OC.Notification.show(message, { + type: "error", + timeout: 3 + }); } } }); diff --git a/l10n/de.js b/l10n/de.js index fa9dac99..2a8b3aa6 100644 --- a/l10n/de.js +++ b/l10n/de.js @@ -45,6 +45,7 @@ OC.L10N.register( "Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Öffne die Datei zum Bearbeiten (aufgrund von Formateinschränkungen können die Daten beim Speichern in den Formaten aus der folgenden Liste verloren gehen)", "View details" : "Details anzeigen", "Save" : "Speichern", - "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Mixed Active Content ist nicht möglich. HTTPS-Adresse für Document Server ist erforderlich." + "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Mixed Active Content ist nicht möglich. HTTPS-Adresse für Document Server ist erforderlich.", + "Restrict access to editors to following groups" : "Den Zugriff auf Editoren auf folgende Gruppen gewähren" }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/de.json b/l10n/de.json index c65ca0bc..eab65102 100644 --- a/l10n/de.json +++ b/l10n/de.json @@ -43,6 +43,7 @@ "Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Öffne die Datei zum Bearbeiten (aufgrund von Formateinschränkungen können die Daten beim Speichern in den Formaten aus der folgenden Liste verloren gehen)", "View details" : "Details anzeigen", "Save" : "Speichern", - "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Mixed Active Content ist nicht möglich. HTTPS-Adresse für Document Server ist erforderlich." + "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Mixed Active Content ist nicht möglich. HTTPS-Adresse für Document Server ist erforderlich.", + "Restrict access to editors to following groups" : "Den Zugriff auf Editoren auf folgende Gruppen gewähren" },"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 39625bae..b4a1c223 100644 --- a/l10n/de_DE.js +++ b/l10n/de_DE.js @@ -45,6 +45,7 @@ OC.L10N.register( "Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Öffnen Sie die Datei zum Bearbeiten (aufgrund von Formateinschränkungen können die Daten beim Speichern in den Formaten aus der folgenden Liste verloren gehen)", "View details" : "Details anzeigen", "Save" : "Speichern", - "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Mixed Active Content ist nicht möglich. HTTPS-Adresse für Document Server ist erforderlich." + "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Mixed Active Content ist nicht möglich. HTTPS-Adresse für Document Server ist erforderlich.", + "Restrict access to editors to following groups" : "Den Zugriff auf Editoren auf folgende Gruppen gewähren" }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/de_DE.json b/l10n/de_DE.json index c069023b..144529c3 100644 --- a/l10n/de_DE.json +++ b/l10n/de_DE.json @@ -43,6 +43,7 @@ "Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Öffnen Sie die Datei zum Bearbeiten (aufgrund von Formateinschränkungen können die Daten beim Speichern in den Formaten aus der folgenden Liste verloren gehen)", "View details" : "Details anzeigen", "Save" : "Speichern", - "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Mixed Active Content ist nicht möglich. HTTPS-Adresse für Document Server ist erforderlich." + "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Mixed Active Content ist nicht möglich. HTTPS-Adresse für Document Server ist erforderlich.", + "Restrict access to editors to following groups" : "Den Zugriff auf Editoren auf folgende Gruppen gewähren" },"pluralForm" :"nplurals=2; plural=(n != 1);" } \ No newline at end of file diff --git a/l10n/es.js b/l10n/es.js index 0c60054c..6440bd9e 100644 --- a/l10n/es.js +++ b/l10n/es.js @@ -45,6 +45,7 @@ OC.L10N.register( "Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Abrir archivo para editar (debido a las restricciones de formato los datos podrían perderse al guardar en los formatos de la siguiente lista)", "View details" : "Ver detalles", "Save" : "Guardar", - "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Contenido Mixto Activo no está permitido. Se requiere la dirección HTTPS para Servidor de Documentos." + "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Contenido Mixto Activo no está permitido. Se requiere la dirección HTTPS para Servidor de Documentos.", + "Restrict access to editors to following groups" : "Restringir el acceso a editores a siguientes grupos" }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/es.json b/l10n/es.json index b7cfa505..920d4c5c 100644 --- a/l10n/es.json +++ b/l10n/es.json @@ -43,6 +43,7 @@ "Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Abrir archivo para editar (debido a las restricciones de formato los datos podrían perderse al guardar en los formatos de la siguiente lista)", "View details" : "Ver detalles", "Save" : "Guardar", - "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Contenido Mixto Activo no está permitido. Se requiere la dirección HTTPS para Servidor de Documentos." + "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Contenido Mixto Activo no está permitido. Se requiere la dirección HTTPS para Servidor de Documentos.", + "Restrict access to editors to following groups" : "Restringir el acceso a editores a siguientes grupos" },"pluralForm" :"nplurals=2; plural=(n != 1);" } \ No newline at end of file diff --git a/l10n/fr.js b/l10n/fr.js index d6906653..e4d0b905 100644 --- a/l10n/fr.js +++ b/l10n/fr.js @@ -45,6 +45,7 @@ OC.L10N.register( "Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Ouvrir le fichier pour édition (en raison de restrictions de format, des données peuvent être perdues lors de l'enregistrement dans les formats de la liste ci-dessous)", "View details" : "Voir les détails", "Save" : "Enregistrer", - "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Le contenu mixte actif n'est pas autorisé. Une adresse HTTPS pour le serveur de document est requise" + "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Le contenu mixte actif n'est pas autorisé. Une adresse HTTPS pour le serveur de document est requise", + "Restrict access to editors to following groups" : "Restreindre l'accès aux éditeurs pour les groupes suivants" }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/fr.json b/l10n/fr.json index 7d7871fe..26e25872 100644 --- a/l10n/fr.json +++ b/l10n/fr.json @@ -43,6 +43,7 @@ "Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Ouvrir le fichier pour édition (en raison de restrictions de format, des données peuvent être perdues lors de l'enregistrement dans les formats de la liste ci-dessous)", "View details" : "Voir les détails", "Save" : "Enregistrer", - "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Le contenu mixte actif n'est pas autorisé. Une adresse HTTPS pour le serveur de document est requise" + "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Le contenu mixte actif n'est pas autorisé. Une adresse HTTPS pour le serveur de document est requise", + "Restrict access to editors to following groups" : "Restreindre l'accès aux éditeurs pour les groupes suivants" },"pluralForm" :"nplurals=2; plural=(n != 1);" } diff --git a/l10n/pt_BR.js b/l10n/pt_BR.js index c5ac35e0..da6f02a4 100644 --- a/l10n/pt_BR.js +++ b/l10n/pt_BR.js @@ -45,6 +45,7 @@ OC.L10N.register( "Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Habilitar edição (devido à restrição dos formatos, dados podem ser perdidos ao salvar nos formatos abaixo)", "View details" : "Ver detalhes", "Save" : "Salvar", - "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Conteúdo Misto não é permitido. É necessário um endereço HTTPS para o Servidor de Documentos." + "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Conteúdo Misto não é permitido. É necessário um endereço HTTPS para o Servidor de Documentos.", + "Restrict access to editors to following groups" : "Acesso apenas para os seguintes grupos" }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/pt_BR.json b/l10n/pt_BR.json index 779c3c51..d49db3de 100644 --- a/l10n/pt_BR.json +++ b/l10n/pt_BR.json @@ -43,6 +43,7 @@ "Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Habilitar edição (devido à restrição dos formatos, dados podem ser perdidos ao salvar nos formatos abaixo)", "View details" : "Ver detalhes", "Save" : "Salvar", - "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Conteúdo Misto não é permitido. É necessário um endereço HTTPS para o Servidor de Documentos." + "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Conteúdo Misto não é permitido. É necessário um endereço HTTPS para o Servidor de Documentos.", + "Restrict access to editors to following groups" : "Acesso apenas para os seguintes grupos" },"pluralForm" :"nplurals=2; plural=(n != 1);" } diff --git a/l10n/ru.js b/l10n/ru.js index 9ba1ec69..1a2702b7 100644 --- a/l10n/ru.js +++ b/l10n/ru.js @@ -45,6 +45,7 @@ OC.L10N.register( "Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Открыть файл на редактирование (из-за ограничений формата данные могут быть утеряны при сохранении в форматы из списка ниже)", "View details" : "Подробнее", "Save" : "Сохранить", - "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Смешанное активное содержимое запрещено. Для Сервера документов необходимо использовать HTTPS-адрес." + "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Смешанное активное содержимое запрещено. Для Сервера документов необходимо использовать HTTPS-адрес.", + "Restrict access to editors to following groups" : "Дать доступ к редакторам только следующим группам" }, "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);"); diff --git a/l10n/ru.json b/l10n/ru.json index a9237025..92fc5edf 100644 --- a/l10n/ru.json +++ b/l10n/ru.json @@ -43,6 +43,7 @@ "Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Открыть файл на редактирование (из-за ограничений формата данные могут быть утеряны при сохранении в форматы из списка ниже)", "View details" : "Подробнее", "Save" : "Сохранить", - "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Смешанное активное содержимое запрещено. Для Сервера документов необходимо использовать HTTPS-адрес." + "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Смешанное активное содержимое запрещено. Для Сервера документов необходимо использовать HTTPS-адрес.", + "Restrict access to editors to following groups" : "Дать доступ к редакторам только следующим группам" },"pluralForm" :"nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);" } \ No newline at end of file diff --git a/l10n/sv.js b/l10n/sv.js index c420728e..0bc18e45 100644 --- a/l10n/sv.js +++ b/l10n/sv.js @@ -45,6 +45,7 @@ OC.L10N.register( "Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Öppna filen för redigering (på grund av formatrestriktioner kan data gå förlorade när du sparar i format från listan nedan)", "View details" : "Visa detaljer", "Save" : "Spara", - "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Blandat aktivt innehåll är inte tillåtet. HTTPS-adress till dokumentserver krävs." + "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Blandat aktivt innehåll är inte tillåtet. HTTPS-adress till dokumentserver krävs.", + "Restrict access to editors to following groups" : "Begränsa åtkomst till följande grupper" }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/sv.json b/l10n/sv.json index 35376be5..afe8f4f0 100644 --- a/l10n/sv.json +++ b/l10n/sv.json @@ -43,6 +43,7 @@ "Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "Öppna filen för redigering (på grund av formatrestriktioner kan data gå förlorade när du sparar i format från listan nedan)", "View details" : "Visa detaljer", "Save" : "Spara", - "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Blandat aktivt innehåll är inte tillåtet. HTTPS-adress till dokumentserver krävs." + "Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Blandat aktivt innehåll är inte tillåtet. HTTPS-adress till dokumentserver krävs.", + "Restrict access to editors to following groups" : "Begränsa åtkomst till följande grupper" },"pluralForm" :"nplurals=2; plural=(n != 1);" } \ No newline at end of file diff --git a/lib/appconfig.php b/lib/appconfig.php index 68de0f56..9ef88e00 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -109,6 +109,13 @@ class AppConfig { */ private $_sameTab = "sameTab"; + /** + * The config key for the setting limit groups + * + * @var string + */ + private $_groups = "groups"; + /** * The config key for the verification * @@ -187,7 +194,7 @@ public function __construct($AppName) { * Get value from the system configuration * * @param string $key - key configuration - * @param string $system - get from root or from app section + * @param bool $system - get from root or from app section * * @return string */ @@ -208,7 +215,7 @@ public function GetSystemValue($key, $system = false) { * @param string $documentServer - document service address */ public function SetDocumentServerUrl($documentServer) { - $documentServer = strtolower(trim($documentServer)); + $documentServer = trim($documentServer); if (strlen($documentServer) > 0) { $documentServer = rtrim($documentServer, "/") . "/"; if (!preg_match("/(^https?:\/\/)|^\//i", $documentServer)) { @@ -246,7 +253,7 @@ public function GetDocumentServerUrl() { * @param string $documentServer - document service address */ public function SetDocumentServerInternalUrl($documentServerInternal) { - $documentServerInternal = strtolower(rtrim(trim($documentServerInternal), "/")); + $documentServerInternal = rtrim(trim($documentServerInternal), "/"); if (strlen($documentServerInternal) > 0) { $documentServerInternal = $documentServerInternal . "/"; if (!preg_match("/^https?:\/\//i", $documentServerInternal)) { @@ -262,6 +269,8 @@ public function SetDocumentServerInternalUrl($documentServerInternal) { /** * Get the document service address available from ownCloud from the application configuration * + * @param bool $origin - take origin + * * @return string */ public function GetDocumentServerInternalUrl($origin) { @@ -281,7 +290,7 @@ public function GetDocumentServerInternalUrl($origin) { * @param string $documentServer - document service address */ public function SetStorageUrl($storageUrl) { - $storageUrl = strtolower(rtrim(trim($storageUrl), "/")); + $storageUrl = rtrim(trim($storageUrl), "/"); if (strlen($storageUrl) > 0) { $storageUrl = $storageUrl . "/"; if (!preg_match("/^https?:\/\//i", $storageUrl)) { @@ -409,27 +418,87 @@ private function GetEditableFormats() { /** * Save the opening setting in a same tab * - * @param boolean $value - same tab + * @param bool $value - same tab */ public function SetSameTab($value) { - $this->logger->info("Set opening in a same tab: " . $value, array("app" => $this->appName)); + $this->logger->info("Set opening in a same tab: " . json_encode($value), array("app" => $this->appName)); - $this->config->setAppValue($this->appName, $this->_sameTab, $value); + $this->config->setAppValue($this->appName, $this->_sameTab, json_encode($value)); } /** * Get the opening setting in a same tab * - * @return boolean + * @return bool */ public function GetSameTab() { return $this->config->getAppValue($this->appName, $this->_sameTab, "false") === "true"; } + /** + * Save the list of groups + * + * @param array $value - same tab + */ + public function SetLimitGroups($groups) { + $value = json_encode($groups); + $this->logger->info("Set groups: " . $value, array("app" => $this->appName)); + + $this->config->setAppValue($this->appName, $this->_groups, $value); + } + + /** + * Get the list of groups + * + * @return array + */ + public function GetLimitGroups() { + $value = $this->config->getAppValue($this->appName, $this->_groups, ""); + if (empty($value)) { + return array(); + } + return json_decode($value, true); + } + + /** + * Check access for group + * + * @return bool + */ + public function isUserAllowedToUse() { + // no user -> no + $userSession = \OC::$server->getUserSession(); + if ($userSession === null || !$userSession->isLoggedIn()) { + return false; + } + + $groups = $this->GetLimitGroups(); + // no group set -> all users are allowed + if (count($groups) === 0) { + return true; + } + + $user = $userSession->getUser(); + + foreach ($groups as $groupName) { + // group unknown -> error and allow nobody + $group = \OC::$server->getGroupManager()->get($groupName); + if ($group === null) { + \OC::$server->getLogger()->error("Group is unknown " . $groupName, ["app" => $this->appName]); + } else { + if ($group->inGroup($user)) { + return true; + } + } + } + + return false; + } + /** * Get the turn off verification setting * - * @return boolean + * @return bool */ public function TurnOffVerification() { $turnOff = $this->getSystemValue($this->_verification); @@ -439,7 +508,7 @@ public function TurnOffVerification() { /** * Get the jwt header setting * - * @return boolean + * @return string */ public function JwtHeader() { $header = $this->getSystemValue($this->_jwtHeader); @@ -452,7 +521,7 @@ public function JwtHeader() { /** * Save the status settings * - * @param boolean $value - error + * @param string $value - error */ public function SetSettingsError($value) { $this->config->setAppValue($this->appName, $this->_settingsError, $value); @@ -461,7 +530,7 @@ public function SetSettingsError($value) { /** * Get the status settings * - * @return boolean + * @return bool */ public function SettingsAreSuccessful() { return empty($this->config->getAppValue($this->appName, $this->_settingsError, "")); diff --git a/lib/documentservice.php b/lib/documentservice.php index 464394dc..8818d19f 100644 --- a/lib/documentservice.php +++ b/lib/documentservice.php @@ -253,7 +253,7 @@ function ProcessConvServResponceError($errorCode) { /** * Request health status * - * @return boolean + * @return bool */ function HealthcheckRequest() { diff --git a/templates/settings.php b/templates/settings.php index 20dffaa7..c2eaaf1c 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -59,6 +59,16 @@
+

+ 0) { ?>checked="checked" /> + +
+ " + style="display: block; margin-top: 6px; width: 265px;" /> +

+
+

checked="checked" />