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/common/mobile/lib/controller/Collaboration.js b/apps/common/mobile/lib/controller/Collaboration.js
index 1b7f6d391..c0df47d38 100644
--- a/apps/common/mobile/lib/controller/Collaboration.js
+++ b/apps/common/mobile/lib/controller/Collaboration.js
@@ -63,7 +63,8 @@ define([
canViewReview,
arrChangeReview = [],
dateChange = [],
- _fileKey;
+ _fileKey,
+ _currentUserGroups;
return {
@@ -113,6 +114,18 @@ define([
if (editor === 'DE') {
_fileKey = mode.fileKey;
}
+
+ if (mode && mode.canUseReviewPermissions) {
+ var permissions = mode.customization.reviewPermissions,
+ arr = [],
+ groups = Common.Utils.UserInfoParser.getParsedGroups(mode.user.fullname);
+ groups && groups.forEach(function(group) {
+ var item = permissions[group.trim()];
+ item && (arr = arr.concat(item));
+ });
+ _currentUserGroups = arr;
+ }
+
return this;
},
@@ -231,7 +244,8 @@ define([
getUsersInfo: function() {
var usersArray = [];
_.each(editUsers, function(item){
- var fio = item.asc_getUserName().split(' ');
+ var name = Common.Utils.UserInfoParser.getParsedName(item.asc_getUserName());
+ var fio = name.split(' ');
var initials = fio[0].substring(0, 1).toUpperCase();
if (fio.length > 1) {
initials += fio[fio.length - 1].substring(0, 1).toUpperCase();
@@ -241,7 +255,7 @@ define([
color: item.asc_getColor(),
id: item.asc_getId(),
idOriginal: item.asc_getIdOriginal(),
- name: item.asc_getUserName(),
+ name: name,
view: item.asc_getView(),
initial: initials
};
@@ -300,6 +314,10 @@ define([
$('#settings-accept-all').hide();
$('#settings-reject-all').hide();
}
+ if (this.appConfig.canUseReviewPermissions) {
+ $('#settings-accept-all').hide();
+ $('#settings-reject-all').hide();
+ }
},
onTrackChanges: function(e) {
@@ -407,6 +425,11 @@ define([
$('.accept-reject').html('' + this.textDelete + '');
$('#btn-delete-change').single('click', _.bind(this.onDeleteChange, this));
}
+ } else {
+ if(arrChangeReview.length != 0 && !arrChangeReview[0].editable) {
+ $('#btn-accept-change').addClass('disabled');
+ $('#btn-reject-change').addClass('disabled');
+ }
}
if(displayMode == "final" || displayMode == "original") {
$('#btn-accept-change').addClass('disabled');
@@ -663,9 +686,7 @@ define([
userColor = item.get_UserColor(),
goto = (item.get_MoveType() == Asc.c_oAscRevisionsMove.MoveTo || item.get_MoveType() == Asc.c_oAscRevisionsMove.MoveFrom);
date = me.dateToLocaleTimeString(date);
- var editable = (item.get_UserId() == _userId);
-
-
+ var editable = me.appConfig.isReviewOnly && (item.get_UserId() == _userId) || !me.appConfig.isReviewOnly && (!me.appConfig.canUseReviewPermissions || me.checkUserGroups(item.get_UserName()));
arr.push({date: date, user: user, usercolor: userColor, changetext: changetext, goto: goto, editable: editable});
});
arrChangeReview = arr;
@@ -677,6 +698,11 @@ define([
this.updateInfoChange();
},
+ checkUserGroups: function(username) {
+ var groups = Common.Utils.UserInfoParser.getParsedGroups(username);
+ return _currentUserGroups && groups && (_.intersection(_currentUserGroups, groups).length>0);
+ },
+
dateToLocaleTimeString: function (date) {
function format(date) {
var strTime,
@@ -736,7 +762,7 @@ define([
},
getInitials: function(name) {
- var fio = name.split(' ');
+ var fio = Common.Utils.UserInfoParser.getParsedName(name).split(' ');
var initials = fio[0].substring(0, 1).toUpperCase();
if (fio.length > 1) {
initials += fio[fio.length - 1].substring(0, 1).toUpperCase();
diff --git a/apps/common/mobile/lib/view/Collaboration.js b/apps/common/mobile/lib/view/Collaboration.js
index 9a90b9cc4..37701504b 100644
--- a/apps/common/mobile/lib/view/Collaboration.js
+++ b/apps/common/mobile/lib/view/Collaboration.js
@@ -177,7 +177,7 @@ define([
if (isAndroid) {
template += '';
}
- template += '
' + comment.username + '
' +
+ template += '
' + me.getUserName(comment.username) + '
' +
'';
if (isAndroid) {
template += '
';
@@ -202,7 +202,7 @@ define([
if (isAndroid) {
template += '' + reply.userInitials + '
'
}
- template += '
' + reply.username + '
' +
+ template += '
' + me.getUserName(reply.username) + '
' +
'
' + reply.date + '
' +
'
';
if (isAndroid) {
@@ -249,7 +249,7 @@ define([
'',
'