From 415d9651df0752b7dfe2da2ed12580e8d666525b Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 17 Jan 2022 12:01:35 +0300 Subject: [PATCH 1/5] [DE forms] Fix Bug 54910 --- .../forms/app/controller/ApplicationController.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/documenteditor/forms/app/controller/ApplicationController.js b/apps/documenteditor/forms/app/controller/ApplicationController.js index f0e333470..6b14b77f9 100644 --- a/apps/documenteditor/forms/app/controller/ApplicationController.js +++ b/apps/documenteditor/forms/app/controller/ApplicationController.js @@ -505,6 +505,7 @@ define([ this.api.asc_registerCallback('asc_onGetEditorPermissions', _.bind(this.onEditorPermissions, this)); this.api.asc_registerCallback('asc_onRunAutostartMacroses', _.bind(this.onRunAutostartMacroses, this)); + this.api.asc_registerCallback('asc_onLicenseChanged', _.bind(this.onLicenseChanged, this)); this.api.asc_setDocInfo(docInfo); this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId); this.api.asc_enableKeyEvents(true); @@ -642,6 +643,17 @@ define([ }); }, + onLicenseChanged: function(params) { + var licType = params.asc_getLicenseType(); + if (licType !== undefined && this.appOptions.canFillForms && + (licType===Asc.c_oLicenseResult.Connections || licType===Asc.c_oLicenseResult.UsersCount || licType===Asc.c_oLicenseResult.ConnectionsOS || licType===Asc.c_oLicenseResult.UsersCountOS + || licType===Asc.c_oLicenseResult.SuccessLimit && (this.appOptions.trialMode & Asc.c_oLicenseMode.Limited) !== 0)) + this._state.licenseType = licType; + + if (this._isDocReady) + this.applyLicense(); + }, + applyLicense: function() { if (this._state.licenseType) { var license = this._state.licenseType, From 0f7cd84acf8213cb82b5e3a1d62e6084052264b7 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 17 Jan 2022 18:09:45 +0300 Subject: [PATCH 2/5] [DE forms] Disable edit buttons when no license (Bug 54910) --- .../app/controller/ApplicationController.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/documenteditor/forms/app/controller/ApplicationController.js b/apps/documenteditor/forms/app/controller/ApplicationController.js index 6b14b77f9..1a49a998c 100644 --- a/apps/documenteditor/forms/app/controller/ApplicationController.js +++ b/apps/documenteditor/forms/app/controller/ApplicationController.js @@ -670,6 +670,10 @@ define([ primary = 'buynow'; } + if (this._state.licenseType!==Asc.c_oLicenseResult.SuccessLimit && this.appOptions.canFillForms) { + this.disableEditing(true); + } + var value = Common.localStorage.getItem("de-license-warning"); value = (value!==null) ? parseInt(value) : 0; var now = (new Date).getTime(); @@ -998,6 +1002,8 @@ define([ }, onShowContentControlsActions: function(obj, x, y) { + if (this._isDisabled) return; + var me = this; switch (obj.type) { case Asc.c_oAscContentControlSpecificType.DateTime: @@ -1730,12 +1736,12 @@ define([ if (this.textMenu && !noobject) { var cancopy = this.api.can_CopyCut(), disabled = menu_props.paraProps && menu_props.paraProps.locked || menu_props.headerProps && menu_props.headerProps.locked || - menu_props.imgProps && (menu_props.imgProps.locked || menu_props.imgProps.content_locked); + menu_props.imgProps && (menu_props.imgProps.locked || menu_props.imgProps.content_locked) || this._isDisabled; this.textMenu.items[0].setDisabled(disabled || !this.api.asc_getCanUndo()); // undo this.textMenu.items[1].setDisabled(disabled || !this.api.asc_getCanRedo()); // redo - this.textMenu.items[3].setDisabled(!cancopy); // copy - this.textMenu.items[4].setDisabled(disabled || !cancopy); // cut + this.textMenu.items[3].setDisabled(disabled || !cancopy); // cut + this.textMenu.items[4].setDisabled(!cancopy); // copy this.textMenu.items[5].setDisabled(disabled) // paste; this.showPopupMenu(this.textMenu, {}, event); @@ -1769,6 +1775,11 @@ define([ } }, + disableEditing: function(state) { + this.view && this.view.btnClear && this.view.btnClear.setDisabled(state); + this._isDisabled = state; + }, + errorDefaultMessage : 'Error code: %1', unknownErrorText : 'Unknown error.', convertationTimeoutText : 'Conversion timeout exceeded.', From d53adf634d0c276e9d46efa6546a59a0001fcd89 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Tue, 18 Jan 2022 11:22:44 +0300 Subject: [PATCH 3/5] [build] refactoring --- build/Gruntfile.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/build/Gruntfile.js b/build/Gruntfile.js index 2d6b3dbde..ec6d63e73 100644 --- a/build/Gruntfile.js +++ b/build/Gruntfile.js @@ -33,7 +33,7 @@ module.exports = function(grunt) { return !!string && !!iconv_lite ? iconv_lite.encode(string,encoding) : string; }; - var jsreplacements = [ + global.jsreplacements = [ { from: /\{\{SUPPORT_EMAIL\}\}/g, to: _encode(process.env.SUPPORT_EMAIL) || 'support@onlyoffice.com' @@ -355,12 +355,12 @@ module.exports = function(grunt) { replacements: [{ from: /\{\{PRODUCT_VERSION\}\}/g, to: packageFile.version - }] + }, ...global.jsreplacements] }, prepareHelp: { src: ['<%= pkg.main.copy.help[0].dest %>/ru/**/*.htm*'], overwrite: true, - replacements: [] + replacements: [...helpreplacements] } }, @@ -427,10 +427,10 @@ module.exports = function(grunt) { } }); - var replace = grunt.config.get('replace'); - replace.writeVersion.replacements.push(...jsreplacements); - replace.prepareHelp.replacements.push(...helpreplacements); - grunt.config.set('replace', replace); + // var replace = grunt.config.get('replace'); + // replace.writeVersion.replacements.push(...global.jsreplacements); + // replace.prepareHelp.replacements.push(...helpreplacements); + // grunt.config.set('replace', replace); }); grunt.registerTask('deploy-reporter', function(){ From 336e2c449f8e88f4dc6fc1acdd00c84494dd5c22 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Tue, 18 Jan 2022 11:23:41 +0300 Subject: [PATCH 4/5] [forms] replace inlined variables --- build/appforms.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/build/appforms.js b/build/appforms.js index f12e37e56..7d0238af6 100644 --- a/build/appforms.js +++ b/build/appforms.js @@ -65,6 +65,17 @@ module.exports = (grunt) => { } }, + replace: { + varsEnviroment: { + src: ['<%= pkg.forms.js.requirejs.options.out %>'], + overwrite: true, + replacements: [{ + from: /\{\{PRODUCT_VERSION\}\}/g, + to: packageFile.version + }, ...global.jsreplacements] + }, + }, + inline: { dist: { src: packageFile.forms.inline.src @@ -76,5 +87,5 @@ module.exports = (grunt) => { grunt.registerTask('deploy-app-forms', ['forms-app-init', 'clean:prebuild', /*'imagemin',*/ 'less', 'requirejs', 'concat', 'copy', 'inline', /*'json-minify',*/ - /*'replace:writeVersion',*/ /*'replace:prepareHelp',*/ 'clean:postbuild']); + 'replace:varsEnviroment', /*'replace:prepareHelp',*/ 'clean:postbuild']); } \ No newline at end of file From 9f16a3c4d386a31d472dbb87f0ed4dfd9e914cb7 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 17 Jan 2022 18:59:46 +0300 Subject: [PATCH 5/5] [DE][PE][SSE] Disable comment, fillForms when no license in the restricted editing mode --- apps/documenteditor/main/app/controller/Main.js | 4 ++-- apps/presentationeditor/main/app/controller/Main.js | 4 ++-- apps/spreadsheeteditor/main/app/controller/Main.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 6122a17b8..b5ee98e89 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1274,7 +1274,7 @@ define([ onLicenseChanged: function(params) { var licType = params.asc_getLicenseType(); - if (licType !== undefined && this.appOptions.canEdit && this.editorConfig.mode !== 'view' && + if (licType !== undefined && (this.appOptions.canEdit || this.appOptions.isRestrictedEdit) && this.editorConfig.mode !== 'view' && (licType===Asc.c_oLicenseResult.Connections || licType===Asc.c_oLicenseResult.UsersCount || licType===Asc.c_oLicenseResult.ConnectionsOS || licType===Asc.c_oLicenseResult.UsersCountOS || licType===Asc.c_oLicenseResult.SuccessLimit && (this.appOptions.trialMode & Asc.c_oLicenseMode.Limited) !== 0)) this._state.licenseType = licType; @@ -1300,7 +1300,7 @@ define([ primary = 'buynow'; } - if (this._state.licenseType!==Asc.c_oLicenseResult.SuccessLimit && this.appOptions.isEdit) { + if (this._state.licenseType!==Asc.c_oLicenseResult.SuccessLimit && (this.appOptions.isEdit || this.appOptions.isRestrictedEdit)) { this.disableEditing(true); Common.NotificationCenter.trigger('api:disconnect'); } diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index bb6012a85..df78c7d1b 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -916,7 +916,7 @@ define([ onLicenseChanged: function(params) { var licType = params.asc_getLicenseType(); - if (licType !== undefined && this.appOptions.canEdit && this.editorConfig.mode !== 'view' && + if (licType !== undefined && (this.appOptions.canEdit || this.appOptions.isRestrictedEdit) && this.editorConfig.mode !== 'view' && (licType===Asc.c_oLicenseResult.Connections || licType===Asc.c_oLicenseResult.UsersCount || licType===Asc.c_oLicenseResult.ConnectionsOS || licType===Asc.c_oLicenseResult.UsersCountOS || licType===Asc.c_oLicenseResult.SuccessLimit && (this.appOptions.trialMode & Asc.c_oLicenseMode.Limited) !== 0)) this._state.licenseType = licType; @@ -942,7 +942,7 @@ define([ primary = 'buynow'; } - if (this._state.licenseType!==Asc.c_oLicenseResult.SuccessLimit && this.appOptions.isEdit) { + if (this._state.licenseType!==Asc.c_oLicenseResult.SuccessLimit && (this.appOptions.isEdit || this.appOptions.isRestrictedEdit)) { this.disableEditing(true); Common.NotificationCenter.trigger('api:disconnect'); } diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 6e332f4ee..48ada36d5 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1017,7 +1017,7 @@ define([ if (this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) return; var licType = params.asc_getLicenseType(); - if (licType !== undefined && this.appOptions.canEdit && this.editorConfig.mode !== 'view' && + if (licType !== undefined && (this.appOptions.canEdit || this.appOptions.isRestrictedEdit) && this.editorConfig.mode !== 'view' && (licType===Asc.c_oLicenseResult.Connections || licType===Asc.c_oLicenseResult.UsersCount || licType===Asc.c_oLicenseResult.ConnectionsOS || licType===Asc.c_oLicenseResult.UsersCountOS || licType===Asc.c_oLicenseResult.SuccessLimit && (this.appOptions.trialMode & Asc.c_oLicenseMode.Limited) !== 0)) this._state.licenseType = licType; @@ -1043,7 +1043,7 @@ define([ primary = 'buynow'; } - if (this._state.licenseType!==Asc.c_oLicenseResult.SuccessLimit && this.appOptions.isEdit) { + if (this._state.licenseType!==Asc.c_oLicenseResult.SuccessLimit && (this.appOptions.isEdit || this.appOptions.isRestrictedEdit)) { this.disableEditing(true); Common.NotificationCenter.trigger('api:disconnect'); }