Disable downloadAs api method when permission.download = false

This commit is contained in:
Julia Radzhabova 2019-01-10 17:20:59 +03:00
parent 04bf403d3b
commit ff9beb8a87
11 changed files with 62 additions and 5 deletions

View file

@ -452,6 +452,10 @@ var ApplicationController = new(function(){
}
function onDownloadAs() {
if ( permissions.download === false) {
Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, me.errorAccessDeny);
return;
}
if (api) api.asc_DownloadAs(Asc.c_oAscFileType.DOCX, true);
}
@ -539,6 +543,7 @@ var ApplicationController = new(function(){
criticalErrorTitle : 'Error',
notcriticalErrorTitle : 'Warning',
scriptLoadError: 'The connection is too slow, some of the components could not be loaded. Please reload the page.',
errorFilePassProtect: 'The file is password protected and cannot be opened.'
errorFilePassProtect: 'The file is password protected and cannot be opened.',
errorAccessDeny: 'You are trying to perform an action you do not have rights for.<br>Please contact your Document Server administrator.'
}
})();

View file

@ -403,6 +403,11 @@ define([
},
onDownloadAs: function(format) {
if ( !this.appOptions.canDownload && !this.appOptions.canDownloadOrigin) {
Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, this.errorAccessDeny);
return;
}
this._state.isFromGatewayDownloadAs = true;
var type = /^(?:(pdf|djvu|xps))$/.exec(this.document.fileType);
if (type && typeof type[1] === 'string')

View file

@ -306,6 +306,11 @@ define([
},
onDownloadAs: function() {
if ( !this.appOptions.canDownload && !this.appOptions.canDownloadOrigin) {
Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, this.errorAccessDeny);
return;
}
this._state.isFromGatewayDownloadAs = true;
var type = /^(?:(pdf|djvu|xps))$/.exec(this.document.fileType);
@ -888,6 +893,10 @@ define([
config.msg = this.errorDataEncrypted;
break;
case Asc.c_oAscError.ID.AccessDeny:
config.msg = this.errorAccessDeny;
break;
default:
config.msg = this.errorDefaultMessage.replace('%1', id);
break;
@ -1355,7 +1364,8 @@ define([
warnLicenseUsersExceeded: 'The number of concurrent users has been exceeded and the document will be opened for viewing only.<br>Please contact your administrator for more information.',
errorDataEncrypted: 'Encrypted changes have been received, they cannot be deciphered.',
closeButtonText: 'Close File',
scriptLoadError: 'The connection is too slow, some of the components could not be loaded. Please reload the page.'
scriptLoadError: 'The connection is too slow, some of the components could not be loaded. Please reload the page.',
errorAccessDeny: 'You are trying to perform an action you do not have rights for.<br>Please contact your Document Server administrator.'
}
})(), DE.Controllers.Main || {}))
});

View file

@ -53,6 +53,7 @@
"DE.Controllers.Main.downloadMergeTitle": "Downloading",
"DE.Controllers.Main.downloadTextText": "Downloading document...",
"DE.Controllers.Main.downloadTitleText": "Downloading Document",
"DE.Controllers.Main.errorAccessDeny": "You are trying to perform an action you do not have rights for.<br>Please contact your Document Server administrator.",
"DE.Controllers.Main.errorBadImageUrl": "Image URL is incorrect",
"DE.Controllers.Main.errorCoAuthoringDisconnect": "Server connection lost. You can't edit anymore.",
"DE.Controllers.Main.errorConnectToServer": "The document could not be saved. Please check connection settings or contact your administrator.<br>When you click the 'OK' button, you will be prompted to download the document.<br><br>Find more information about connecting Document Server <a href=\"https://api.onlyoffice.com/editors/callback\" target=\"_blank\">here</a>",

View file

@ -552,6 +552,10 @@ var ApplicationController = new(function(){
}
function onDownloadAs() {
if ( permissions.download === false) {
Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, me.errorAccessDeny);
return;
}
if (api) api.asc_DownloadAs(Asc.c_oAscFileType.PPTX, true);
}
// Helpers
@ -610,6 +614,7 @@ var ApplicationController = new(function(){
criticalErrorTitle : 'Error',
notcriticalErrorTitle : 'Warning',
scriptLoadError: 'The connection is too slow, some of the components could not be loaded. Please reload the page.',
errorFilePassProtect: 'The file is password protected and cannot be opened.'
errorFilePassProtect: 'The file is password protected and cannot be opened.',
errorAccessDeny: 'You are trying to perform an action you do not have rights for.<br>Please contact your Document Server administrator.'
}
})();

