mirror of
https://github.com/ONLYOFFICE/web-apps.git
synced 2026-07-24 20:10:25 +08:00
Merge pull request #2729 from ONLYOFFICE/fix/pdf-protect
Fix/pdf protect
This commit is contained in:
@ -156,7 +156,8 @@ require([
|
||||
'Common.Controllers.Chat',
|
||||
'Common.Controllers.Comments',
|
||||
'Common.Controllers.Draw',
|
||||
'Common.Controllers.Plugins'
|
||||
'Common.Controllers.Plugins',
|
||||
'Common.Controllers.Protection'
|
||||
]
|
||||
});
|
||||
|
||||
@ -185,7 +186,8 @@ require([
|
||||
'common/main/lib/controller/Chat',
|
||||
/** coauthoring end **/
|
||||
'common/main/lib/controller/Plugins',
|
||||
'common/main/lib/controller/Draw'
|
||||
'common/main/lib/controller/Draw',
|
||||
'common/main/lib/controller/Protection'
|
||||
], function() {
|
||||
app.start();
|
||||
});
|
||||
|
||||
@ -411,7 +411,7 @@ define([
|
||||
var value;
|
||||
|
||||
var fast_coauth = Common.Utils.InternalSettings.get("pdfe-settings-coauthmode"),
|
||||
canPDFSave = this.mode.isPDFAnnotate || this.mode.isPDFEdit;
|
||||
canPDFSave = (this.mode.isPDFAnnotate || this.mode.isPDFEdit) && !this.mode.isOffline;
|
||||
/** coauthoring begin **/
|
||||
if (this.mode.isEdit && !this.mode.isOffline && this.mode.canCoAuthoring && canPDFSave ) {
|
||||
if (this.mode.canChangeCoAuthoring) {
|
||||
|
||||
@ -1196,9 +1196,9 @@ define([
|
||||
this.appOptions.isEdit = !this.appOptions.isXpsViewer && !this.appOptions.isForm;
|
||||
this.appOptions.canPDFEdit = false;//(this.permissions.edit !== false) && this.appOptions.canLicense;
|
||||
this.appOptions.isPDFEdit = false; // this.appOptions.canPDFEdit && this.editorConfig.mode !== 'view'; !! always open in view mode
|
||||
this.appOptions.canPDFAnnotate = this.appOptions.canSwitchMode && this.appOptions.canLicense && (this.permissions.comment!== false);
|
||||
this.appOptions.canPDFAnnotate = (this.appOptions.canSwitchMode || !this.appOptions.isXpsViewer && !this.appOptions.isForm && this.appOptions.isDesktopApp && this.appOptions.isOffline) && this.appOptions.canLicense && (this.permissions.comment!== false);
|
||||
this.appOptions.canPDFAnnotate = this.appOptions.canPDFAnnotate && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.comments===false);
|
||||
this.appOptions.isPDFAnnotate = false;// this.appOptions.canLicense && this.appOptions.canPDFAnnotate && !this.appOptions.isPDFEdit && this.editorConfig.mode !== 'view'; !! always open in view mode
|
||||
this.appOptions.isPDFAnnotate = this.appOptions.canPDFAnnotate && this.appOptions.isDesktopApp && this.appOptions.isOffline; // this.appOptions.canPDFAnnotate && !this.appOptions.isPDFEdit && this.editorConfig.mode !== 'view'; !! online files always open in view mode
|
||||
this.appOptions.canComments = !this.appOptions.isXpsViewer && !this.appOptions.isForm;
|
||||
this.appOptions.canViewComments = this.appOptions.canComments;
|
||||
this.appOptions.canChat = this.appOptions.canLicense && !this.appOptions.isOffline && !(this.permissions.chat===false || (this.permissions.chat===undefined) &&
|
||||
@ -1225,7 +1225,7 @@ define([
|
||||
this.appOptions.trialMode = params.asc_getLicenseMode();
|
||||
this.appOptions.isBeta = params.asc_getIsBeta();
|
||||
this.appOptions.isSignatureSupport= false;//this.appOptions.isEdit && this.appOptions.isDesktopApp && this.appOptions.isOffline && this.api.asc_isSignaturesSupport() && (this.permissions.protect!==false);
|
||||
this.appOptions.isPasswordSupport = false;//this.appOptions.isEdit && this.api.asc_isProtectionSupport() && (this.permissions.protect!==false);
|
||||
this.appOptions.isPasswordSupport = this.appOptions.isEdit && this.appOptions.isDesktopApp && this.appOptions.isOffline && this.api.asc_isProtectionSupport() && (this.permissions.protect!==false) && !this.appOptions.isForm;
|
||||
this.appOptions.canProtect = (this.permissions.protect!==false);
|
||||
this.appOptions.canHelp = !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.help===false);
|
||||
this.appOptions.canSubmitForms = this.appOptions.canLicense && (typeof (this.editorConfig.customization) == 'object') && !!this.editorConfig.customization.submitForm && !this.appOptions.isOffline;
|
||||
@ -1464,7 +1464,9 @@ define([
|
||||
if (this.appOptions.isEdit) {
|
||||
// var fontsControllers = application.getController('Common.Controllers.Fonts');
|
||||
// fontsControllers && fontsControllers.setApi(me.api);
|
||||
// application.getController('Common.Controllers.Protection').setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api);
|
||||
|
||||
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');
|
||||
viewport.applyEditorMode();
|
||||
|
||||
@ -457,10 +457,10 @@ define([
|
||||
}
|
||||
});
|
||||
} else if (this.api) {
|
||||
var isModified = this.api.asc_isDocumentCanSave();
|
||||
var isSyncButton = toolbar.btnCollabChanges && toolbar.btnCollabChanges.cmpEl.hasClass('notify');
|
||||
if (!isModified && !isSyncButton && !toolbar.mode.forcesave)
|
||||
return;
|
||||
// var isModified = this.api.asc_isDocumentCanSave();
|
||||
// var isSyncButton = toolbar.btnCollabChanges && toolbar.btnCollabChanges.cmpEl.hasClass('notify');
|
||||
// if (!isModified && !isSyncButton && !toolbar.mode.forcesave)
|
||||
// return;
|
||||
|
||||
this.api.asc_Save();
|
||||
toolbar.btnSave && toolbar.btnSave.setDisabled(!toolbar.mode.forcesave && !toolbar.mode.saveAlwaysEnabled);
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
<li id="fm-btn-print" class="fm-btn"></li>
|
||||
<li id="fm-btn-print-with-preview" class="fm-btn"></li>
|
||||
<li id="fm-btn-rename" class="fm-btn"></li>
|
||||
<li id="fm-btn-protect" class="fm-btn"></li>
|
||||
<li class="devider"></li>
|
||||
<li id="fm-btn-recent" class="fm-btn"></li>
|
||||
<li id="fm-btn-create" class="fm-btn"></li>
|
||||
@ -31,5 +32,6 @@
|
||||
<div id="panel-rights" class="content-box"></div>
|
||||
<div id="panel-settings" class="content-box"></div>
|
||||
<div id="panel-help" class="content-box"></div>
|
||||
<div id="panel-protect" class="content-box"></div>
|
||||
<div id="panel-print" class="content-box"></div>
|
||||
</div>
|
||||
@ -447,6 +447,11 @@ define([
|
||||
!this.panels['recent'] && (this.panels['recent'] = (new Common.Views.RecentFiles({ el: '#panel-recentfiles', menu:this, recent: this.mode.recent})).render());
|
||||
}
|
||||
|
||||
if (this.mode.isSignatureSupport || this.mode.isPasswordSupport) {
|
||||
!this.panels['protect'] && (this.panels['protect'] = (new PDFE.Views.FileMenuPanels.ProtectDoc({menu:this})).render());
|
||||
this.panels['protect'].setMode(this.mode);
|
||||
}
|
||||
|
||||
if (this.mode.canDownload) {
|
||||
!this.panels['saveas'] && (this.panels['saveas'] = ((new PDFE.Views.FileMenuPanels.ViewSaveAs({menu: this, fileType: this.document.fileType, mode: this.mode})).render()));
|
||||
} else if (this.mode.canDownloadOrigin)
|
||||
|
||||
@ -659,7 +659,7 @@ define([
|
||||
this.mode = mode;
|
||||
|
||||
var fast_coauth = Common.Utils.InternalSettings.get("pdfe-settings-coauthmode"),
|
||||
canPDFSave = mode.isPDFAnnotate || mode.isPDFEdit;
|
||||
canPDFSave = (mode.isPDFAnnotate || mode.isPDFEdit) && !mode.isOffline;
|
||||
|
||||
$('tr.edit', this.el)[mode.isEdit?'show':'hide']();
|
||||
$('tr.autosave', this.el)[mode.isEdit && canPDFSave && (mode.canChangeCoAuthoring || !fast_coauth) ? 'show' : 'hide']();
|
||||
@ -1985,6 +1985,191 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
PDFE.Views.FileMenuPanels.ProtectDoc = Common.UI.BaseView.extend(_.extend({
|
||||
el: '#panel-protect',
|
||||
menu: undefined,
|
||||
|
||||
template: _.template([
|
||||
'<label id="id-fms-lbl-protect-header"><%= scope.strProtect %></label>',
|
||||
'<div id="id-fms-password">',
|
||||
'<label class="header"><%= scope.strEncrypt %></label>',
|
||||
'<div class="encrypt-block">',
|
||||
'<div class="description"><%= scope.txtProtectDocument %></div>',
|
||||
'<div id="fms-btn-add-pwd"></div>',
|
||||
'</div>',
|
||||
'<div class="encrypted-block">',
|
||||
'<div class="description"><%= scope.txtEncrypted %></div>',
|
||||
'<div class="buttons">',
|
||||
'<div id="fms-btn-change-pwd"></div>',
|
||||
'<div id="fms-btn-delete-pwd" class="margin-left-16"></div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div id="id-fms-signature">',
|
||||
'<label class="header"><%= scope.strSignature %></label>',
|
||||
'<div class="add-signature-block">',
|
||||
'<div class="description"><%= scope.txtAddSignature %></div>',
|
||||
'<div id="fms-btn-invisible-sign"></div>',
|
||||
'</div>',
|
||||
'<div class="added-signature-block">',
|
||||
'<div class="description"><%= scope.txtAddedSignature %></div>',
|
||||
'</div>',
|
||||
'<div id="id-fms-signature-view"></div>',
|
||||
'</div>'
|
||||
].join('')),
|
||||
|
||||
initialize: function(options) {
|
||||
Common.UI.BaseView.prototype.initialize.call(this,arguments);
|
||||
|
||||
this.menu = options.menu;
|
||||
|
||||
var me = this;
|
||||
this.templateSignature = _.template([
|
||||
'<div class="<% if (!hasSigned) { %>hidden<% } %>"">',
|
||||
'<div class="signature-tip"><%= tipText %></div>',
|
||||
'<div class="buttons">',
|
||||
'<label class="link signature-view-link margin-right-20" data-hint="2" data-hint-direction="bottom" data-hint-offset="medium">' + me.txtView + '</label>',
|
||||
'<label class="link signature-edit-link <% if (!hasSigned) { %>hidden<% } %>" data-hint="2" data-hint-direction="bottom" data-hint-offset="medium">' + me.txtEdit + '</label>',
|
||||
'</div>',
|
||||
'</div>'
|
||||
].join(''));
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.template({scope: this}));
|
||||
|
||||
var protection = PDFE.getController('Common.Controllers.Protection').getView();
|
||||
|
||||
this.btnAddPwd = protection.getButton('add-password');
|
||||
this.btnAddPwd.render(this.$el.find('#fms-btn-add-pwd'));
|
||||
this.btnAddPwd.on('click', _.bind(this.closeMenu, this));
|
||||
|
||||
this.btnChangePwd = protection.getButton('change-password');
|
||||
this.btnChangePwd.render(this.$el.find('#fms-btn-change-pwd'));
|
||||
this.btnChangePwd.on('click', _.bind(this.closeMenu, this));
|
||||
|
||||
this.btnDeletePwd = protection.getButton('del-password');
|
||||
this.btnDeletePwd.render(this.$el.find('#fms-btn-delete-pwd'));
|
||||
this.btnDeletePwd.on('click', _.bind(this.closeMenu, this));
|
||||
|
||||
this.cntPassword = $('#id-fms-password');
|
||||
this.cntEncryptBlock = this.$el.find('.encrypt-block');
|
||||
this.cntEncryptedBlock = this.$el.find('.encrypted-block');
|
||||
|
||||
this.btnAddInvisibleSign = protection.getButton('signature');
|
||||
this.btnAddInvisibleSign.render(this.$el.find('#fms-btn-invisible-sign'));
|
||||
this.btnAddInvisibleSign.on('click', _.bind(this.closeMenu, this));
|
||||
|
||||
this.cntSignature = $('#id-fms-signature');
|
||||
this.cntSignatureView = $('#id-fms-signature-view');
|
||||
|
||||
this.cntAddSignature = this.$el.find('.add-signature-block');
|
||||
this.cntAddedSignature = this.$el.find('.added-signature-block');
|
||||
|
||||
if (_.isUndefined(this.scroller)) {
|
||||
this.scroller = new Common.UI.Scroller({
|
||||
el: this.$el,
|
||||
suppressScrollX: true,
|
||||
alwaysVisibleY: true
|
||||
});
|
||||
}
|
||||
|
||||
this.$el.on('click', '.signature-edit-link', _.bind(this.onEdit, this));
|
||||
this.$el.on('click', '.signature-view-link', _.bind(this.onView, this));
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
show: function() {
|
||||
Common.UI.BaseView.prototype.show.call(this,arguments);
|
||||
this.updateSignatures();
|
||||
this.updateEncrypt();
|
||||
this.scroller && this.scroller.update();
|
||||
},
|
||||
|
||||
setMode: function(mode) {
|
||||
this.mode = mode;
|
||||
this.cntSignature.toggleClass('hidden', !this.mode.isSignatureSupport);
|
||||
this.cntPassword.toggleClass('hidden', !this.mode.isPasswordSupport);
|
||||
},
|
||||
|
||||
setApi: function(o) {
|
||||
this.api = o;
|
||||
return this;
|
||||
},
|
||||
|
||||
closeMenu: function() {
|
||||
this.menu && this.menu.hide();
|
||||
},
|
||||
|
||||
onEdit: function() {
|
||||
this.menu && this.menu.hide();
|
||||
|
||||
var me = this;
|
||||
Common.UI.warning({
|
||||
title: this.notcriticalErrorTitle,
|
||||
msg: this.txtEditWarning,
|
||||
buttons: ['ok', 'cancel'],
|
||||
primary: 'ok',
|
||||
callback: function(btn) {
|
||||
if (btn == 'ok') {
|
||||
me.api.asc_RemoveAllSignatures();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
onView: function() {
|
||||
this.menu && this.menu.hide();
|
||||
// PDFE.getController('RightMenu').rightmenu.SetActivePane(Common.Utils.documentSettingsType.Signature, true);
|
||||
},
|
||||
|
||||
updateSignatures: function(){
|
||||
var valid = this.api.asc_getSignatures(),
|
||||
hasValid = false,
|
||||
hasInvalid = false;
|
||||
|
||||
_.each(valid, function(item, index){
|
||||
if (item.asc_getValid()==0)
|
||||
hasValid = true;
|
||||
else
|
||||
hasInvalid = true;
|
||||
});
|
||||
|
||||
// hasValid = true;
|
||||
// hasInvalid = true;
|
||||
|
||||
var tipText = (hasInvalid) ? this.txtSignedInvalid : (hasValid ? this.txtSigned : "");
|
||||
this.cntSignatureView.html(this.templateSignature({tipText: tipText, hasSigned: (hasValid || hasInvalid)}));
|
||||
|
||||
var isAddedSignature = this.btnAddInvisibleSign.$el.find('button').hasClass('hidden');
|
||||
this.cntAddSignature.toggleClass('hidden', isAddedSignature);
|
||||
this.cntAddedSignature.toggleClass('hidden', !isAddedSignature);
|
||||
},
|
||||
|
||||
updateEncrypt: function() {
|
||||
var isProtected = this.btnAddPwd.$el.find('button').hasClass('hidden');
|
||||
this.cntEncryptBlock.toggleClass('hidden', isProtected);
|
||||
this.cntEncryptedBlock.toggleClass('hidden', !isProtected);
|
||||
},
|
||||
|
||||
strProtect: 'Protect Document',
|
||||
strSignature: 'With Signature',
|
||||
txtView: 'View signatures',
|
||||
txtEdit: 'Edit document',
|
||||
txtSigned: 'Valid signatures has been added to the document. The document is protected from editing.',
|
||||
txtSignedInvalid: 'Some of the digital signatures in document are invalid or could not be verified. The document is protected from editing.',
|
||||
notcriticalErrorTitle: 'Warning',
|
||||
txtEditWarning: 'Editing will remove the signatures from the document.<br>Are you sure you want to continue?',
|
||||
strEncrypt: 'With Password',
|
||||
txtProtectDocument: 'Encrypt this document with a password',
|
||||
txtEncrypted: 'A password is required to open this document',
|
||||
txtAddSignature: 'Ensure the integrity of the document by adding an<br>invisible digital signature',
|
||||
txtAddedSignature: 'Valid signatures have been added to the document.<br>The document is protected from editing.'
|
||||
|
||||
}, PDFE.Views.FileMenuPanels.ProtectDoc || {}));
|
||||
|
||||
PDFE.Views.PrintWithPreview = Common.UI.BaseView.extend(_.extend({
|
||||
el: '#panel-print',
|
||||
menu: undefined,
|
||||
|
||||
@ -148,6 +148,7 @@ require([
|
||||
,'Common.Controllers.Comments'
|
||||
,'Common.Controllers.Draw'
|
||||
,'Common.Controllers.Plugins'
|
||||
,'Common.Controllers.Protection'
|
||||
]
|
||||
});
|
||||
|
||||
@ -176,6 +177,7 @@ require([
|
||||
,'common/main/lib/controller/Chat'
|
||||
,'common/main/lib/controller/Plugins'
|
||||
,'common/main/lib/controller/Draw'
|
||||
,'common/main/lib/controller/Protection'
|
||||
], function() {
|
||||
window.compareVersions = true;
|
||||
app.start();
|
||||
|
||||
@ -520,6 +520,19 @@
|
||||
"PDFE.Views.FileMenuPanels.DocumentRights.txtAccessRights": "Access Rights",
|
||||
"PDFE.Views.FileMenuPanels.DocumentRights.txtBtnAccessRights": "Change access rights",
|
||||
"PDFE.Views.FileMenuPanels.DocumentRights.txtRights": "Persons who have rights",
|
||||
"PDFE.Views.FileMenuPanels.ProtectDoc.strEncrypt": "With password",
|
||||
"PDFE.Views.FileMenuPanels.ProtectDoc.strProtect": "Protect Document",
|
||||
"PDFE.Views.FileMenuPanels.ProtectDoc.strSignature": "With signature",
|
||||
"PDFE.Views.FileMenuPanels.ProtectDoc.txtAddedSignature": "Valid signatures have been added to the document.<br>The document is protected from editing.",
|
||||
"PDFE.Views.FileMenuPanels.ProtectDoc.txtAddSignature": "Ensure the integrity of the document by adding an<br>invisible digital signature",
|
||||
"PDFE.Views.FileMenuPanels.ProtectDoc.txtEdit": "Edit document",
|
||||
"PDFE.Views.FileMenuPanels.ProtectDoc.txtEditWarning": "Editing will remove signatures from the document.<br>Continue?",
|
||||
"PDFE.Views.FileMenuPanels.ProtectDoc.txtEncrypted": "This document has been protected with password",
|
||||
"PDFE.Views.FileMenuPanels.ProtectDoc.txtProtectDocument": "Encrypt this document with a password",
|
||||
"PDFE.Views.FileMenuPanels.ProtectDoc.txtRequestedSignatures": "This document needs to be signed.",
|
||||
"PDFE.Views.FileMenuPanels.ProtectDoc.txtSigned": "Valid signatures have been added to the document. The document is protected from editing.",
|
||||
"PDFE.Views.FileMenuPanels.ProtectDoc.txtSignedInvalid": "Some of the digital signatures in the document are invalid or could not be verified. The document is protected from editing.",
|
||||
"PDFE.Views.FileMenuPanels.ProtectDoc.txtView": "View signatures",
|
||||
"PDFE.Views.FileMenuPanels.Settings.okButtonText": "Apply",
|
||||
"PDFE.Views.FileMenuPanels.Settings.strCoAuthMode": "Co-editing Mode",
|
||||
"PDFE.Views.FileMenuPanels.Settings.strFast": "Fast",
|
||||
|
||||
Reference in New Issue
Block a user