[open-ils-commits] r433 - conifer/trunk/circ (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Sat May 2 12:46:17 EDT 2009


Author: dbs
Date: 2009-05-02 12:46:14 -0400 (Sat, 02 May 2009)
New Revision: 433

Added:
   conifer/trunk/circ/circ_permit_copy.js
Log:
Prevent loans of items between patrons whose home library != copy's circulating library

Exceptions are for patrons belonging to systems like Laurentian campus libraries


Added: conifer/trunk/circ/circ_permit_copy.js
===================================================================
--- conifer/trunk/circ/circ_permit_copy.js	                        (rev 0)
+++ conifer/trunk/circ/circ_permit_copy.js	2009-05-02 16:46:14 UTC (rev 433)
@@ -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();
+



More information about the open-ils-commits mailing list