Skip to content
Snippets Groups Projects
Commit df9b4c40 authored by Simon Leipold's avatar Simon Leipold
Browse files

Permissions - bug fix permission detail - conditional permissions did not show up

parent 87941cb8
No related branches found
No related tags found
No related merge requests found
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;
......
......@@ -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment