From df9b4c4090565fd08549511aa96af6737084f8a5 Mon Sep 17 00:00:00 2001 From: Simon Leipold <s.leipold@adito.de> Date: Thu, 22 Aug 2019 15:08:55 +0200 Subject: [PATCH] Permissions - bug fix permission detail - conditional permissions did not show up --- .../recordcontainers/jdito/contentProcess.js | 24 ++++++++++++------- process/Permission_lib/process.js | 13 ++++++++++ 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/entity/PermissionDetail_entity/recordcontainers/jdito/contentProcess.js b/entity/PermissionDetail_entity/recordcontainers/jdito/contentProcess.js index e8b93be464..ce9afce8a6 100644 --- a/entity/PermissionDetail_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/PermissionDetail_entity/recordcontainers/jdito/contentProcess.js @@ -1,3 +1,4 @@ +import("system.logging"); import("Sql_lib"); import("system.util"); import("system.vars"); @@ -106,21 +107,22 @@ if (selectedPermission == null) { } } +logging.log(res.sort(sortResultsByCondition).sort(sortResultsByAccessTypes).toSource()); result.object(res.sort(sortResultsByCondition).sort(sortResultsByAccessTypes)); function prepareResultArray(pEntry, pRes) { - var rootPermission = ""; + var parentPermission = ""; + var noCond = "{\"entity\":\"" + pEntry.entity + "\",\"filter\":{\"type\":\"group\",\"operator\":\"AND\",\"childs\":[]}}"; + if (pEntry.accesstype != "E") { - if (pEntry.accesstype == "F" && pEntry.cond != "" && pEntry.cond != noCond) { - rootPermission = PermissionUtil.getPermissionWithoutCond(PermissionUtil.getParentSet(pEntry.permissionid)); - if (rootPermission == "") { - rootPermission = PermissionUtil.getPermissionRoot(pEntry.permissionid); - } - } else - rootPermission = PermissionUtil.getPermissionRoot(pEntry.permissionid); + if (pEntry.cond == "" || pEntry.cond == noCond) { // default permission + parentPermission = PermissionUtil.getPermissionWithoutCond(PermissionUtil.getParentSetOfSet(PermissionUtil.getParentSet(pEntry.permissionid))); + } else { // conditional permission + parentPermission = PermissionUtil.getPermissionWithoutCond(PermissionUtil.getParentSet(pEntry.permissionid)); + } } pRes.push([pEntry.permissionid, pEntry.entity, pEntry.role, pEntry.field, pEntry.cond, - sortActions(pEntry.action.split(","), pEntry.accesstype).join(","), pEntry.accesstype, pEntry.condtype, rootPermission]); + sortActions(pEntry.action.split(","), pEntry.accesstype).join(","), pEntry.accesstype, pEntry.condtype, parentPermission]); return pRes; } @@ -191,6 +193,10 @@ function sortResultsByCondition(a, b) { if (a[4] == "" || a[4] == noCond) { return -1; } else if (b[4] == "" || b[4] == noCond) { + return -1; + } else if (a[4] != "" && a[4] != noCond) { + return 1; + } else if (b[4] != "" && b[4] != noCond) { return 1; } else { return 0; diff --git a/process/Permission_lib/process.js b/process/Permission_lib/process.js index bfe618882b..998770b147 100644 --- a/process/Permission_lib/process.js +++ b/process/Permission_lib/process.js @@ -286,6 +286,19 @@ function PermissionUtil () {} + " where ASYS_PERMISSIONID = '" + pPermId + "'"; return db.cell(sqlStr, alias); } + + /** + * Gets the parent permission set of a set. + * + * @param {String} pSetId id of the permission set + * + * @result {String} returns id of the parent permission set of the given set. Never 'null', empty string if there is no result. + */ + PermissionUtil.getParentSetOfSet = function(pSetId) { + var sqlStr = "select ASYS_PERMISSIONSET_ID from ASYS_PERMISSIONSET" + + " where ASYS_PERMISSIONSETID = '" + pSetId + "'"; + return db.cell(sqlStr, alias); + } /** * Checks if the given permission set has any children left. -- GitLab