diff --git a/css/admin.scss b/css/admin.scss index 0d2a579709..e3288991dd 100644 --- a/css/admin.scss +++ b/css/admin.scss @@ -27,6 +27,10 @@ input#zoteroAPIKeyField { width: 300px; } +textarea#documentSigningCaField { + width: 600px; +} + #richdocuments, #richdocuments-templates { // inline buttons on section headers diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index d2eebe3a57..e4af5ca6cd 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -235,7 +235,8 @@ public function updateWatermarkSettings($settings = []): JSONResponse { * @return JSONResponse */ public function setPersonalSettings($templateFolder, - $zoteroAPIKeyInput) { + $zoteroAPIKeyInput, + $documentSigningCaInput) { $message = $this->l10n->t('Saved'); $status = 'success'; @@ -256,6 +257,15 @@ public function setPersonalSettings($templateFolder, } } + if ($documentSigningCaInput !== null) { + try { + $this->config->setUserValue($this->userId, 'richdocuments', 'documentSigningCa', $documentSigningCaInput); + } catch (PreConditionNotMetException $e) { + $message = $this->l10n->t('Error when saving'); + $status = 'error'; + } + } + $response = [ 'status' => $status, 'data' => ['message' => $message] diff --git a/lib/Service/CapabilitiesService.php b/lib/Service/CapabilitiesService.php index e15cc7a660..a97c7a234b 100644 --- a/lib/Service/CapabilitiesService.php +++ b/lib/Service/CapabilitiesService.php @@ -85,6 +85,10 @@ public function hasWASMSupport(): bool { return $this->getCapabilities()['hasWASMSupport'] ?? false; } + public function hasDocumentSigningSupport(): bool { + return $this->getCapabilities()['hasDocumentSigningSupport'] ?? false; + } + public function hasFormFilling(): bool { return $this->isVersionAtLeast('24.04.5.2'); } diff --git a/lib/Settings/Personal.php b/lib/Settings/Personal.php index 03c544597c..352b89ab73 100644 --- a/lib/Settings/Personal.php +++ b/lib/Settings/Personal.php @@ -45,6 +45,8 @@ public function getForm() { 'personal', [ 'templateFolder' => $this->config->getUserValue($this->userId, 'richdocuments', 'templateFolder', ''), + 'hasDocumentSigningSupport' => $this->capabilitiesService->hasDocumentSigningSupport(), + 'documentSigningCa' => $this->config->getUserValue($this->userId, 'richdocuments', 'documentSigningCa', ''), 'hasZoteroSupport' => $this->capabilitiesService->hasZoteroSupport(), 'zoteroAPIKey' => $this->config->getUserValue($this->userId, 'richdocuments', 'zoteroAPIKey', '') ], diff --git a/src/personal.js b/src/personal.js index bbff0019ae..28e5bcaf16 100644 --- a/src/personal.js +++ b/src/personal.js @@ -17,6 +17,10 @@ import { showError } from '@nextcloud/dialogs' this.zoteroAPIKeySaveButton = document.getElementById('zoteroAPIKeySave') this.zoteroAPIKeyRemoveButton = document.getElementById('zoteroAPIKeyRemove') + this.documentSigningCaInput = document.getElementById('documentSigningCaField') + this.documentSigningCaSaveButton = document.getElementById('documentSigningCaSave') + this.documentSigningCaRemoveButton = document.getElementById('documentSigningCaRemove') + const self = this this.templateSelectButton.addEventListener('click', function() { OC.dialogs.filepicker(t('richdocuments', 'Select a personal template folder'), function(datapath, returntype) { @@ -31,6 +35,12 @@ import { showError } from '@nextcloud/dialogs' }) this.zoteroAPIKeyRemoveButton.addEventListener('click', this.resetZoteroAPI.bind(this)) + + this.documentSigningCaSaveButton.addEventListener('click', function() { + self.updateDocumentSigningCa(self.documentSigningCaInput.value) + }) + + this.documentSigningCaRemoveButton.addEventListener('click', this.resetDocumentSigningCa.bind(this)) } PersonalSettings.prototype.updateSetting = function(path) { @@ -69,6 +79,24 @@ import { showError } from '@nextcloud/dialogs' }) } + PersonalSettings.prototype.updateDocumentSigningCa = function(ca) { + const self = this + this._updateSetting({ documentSigningCaInput: ca }, function() { + self.documentSigningCaInput.value = ca + }, function() { + showError(t('richdocuments', 'Failed to update the document signing CA chain')) + }) + } + + PersonalSettings.prototype.resetDocumentSigningCa = function() { + const self = this + this._updateSetting({ documentSigningCaInput: '' }, function() { + self.documentSigningCaInput.value = '' + }, function() { + + }) + } + PersonalSettings.prototype._updateSetting = function(data, successCallback, errorCallback) { OC.msg.startAction('#documents-admin-msg', t('richdocuments', 'Saving …')) const request = new XMLHttpRequest() diff --git a/templates/personal.php b/templates/personal.php index b5e08ee81e..ac35a384e3 100644 --- a/templates/personal.php +++ b/templates/personal.php @@ -30,5 +30,18 @@

t('This instance does not support Zotero, because the feature is missing or disabled. Please contact the administration.')); ?>

+

t('Document signing')) ?>

+ +
+


+
+ + +

+

t('To use document signing, specify your signing certificate, key and CA chain here.')); ?>

+
+ +

t('This instance does not support document signing, because the feature is missing or disabled. Please contact the administrator.')); ?>

+