From 48ab72fb14704371a5df247beffcee77ad0550c1 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 18 Mar 2021 00:03:49 +0300 Subject: [PATCH] Refactoring --- apps/common/main/lib/util/utils.js | 46 +++++++++++++++--------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/apps/common/main/lib/util/utils.js b/apps/common/main/lib/util/utils.js index 51fe76578..919b3876c 100644 --- a/apps/common/main/lib/util/utils.js +++ b/apps/common/main/lib/util/utils.js @@ -996,29 +996,21 @@ Common.Utils.UserInfoParser = new(function() { return false; }; + var _getParsedGroups = function(username) { + if (parse && username) { + var idx = username.indexOf(separator), + groups = (idx>-1) ? username.substring(0, idx).split(',') : []; + for (var i=0; i-1) ? username.substring(0, idx).split(',') : []; - for (var i=0; i0) reviewGroups = groups; } else if (permissions) { // old version of review permissions var arr = [], - arrgroups = this.getParsedGroups(username); + arrgroups = _getParsedGroups(username); arrgroups && arrgroups.forEach(function(group) { var item = permissions[group.trim()]; item && (arr = arr.concat(item)); @@ -1057,7 +1057,7 @@ Common.Utils.UserInfoParser = new(function() { canEditReview: function(username) { if (!parse || !reviewGroups) return true; - var groups = this.getParsedGroups(username); + var groups = _getParsedGroups(username); groups && (groups.length==0) && (groups = [""]); return _intersection(reviewGroups, groups); }, @@ -1065,7 +1065,7 @@ Common.Utils.UserInfoParser = new(function() { canViewComment: function(username) { if (!parse || !commentGroups) return true; - var groups = this.getParsedGroups(username); + var groups = _getParsedGroups(username); groups && (groups.length==0) && (groups = [""]); return _intersection(commentGroups.view, groups); }, @@ -1073,7 +1073,7 @@ Common.Utils.UserInfoParser = new(function() { canEditComment: function(username) { if (!parse || !commentGroups) return true; - var groups = this.getParsedGroups(username); + var groups = _getParsedGroups(username); groups && (groups.length==0) && (groups = [""]); return _intersection(commentGroups.edit, groups); }, @@ -1081,7 +1081,7 @@ Common.Utils.UserInfoParser = new(function() { canDeleteComment: function(username) { if (!parse || !commentGroups) return true; - var groups = this.getParsedGroups(username); + var groups = _getParsedGroups(username); groups && (groups.length==0) && (groups = [""]); return _intersection(commentGroups.remove, groups); }