Merge permission sources into one. Use global variable for file permission.
Signed-off-by: Gökay Şatır <gokaysatir@collabora.com> Change-Id: I19b6c0e95ccc3249219c88224b8c183992cd3b6dpull/5478/head
parent
fa14b9aecf
commit
192e12a864
|
@ -248,12 +248,12 @@ L.Map.include({
|
||||||
// Can user make changes to the document or not
|
// Can user make changes to the document or not
|
||||||
// i.e: user can not make changes(even can not add comments) is document is shared as read only
|
// i.e: user can not make changes(even can not add comments) is document is shared as read only
|
||||||
canUserWrite: function() {
|
canUserWrite: function() {
|
||||||
return window.docPermission === 'edit';
|
return app.file.permission === 'edit';
|
||||||
},
|
},
|
||||||
|
|
||||||
// If user has write access he can always add comments
|
// If user has write access he can always add comments
|
||||||
isPermissionEditForComments: function() {
|
isPermissionEditForComments: function() {
|
||||||
return this.canUserWrite();
|
return this.canUserWrite() || app.file.editComment;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Is user currently in read only mode (i.e: initial mobile read only view mode, user may have write access)
|
// Is user currently in read only mode (i.e: initial mobile read only view mode, user may have write access)
|
||||||
|
|
|
@ -39,9 +39,7 @@ app.definitions.Socket = L.Class.extend({
|
||||||
|
|
||||||
connect: function(socket) {
|
connect: function(socket) {
|
||||||
var map = this._map;
|
var map = this._map;
|
||||||
if (map.options.permission) {
|
map.options.docParams['permission'] = app.file.permission;
|
||||||
map.options.docParams['permission'] = map.options.permission;
|
|
||||||
}
|
|
||||||
if (this.socket) {
|
if (this.socket) {
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
|
@ -598,33 +596,30 @@ app.definitions.Socket = L.Class.extend({
|
||||||
var perm = textMsg.substring('perm:'.length).trim();
|
var perm = textMsg.substring('perm:'.length).trim();
|
||||||
|
|
||||||
// Never make the permission more permissive than it originally was.
|
// Never make the permission more permissive than it originally was.
|
||||||
if (this._map.options.permission == 'edit')
|
if (app.file.permission == 'edit')
|
||||||
{
|
app.file.permission = perm;
|
||||||
this._map.options.permission = perm;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._map._docLayer) {
|
if (this._map._docLayer)
|
||||||
this._map.setPermission(this._map.options.permission);
|
this._map.setPermission(app.file.permission);
|
||||||
}
|
|
||||||
|
|
||||||
app.file.disableSidebar = perm !== 'edit';
|
app.file.disableSidebar = perm !== 'edit';
|
||||||
app.file.readOnly = this._map.options.permission === 'readonly';
|
app.file.readOnly = app.file.permission === 'readonly';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (textMsg.startsWith('filemode:')) {
|
else if (textMsg.startsWith('filemode:')) {
|
||||||
var json = JSON.parse(textMsg.substring('filemode:'.length).trim());
|
var json = JSON.parse(textMsg.substring('filemode:'.length).trim());
|
||||||
|
|
||||||
// Never make the permission more permissive than it originally was.
|
// Never make the permission more permissive than it originally was.
|
||||||
if (this._map.options.permission == 'edit' && json.readOnly)
|
if (app.file.permission == 'edit' && json.readOnly)
|
||||||
{
|
{
|
||||||
this._map.options.permission = 'readonly';
|
app.file.permission = 'readonly';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._map._docLayer) {
|
if (this._map._docLayer) {
|
||||||
this._map.setPermission(this._map.options.permission);
|
this._map.setPermission(app.file.permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.file.readOnly = this._map.options.permission === 'readonly';
|
app.file.readOnly = app.file.permission === 'readonly';
|
||||||
app.file.editComment = json.editComment; // Allowed even in readonly mode.
|
app.file.editComment = json.editComment; // Allowed even in readonly mode.
|
||||||
}
|
}
|
||||||
else if (textMsg.startsWith('lockfailed:')) {
|
else if (textMsg.startsWith('lockfailed:')) {
|
||||||
|
@ -1281,7 +1276,7 @@ app.definitions.Socket = L.Class.extend({
|
||||||
// if this is save-as, we need to load the document with edit permission
|
// if this is save-as, we need to load the document with edit permission
|
||||||
// otherwise the user has to close the doc then re-open it again
|
// otherwise the user has to close the doc then re-open it again
|
||||||
// in order to be able to edit.
|
// in order to be able to edit.
|
||||||
this._map.options.permission = 'edit';
|
app.file.permission = 'edit';
|
||||||
this.close();
|
this.close();
|
||||||
this._map.loadDocument();
|
this._map.loadDocument();
|
||||||
this._map.sendInitUNOCommands();
|
this._map.sendInitUNOCommands();
|
||||||
|
@ -1373,7 +1368,6 @@ app.definitions.Socket = L.Class.extend({
|
||||||
var docLayer = null;
|
var docLayer = null;
|
||||||
if (command.type === 'text') {
|
if (command.type === 'text') {
|
||||||
docLayer = new L.WriterTileLayer('', {
|
docLayer = new L.WriterTileLayer('', {
|
||||||
permission: this._map.options.permission,
|
|
||||||
tileWidthTwips: tileWidthTwips / app.dpiScale,
|
tileWidthTwips: tileWidthTwips / app.dpiScale,
|
||||||
tileHeightTwips: tileHeightTwips / app.dpiScale,
|
tileHeightTwips: tileHeightTwips / app.dpiScale,
|
||||||
docType: command.type
|
docType: command.type
|
||||||
|
@ -1381,7 +1375,6 @@ app.definitions.Socket = L.Class.extend({
|
||||||
}
|
}
|
||||||
else if (command.type === 'spreadsheet') {
|
else if (command.type === 'spreadsheet') {
|
||||||
docLayer = new L.CalcTileLayer('', {
|
docLayer = new L.CalcTileLayer('', {
|
||||||
permission: this._map.options.permission,
|
|
||||||
tileWidthTwips: tileWidthTwips / app.dpiScale,
|
tileWidthTwips: tileWidthTwips / app.dpiScale,
|
||||||
tileHeightTwips: tileHeightTwips / app.dpiScale,
|
tileHeightTwips: tileHeightTwips / app.dpiScale,
|
||||||
docType: command.type
|
docType: command.type
|
||||||
|
@ -1389,7 +1382,6 @@ app.definitions.Socket = L.Class.extend({
|
||||||
}
|
}
|
||||||
else if (command.type === 'presentation' || command.type === 'drawing') {
|
else if (command.type === 'presentation' || command.type === 'drawing') {
|
||||||
docLayer = new L.ImpressTileLayer('', {
|
docLayer = new L.ImpressTileLayer('', {
|
||||||
permission: this._map.options.permission,
|
|
||||||
tileWidthTwips: tileWidthTwips / app.dpiScale,
|
tileWidthTwips: tileWidthTwips / app.dpiScale,
|
||||||
tileHeightTwips: tileHeightTwips / app.dpiScale,
|
tileHeightTwips: tileHeightTwips / app.dpiScale,
|
||||||
docType: command.type
|
docType: command.type
|
||||||
|
@ -1409,7 +1401,7 @@ app.definitions.Socket = L.Class.extend({
|
||||||
this._map._isNotebookbarLoadedOnCore = false;
|
this._map._isNotebookbarLoadedOnCore = false;
|
||||||
var uiMode = this._map.uiManager.getCurrentMode();
|
var uiMode = this._map.uiManager.getCurrentMode();
|
||||||
this._map.fire('changeuimode', {mode: uiMode, force: true});
|
this._map.fire('changeuimode', {mode: uiMode, force: true});
|
||||||
this._map.setPermission(this._map.options.permission);
|
this._map.setPermission(app.file.permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._map.fire('docloaded', {status: true});
|
this._map.fire('docloaded', {status: true});
|
||||||
|
|
|
@ -9,6 +9,7 @@ window.app = { // Shouldn't have any functions defined.
|
||||||
file: {
|
file: {
|
||||||
editComment: false,
|
editComment: false,
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
|
permission: 'readonly',
|
||||||
disableSidebar: false,
|
disableSidebar: false,
|
||||||
size: {
|
size: {
|
||||||
pixels: [0, 0], // This can change according to the zoom level and document's size.
|
pixels: [0, 0], // This can change according to the zoom level and document's size.
|
||||||
|
@ -78,4 +79,6 @@ if (activateValidation) {
|
||||||
};
|
};
|
||||||
|
|
||||||
window.app = new Proxy(window.app, validator);
|
window.app = new Proxy(window.app, validator);
|
||||||
|
window.app.file = new Proxy(window.app.file, validator);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5442,7 +5442,7 @@ L.CanvasTileLayer = L.Layer.extend({
|
||||||
|
|
||||||
// This layergroup contains all the layers corresponding to other's view
|
// This layergroup contains all the layers corresponding to other's view
|
||||||
this._viewLayerGroup = new L.LayerGroup();
|
this._viewLayerGroup = new L.LayerGroup();
|
||||||
if (this.options.permission !== 'readonly') {
|
if (app.file.permission !== 'readonly') {
|
||||||
map.addLayer(this._viewLayerGroup);
|
map.addLayer(this._viewLayerGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5511,7 +5511,7 @@ L.CanvasTileLayer = L.Layer.extend({
|
||||||
// generated just for the validity-dropdown-icon.
|
// generated just for the validity-dropdown-icon.
|
||||||
map.on('dropdownmarkertapped', this._onDropDownButtonClick, this);
|
map.on('dropdownmarkertapped', this._onDropDownButtonClick, this);
|
||||||
|
|
||||||
map.setPermission(this.options.permission);
|
map.setPermission(app.file.permission);
|
||||||
|
|
||||||
map.fire('statusindicator', {statusType: 'coolloaded'});
|
map.fire('statusindicator', {statusType: 'coolloaded'});
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,9 @@ else if (wopiSrc !== '' && accessHeader !== '') {
|
||||||
}
|
}
|
||||||
|
|
||||||
var filePath = getParameterByName('file_path');
|
var filePath = getParameterByName('file_path');
|
||||||
var permission = getParameterByName('permission') || 'edit';
|
|
||||||
|
app.file.permission = getParameterByName('permission') || 'edit';
|
||||||
|
|
||||||
var timestamp = getParameterByName('timestamp');
|
var timestamp = getParameterByName('timestamp');
|
||||||
// Should the document go inactive or not
|
// Should the document go inactive or not
|
||||||
var alwaysActive = getParameterByName('alwaysactive');
|
var alwaysActive = getParameterByName('alwaysactive');
|
||||||
|
@ -45,7 +47,6 @@ var map = L.map('map', {
|
||||||
server: host,
|
server: host,
|
||||||
doc: docURL,
|
doc: docURL,
|
||||||
docParams: docParams,
|
docParams: docParams,
|
||||||
permission: permission,
|
|
||||||
timestamp: timestamp,
|
timestamp: timestamp,
|
||||||
documentContainer: 'document-container',
|
documentContainer: 'document-container',
|
||||||
debug: debugMode,
|
debug: debugMode,
|
||||||
|
@ -78,7 +79,6 @@ window.addEventListener('beforeunload', function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
window.docPermission = permission;
|
|
||||||
window.bundlejsLoaded = true;
|
window.bundlejsLoaded = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -122,10 +122,10 @@ L.Map.WOPI = L.Handler.extend({
|
||||||
this.UserCanRename = !!wopiInfo['UserCanRename'];
|
this.UserCanRename = !!wopiInfo['UserCanRename'];
|
||||||
this.EnableShare = !!wopiInfo['EnableShare'];
|
this.EnableShare = !!wopiInfo['EnableShare'];
|
||||||
this.UserCanWrite = !!wopiInfo['UserCanWrite'];
|
this.UserCanWrite = !!wopiInfo['UserCanWrite'];
|
||||||
if (this.UserCanWrite)
|
if (this.UserCanWrite) // There are 2 places that set the file permissions, WOPI and URI. Don't change permission if URI doesn't allow.
|
||||||
window.docPermission = 'edit';
|
app.file.permission = (app.file.permission === 'edit' ? 'edit': app.file.permission);
|
||||||
else
|
else
|
||||||
window.docPermission = 'readonly';
|
app.file.permission = 'readonly';
|
||||||
|
|
||||||
if (wopiInfo['HideUserList'])
|
if (wopiInfo['HideUserList'])
|
||||||
this.HideUserList = wopiInfo['HideUserList'].split(',');
|
this.HideUserList = wopiInfo['HideUserList'].split(',');
|
||||||
|
|
Loading…
Reference in New Issue