From 54667749cedc1614e9f0f6a93d90b7f0970e0a9a Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 26 Aug 2008 20:03:52 +0000 Subject: [PATCH] added method to find "where" a given action can be performed based on perm orgs and a context org git-svn-id: svn://svn.open-ils.org/ILS/trunk@10456 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/xul/staff_client/server/admin/adminlib.js | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Open-ILS/xul/staff_client/server/admin/adminlib.js b/Open-ILS/xul/staff_client/server/admin/adminlib.js index 748f3bca0b..3872268a96 100644 --- a/Open-ILS/xul/staff_client/server/admin/adminlib.js +++ b/Open-ILS/xul/staff_client/server/admin/adminlib.js @@ -75,6 +75,29 @@ function fetchHighestWorkPermOrgs(session, userId, perms, onload) { } } +/* + takes org IDs + Finds the lowest relevent org unit between a context org unit and a set of + permission orgs. This defines the sphere of influence for a given action + on a specific set of data. if the context org shares no common nodes with + the set of permission orgs, null is returned. + returns the orgUnit object + */ +function findReleventRootOrg(permOrgList, contextOrgId) { + var contextOrgNode = findOrgUnit(contextOrgId); + for(var i = 0; i < permOrgList.length; i++) { + var permOrg = findOrgUnit(permOrgList[i]); + if(orgIsMine(permOrg, contextOrgNode)) { + // perm org is equal to or a parent of the context org, so the context org is the highest + return contextOrgNode; + } else if(orgIsMine(contextOrgNode, permOrg)) { + // perm org is a child if the context org, so permOrg is the highest org + return permOrg; + } + } + return null; +} + /* offset is the depth of the highest org in the tree we're building -- 2.11.0