--- /dev/null
+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();
+