View file

@ -383,6 +383,11 @@ define([
},
onDownloadAs: function(format) {
if ( !this.appOptions.canDownload ) {
Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, this.errorAccessDeny);
return;
}
this._state.isFromGatewayDownloadAs = true;
var _format = (format && (typeof format == 'string')) ? Asc.c_oAscFileType[ format.toUpperCase() ] : null,
_supported = [

View file

@ -303,6 +303,11 @@ define([
},
onDownloadAs: function() {
if ( !this.appOptions.canDownload) {
Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, this.errorAccessDeny);
return;
}
this._state.isFromGatewayDownloadAs = true;
this.api.asc_DownloadAs(Asc.c_oAscFileType.PPTX, true);
},
@ -838,6 +843,10 @@ define([
config.msg = this.errorDataEncrypted;
break;
case Asc.c_oAscError.ID.AccessDeny:
config.msg = this.errorAccessDeny;
break;
default:
config.msg = this.errorDefaultMessage.replace('%1', id);
break;
@ -1347,7 +1356,8 @@ define([
warnLicenseUsersExceeded: 'The number of concurrent users has been exceeded and the document will be opened for viewing only.<br>Please contact your administrator for more information.',
errorDataEncrypted: 'Encrypted changes have been received, they cannot be deciphered.',
closeButtonText: 'Close File',
scriptLoadError: 'The connection is too slow, some of the components could not be loaded. Please reload the page.'
scriptLoadError: 'The connection is too slow, some of the components could not be loaded. Please reload the page.',
errorAccessDeny: 'You are trying to perform an action you do not have rights for.<br>Please contact your Document Server administrator.'
}
})(), PE.Controllers.Main || {}))
});

View file

@ -68,6 +68,7 @@
"PE.Controllers.Main.downloadErrorText": "Download failed.",
"PE.Controllers.Main.downloadTextText": "Downloading document...",
"PE.Controllers.Main.downloadTitleText": "Downloading Document",
"PE.Controllers.Main.errorAccessDeny": "You are trying to perform an action you do not have rights for.<br>Please contact your Document Server administrator.",
"PE.Controllers.Main.errorBadImageUrl": "Image URL is incorrect",
"PE.Controllers.Main.errorCoAuthoringDisconnect": "Server connection lost. You can't edit anymore.",
"PE.Controllers.Main.errorConnectToServer": "The document could not be saved. Please check connection settings or contact your administrator.<br>When you click the 'OK' button, you will be prompted to download the document.<br><br>Find more information about connecting Document Server <a href=\"https://api.onlyoffice.com/editors/callback\" target=\"_blank\">here</a>",

View file

@ -458,6 +458,10 @@ var ApplicationController = new(function(){
}
function onDownloadAs() {
if ( permissions.download === false) {
Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, me.errorAccessDeny);
return;
}
api.asc_DownloadAs(Asc.c_oAscFileType.XLSX, true);
}
@ -557,6 +561,7 @@ var ApplicationController = new(function(){
criticalErrorTitle : 'Error',
notcriticalErrorTitle : 'Warning',
scriptLoadError: 'The connection is too slow, some of the components could not be loaded. Please reload the page.',
errorFilePassProtect: 'The file is password protected and cannot be opened.'
errorFilePassProtect: 'The file is password protected and cannot be opened.',
errorAccessDeny: 'You are trying to perform an action you do not have rights for.<br>Please contact your Document Server administrator.'
}
})();

View file

@ -409,6 +409,11 @@ define([
},
onDownloadAs: function(format) {
if ( !this.appOptions.canDownload) {
Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, this.errorAccessDeny);
return;
}
this._state.isFromGatewayDownloadAs = true;
var _format = (format && (typeof format == 'string')) ? Asc.c_oAscFileType[ format.toUpperCase() ] : null,
_supported = [

View file

@ -306,6 +306,11 @@ define([
},
onDownloadAs: function() {
if ( !this.appOptions.canDownload) {
Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, this.errorAccessDeny);
return;
}
this._state.isFromGatewayDownloadAs = true;
this.api.asc_DownloadAs(Asc.c_oAscFileType.XLSX, true);
},