5 function fetchUser(session) {
8 session = cgi.param('ses');
10 if(!session) throw "User session is not defined";
12 var request = new Request(FETCH_SESSION, session, 1 );
14 var user = request.result();
15 if(checkILSEvent(user)) throw user;
21 * Fetches the highest org at for each perm and stores the value in
22 * PERMS[ permName ]. It also returns the org list to the caller
24 function fetchHighestPermOrgs( session, userId, perms ) {
25 var req = new RemoteRequest(
27 'open-ils.actor.user.perm.highest_org.batch',
28 session, userId, perms );
30 var orgs = req.getResultObject();
31 for( var i = 0; i != orgs.length; i++ )
32 PERMS[ perms[i] ] = ( orgs[i] != null ) ? orgs[i] : -1 ;
36 /* offset is the depth of the highest org
37 in the tree we're building
39 function buildOrgSel(selector, org, offset) {
40 insertSelectorVal( selector, -1,
41 org.name(), org.id(), null, findOrgDepth(org) - offset );
42 for( var c in org.children() )
43 buildOrgSel( selector, org.children()[c], offset);
46 /** removes all child nodes in 'tbody' that have the attribute 'key' defined */
47 function cleanTbody(tbody, key) {
48 for( var c = 0; c < tbody.childNodes.length; c++ ) {
49 var child = tbody.childNodes[c];
50 if(child && child.getAttribute(key)) tbody.removeChild(child);