From 5efa7356de9f503b00de4521335cd68f802b1eb7 Mon Sep 17 00:00:00 2001 From: dbs Date: Sat, 2 May 2009 16:46:14 +0000 Subject: [PATCH] Prevent loans of items between patrons whose home library != copy's circulating library Exceptions are for patrons belonging to systems like Laurentian campus libraries git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/trunk@433 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- circ/circ_permit_copy.js | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 circ/circ_permit_copy.js diff --git a/circ/circ_permit_copy.js b/circ/circ_permit_copy.js new file mode 100644 index 0000000000..4550a1e0ef --- /dev/null +++ b/circ/circ_permit_copy.js @@ -0,0 +1,55 @@ +function go() { + +/* load the lib script */ +load_lib('circ/circ_lib.js'); +load_lib('JSON_v1.js'); +log_vars('circ_permit_copy'); + +var lusys = ['LUSYS', 'CRC', 'HUNTINGTON', 'LDCR', 'MRC', 'OSUL', 'MEDIACEN', 'SUDBURY']; +var hearstsys = ['HEARSTSYS', 'HEARST', 'KAP', 'TIMMINS']; +var nosmsys = ['OSM', 'NOSME', 'NOSMW']; + +/* In theory, isOrgDescendent would work - but it isn't, for some reason */ +if (patron.home_ou.id != copy.circ_lib.id) { + /* Laurentian campus patrons can borrow from one another */ + if (isOrgDescendent('LUSYS', patron.home_ou.id) && isOrgDescendent('LUSYS', copy.circ_lib.id)) { + // go in peace + } else if (isAMember(patron.home_ou.shortname, lusys) && isAMember(copy.circ_lib.shortname, lusys)) { + // No problemo + } else if (isOrgDescendent('HEARSTSYS', patron.home_ou.id) && isOrgDescendent('LUSYS', copy.circ_lib.id)) { + // go in peace + } else if (isAMember(patron.home_ou.shortname, hearstsys) && isAMember(copy.circ_lib.shortname, hearstsys)) { + // No problemo + } else if (isOrgDescendent('OSM', patron.home_ou.id) && isOrgDescendent('OSM', copy.circ_lib.id)) { + // go in peace + } else if (isAMember(patron.home_ou.shortname, nosmsys) && isAMember(copy.circ_lib.shortname, nosmsys)) { + // No problemo + } else { + result.events.push('CIRC_EXCEEDS_COPY_RANGE'); + } +} + +if( ! isTrue(copy.circulate) || !isTrue(copy.location.circulate) ) + result.events.push('COPY_CIRC_NOT_ALLOWED'); + + +if( ! isTrue(isRenewal) ) { + if(copyStatus != 'Available' && + copyStatus != 'On holds shelf' && copyStatus != 'Reshelving' ) { + result.events.push('COPY_NOT_AVAILABLE'); + } +} + +} + +function isAMember(shortname, group) { + for (var i = 0; i < group.length; i++) { + if (group[i] == shortname) { + return true; + } + } + return false; +} + +go(); + -- 2.11.0