diff --git a/entity/RoleChildren_entity/recordcontainers/jdito/contentProcess.js b/entity/RoleChildren_entity/recordcontainers/jdito/contentProcess.js index f21fb44def8424121f454521bd9e67d5f87b43ac..9732fa101c6800e06be36ac08d1f4925b50fc40a 100644 --- a/entity/RoleChildren_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/RoleChildren_entity/recordcontainers/jdito/contentProcess.js @@ -5,18 +5,18 @@ import("system.result"); import("system.util"); var alias = SqlUtils.getSystemAlias(); -var parentRoleName = vars.exists("$param.RoleId_param") && vars.get("$param.RoleId_param"); +var selectedRoleName = vars.exists("$param.RoleId_param") && vars.get("$param.RoleId_param"); var children = []; -if (parentRoleName && parentRoleName.indexOf("CUSTOM_") != -1) { - // roles can only be assigned to CUSTOM roles -> parent role has to be a viable CUSTOM role - childRoles = newSelect("ID, CHILD_ROLE", alias) - .from("ASYS_ROLES_CHILDREN") - .where("ASYS_ROLES_CHILDREN.PARENT_ROLE", parentRoleName) - .table(); +// roles can only be assigned to CUSTOM roles -> selected role has to be a viable CUSTOM role +if (selectedRoleName && selectedRoleName.indexOf("CUSTOM_") != -1) { + var childRoles = newSelect("ID, CHILD_ROLE", alias) + .from("ASYS_ROLES_CHILDREN") + .where("ASYS_ROLES_CHILDREN.PARENT_ROLE", selectedRoleName) + .table(); for each (let childRole in childRoles) { - children.push([childRole[0], childRole[1], parentRoleName]); + children.push([childRole[0], childRole[1], selectedRoleName]); } var ids = vars.get("$local.idvalues"); diff --git a/process/Permission_lib/process.js b/process/Permission_lib/process.js index ac78dd31487180e906888cb754df6a8157444b11..5a054df59deb6cdfe0d38df1f7fd57d54b00dacb 100644 --- a/process/Permission_lib/process.js +++ b/process/Permission_lib/process.js @@ -836,6 +836,20 @@ function PermissionUtil () {} return true; } + /** + * Gets all parent roles of the given role. + * + * @param {String} pRoleName name of the role, mandatory + * + * @result {String[]} returns role names of the parent roles, if there are none then returns empty array + */ + PermissionUtil.getHierarchyParents = function(pRoleName) { + return newSelect("PARENT_ROLE", alias) + .from("ASYS_ROLES_CHILDREN") + .where("ASYS_ROLES_CHILDREN.CHILD_ROLE", pRoleName) + .arrayColumn(true); + } + } //end of block