diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index 4d842e87f..d8a79c5cc 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -117,6 +117,16 @@ define([ if (data) { this.currentUserId = data.config.user.id; + if (this.appConfig && this.appConfig.canUseReviewPermissions) { + var permissions = this.appConfig.customization.reviewPermissions, + arr = [], + groups = Common.Utils.UserInfoParser.getParsedGroups(data.config.user.fullname); + groups && groups.forEach(function(group) { + var item = permissions[group.trim()]; + item && (arr = arr.concat(item)); + }); + this.currentUserGroups = arr; + } this.sdkViewName = data['sdkviewname'] || this.sdkViewName; } return this; @@ -183,7 +193,8 @@ define([ posY = sdkchange[0].get_Y(), animate = ( Math.abs(this._state.posx-posX)>0.001 || Math.abs(this._state.posy-posY)>0.001) || (sdkchange.length !== this._state.changes_length), lock = (sdkchange[0].get_LockUserId()!==null), - lockUser = this.getUserName(sdkchange[0].get_LockUserId()); + lockUser = this.getUserName(sdkchange[0].get_LockUserId()), + editable = changes[0].get('editable'); this.getPopover().hideTips(); this.popoverChanges.reset(changes); @@ -195,14 +206,15 @@ define([ this.getPopover().showReview(animate, lock, lockUser); - if (this.appConfig.canReview && !this.appConfig.isReviewOnly && this._state.lock !== lock) { - this.view.btnAccept.setDisabled(lock==true); - this.view.btnReject.setDisabled(lock==true); + var btnlock = lock || !editable; + if (this.appConfig.canReview && !this.appConfig.isReviewOnly && this._state.lock !== btnlock) { + this.view.btnAccept.setDisabled(btnlock); + this.view.btnReject.setDisabled(btnlock); if (this.dlgChanges) { - this.dlgChanges.btnAccept.setDisabled(lock==true); - this.dlgChanges.btnReject.setDisabled(lock==true); + this.dlgChanges.btnAccept.setDisabled(btnlock); + this.dlgChanges.btnReject.setDisabled(btnlock); } - this._state.lock = lock; + this._state.lock = btnlock; } this._state.posx = posX; this._state.posy = posY; @@ -459,7 +471,7 @@ define([ scope : me.view, hint : !me.appConfig.canReview, goto : (item.get_MoveType() == Asc.c_oAscRevisionsMove.MoveTo || item.get_MoveType() == Asc.c_oAscRevisionsMove.MoveFrom), - editable : (item.get_UserId() == me.currentUserId) + editable : me.appConfig.isReviewOnly && (item.get_UserId() == me.currentUserId) || !me.appConfig.isReviewOnly && (!me.appConfig.canUseReviewPermissions || me.checkUserGroups(item.get_UserName())) }); arr.push(change); @@ -467,10 +479,15 @@ define([ return arr; }, + checkUserGroups: function(username) { + var groups = Common.Utils.UserInfoParser.getParsedGroups(username); + return this.currentUserGroups && groups && (_.intersection(this.currentUserGroups, groups).length>0); + }, + getUserName: function(id){ if (this.userCollection && id!==null){ var rec = this.userCollection.findUser(id); - if (rec) return rec.get('username'); + if (rec) return Common.Utils.UserInfoParser.getParsedName(rec.get('username')); } return ''; }, diff --git a/apps/common/main/lib/template/ReviewChangesPopover.template b/apps/common/main/lib/template/ReviewChangesPopover.template index 0f6ed8e70..aa9b75381 100644 --- a/apps/common/main/lib/template/ReviewChangesPopover.template +++ b/apps/common/main/lib/template/ReviewChangesPopover.template @@ -13,7 +13,7 @@ <% if (editable) { %>
<% } %> - <% } else { %> + <% } else if (editable) { %>
<% } %> diff --git a/apps/common/main/lib/util/utils.js b/apps/common/main/lib/util/utils.js index 948cbb4e3..ab2262a08 100644 --- a/apps/common/main/lib/util/utils.js +++ b/apps/common/main/lib/util/utils.js @@ -959,4 +959,31 @@ Common.Utils.ModalWindow = new(function() { return count>0; } } +})(); + +Common.Utils.UserInfoParser = new(function() { + var parse = false; + return { + setParser: function(value) { + parse = !!value; + }, + + getParsedName: function(username) { + if (parse && username) { + return username.substring(username.indexOf(':')+1); + } else + return username; + }, + + getParsedGroups: function(username) { + if (parse && username) { + var idx = username.indexOf(':'), + groups = (idx>-1) ? username.substring(0, idx).split(',') : []; + for (var i=0; i', '
', '
', - '
<%= Common.Utils.String.htmlEncode(username) %>', + '
<%= Common.Utils.String.htmlEncode(Common.Utils.UserInfoParser.getParsedName(username)) %>', '', '<% if (canRestore && selected) { %>', '', diff --git a/apps/common/main/lib/view/ReviewChanges.js b/apps/common/main/lib/view/ReviewChanges.js index bbb3bbf2c..570356601 100644 --- a/apps/common/main/lib/view/ReviewChanges.js +++ b/apps/common/main/lib/view/ReviewChanges.js @@ -108,7 +108,7 @@ define([ me.fireEvent('reviewchange:accept', [me.btnAccept, 'current']); }); - this.btnAccept.menu.on('item:click', function (menu, item, e) { + this.btnAccept.menu && this.btnAccept.menu.on('item:click', function (menu, item, e) { me.fireEvent('reviewchange:accept', [menu, item]); }); @@ -116,7 +116,7 @@ define([ me.fireEvent('reviewchange:reject', [me.btnReject, 'current']); }); - this.btnReject.menu.on('item:click', function (menu, item, e) { + this.btnReject.menu && this.btnReject.menu.on('item:click', function (menu, item, e) { me.fireEvent('reviewchange:reject', [menu, item]); }); @@ -202,14 +202,14 @@ define([ this.btnAccept = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', caption: this.txtAccept, - split: true, + split: !this.appConfig.canUseReviewPermissions, iconCls: 'toolbar__icon btn-review-save' }); this.btnReject = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', caption: this.txtReject, - split: true, + split: !this.appConfig.canUseReviewPermissions, iconCls: 'toolbar__icon btn-review-deny' }); @@ -358,36 +358,37 @@ define([ if ( config.canReview ) { me.btnTurnOn.updateHint(me.tipReview); - me.btnAccept.setMenu( - new Common.UI.Menu({ - items: [ - { - caption: me.txtAcceptCurrent, - value: 'current' - }, - { - caption: me.txtAcceptAll, - value: 'all' - } - ] - }) - ); + if (!me.appConfig.canUseReviewPermissions) { + me.btnAccept.setMenu( + new Common.UI.Menu({ + items: [ + { + caption: me.txtAcceptCurrent, + value: 'current' + }, + { + caption: me.txtAcceptAll, + value: 'all' + } + ] + }) + ); + me.btnReject.setMenu( + new Common.UI.Menu({ + items: [ + { + caption: me.txtRejectCurrent, + value: 'current' + }, + { + caption: me.txtRejectAll, + value: 'all' + } + ] + }) + ); + } me.btnAccept.updateHint([me.tipAcceptCurrent, me.txtAcceptChanges]); - - me.btnReject.setMenu( - new Common.UI.Menu({ - items: [ - { - caption: me.txtRejectCurrent, - value: 'current' - }, - { - caption: me.txtRejectAll, - value: 'all' - } - ] - }) - ); me.btnReject.updateHint([me.tipRejectCurrent, me.txtRejectChanges]); if (config.canFeatureComparison) { @@ -583,7 +584,7 @@ define([ }, getUserName: function (username) { - return Common.Utils.String.htmlEncode(username); + return Common.Utils.String.htmlEncode(Common.Utils.UserInfoParser.getParsedName(username)); }, turnChanges: function(state) { @@ -771,7 +772,7 @@ define([ caption : this.txtAccept, split : true, disabled : this.mode.isReviewOnly, - menu : new Common.UI.Menu({ + menu : this.mode.canUseReviewPermissions ? false : new Common.UI.Menu({ items: [ this.mnuAcceptCurrent = new Common.UI.MenuItem({ caption: this.txtAcceptCurrent, @@ -791,7 +792,7 @@ define([ caption : this.txtReject, split : true, disabled : this.mode.isReviewOnly, - menu : new Common.UI.Menu({ + menu : this.mode.canUseReviewPermissions ? false : new Common.UI.Menu({ items: [ this.mnuRejectCurrent = new Common.UI.MenuItem({ caption: this.txtRejectCurrent, @@ -819,7 +820,7 @@ define([ me.fireEvent('reviewchange:accept', [me.btnAccept, 'current']); }); - this.btnAccept.menu.on('item:click', function (menu, item, e) { + this.btnAccept.menu && this.btnAccept.menu.on('item:click', function (menu, item, e) { me.fireEvent('reviewchange:accept', [menu, item]); }); @@ -827,7 +828,7 @@ define([ me.fireEvent('reviewchange:reject', [me.btnReject, 'current']); }); - this.btnReject.menu.on('item:click', function (menu, item, e) { + this.btnReject.menu && this.btnReject.menu.on('item:click', function (menu, item, e) { me.fireEvent('reviewchange:reject', [menu, item]); }); diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 7a258277c..e326f8f13 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -372,8 +372,7 @@ define([ this.appOptions.mentionShare = !((typeof (this.appOptions.customization) == 'object') && (this.appOptions.customization.mentionShare==false)); appHeader = this.getApplication().getController('Viewport').getView('Common.Views.Header'); - appHeader.setCanBack(this.appOptions.canBackToFolder === true, (this.appOptions.canBackToFolder) ? this.editorConfig.customization.goback.text : '') - .setUserName(this.appOptions.user.fullname); + appHeader.setCanBack(this.appOptions.canBackToFolder === true, (this.appOptions.canBackToFolder) ? this.editorConfig.customization.goback.text : ''); if (this.editorConfig.lang) this.api.asc_setLocale(this.editorConfig.lang); @@ -1273,6 +1272,10 @@ define([ if (this.appOptions.canBranding) appHeader.setBranding(this.editorConfig.customization); + this.appOptions.canUseReviewPermissions = this.appOptions.canBranding && this.appOptions.canLicense && this.editorConfig.customization && this.editorConfig.customization.reviewPermissions && (typeof (this.editorConfig.customization.reviewPermissions) == 'object'); + Common.Utils.UserInfoParser.setParser(this.appOptions.canUseReviewPermissions); + appHeader.setUserName(Common.Utils.UserInfoParser.getParsedName(this.appOptions.user.fullname)); + this.appOptions.canRename && appHeader.setCanRename(true); this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins); this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions); diff --git a/apps/documenteditor/main/app/view/DocumentHolder.js b/apps/documenteditor/main/app/view/DocumentHolder.js index 292e00327..cac724954 100644 --- a/apps/documenteditor/main/app/view/DocumentHolder.js +++ b/apps/documenteditor/main/app/view/DocumentHolder.js @@ -359,7 +359,7 @@ define([ if (usersStore){ var rec = usersStore.findUser(id); if (rec) - return rec.get('username'); + return Common.Utils.UserInfoParser.getParsedName(rec.get('username')); } return me.guestText; }; diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index d89dcf1a6..ee31cb181 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -1121,7 +1121,7 @@ define([ visible = this._ShowHideInfoItem(this.lblModifyDate, !!value) || visible; value = props.asc_getLastModifiedBy(); if (value) - this.lblModifyBy.text(value); + this.lblModifyBy.text(Common.Utils.UserInfoParser.getParsedName(value)); visible = this._ShowHideInfoItem(this.lblModifyBy, !!value) || visible; $('tr.divider.modify', this.el)[visible?'show':'hide'](); diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index cac7e7d86..dc4f4a1bf 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -331,8 +331,7 @@ define([ this.appOptions.mentionShare = !((typeof (this.appOptions.customization) == 'object') && (this.appOptions.customization.mentionShare==false)); appHeader = this.getApplication().getController('Viewport').getView('Common.Views.Header'); - appHeader.setCanBack(this.appOptions.canBackToFolder === true, (this.appOptions.canBackToFolder) ? this.editorConfig.customization.goback.text : '') - .setUserName(this.appOptions.user.fullname); + appHeader.setCanBack(this.appOptions.canBackToFolder === true, (this.appOptions.canBackToFolder) ? this.editorConfig.customization.goback.text : ''); if (this.editorConfig.lang) this.api.asc_setLocale(this.editorConfig.lang); @@ -976,6 +975,10 @@ define([ if (this.appOptions.canBranding) appHeader.setBranding(this.editorConfig.customization); + this.appOptions.canUseReviewPermissions = this.appOptions.canBranding && this.appOptions.canLicense && this.editorConfig.customization && this.editorConfig.customization.reviewPermissions && (typeof (this.editorConfig.customization.reviewPermissions) == 'object'); + Common.Utils.UserInfoParser.setParser(this.appOptions.canUseReviewPermissions); + appHeader.setUserName(Common.Utils.UserInfoParser.getParsedName(this.appOptions.user.fullname)); + this.appOptions.canRename && appHeader.setCanRename(true); this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins); this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions); diff --git a/apps/presentationeditor/main/app/view/DocumentHolder.js b/apps/presentationeditor/main/app/view/DocumentHolder.js index 8b23928e1..53670b510 100644 --- a/apps/presentationeditor/main/app/view/DocumentHolder.js +++ b/apps/presentationeditor/main/app/view/DocumentHolder.js @@ -363,7 +363,7 @@ define([ if (usersStore){ var rec = usersStore.findUser(id); if (rec) - return rec.get('username'); + return Common.Utils.UserInfoParser.getParsedName(rec.get('username')); } return me.guestText; }; diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index 23651deeb..197bcf22a 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -994,7 +994,7 @@ define([ visible = this._ShowHideInfoItem(this.lblModifyDate, !!value) || visible; value = props.asc_getLastModifiedBy(); if (value) - this.lblModifyBy.text(value); + this.lblModifyBy.text(Common.Utils.UserInfoParser.getParsedName(value)); visible = this._ShowHideInfoItem(this.lblModifyBy, !!value) || visible; $('tr.divider.modify', this.el)[visible?'show':'hide'](); diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index e0b4360f4..caf2b3c5d 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -1065,7 +1065,7 @@ define([ if (usersStore){ var rec = usersStore.findUser(id); if (rec) - return rec.get('username'); + return Common.Utils.UserInfoParser.getParsedName(rec.get('username')); } return me.guestText; }; diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 60801c928..b6f72d27b 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -360,8 +360,7 @@ define([ this.appOptions.canFeaturePivot = !!this.api.asc_isSupportFeature("pivot-tables"); this.headerView = this.getApplication().getController('Viewport').getView('Common.Views.Header'); - this.headerView.setCanBack(this.appOptions.canBackToFolder === true, (this.appOptions.canBackToFolder) ? this.editorConfig.customization.goback.text : '') - .setUserName(this.appOptions.user.fullname); + this.headerView.setCanBack(this.appOptions.canBackToFolder === true, (this.appOptions.canBackToFolder) ? this.editorConfig.customization.goback.text : ''); var reg = Common.localStorage.getItem("sse-settings-reg-settings"), isUseBaseSeparator = Common.localStorage.getBool("sse-settings-use-base-separator", true), @@ -1032,6 +1031,9 @@ define([ this.headerView.setBranding(this.editorConfig.customization); this.appOptions.canRename && this.headerView.setCanRename(true); + this.appOptions.canUseReviewPermissions = this.appOptions.canBranding && this.appOptions.canLicense && this.editorConfig.customization && this.editorConfig.customization.reviewPermissions && (typeof (this.editorConfig.customization.reviewPermissions) == 'object'); + Common.Utils.UserInfoParser.setParser(this.appOptions.canUseReviewPermissions); + this.headerView.setUserName(Common.Utils.UserInfoParser.getParsedName(this.appOptions.user.fullname)); } else this.appOptions.canModifyFilter = true; diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index ac727379f..9e5d562da 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -1801,7 +1801,7 @@ define([ visible = this._ShowHideInfoItem(this.lblModifyDate, !!value) || visible; value = props.asc_getLastModifiedBy(); if (value) - this.lblModifyBy.text(value); + this.lblModifyBy.text(Common.Utils.UserInfoParser.getParsedName(value)); visible = this._ShowHideInfoItem(this.lblModifyBy, !!value) || visible; $('tr.divider.modify', this.el)[visible?'show':'hide'](); diff --git a/apps/spreadsheeteditor/main/app/view/NameManagerDlg.js b/apps/spreadsheeteditor/main/app/view/NameManagerDlg.js index 3bd12f438..9ac77fb32 100644 --- a/apps/spreadsheeteditor/main/app/view/NameManagerDlg.js +++ b/apps/spreadsheeteditor/main/app/view/NameManagerDlg.js @@ -361,7 +361,7 @@ define([ 'text!spreadsheeteditor/main/app/template/NameManagerDlg.template', if (usersStore){ var rec = usersStore.findUser(id); if (rec) - return rec.get('username'); + return Common.Utils.UserInfoParser.getParsedName(rec.get('username')); } return this.guestText; },