From 78bb5ffa5ad093eea7c2eb7e05ba410b9202672e Mon Sep 17 00:00:00 2001 From: phasefx Date: Thu, 30 Apr 2009 20:47:35 +0000 Subject: [PATCH] more correct permission handling for registering workstations..builds the library drop-down based on work orgs. But was also done because I was getting a weird -1 result on the admin user from open-ils.actor.user.perm.highest_org git-svn-id: svn://svn.open-ils.org/ILS/trunk@13025 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../chrome/content/main/constants.js | 2 ++ .../xul/staff_client/server/main/ws_info.xul | 31 ++++++++++--------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index 0003e9e929..f5ce8a76bd 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -229,6 +229,8 @@ const api = { 'PERM_CHECK' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.perm.check' }, 'PERM_MULTI_ORG_CHECK' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.perm.check.multi_org' }, 'PERM_RETRIEVE_HIGHEST_ORG' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.perm.highest_org' }, + 'PERM_RETRIEVE_WORK_OU' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.has_work_perm_at' }, + 'BATCH_PERM_RETRIEVE_WORK_OU' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.has_work_perm_at.batch' }, 'MARC_XML_RECORD_CREATE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.xml.create' }, 'MARC_XML_RECORD_IMPORT' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.xml.import' }, 'MARC_XML_RECORD_REPLACE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.marc.replace' }, diff --git a/Open-ILS/xul/staff_client/server/main/ws_info.xul b/Open-ILS/xul/staff_client/server/main/ws_info.xul index 122d17b084..b629cebad7 100644 --- a/Open-ILS/xul/staff_client/server/main/ws_info.xul +++ b/Open-ILS/xul/staff_client/server/main/ws_info.xul @@ -76,25 +76,28 @@ g.aout_hash[ g.aout_list[i].id() ] = g.aout_list[i]; } - var highest_org_id = g.network.simple_request( - 'PERM_RETRIEVE_HIGHEST_ORG', - [ xulG.auth.session.key, g.user.id(), 'REGISTER_WORKSTATION'] + var work_ous = g.network.simple_request( + 'PERM_RETRIEVE_WORK_OU', + [ xulG.auth.session.key, 'REGISTER_WORKSTATION'] ); - if (highest_org_id == -1 || highest_org_id == '-1') { + if (work_ous.length == 0) { alert(document.getElementById('commonStrings').getString('staff.main.gen_offline_widgets.workstation_registration_denied')); xulG.auth.logoff(); return; } - var perm_depth = findOrgDepth( highest_org_id ); - - g.my_libs_tree = g.network.simple_request( - 'FM_AOU_DESCENDANTS_RETRIEVE', - [ g.user.home_ou(), perm_depth ] - ); - if (!instanceOf(g.my_libs_tree,aou)) { /* FIXME - workaround for weird descendants call result */ - g.my_libs_tree = g.my_libs_tree[0]; - } - g.my_libs = util.fm_utils.flatten_ou_branch( g.my_libs_tree ); + g.my_libs = []; + for (var i = 0; i < work_ous.length; i++ ) { + var perm_depth = findOrgDepth( work_ous[i] ); + + g.my_libs_tree = g.network.simple_request( + 'FM_AOU_DESCENDANTS_RETRIEVE', + [ work_ous[i], perm_depth ] + ); + if (!instanceOf(g.my_libs_tree,aou)) { /* FIXME - workaround for weird descendants call result */ + g.my_libs_tree = g.my_libs_tree[0]; + } + g.my_libs = g.my_libs.concat( util.fm_utils.flatten_ou_branch( g.my_libs_tree ) ); + } g.my_libs_shortname_hash = {}; g.my_libs_ou_hash = {}; -- 2.43.2