From 1bd72034897564573109cf911250161c8fbb3381 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 7 Apr 2021 18:04:54 +0300 Subject: [PATCH] Move UserInfoParser to sdkjs --- apps/common/main/lib/util/utils.js | 110 ----------------------------- 1 file changed, 110 deletions(-) diff --git a/apps/common/main/lib/util/utils.js b/apps/common/main/lib/util/utils.js index f6e983059..a494fd29d 100644 --- a/apps/common/main/lib/util/utils.js +++ b/apps/common/main/lib/util/utils.js @@ -981,113 +981,3 @@ Common.Utils.ModalWindow = new(function() { } } })(); - -Common.Utils.UserInfoParser = new(function() { - var parse = false, - separator = String.fromCharCode(160), - username = '', - _reviewPermissions, - reviewGroups, - commentGroups; - - var _intersection = function (arr1, arr2) { - if (arr1 && arr2) { - for (var i=0; i-1) - return true; - } - } - 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; i0) - reviewGroups = groups; - } else if (permissions) { // old version of review permissions - var arr = [], - arrgroups = _getParsedGroups(username); - arrgroups && arrgroups.forEach(function(group) { - var item = permissions[group.trim()]; - item && (arr = arr.concat(item)); - }); - reviewGroups = arr; - _reviewPermissions = permissions; - } - }, - - setCommentPermissions: function(groups) { - if (groups && typeof groups == 'object') { - commentGroups = { - view: (typeof groups.view == 'object' && groups.view.length>0) ? groups.view : null, - edit: (typeof groups.edit == 'object' && groups.edit.length>0) ? groups.edit : null, - remove: (typeof groups.remove == 'object' && groups.remove.length>0) ? groups.remove : null - }; - } - }, - - canEditReview: function(username) { - if (!parse || !reviewGroups) return true; - - var groups = _getParsedGroups(username); - groups && (groups.length==0) && (groups = [""]); - return _intersection(reviewGroups, groups); - }, - - canViewComment: function(username) { - if (!parse || !commentGroups || !commentGroups.view) return true; - - var groups = _getParsedGroups(username); - groups && (groups.length==0) && (groups = [""]); - return _intersection(commentGroups.view, groups); - }, - - canEditComment: function(username) { - if (!parse || !commentGroups || !commentGroups.edit) return true; - - var groups = _getParsedGroups(username); - groups && (groups.length==0) && (groups = [""]); - return _intersection(commentGroups.edit, groups); - }, - - canDeleteComment: function(username) { - if (!parse || !commentGroups || !commentGroups.remove) return true; - - var groups = _getParsedGroups(username); - groups && (groups.length==0) && (groups = [""]); - return _intersection(commentGroups.remove, groups); - } - } -})();