1 /* takes an org unit or id and return the numeric depth */
2 function findOrgDepth(org_id_or_node) {
4 if(org_id_or_node == null || globalOrgTypes == null)
7 var org = findOrgUnit(org_id_or_node);
9 var t = findOrgType(org.ou_type());
10 if(t != null) return t.depth();
15 /* takes the org type id from orgunit.ou_type() field and returns
16 the org type object */
17 function findOrgType(type_id) {
19 if(type_id == null || globalOrgTypes == null)
22 if(typeof type_id == 'object')
25 for(var type in globalOrgTypes) {
26 var t =globalOrgTypes[type];
27 if( t.id() == type_id || t.id() == parseInt(type_id) )
34 /* returns an org unit by id. if an object is passed in as the id,
35 then the object is assumed to be an org unit and is returned */
36 function findOrgUnit(org_id) {
37 if(org_id == null) return null;
38 if(typeof org_id == 'object') return org_id;
39 return orgArraySearcher[org_id];
43 /* builds a trail from the top of the org tree to the node provide.
44 basically fleshes out 'my orgs'
45 Returns an array of [org0, org1, ..., myorg]
47 function orgNodeTrail(node) {
48 var nodeArray = new Array();
51 node = findOrgUnit(node.parent_ou());
53 nodeArray = nodeArray.reverse();
58 /* returns an array of sibling org units */
59 function findSiblingOrgs(node) {
60 return findOrgUnit(node.parent_ou()).children();