diff --git a/apps/documenteditor/main/app/controller/DocProtection.js b/apps/documenteditor/main/app/controller/DocProtection.js index 113b949fb9..06ace9b199 100644 --- a/apps/documenteditor/main/app/controller/DocProtection.js +++ b/apps/documenteditor/main/app/controller/DocProtection.js @@ -98,7 +98,7 @@ define([ this.appConfig = mode; this.currentUserId = mode.user.id; - this.appConfig.isEdit && (this.view = this.createView('DocProtection', { + this.appConfig.isEdit && this.appConfig.canProtect && (this.view = this.createView('DocProtection', { mode: mode })); diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index b1c02f23f8..42b3a7adb6 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1549,7 +1549,7 @@ define([ this.appOptions.isBeta = params.asc_getIsBeta(); this.appOptions.isSignatureSupport= this.appOptions.isEdit && this.appOptions.isDesktopApp && this.appOptions.isOffline && this.api.asc_isSignaturesSupport() && (this.permissions.protect!==false); this.appOptions.isPasswordSupport = this.appOptions.isEdit && this.api.asc_isProtectionSupport() && (this.permissions.protect!==false); - this.appOptions.canProtect = (this.appOptions.isSignatureSupport || this.appOptions.isPasswordSupport); + this.appOptions.canProtect = (this.permissions.protect!==false); this.appOptions.canEditContentControl = (this.permissions.modifyContentControl!==false); this.appOptions.canHelp = !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.help===false); this.appOptions.canSubmitForms = false; // this.appOptions.canLicense && (typeof (this.editorConfig.customization) == 'object') && !!this.editorConfig.customization.submitForm; diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 6c4c87f424..336d4e84cb 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -3275,16 +3275,17 @@ define([ // if ($panel) me.toolbar.addTab(tab, $panel, 6); // } // } - - tab = {action: 'protect', caption: me.toolbar.textTabProtect, layoutname: 'toolbar-protect', dataHintTitle: 'T'}; - $panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel(); - if ($panel) { - config.canProtect && $panel.append($('
')); - var doctab = me.getApplication().getController('DocProtection'); - $panel.append(doctab.createToolbarPanel()); - me.toolbar.addTab(tab, $panel, 6); - me.toolbar.setVisible('protect', Common.UI.LayoutManager.isElementVisible('toolbar-protect')); - Array.prototype.push.apply(me.toolbar.lockControls, doctab.getView('DocProtection').getButtons()); + if ( config.canProtect ) { + tab = {action: 'protect', caption: me.toolbar.textTabProtect, layoutname: 'toolbar-protect', dataHintTitle: 'T'}; + $panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel(); + if ($panel) { + (config.isSignatureSupport || config.isPasswordSupport) && $panel.append($('')); + var doctab = me.getApplication().getController('DocProtection'); + $panel.append(doctab.createToolbarPanel()); + me.toolbar.addTab(tab, $panel, 6); + me.toolbar.setVisible('protect', Common.UI.LayoutManager.isElementVisible('toolbar-protect')); + Array.prototype.push.apply(me.toolbar.lockControls, doctab.getView('DocProtection').getButtons()); + } } var links = me.getApplication().getController('Links'); diff --git a/apps/documenteditor/main/app/view/FileMenu.js b/apps/documenteditor/main/app/view/FileMenu.js index 3f55df63f8..e3b09343bd 100644 --- a/apps/documenteditor/main/app/view/FileMenu.js +++ b/apps/documenteditor/main/app/view/FileMenu.js @@ -401,8 +401,8 @@ define([ this.miPrint[this.mode.canPrint && !this.mode.canPreviewPrint ?'show':'hide'](); this.miPrintWithPreview[this.mode.canPreviewPrint?'show':'hide'](); this.miRename[(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide'](); - this.miProtect[this.mode.canProtect ?'show':'hide'](); - separatorVisible = (this.mode.canDownload || this.mode.canDownloadOrigin || this.mode.isEdit && Common.UI.LayoutManager.isElementVisible('toolbar-file-save') || this.mode.canPrint || this.mode.canProtect || + this.miProtect[(this.mode.isSignatureSupport || this.mode.isPasswordSupport) ?'show':'hide'](); + separatorVisible = (this.mode.canDownload || this.mode.canDownloadOrigin || this.mode.isEdit && Common.UI.LayoutManager.isElementVisible('toolbar-file-save') || this.mode.canPrint || (this.mode.isSignatureSupport || this.mode.isPasswordSupport) || !this.mode.isEdit && this.mode.canEdit && this.mode.canRequestEditRights || this.mode.canRename && !this.mode.isDesktopApp) && !this.mode.isDisconnected; this.miProtect.$el.find('+.devider')[separatorVisible?'show':'hide'](); separatorVisible && (lastSeparator = this.miProtect.$el.find('+.devider')); @@ -462,7 +462,7 @@ define([ !this.panels['recent'] && (this.panels['recent'] = (new DE.Views.FileMenuPanels.RecentFiles({menu:this, recent: this.mode.recent})).render()); } - if (this.mode.canProtect) { + if (this.mode.isSignatureSupport || this.mode.isPasswordSupport) { !this.panels['protect'] && (this.panels['protect'] = (new DE.Views.FileMenuPanels.ProtectDoc({menu:this})).render()); this.panels['protect'].setMode(this.mode); } diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 09ec2e24f0..ff2f474ab0 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -1220,7 +1220,7 @@ define([ this.appOptions.isBeta = params.asc_getIsBeta(); this.appOptions.isSignatureSupport= this.appOptions.isEdit && this.appOptions.isDesktopApp && this.appOptions.isOffline && this.api.asc_isSignaturesSupport() && (this.permissions.protect!==false); this.appOptions.isPasswordSupport = this.appOptions.isEdit && this.api.asc_isProtectionSupport() && (this.permissions.protect!==false); - this.appOptions.canProtect = (this.appOptions.isSignatureSupport || this.appOptions.isPasswordSupport); + this.appOptions.canProtect = (this.permissions.protect!==false); this.appOptions.canHelp = !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.help===false); this.appOptions.isRestrictedEdit = !this.appOptions.isEdit && this.appOptions.canComments; @@ -1370,7 +1370,7 @@ define([ fontsControllers && fontsControllers.setApi(me.api); rightmenuController && rightmenuController.setApi(me.api); - if (me.appOptions.canProtect) + if (me.appOptions.isSignatureSupport || me.appOptions.isPasswordSupport) application.getController('Common.Controllers.Protection').setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api); var viewport = this.getApplication().getController('Viewport').getView('Viewport'); diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index 4522f0fb1e..8027cab380 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -2689,7 +2689,7 @@ define([ } if ( config.isDesktopApp ) { - if ( config.canProtect ) { // don't add protect panel to toolbar + if (config.isSignatureSupport || config.isPasswordSupport) { // don't add protect panel to toolbar tab = {action: 'protect', caption: me.toolbar.textTabProtect, layoutname: 'toolbar-protect', dataHintTitle: 'T'}; $panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel(); if ($panel) diff --git a/apps/presentationeditor/main/app/view/FileMenu.js b/apps/presentationeditor/main/app/view/FileMenu.js index 1b2d588d76..8935821a1c 100644 --- a/apps/presentationeditor/main/app/view/FileMenu.js +++ b/apps/presentationeditor/main/app/view/FileMenu.js @@ -397,8 +397,8 @@ define([ this.miPrint[this.mode.canPrint && !this.mode.canPreviewPrint ?'show':'hide'](); this.miPrintWithPreview[this.mode.canPreviewPrint?'show':'hide'](); this.miRename[(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide'](); - this.miProtect[this.mode.canProtect ?'show':'hide'](); - separatorVisible = (this.mode.canDownload || this.mode.isEdit && Common.UI.LayoutManager.isElementVisible('toolbar-file-save') || this.mode.canPrint || this.mode.canProtect || + this.miProtect[(this.mode.isSignatureSupport || this.mode.isPasswordSupport) ?'show':'hide'](); + separatorVisible = (this.mode.canDownload || this.mode.isEdit && Common.UI.LayoutManager.isElementVisible('toolbar-file-save') || this.mode.canPrint || (this.mode.isSignatureSupport || this.mode.isPasswordSupport) || !this.mode.isEdit && this.mode.canEdit && this.mode.canRequestEditRights || this.mode.canRename && !this.mode.isDesktopApp) && !this.mode.isDisconnected; this.miProtect.$el.find('+.devider')[separatorVisible?'show':'hide'](); separatorVisible && (lastSeparator = this.miProtect.$el.find('+.devider')); @@ -458,7 +458,7 @@ define([ !this.panels['recent'] && (this.panels['recent'] = (new PE.Views.FileMenuPanels.RecentFiles({menu:this, recent: this.mode.recent})).render()); } - if (this.mode.canProtect) { + if (this.mode.isSignatureSupport || this.mode.isPasswordSupport) { !this.panels['protect'] && (this.panels['protect'] = (new PE.Views.FileMenuPanels.ProtectDoc({menu:this})).render()); this.panels['protect'].setMode(this.mode); } diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 9f6c8efe05..772727604b 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1337,7 +1337,7 @@ define([ && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle); this.appOptions.isPasswordSupport = this.appOptions.isEdit && this.api.asc_isProtectionSupport() && (this.permissions.protect!==false) && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle); - this.appOptions.canProtect = (this.appOptions.isSignatureSupport || this.appOptions.isPasswordSupport); + this.appOptions.canProtect = (this.permissions.protect!==false) && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle); this.appOptions.canHelp = !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.help===false); this.appOptions.isRestrictedEdit = !this.appOptions.isEdit && this.appOptions.canComments; diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 33bbb69e7d..f4675a8467 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -2560,7 +2560,7 @@ define([ this._state.prstyle = undefined; } - if ( this.appConfig.isDesktopApp && this.appConfig.canProtect ) { + if ( this.appConfig.isDesktopApp && (this.appConfig.isSignatureSupport || this.appConfig.isPasswordSupport) ) { this.getApplication().getController('Common.Controllers.Protection').SetDisabled(is_cell_edited, false); } } else { @@ -4567,23 +4567,25 @@ define([ me.toolbar.processPanelVisible(null, true, true); } - var tab = {action: 'protect', caption: me.toolbar.textTabProtect, layoutname: 'toolbar-protect', dataHintTitle: 'T'}; - var $panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel(); - if ($panel) { - config.canProtect && $panel.append($('')); - var wbtab = me.getApplication().getController('WBProtection'); - $panel.append(wbtab.createToolbarPanel()); - me.toolbar.addTab(tab, $panel, 7); - me.toolbar.setVisible('protect', Common.UI.LayoutManager.isElementVisible('toolbar-protect')); - Array.prototype.push.apply(me.toolbar.lockControls, wbtab.getView('WBProtection').getButtons()); + if ( config.canProtect ) { + var tab = {action: 'protect', caption: me.toolbar.textTabProtect, layoutname: 'toolbar-protect', dataHintTitle: 'T'}; + var $panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel(); + if ($panel) { + (config.isSignatureSupport || config.isPasswordSupport) && $panel.append($('')); + var wbtab = me.getApplication().getController('WBProtection'); + $panel.append(wbtab.createToolbarPanel()); + me.toolbar.addTab(tab, $panel, 7); + me.toolbar.setVisible('protect', Common.UI.LayoutManager.isElementVisible('toolbar-protect')); + Array.prototype.push.apply(me.toolbar.lockControls, wbtab.getView('WBProtection').getButtons()); + } } } } if ( !config.isEditDiagram && !config.isEditMailMerge && !config.isEditOle ) { - tab = {caption: me.toolbar.textTabView, action: 'view', extcls: config.isEdit ? 'canedit' : '', layoutname: 'toolbar-view', dataHintTitle: 'W'}; + var tab = {caption: me.toolbar.textTabView, action: 'view', extcls: config.isEdit ? 'canedit' : '', layoutname: 'toolbar-view', dataHintTitle: 'W'}; var viewtab = me.getApplication().getController('ViewTab'); viewtab.setApi(me.api).setConfig({toolbar: me, mode: config}); - $panel = viewtab.createToolbarPanel(); + var $panel = viewtab.createToolbarPanel(); if ($panel) { me.toolbar.addTab(tab, $panel, 8); me.toolbar.setVisible('view', Common.UI.LayoutManager.isElementVisible('toolbar-view')); diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index 6c5d400e3d..7c64baa3d4 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -98,7 +98,7 @@ define([ setMode: function(mode) { this.appConfig = mode; - this.appConfig.isEdit && (this.view = this.createView('WBProtection', { + this.appConfig.isEdit && this.appConfig.canProtect && (this.view = this.createView('WBProtection', { mode: mode })); diff --git a/apps/spreadsheeteditor/main/app/view/FileMenu.js b/apps/spreadsheeteditor/main/app/view/FileMenu.js index 22a2e0c6e6..aff7a7efdf 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenu.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenu.js @@ -368,8 +368,8 @@ define([ this.miEdit[!this.mode.isEdit && this.mode.canEdit && this.mode.canRequestEditRights ?'show':'hide'](); this.miPrintWithPreview[this.mode.canPrint?'show':'hide'](); this.miRename[(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide'](); - this.miProtect[this.mode.canProtect ?'show':'hide'](); - separatorVisible = (this.mode.canDownload || this.mode.isEdit && Common.UI.LayoutManager.isElementVisible('toolbar-file-save') || this.mode.canPrint || this.mode.canProtect || + this.miProtect[(this.mode.isSignatureSupport || this.mode.isPasswordSupport) ?'show':'hide'](); + separatorVisible = (this.mode.canDownload || this.mode.isEdit && Common.UI.LayoutManager.isElementVisible('toolbar-file-save') || this.mode.canPrint || (this.mode.isSignatureSupport || this.mode.isPasswordSupport) || !this.mode.isEdit && this.mode.canEdit && this.mode.canRequestEditRights || this.mode.canRename && !this.mode.isDesktopApp) && !this.mode.isDisconnected; this.miProtect.$el.find('+.devider')[separatorVisible?'show':'hide'](); separatorVisible && (lastSeparator = this.miProtect.$el.find('+.devider')); @@ -429,7 +429,7 @@ define([ !this.panels['recent'] && (this.panels['recent'] = (new SSE.Views.FileMenuPanels.RecentFiles({menu:this, recent: this.mode.recent})).render()); } - if (this.mode.canProtect) { + if (this.mode.isSignatureSupport || this.mode.isPasswordSupport) { !this.panels['protect'] && (this.panels['protect'] = (new SSE.Views.FileMenuPanels.ProtectDoc({menu:this})).render()); this.panels['protect'].setMode(this.mode); } diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index 8a013f4839..c14cbb9c5e 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -745,7 +745,7 @@ define([ this.tabMenu.items[7].setDisabled(select.length>1); this.tabMenu.items[8].setDisabled(issheetlocked || isdocprotected); - this.tabMenu.items[7].setVisible(!this.mode.isEditOle); + this.tabMenu.items[7].setVisible(!this.mode.isEditOle && this.mode.canProtect); this.tabMenu.items[7].setCaption(this.api.asc_isProtectedSheet() ? this.itemUnProtect : this.itemProtect); if (select.length === 1) {